匿评结束后提交的作品也应计算缺评扣分

This commit is contained in:
cxt 2016-12-06 16:13:04 +08:00
parent 5a6e64beb2
commit 494946c70e
2 changed files with 17 additions and 1 deletions

View File

@ -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") 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.late_penalty = @homework.late_penalty
student_work.work_status = 2 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 else
student_work.late_penalty = 0 student_work.late_penalty = 0
student_work.work_status = 1 student_work.work_status = 1

View File

@ -1190,6 +1190,14 @@ class UsersController < ApplicationController
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") 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.late_penalty = homework.late_penalty
student_work.work_status = 2 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 else
student_work.late_penalty = 0 student_work.late_penalty = 0
student_work.work_status = 1 student_work.work_status = 1