迟交扣分记录

This commit is contained in:
sw 2015-07-02 16:40:12 +08:00
parent 08c9d5a498
commit 0d0e294c10
1 changed files with 8 additions and 0 deletions

View File

@ -161,6 +161,14 @@ class HomeworkCommonController < ApplicationController
#关闭匿评
def stop_anonymous_comment
@homework_detail_manual.update_column('comment_status', 3)
work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
@homework.student_works.each do |student_work|
absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
student_work.save
end
respond_to do |format|
format.js
end