dev_local
daiao 6 years ago
parent 6a7e82802a
commit fbdde1bea9

@ -106,6 +106,7 @@ class ChallengesController < ApplicationController
def update def update
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
tab = params[:tab].to_i tab = params[:tab].to_i
logger.info("########params[:challenge]:#{params[:challenge]}")
@challenge.update_attributes(params[:challenge]) @challenge.update_attributes(params[:challenge])
if tab == 1 if tab == 1
@challenge.challenge_tags.delete_all @challenge.challenge_tags.delete_all
@ -120,14 +121,21 @@ class ChallengesController < ApplicationController
sets_output = @test_sets.map(&:output) sets_output = @test_sets.map(&:output)
sets_input = @test_sets.map(&:input) sets_input = @test_sets.map(&:input)
sets_open = @test_sets.map(&:is_public) sets_open = @test_sets.map(&:is_public)
score = @test_sets.map(&:score)
params_hidden = params[:test_set][:hidden].map{|hidden| hidden.to_i == 0} 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? @test_sets.delete_all unless @test_sets.blank?
if params[:test_set][:hidden].length > 0 if params[:test_set][:hidden].length > 0
params[:test_set][:input].each_with_index do |input, index| params[:test_set][:input].each_with_index do |input, index|
unless (input[index] == params[:test_set][:output][index] && input[index].nil?) 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 end
end end
@ -302,7 +310,9 @@ class ChallengesController < ApplicationController
if params[:test_set][:hidden].length > 0 if params[:test_set][:hidden].length > 0
params[:test_set][:input].each_with_index do |input, index| params[:test_set][:input].each_with_index do |input, index|
unless (input[index] == params[:test_set][:output][index] && input[index].nil?) 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 end
end end

@ -13,7 +13,7 @@
<% end %> <% end %>
</p> </p>
<div class="justify break_full_word new_li mb50" id="challenge_editorMd_description"> <div class="justify break_full_word new_li mb50" id="challenge_editorMd_description">
<textarea style="display:none;"><%= @shixun.description %></textarea> <textarea style="display:none;"><%#= @shixun.description %></textarea>
</div> </div>
<p class="clearfix mb10"> <p class="clearfix mb10">
<span class="font-16 fl">全部任务</span> <span class="font-16 fl">全部任务</span>

