This commit is contained in:
cxt 2019-04-26 16:24:27 +08:00
parent d5f8a4c2de
commit b57c680afd
1 changed files with 3 additions and 3 deletions

View File

@ -973,7 +973,7 @@ class StudentWorkController < ApplicationController
when 2 #教辅评分 教辅评分显示平均分
#@work.teaching_asistant_score = @work.student_works_scores.where(:reviewer_role => 2).average(:score).try(:round, 2).to_f
if @homework.homework_detail_manual.ta_mode == 1
ts_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 2 AND score IS NOT NULL ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
ts_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM student_works_scores where id in (select max(id) FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 2 AND score IS NOT NULL GROUP BY user_id)")
@work.teaching_asistant_score = ts_score.first.score.nil? ? nil : ts_score.first.score.try(:round, 2).to_f
else
@work.teaching_asistant_score = @new_score.score
@ -983,13 +983,13 @@ class StudentWorkController < ApplicationController
end
when 3 #学生评分 学生评分显示平均分
#@work.student_score = @work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f
stu_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 3 AND appeal_status != 3 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
stu_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM student_works_scores where id in (select max(id) FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 3 AND appeal_status != 3 GROUP BY user_id)")
@work.student_score = stu_score.first.score.try(:round, 2).to_f
if @is_group_leader
add_score_to_member @work, @homework, @new_score
end
User.current.student_works_scores.where(student_work_id => @work.id, :reviewer_role => 3, :appeal_status => 1).update_all(:appeal_status => 5)
User.current.student_works_scores.where(:student_work_id => @work.id, :reviewer_role => 3, :appeal_status => 1).update_all(:appeal_status => 5)
#更新CourseHomeworkStatistics中该学生的待匿评数, 只计算第一次评分
if User.current.student_works_scores.where(:student_work_id => @work.id, :reviewer_role => 3).count == 1