修改教师评分为所有教师的平均评分(包括非主讲教师)
This commit is contained in:
parent
2b279e124b
commit
f39d7e374a
|
@ -497,11 +497,20 @@ class BidsController < ApplicationController
|
|||
#@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")
|
||||
teachers = "("
|
||||
teacher_members = searchTeacherAndAssistant(@bid.courses.first)
|
||||
teacher_members.each do |member|
|
||||
if member == teacher_members.last
|
||||
teachers += member.user_id.to_s + ")"
|
||||
else
|
||||
teachers += member.user_id.to_s + ","
|
||||
end
|
||||
end
|
||||
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 = #{@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
|
||||
(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
|
||||
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY
|
||||
(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")
|
||||
s_score DESC,created_at ASC")
|
||||
|
||||
limit = 10
|
||||
feedback_count = all_homework_list.count
|
||||
|
|
Loading…
Reference in New Issue