From d5b8cb03906b8ae16b058dd70444cce8b7bd4fb5 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sun, 5 May 2019 16:19:12 +0800 Subject: [PATCH 1/3] 1 --- app/controllers/myshixuns_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index e0157b67..8c5af420 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -557,7 +557,8 @@ class MyshixunsController < ApplicationController if !resubmit.blank? game.update_attributes!(:retry_status => 1, :resubmit_identifier => resubmit) else - game.update_attributes!(:status => 0) + score = ((challenge.score * test_set_score) / 100.to_f).to_i + game.update_attributes!(:status => 0, :final_score => score) end end test_cases_time = format("%.3f", (Time.now.to_f - t1.to_f)).to_f From 91f21434fbcaa3a453442acd0c223408d45d2640 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sun, 5 May 2019 16:35:12 +0800 Subject: [PATCH 2/3] 1 --- app/controllers/myshixuns_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 8c5af420..c037618b 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -509,6 +509,7 @@ class MyshixunsController < ApplicationController game.update_column(:picture_path, pics) end logger.info("training_task_status start#2**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") + test_set_score = 0 unless jenkins_testsets.blank? jenkins_testsets.each_with_index do |j_test_set, i| logger.info("j_test_set: ############## #{j_test_set}") @@ -518,6 +519,10 @@ class MyshixunsController < ApplicationController Output.create!(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'], :actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => game.query_index, :compile_success => compile_success.to_i) + # 如果设置了按测试集给分,则需要统计测试集的分值 + if challenge.test_set_score && j_test_set['passed'].to_i == 1 + test_set_score += challenge.test_sets.where(:position => j_test_set['caseId']).pluck(:score).first + end end end logger.info("#############status: #{status}") From e04fb60aeb770e12a0c7f7d060a9fac42002e17c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sun, 5 May 2019 16:35:45 +0800 Subject: [PATCH 3/3] 1 --- .../20190505075651_add_test_set_score_for_challenges.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/migrate/20190505075651_add_test_set_score_for_challenges.rb b/db/migrate/20190505075651_add_test_set_score_for_challenges.rb index 84d027f6..233fcad8 100644 --- a/db/migrate/20190505075651_add_test_set_score_for_challenges.rb +++ b/db/migrate/20190505075651_add_test_set_score_for_challenges.rb @@ -1,7 +1,7 @@ class AddTestSetScoreForChallenges < ActiveRecord::Migration def up - add_column :test_sets, :score, :integer - add_column :challenges, :test_set_score, :boolean, :default => false + #add_column :test_sets, :score, :integer + #add_column :challenges, :test_set_score, :boolean, :default => false end def down