diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 9f0cc1d4d..49e54a273 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -1,6 +1,7 @@ class StudentWorkController < ApplicationController layout "base_courses" include StudentWorkHelper + require 'bigdecimal' before_filter :find_homework, :only => [:new, :index, :create] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work] before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] @@ -150,7 +151,10 @@ class StudentWorkController < ApplicationController if @work.student_score.nil? @work.final_score = @work.teaching_asistant_score else - @work.final_score = format("%.2f",@work.teaching_asistant_score * @homework.homework_detail_manual.ta_proportion + @work.student_score * (1 - @homework.homework_detail_manual.ta_proportion)) + final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}") + final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}")) + final_score = final_ta_score + final_s_score + @work.final_score = format("%.2f",final_score.to_f) end end when 3 #学生评分 学生评分显示平均分 @@ -159,7 +163,10 @@ class StudentWorkController < ApplicationController if @work.teaching_asistant_score.nil? @work.final_score = @work.student_score else - @work.final_score = format("%.2f",@work.teaching_asistant_score * @homework.homework_detail_manual.ta_proportion + @work.student_score * (1 - @homework.homework_detail_manual.ta_proportion)) + final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}") + final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}")) + final_score = final_ta_score + final_s_score + @work.final_score = format("%.2f",final_score.to_f) end end end