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 @@