From e0d85f72a1bf1d863212e157450dba8ba0bea2bb Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 8 Nov 2014 13:43:29 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=8C=BF=E8=AF=84=E4=BD=9C=E4=B8=9A=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=88=91=E7=9A=84=E5=88=86=E6=95=B0=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE=202.=E5=AD=A6=E7=94=9F=E5=8F=AF?= =?UTF-8?q?=E5=A4=9A=E6=AC=A1=E8=BF=9B=E8=A1=8C=E5=8C=BF=E8=AF=84=E8=AF=84?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 6 ++---- app/controllers/homework_attach_controller.rb | 6 ++---- app/views/homework_attach/_homework.html.erb | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 1de222c7c..a8a351eb1 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -508,15 +508,13 @@ class BidsController < ApplicationController WHERE table1.t_score IS NULL") @cur_type = 1 else - m_score_null = @bid.comment_status == 2 ? "IS NOT NULL" : "IS NULL" - all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM(SELECT homework_attaches.*, + all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers}) AS t_score, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score, (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id}) AS m_score FROM homework_attaches INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id - WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC) AS table1 - WHERE table1.m_score #{m_score_null}") + WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC") @is_student_batch_homework = true @cur_type = 4 end diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 6b311989e..8c6b8ef6f 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -98,17 +98,15 @@ class HomeworkAttachController < ApplicationController #获取学生匿评列表 def get_student_batch_homework - m_score_null = @bid.comment_status == 2 ? "IS NOT NULL" : "IS NULL" @is_student_batch_homework = true teachers = find_course_teachers @course - all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM(SELECT homework_attaches.*, + all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers}) AS t_score, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score, (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id}) AS m_score FROM homework_attaches INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id - WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC) AS table1 - WHERE table1.m_score #{m_score_null}") + WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC") @cur_page = params[:page] || 1 @cur_type = 4 @homework_list = paginateHelper all_homework_list,10 diff --git a/app/views/homework_attach/_homework.html.erb b/app/views/homework_attach/_homework.html.erb index f4ed0a9f2..2f1028feb 100644 --- a/app/views/homework_attach/_homework.html.erb +++ b/app/views/homework_attach/_homework.html.erb @@ -35,7 +35,7 @@
  • <%= is_student_batch_homework ? l(:label_my_score) : l(:label_student_score)%>: - <%= homework.s_score.nil? ? l(:label_without_score) : format("%.2f",(is_student_batch_homework ? (homework.m_score.nil? ? 0 : homework.m_score) : (homework.s_score.nil? ? 0 : homework.s_score))) %> + <%= is_student_batch_homework ? (homework.m_score.nil? ? l(:label_without_score) : homework.m_score) : (homework.s_score.nil? ? l(:label_without_score) : homework.s_score)%>
  • <% if is_teacher %>