From a8c5d180694d0f5b510c02573ce07869f95513ae Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 18 Sep 2015 09:32:25 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=B9=8B=E5=89=8D=E6=99=AE=E9=80=9A?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=9B=B4=E6=94=B9=E4=B8=BA=E5=8C=BF=E8=AF=84?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E3=80=82=E3=80=82=E3=80=82=202=E3=80=81?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=AF=84=E5=88=86=E4=B8=BAnull=E6=97=B6?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=B8=BA0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 12 +++++------ .../20150918004521_system_score_default.rb | 15 ++++++++++++++ .../20150918005722_about_normal_homework.rb | 20 +++++++++++++++++++ db/schema.rb | 4 ++-- 4 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20150918004521_system_score_default.rb create mode 100644 db/migrate/20150918005722_about_normal_homework.rb diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 79ad0d2d0..83128c45a 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -637,7 +637,7 @@ class StudentWorkController < ApplicationController student_work.final_score = student_work.system_score else ta_proportion = homework.homework_detail_programing.ta_proportion + homework.homework_detail_manual.ta_proportion / 2 - final_sy_score = BigDecimal.new("#{student_work.system_score}") * BigDecimal.new("#{ta_proportion}") + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}") final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) final_score = final_sy_score + final_st_score student_work.final_score = format("%.2f",final_score.to_f) @@ -647,13 +647,13 @@ class StudentWorkController < ApplicationController student_work.final_score = student_work.system_score else ta_proportion = homework.homework_detail_programing.ta_proportion + (1.0 - homework.homework_detail_manual.ta_proportion - homework.homework_detail_programing.ta_proportion) / 2 - final_sy_score = BigDecimal.new("#{student_work.system_score}") * BigDecimal.new("#{ta_proportion}") + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}") final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) final_score = final_sy_score + final_ts_score student_work.final_score = format("%.2f",final_score.to_f) end else - final_sy_score = BigDecimal.new("#{student_work.system_score}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}") final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") - BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}")) final_score = final_sy_score + final_ts_score + final_st_score @@ -666,7 +666,7 @@ class StudentWorkController < ApplicationController student_work.final_score = student_work.system_score else ta_proportion = homework.homework_detail_programing.ta_proportion + homework.homework_detail_manual.ta_proportion / 2 - final_sy_score = BigDecimal.new("#{student_work.system_score}") * BigDecimal.new("#{ta_proportion}") + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}") final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) final_score = final_sy_score + final_st_score student_work.final_score = format("%.2f",final_score.to_f) @@ -676,13 +676,13 @@ class StudentWorkController < ApplicationController student_work.final_score = student_work.system_score else ta_proportion = homework.homework_detail_programing.ta_proportion + (1.0 - homework.homework_detail_manual.ta_proportion - homework.homework_detail_programing.ta_proportion) / 2 - final_sy_score = BigDecimal.new("#{student_work.system_score}") * BigDecimal.new("#{ta_proportion}") + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}") final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) final_score = final_sy_score + final_ts_score student_work.final_score = format("%.2f",final_score.to_f) end else - final_sy_score = BigDecimal.new("#{student_work.system_score}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}") final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") - BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}")) final_score = final_sy_score + final_ts_score + final_st_score diff --git a/db/migrate/20150918004521_system_score_default.rb b/db/migrate/20150918004521_system_score_default.rb new file mode 100644 index 000000000..6195caad9 --- /dev/null +++ b/db/migrate/20150918004521_system_score_default.rb @@ -0,0 +1,15 @@ +class SystemScoreDefault < ActiveRecord::Migration + def up + change_column :student_works,:system_score,:float,:default => 0 + + + # StudentWork.where("system_score is null").each do |student_work| + # student_work.system_score = 0 + # student_work.save + # end + end + + def down + change_column :student_works,:system_score,:float + end +end diff --git a/db/migrate/20150918005722_about_normal_homework.rb b/db/migrate/20150918005722_about_normal_homework.rb new file mode 100644 index 000000000..8e0ddf00a --- /dev/null +++ b/db/migrate/20150918005722_about_normal_homework.rb @@ -0,0 +1,20 @@ +class AboutNormalHomework < ActiveRecord::Migration + def up + HomeworkCommon.where(:homework_type => 0).each do |homework| + unless homework.homework_detail_manual + homework_detail_manual = HomeworkDetailManual.new + homework_detail_manual.ta_proportion = 0.6 + homework_detail_manual.comment_status = 1 + homework_detail_manual.evaluation_start = homework.created_at + homework_detail_manual.evaluation_end = homework.created_at + homework_detail_manual.evaluation_num = 3 + homework_detail_manual.absence_penalty = 5 + homework_detail_manual.homework_common_id = homework.id + homework_detail_manual.save + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 9f3cdecca..78c0802e7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150917022239) do +ActiveRecord::Schema.define(:version => 20150918005722) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1328,7 +1328,7 @@ ActiveRecord::Schema.define(:version => 20150917022239) do t.datetime "updated_at", :null => false t.integer "late_penalty", :default => 0 t.integer "absence_penalty", :default => 0 - t.integer "system_score" + t.float "system_score", :default => 0.0 t.boolean "is_test", :default => false end