#1369 修复查看作业列表错误的BUG

This commit is contained in:
sw 2014-08-18 16:46:34 +08:00
parent e181f0ed4d
commit 5fb1b220e5
1 changed files with 6 additions and 1 deletions

View File

@ -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|