@ -5,7 +5,7 @@
<span class="fl mt5 mr10 color-orange">*</span><span class="color-blue font-16 fl mr20" name="sample_inputs_label">组1</span> <span class="fl mt5 mr10 color-orange">*</span><span class="color-blue font-16 fl mr20" name="sample_inputs_label">组1</span>
<span class="fl color-grey-6 width90px mt3 none" name="percentagenumbox"> <span class="fl color-grey-6 width90px mt3 none" name="percentagenumbox">
<input class="fl martopf4 width44pxinline" name="percentagenum"> <input class="fl martopf4 width44pxinline" name="test_set[score][]">
<span class="mr15 wid10px">%</span> <span class="mr15 wid10px">%</span>
</span> </span>
@ -166,7 +166,7 @@
<label class="panel-form-label fl">得分规范:</label> <label class="panel-form-label fl">得分规范:</label>
<div class="radioStyle ml10"> <div class="radioStyle ml10">
<input type="radio" name="specification" value="All_tests" id="All_tests" class="ml-3 mr5 magic-radio" onchange="hideSystem_score_percentage()"/> <input type="radio" name="challenge[test_set_score]" value="0" id="All_tests" class="ml-3 mr5 magic-radio" onchange="hideSystem_score_percentage()"/>
<label class="mt3 maxwidth600" for="All_tests">通过全部测试集 <label class="mt3 maxwidth600" for="All_tests">通过全部测试集
<span class="color979797">(学员评测,仅当所有测试集都正确时,才获得一次性奖励)</span> <span class="color979797">(学员评测,仅当所有测试集都正确时,才获得一次性奖励)</span>
</label> </label>
@ -178,7 +178,7 @@
<label class="panel-form-label fl transparent">得分规范:</label> <label class="panel-form-label fl transparent">得分规范:</label>
<div class="fl ml10"> <div class="fl ml10">
<input type="radio" name="specification" value="Partial_test" id="Partial_test" class="ml5 mr5 magic-radio" onchange="showSystem_score_percentage()"/> <input type="radio" name="challenge[test_set_score]" value="1" id="Partial_test" class="ml5 mr5 magic-radio" onchange="showSystem_score_percentage()"/>
<label class="mt3 maxwidth600" for="Partial_test">通过部分测试集 <label class="mt3 maxwidth600" for="Partial_test">通过部分测试集
<span class="color979797">(学员评测,当至少有一组测试集正确时,即可获得其对应比例的奖励)</span> <span class="color979797">(学员评测,当至少有一组测试集正确时,即可获得其对应比例的奖励)</span>
</label> </label>
@ -202,9 +202,6 @@
</li> </li>
<div class="df"> <div class="df">
<div class="flex1 mr20"> <div class="flex1 mr20">
<div id="test_array_set"> <div id="test_array_set">
@ -215,7 +212,7 @@
<!---------填写百分比-----------> <!---------填写百分比----------->
<span class="fl color-grey-6 width90px mt3 none" name="percentagenumbox"> <span class="fl color-grey-6 width90px mt3 none" name="percentagenumbox">
<input class="fl martopf4 width44pxinline" name="percentagenum"> <input class="fl martopf4 width44pxinline" name="test_set[score][]">
<span class="mr15 wid10px">%</span> <span class="mr15 wid10px">%</span>
</span> </span>
<!--//----------------//--> <!--//----------------//-->
@ -241,7 +238,7 @@
<!---------填写百分比-----------> <!---------填写百分比----------->
<span class="fl color-grey-6 width90px mt3 none" name="percentagenumbox"> <span class="fl color-grey-6 width90px mt3 none" name="percentagenumbox">
<input class="fl martopf4 width44pxinline" name="percentagenum"> <input class="fl martopf4 width44pxinline" name="test_set[score][]">
<span class="mr15 wid10px">%</span> <span class="mr15 wid10px">%</span>
</span> </span>
<!--------------------> <!-------------------->
@ -279,7 +276,7 @@
<script> <script>
//百分比 //百分比
function getpercentage(){ function getpercentage(){
var percentagelist = document.getElementsByName("percentagenum"); var percentagelist = document.getElementsByName("test_set[score][]");
var percentagenumbox = document.getElementsByName("percentagenumbox"); var percentagenumbox = document.getElementsByName("percentagenumbox");
if($("#Partial_test").is(":checked")){ if($("#Partial_test").is(":checked")){
if($("#Equal_proportion").is(":checked")){ if($("#Equal_proportion").is(":checked")){

@ -83,7 +83,7 @@
<label class="panel-form-label fl">得分规范:</label> <label class="panel-form-label fl">得分规范:</label>
<div class="radioStyle ml10"> <div class="radioStyle ml10">
<input type="radio" name="specification" value="All_tests" id="All_tests" disabled class="ml-3 mr5 magic-radio" onchange="hideSystem_score_percentage()"/> <input type="radio" name="specification" <%= @challenge.test_set_score ? "" : "checked" %> value="All_tests" id="All_tests" disabled class="ml-3 mr5 magic-radio" onchange="hideSystem_score_percentage()"/>
<label class="mt3 maxwidth600" for="All_tests">通过全部测试集 <label class="mt3 maxwidth600" for="All_tests">通过全部测试集
<span class="color979797">(学员评测,仅当所有测试集都正确时,才获得一次性奖励)</span> <span class="color979797">(学员评测,仅当所有测试集都正确时,才获得一次性奖励)</span>
</label> </label>
@ -95,7 +95,7 @@
<label class="panel-form-label fl transparent">得分规范:</label> <label class="panel-form-label fl transparent">得分规范:</label>
<div class="fl ml10"> <div class="fl ml10">
<input type="radio" name="specification" value="Partial_test" id="Partial_test" disabled class="ml5 mr5 magic-radio" onchange="showSystem_score_percentage()"/> <input type="radio" name="specification" <%= @challenge.test_set_score ? "checked" : "" %> value="Partial_test" id="Partial_test" disabled class="ml5 mr5 magic-radio" onchange="showSystem_score_percentage()"/>
<label class="mt3 maxwidth600" for="Partial_test">通过部分测试集 <label class="mt3 maxwidth600" for="Partial_test">通过部分测试集
<span class="color979797">(学员评测,当至少有一组测试集正确时,即可获得其对应比例的奖励)</span> <span class="color979797">(学员评测,当至少有一组测试集正确时,即可获得其对应比例的奖励)</span>
</label> </label>

Loading…
Cancel
Save