删除匿评评分数据

This commit is contained in:
cxt 2015-11-30 13:12:35 +08:00
parent 2749066908
commit 7f4e47eadc
2 changed files with 14 additions and 1 deletions

View File

@ -0,0 +1,13 @@
namespace :delete_evalution do
desc "delete evaluation"
task :delete => :environment do
homework = HomeworkCommon.where("id = 844").first
homework.homework_detail_manual.update_column('comment_status', 3)
student_work_score = StudentWorksScore.where("student_work_id = 28088 and user_id = 9263").first
student_work_score.destroy
student_work_9203 = StudentWork.where("id = 28088").first
student_work_9263 = StudentWork.where("homework_common_id = 844 and user_id = 9263").first
student_work_9203.update_column("student_score",91)
student_work_9263.update_column("absence_penalty",student_work_9263.absence_penalty+homework.homework_detail_manual.absence_penalty)
end
end

View File

@ -60,7 +60,7 @@ namespace :homework_evaluation do
work_ids = "(" + homework_common.student_works.map(&:id).join(",") + ")"
homework_common.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_manuals.absence_penalty : 0
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
student_work.save
end
homework_detail_manual.update_column('comment_status', 3)