From 5fb1b220e570222d78f2d71f6544b1f8b16d0de7 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 18 Aug 2014 16:46:34 +0800 Subject: [PATCH] =?UTF-8?q?#1369=20=E4=BF=AE=E5=A4=8D=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index be27a71ea..047f7103e 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -488,6 +488,11 @@ class BidsController < ApplicationController if @bid.homework_type @homework = HomeworkAttach.new + if @bid.proportion + teacher_proportion = @bid.proportion * 1.0 / 100 + else + teacher_proportion = 1.0 + end #@homework_list = @bid.homeworks #增加作业按评分排序, #@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC") @@ -495,7 +500,7 @@ class BidsController < ApplicationController (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{@bid.author_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.author_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 * #{@bid.proportion * 1.0 / 100} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - @bid.proportion * 1.0 / 100} END) DESC,created_at ASC") + (CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) DESC,created_at ASC") if params[:student_id].present? @temp = [] @homework_list.each do |pro|