From 2938679795fe0a31d3c5dd7ba0a3845eebf61f57 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 3 Jul 2015 11:41:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9F=E4=BA=A4=E5=92=8C=E7=BC=BA=E8=AF=84?= =?UTF-8?q?=E6=89=A3=E5=88=86=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=B8=BA0?= =?UTF-8?q?=E5=90=8E=E7=BB=A7=E7=BB=AD=E4=BF=AE=E6=94=B9=E6=9C=89=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 6b33a38ec..7808691cf 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -92,7 +92,7 @@ class HomeworkCommonController < ApplicationController @homework.publish_time = params[:homework_common][:publish_time] @homework.homework_type = params[:homework_common][:homework_type] unless @homework.late_penalty == params[:late_penalty] - @homework.student_works.where("late_penalty != 0").each do |student_work| + @homework.student_works.where("created_at > #{@homework.end_time}").each do |student_work| student_work.late_penalty = params[:late_penalty] student_work.save end @@ -108,8 +108,10 @@ class HomeworkCommonController < ApplicationController @homework_detail_manual.evaluation_num = params[:evaluation_num] unless @homework_detail_manual.absence_penalty == params[:absence_penalty] if @homework_detail_manual.comment_status == 3 #当前作业处于匿评结束状态,修改缺评扣分才会修改每个作品应扣分的值 - @homework.student_works.where("absence_penalty != 0").each do |student_work| - student_work.absence_penalty = student_work.absence_penalty / @homework_detail_manual.absence_penalty * params[:absence_penalty].to_i + 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 end