diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 6b2cd21ed..86f555daa 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -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