From bb86ef4612475417be1c5c4db152d3e3d53e5515 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 1 Jul 2014 09:23:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=88=97=E8=A1=A8=E6=97=B6=E8=AF=BE=E7=A8=8B=E8=80=81?= =?UTF-8?q?=E5=B8=88=E5=8F=82=E6=95=B0=E8=8E=B7=E5=8F=96=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 1318f9f5..5f20d2ce 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -498,8 +498,8 @@ class BidsController < ApplicationController #增加作业按评分排序, #@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC") @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 = 659) AS t_score, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id <> 659) AS s_score + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{@bid.courses.first.teacher.id}) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id <> #{@bid.courses.first.teacher.id}) AS s_score FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY (CASE WHEN t_score IS NULL THEN 0 ELSE t_score * 0.6 END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * 0.4 END) DESC,created_at ASC") if params[:student_id].present?