From c49627913b62c2e33736a91f201d4dd10b2685ab Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 3 May 2016 15:12:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E8=AF=84=E5=88=86=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=B8=AD=E7=9A=84=E6=95=99=E5=B8=88=E4=BC=98=E5=85=88?= =?UTF-8?q?=EF=BC=8C=E8=AF=84=E5=88=86=E6=9C=AA=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 34 ++++++++++++++----- app/models/student_work.rb | 38 ++++++++++++++++------ 2 files changed, 53 insertions(+), 19 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 909c68715..d4646f7d5 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -792,7 +792,7 @@ class StudentWorkController < ApplicationController if homework_detail_manual.ta_proportion.to_s != params[:ta_proportion].to_s || @homework.teacher_priority.to_s != teacher_priority.to_s || (homework_detail_programing && homework_detail_programing.ta_proportion.to_s != params[:sy_proportion].to_s) homework_detail_manual.ta_proportion = params[:ta_proportion] homework_detail_programing.ta_proportion = params[:sy_proportion] if homework_detail_programing - @homework.teacher_priority = teacher_priority + @homework.update_column('teacher_priority', teacher_priority) homework_detail_manual.save if homework_detail_manual homework_detail_programing.save if homework_detail_programing @@ -1175,8 +1175,12 @@ class StudentWorkController < ApplicationController final_score = final_ta_score + final_s_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end end else #不考虑教师评分 if student_work.teaching_asistant_score.nil? @@ -1190,8 +1194,12 @@ class StudentWorkController < ApplicationController final_score = final_ta_score + final_s_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end end elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业-----设定:系统评分必定不为空 if homework.teacher_priority == 1 #教师优先 @@ -1226,8 +1234,12 @@ class StudentWorkController < ApplicationController final_score = final_sy_score + final_ts_score + final_st_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end end else #不考虑教师评分 if student_work.teaching_asistant_score.nil? #教辅未评分 @@ -1257,8 +1269,12 @@ class StudentWorkController < ApplicationController final_score = final_sy_score + final_ts_score + final_st_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end end end end diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 40c66a632..989df40b0 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -63,11 +63,17 @@ class StudentWork < ActiveRecord::Base final_score = final_ta_score + final_s_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end end else #不考虑教师评分 - if student_work.teaching_asistant_score.nil? + if student_work.student_score.nil? && student_work.teaching_asistant_score.nil? + student_work.final_score = student_work.teacher_score + elsif student_work.teaching_asistant_score.nil? student_work.final_score = student_work.student_score elsif student_work.student_score.nil? student_work.final_score = student_work.teaching_asistant_score @@ -78,8 +84,12 @@ class StudentWork < ActiveRecord::Base final_score = final_ta_score + final_s_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end end elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业-----设定:系统评分必定不为空 if homework.teacher_priority == 1 #教师优先 @@ -114,9 +124,13 @@ class StudentWork < ActiveRecord::Base final_score = final_sy_score + final_ts_score + final_st_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score - end + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end + end else #不考虑教师评分 if student_work.teaching_asistant_score.nil? #教辅未评分 if student_work.student_score.nil? @@ -145,8 +159,12 @@ class StudentWork < ActiveRecord::Base final_score = final_sy_score + final_ts_score + final_st_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end end end end