|
|
@ -191,21 +191,28 @@ class ChallengesController < ApplicationController
|
|
|
|
sets_input = test_set.map(&:input)
|
|
|
|
sets_input = test_set.map(&:input)
|
|
|
|
sets_open = test_set.map(&:is_public)
|
|
|
|
sets_open = test_set.map(&:is_public)
|
|
|
|
set_score = test_set.map(&:score)
|
|
|
|
set_score = test_set.map(&:score)
|
|
|
|
|
|
|
|
set_match_rule = test_set.map(&:match_rule)
|
|
|
|
params_hidden = params[:test_set].map{|set| set[:hidden].to_i == 0}
|
|
|
|
params_hidden = params[:test_set].map{|set| set[:hidden].to_i == 0}
|
|
|
|
params_output = params[:test_set].map{|set| set[:output] }
|
|
|
|
params_output = params[:test_set].map{|set| set[:output] }
|
|
|
|
params_input = params[:test_set].map{|set| set[:input] }
|
|
|
|
params_input = params[:test_set].map{|set| set[:input] }
|
|
|
|
params_score = params[:test_set].map{|set| set[:score]}
|
|
|
|
params_score = params[:test_set].map{|set| set[:score]}
|
|
|
|
|
|
|
|
params_test_set = params[:test_set].map{|set| set[:match_rule]}
|
|
|
|
# 测试集变化则需要更新(输入、 输出、 是否隐藏)
|
|
|
|
# 测试集变化则需要更新(输入、 输出、 是否隐藏)
|
|
|
|
if sets_output != params_output || sets_open != params_hidden || sets_input != params_input || set_score != params_score
|
|
|
|
if sets_output != params_output || sets_open != params_hidden || sets_input != params_input ||
|
|
|
|
|
|
|
|
set_score != params_score || params_test_set != set_match_rule
|
|
|
|
test_set.delete_all unless test_set.blank?
|
|
|
|
test_set.delete_all unless test_set.blank?
|
|
|
|
params[:test_set].each_with_index do |set, index|
|
|
|
|
params[:test_set].each_with_index do |set, index|
|
|
|
|
TestSet.create(:challenge_id => @challenge.id,
|
|
|
|
# last: 末尾匹配, full: 全完匹配
|
|
|
|
:input => "#{set[:input]}",
|
|
|
|
logger.info("set: #{set}; match_rule : #{set[:match_rule]}")
|
|
|
|
:output => "#{set[:output]}",
|
|
|
|
match_rule = set[:match_rule] == 'last' ? 'last' : 'full'
|
|
|
|
:is_public => params_hidden[index],
|
|
|
|
TestSet.create(:challenge_id => @challenge.id,
|
|
|
|
:score => set[:score],
|
|
|
|
:input => "#{set[:input]}",
|
|
|
|
:position => (index + 1))
|
|
|
|
:output => "#{set[:output]}",
|
|
|
|
end
|
|
|
|
:is_public => params_hidden[index],
|
|
|
|
|
|
|
|
:score => set[:score],
|
|
|
|
|
|
|
|
:match_rule => "#{match_rule}",
|
|
|
|
|
|
|
|
:position => (index + 1))
|
|
|
|
|
|
|
|
end
|
|
|
|
@challenge.update_column(:modify_time, Time.now)
|
|
|
|
@challenge.update_column(:modify_time, Time.now)
|
|
|
|
# 测试集的
|
|
|
|
# 测试集的
|
|
|
|
@shixun.myshixuns.update_all(:system_tip => 0)
|
|
|
|
@shixun.myshixuns.update_all(:system_tip => 0)
|
|
|
|