From fbdde1bea92164f04d4e0f75be3d33bd2a3af0c0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sun, 5 May 2019 15:15:59 +0800 Subject: [PATCH] 1 --- app/controllers/challenges_controller.rb | 16 +++++++++++++--- app/views/challenges/_content_list.html.erb | 2 +- .../challenges/_edit_evaluating_page.html.erb | 15 ++++++--------- app/views/challenges/_evaluate_show.html.erb | 4 ++-- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 5bd8f537..6c180738 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -106,6 +106,7 @@ class ChallengesController < ApplicationController def update ActiveRecord::Base.transaction do tab = params[:tab].to_i + logger.info("########params[:challenge]:#{params[:challenge]}") @challenge.update_attributes(params[:challenge]) if tab == 1 @challenge.challenge_tags.delete_all @@ -120,14 +121,21 @@ class ChallengesController < ApplicationController sets_output = @test_sets.map(&:output) sets_input = @test_sets.map(&:input) sets_open = @test_sets.map(&:is_public) + score = @test_sets.map(&:score) params_hidden = params[:test_set][:hidden].map{|hidden| hidden.to_i == 0} # 测试集变化则需要更新(输入、 输出、 是否隐藏) - if sets_output != params[:test_set][:output] || sets_open != params_hidden || sets_input != params[:test_set][:input] + if sets_output != params[:test_set][:output] || sets_open != params_hidden || sets_input != params[:test_set][:input] || + score != params[:test_set][:score] @test_sets.delete_all unless @test_sets.blank? if params[:test_set][:hidden].length > 0 params[:test_set][:input].each_with_index do |input, index| unless (input[index] == params[:test_set][:output][index] && input[index].nil?) - TestSet.create(:challenge_id => @challenge.id, :input => "#{input}", :output => "#{params[:test_set][:output][index]}", :is_public => params_hidden[index], :position => (index + 1)) + logger.info("########:score:----##{params[:test_set][:score][index]}") + TestSet.create(:challenge_id => @challenge.id, :input => "#{input}", + :output => "#{params[:test_set][:output][index]}", + :is_public => params_hidden[index], + :score => params[:test_set][:score][index], + :position => (index + 1)) end end end @@ -302,7 +310,9 @@ class ChallengesController < ApplicationController if params[:test_set][:hidden].length > 0 params[:test_set][:input].each_with_index do |input, index| unless (input[index] == params[:test_set][:output][index] && input[index].nil?) - TestSet.create(:challenge_id => @challenge.id, :input => input, :output => params[:test_set][:output][index], :is_public => params_hidden[index], :position => (index + 1)) + TestSet.create(:challenge_id => @challenge.id, :input => input, :output => params[:test_set][:output][index], + :is_public => params_hidden[index], :position => (index + 1), + :score => params[:test_set][:score][index]) end end end diff --git a/app/views/challenges/_content_list.html.erb b/app/views/challenges/_content_list.html.erb index bc7743de..dec91671 100644 --- a/app/views/challenges/_content_list.html.erb +++ b/app/views/challenges/_content_list.html.erb @@ -13,7 +13,7 @@ <% end %>

- +

全部任务 diff --git a/app/views/challenges/_edit_evaluating_page.html.erb b/app/views/challenges/_edit_evaluating_page.html.erb index c80f0689..4b1149fb 100644 --- a/app/views/challenges/_edit_evaluating_page.html.erb +++ b/app/views/challenges/_edit_evaluating_page.html.erb @@ -5,7 +5,7 @@ *组1 - + % @@ -166,7 +166,7 @@

- + @@ -178,7 +178,7 @@
- + @@ -202,9 +202,6 @@ - - -
@@ -215,7 +212,7 @@ - + % @@ -241,7 +238,7 @@ - + % @@ -279,7 +276,7 @@