系统评分后获取得分赋值到系统评分字段,并计算最终得分

This commit is contained in:
sw 2015-07-17 16:12:29 +08:00
parent 26843c311f
commit 59b2f247c5
1 changed files with 20 additions and 0 deletions

View File

@ -382,6 +382,7 @@ class StudentWorkController < ApplicationController
def set_program_score def set_program_score
stundet_work = StudentWork.find_by_id params[:student_work_id] stundet_work = StudentWork.find_by_id params[:student_work_id]
@course = stundet_work.homework_common.course @course = stundet_work.homework_common.course
student_score_count = 0
if stundet_work && params[:results] && params[:results].class.to_s == "Array" if stundet_work && params[:results] && params[:results].class.to_s == "Array"
homework_common = stundet_work.homework_common homework_common = stundet_work.homework_common
params[:results].each do |result| params[:results].each do |result|
@ -391,9 +392,28 @@ class StudentWorkController < ApplicationController
student_work_test.student_work = stundet_work student_work_test.student_work = stundet_work
student_work_test.homework_test = homework_test student_work_test.homework_test = homework_test
student_work_test.result = result[:status] student_work_test.result = result[:status]
if student_work_test.result == 0
student_score_count += 1
end
student_work_test.save! student_work_test.save!
end end
end end
unless homework_common.homework_tests.empty?
stundet_work.student_score = student_score_count * 100.0 / homework_common.homework_tests.count
if stundet_work.teacher_score.nil?
if stundet_work.teaching_asistant_score.nil?
stundet_work.final_score = stundet_work.student_score
else
final_ta_score = BigDecimal.new("#{stundet_work.teaching_asistant_score}") * BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}")
final_s_score = BigDecimal.new("#{stundet_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}"))
final_score = final_ta_score + final_s_score
stundet_work.final_score = format("%.1f",final_score.to_f)
end
end
stundet_work.save!
end
end end
end end