|
|
|
@ -181,7 +181,7 @@ class ChallengesController < ApplicationController
|
|
|
|
|
begin
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
tab = params[:tab].to_i
|
|
|
|
|
@challenge.update_attributes(challenge_params)
|
|
|
|
|
@challenge.update_attributes!(challenge_params)
|
|
|
|
|
if tab == 0 && @challenge.st == 0
|
|
|
|
|
@challenge.challenge_tags.delete_all
|
|
|
|
|
if params[:challenge_tag].present?
|
|
|
|
@ -211,7 +211,7 @@ class ChallengesController < ApplicationController
|
|
|
|
|
# last: 末尾匹配, full: 全完匹配
|
|
|
|
|
logger.info("set: #{set}; match_rule : #{set[:match_rule]}")
|
|
|
|
|
match_rule = set[:match_rule] == 'last' ? 'last' : 'full'
|
|
|
|
|
TestSet.create(:challenge_id => @challenge.id,
|
|
|
|
|
TestSet.create!(:challenge_id => @challenge.id,
|
|
|
|
|
:input => "#{set[:input]}",
|
|
|
|
|
:output => "#{set[:output]}",
|
|
|
|
|
:is_public => params_hidden[index],
|
|
|
|
@ -237,9 +237,9 @@ class ChallengesController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
rescue => e
|
|
|
|
|
logger_error("##update_challenges: ##{e.message}")
|
|
|
|
|
tip_exception("更新失败!")
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
logger.error("##update_challenges: ##{e.message}")
|
|
|
|
|
tip_exception("#{e.message}")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
@ -262,7 +262,7 @@ class ChallengesController < ApplicationController
|
|
|
|
|
params[:challenge_answer].each_with_index do |answer, index|
|
|
|
|
|
# 内容为空不保存
|
|
|
|
|
next if answer[:contents].blank?
|
|
|
|
|
ChallengeAnswer.create(name: answer[:name], contents: answer[:contents],
|
|
|
|
|
ChallengeAnswer.create!(name: answer[:name], contents: answer[:contents],
|
|
|
|
|
level: index+1, score: answer[:score], challenge_id: @challenge.id)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|