diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 596775045..3c0469e9b 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -587,6 +587,14 @@ class StudentWorkController < ApplicationController if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") student_work.late_penalty = @homework.late_penalty student_work.work_status = 2 + # 缺评扣分 + if @homework.homework_detail_manual.no_anon_penalty == 0 && @homework.homework_detail_manual.comment_status == 3 && @homework.anonymous_comment == 0 + work_ids = "(" + @homework.student_works.has_committed.map(&:id).join(",") + ")" + all_dis_eva = StudentWorksEvaluationDistribution.where("student_work_id IN #{work_ids}") + has_sw_count = all_dis_eva.select("distinct user_id").count + anon_count = all_dis_eva.count / has_sw_count + student_work.absence_penalty = @homework.homework_detail_manual.absence_penalty * anon_count + end else student_work.late_penalty = 0 student_work.work_status = 1 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index da7cfd849..93ae61d6a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1186,10 +1186,18 @@ class UsersController < ApplicationController student_work = StudentWork.where(homework_common_id: homework.id, user_id: User.current.id).first if student_work - #提交作品时,计算是否迟交 + # 提交作品时,计算是否迟交 if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") student_work.late_penalty = homework.late_penalty student_work.work_status = 2 + # 缺评扣分 + if homework.homework_detail_manual.no_anon_penalty == 0 && homework.homework_detail_manual.comment_status == 3 && homework.anonymous_comment == 0 + work_ids = "(" + homework.student_works.has_committed.map(&:id).join(",") + ")" + all_dis_eva = StudentWorksEvaluationDistribution.where("student_work_id IN #{work_ids}") + has_sw_count = all_dis_eva.select("distinct user_id").count + anon_count = all_dis_eva.count / has_sw_count + student_work.absence_penalty = homework.homework_detail_manual.absence_penalty * anon_count + end else student_work.late_penalty = 0 student_work.work_status = 1