Merge branch 'dev_shixun_project' of https://git.trustie.net/jacknudt/trustieforge into dev_shixun_project
This commit is contained in:
commit
1c00afe368
|
@ -27,6 +27,20 @@ class ChallengesController < ApplicationController
|
|||
@challenge.shixun = @shixun
|
||||
@challenge.user = User.current
|
||||
if @challenge.save
|
||||
if params[:sample][:input].length > 0
|
||||
params[:sample][:input].each_with_index do |value, index|
|
||||
unless (value == params[:sample][:output][index] && value.blank?)
|
||||
ChallengeSample.create(:challenge_id => @challenge.id, :input => value, :output => params[:sample][:output][index])
|
||||
end
|
||||
end
|
||||
end
|
||||
if params[:program][:input].length > 0
|
||||
params[:program][:input].each_with_index do |value, index|
|
||||
unless (value == params[:program][:output][index] && value.blank?)
|
||||
TestSet.create(:challenge_id => @challenge.id, :input => value, :output => params[:program][:output][index])
|
||||
end
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun)}
|
||||
end
|
||||
|
@ -114,6 +128,16 @@ class ChallengesController < ApplicationController
|
|||
end
|
||||
|
||||
private
|
||||
def count_input input, output
|
||||
if input.length == 0 && output.length == 0
|
||||
result = 0
|
||||
else
|
||||
if input.length > output.length
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def tpi_manager_allowed
|
||||
unless (@shixun.tpi? && User.current.manager_of_shixun?(@shixun))
|
||||
render_403
|
||||
|
|
|
@ -1,2 +1,14 @@
|
|||
module MyshixunsHelper
|
||||
|
||||
def myshixun_score myshixun
|
||||
|
||||
end
|
||||
|
||||
def time_ranking myshixun
|
||||
|
||||
end
|
||||
|
||||
def score_ranking myshixun
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
class Challenge < ActiveRecord::Base
|
||||
belongs_to :shixun,:touch=> true
|
||||
belongs_to :user
|
||||
has_many :shixun_comments
|
||||
has_many :challenge_samples, :dependent => :destroy
|
||||
has_many :test_sets, :dependent => :destroy
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<a href="javascript:void(0)" title="增加" class="sample_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt12"></i></a>
|
||||
<a href="javascript:void(0)" title="删除" class="sample_icon_remove"><i class="fa fa-times-circle color-grey font-16 ml10 fl mt12"></i></a>
|
||||
</p>
|
||||
<input type="text" class="panel-form-width-670 panel-form-height-30 mb10" name="program[input][]" id="textarea_input_test" placeholder="样例输入" />
|
||||
<input type="text" class="panel-form-width-670 panel-form-height-30" name="program[output][]" id="textarea_output_test" placeholder="样例输出" />
|
||||
<input type="text" class="panel-form-width-670 panel-form-height-30 mb10" name="sample[input][]" id="textarea_input_test" placeholder="样例输入" />
|
||||
<input type="text" class="panel-form-width-670 panel-form-height-30" name="sample[output][]" id="textarea_output_test" placeholder="样例输出" />
|
||||
</li>
|
||||
</script>
|
||||
<script id="t:test-answer-list" type="text/html">
|
||||
|
@ -45,8 +45,8 @@
|
|||
<span class="color-grey fr" style="font-size:12px;">温馨提示:输入样例供学员参考。</span>
|
||||
<a href="javascript:void(0)" title="增加" class="sample_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt12"></i></a>
|
||||
</p>
|
||||
<input type="text" class="panel-form-width-670 panel-form-height-30 mb10" name="program[input][]" id="textarea_sample_input_test" placeholder="样例输入" />
|
||||
<input type="text" class="panel-form-width-670 panel-form-height-30" name="program[output][]" id="textarea_sample_output_test" placeholder="样例输出" />
|
||||
<input type="text" class="panel-form-width-670 panel-form-height-30 mb10" name="sample[input][]" id="textarea_sample_input_test" placeholder="样例输入" />
|
||||
<input type="text" class="panel-form-width-670 panel-form-height-30" name="sample[output][]" id="textarea_sample_output_test" placeholder="样例输出" />
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
Loading…
Reference in New Issue