预备知识更新数据
This commit is contained in:
parent
e1280f0689
commit
643fc6ce6b
|
|
@ -124,10 +124,6 @@ class ChallengesController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
if params[:tab] == "6"
|
||||
@shixun.update_attribute("propaedeutics", params[:shixun][:propaedeutics])
|
||||
redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => params[:tab])
|
||||
else
|
||||
ActiveRecord::Base.transaction do
|
||||
@challenge.update_attributes(params[:challenge])
|
||||
if (params[:tab] == "1" || params[:tab].nil?) && @challenge.st != 0
|
||||
|
|
@ -147,38 +143,6 @@ class ChallengesController < ApplicationController
|
|||
redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => params[:tab])
|
||||
end
|
||||
end
|
||||
end
|
||||
=begin
|
||||
respond_to do |format|
|
||||
ActiveRecord::Base.transaction do
|
||||
@challenge.update_attributes(params[:challenge])
|
||||
begin
|
||||
@test_sets.delete_all unless @test_sets.blank?
|
||||
@challenge_tags.delete_all unless @challenge_tags.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?)
|
||||
params[:test_set][:hidden][index].to_i == 0 ? open = 1 : open = 0
|
||||
TestSet.create(:challenge_id => @challenge.id, :input => input, :output => params[:test_set][:output][index], :is_public => open, :position => (index + 1))
|
||||
end
|
||||
end
|
||||
end
|
||||
unless params[:knowledge].blank?
|
||||
params[:knowledge][:input].each do |input|
|
||||
ChallengeTag.create(:name => input, :challenge_id => @challenge.id)
|
||||
end
|
||||
end
|
||||
# 向jenkins端发送请求,构建公共测试用例
|
||||
add_shixun_modify_status(@shixun, 1)
|
||||
format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun), notice: '更新成功!'}
|
||||
rescue Exception => e
|
||||
flash[:error] = "#{e.message}"
|
||||
format.html{redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun)}
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
end
|
||||
=end
|
||||
end
|
||||
|
||||
def update_evaluation
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<div id="edit_answer_show">
|
||||
<div class="clearfix mb20">
|
||||
<p class="fr">
|
||||
<% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %>
|
||||
<% if User.current.manager_of_shixun?(@shixun) %>
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 3, :editor => 3) %>" class="shixun-task-btn task-btn-green fr">编辑</a>
|
||||
<% end %>
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<div class="panel-form">
|
||||
<% if @editor.blank? && !@shixun.propaedeutics.blank? %>
|
||||
<% if @editor.blank? && !@challenge.ready_knowledge.blank? %>
|
||||
<div id="edit_answer_show">
|
||||
<div class="clearfix mb20">
|
||||
<p class="fr">
|
||||
<% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %>
|
||||
<% if User.current.manager_of_shixun?(@shixun) %>
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 6, :editor => 6) %>" class="shixun-task-btn task-btn-green fr">编辑</a>
|
||||
<% end %>
|
||||
</p>
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
<li class="clearfix">
|
||||
<label class=" panel-form-label fl"> 预备知识:</label>
|
||||
<div class="fl task-bg-grey panel-box-sizing panel-form-width-690 new_li" id="challenge_editorMd_propaedeutics" style="width: 90%">
|
||||
<textarea style="display:none;"><%= @shixun.propaedeutics.blank? ? "无" : (@shixun.propaedeutics) %></textarea>
|
||||
<textarea style="display:none;"><%= @challenge.ready_knowledge.blank? ? "无" : (@challenge.ready_knowledge) %></textarea>
|
||||
</div>
|
||||
<!-- <div class="fl task-bg-grey panel-box-sizing panel-form-width-690 new_li" id="tpm_answer_show" style="width: 90%">
|
||||
<textarea style="display:none;"><%#= @challenge.answer.blank? ? "无" : (@challenge.answer) %></textarea>
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if @shixun.propaedeutics.blank? || !@editor.blank? %>
|
||||
<% if @challenge.ready_knowledge.blank? || !@editor.blank? %>
|
||||
<ul class="" id="answer_edit">
|
||||
<%= labelled_form_for @challenge, :url => shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 6), :html => {:id => "challenge_shixun_propaedeutics"} do |f| %>
|
||||
<%= render :partial => "propaedeutics_form", :locals => {:f => f} %>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<div id="scroe_show" class="<%= @challenge.score.blank? ? "undis" : "" %>">
|
||||
<div class="clearfix mb20">
|
||||
<p class="fr">
|
||||
<% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %>
|
||||
<% if User.current.manager_of_shixun?(@shixun) %>
|
||||
<a href="javascript:void(0);" class="shixun-task-btn task-btn-green fr" id="edit_score">编辑</a>
|
||||
<% end %>
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<div id="edit_skill_show" class="<%= @challenge_tags.blank? ? "undis" : "" %>">
|
||||
<div class="clearfix mb20">
|
||||
<p class="fr">
|
||||
<% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %>
|
||||
<% if User.current.manager_of_shixun?(@shixun) %>
|
||||
<a href="javascript:void(0);" class="shixun-task-btn task-btn-green fr" id="edit_skill">编辑</a>
|
||||
<% end %>
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<div id="task_pass_show">
|
||||
<div class="clearfix mb20">
|
||||
<p class="fr">
|
||||
<% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %>
|
||||
<% if User.current.manager_of_shixun?(@shixun) %>
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :editor => 1) %>" class="shixun-task-btn task-btn-green fr">编辑</a>
|
||||
<% end %>
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@
|
|||
<li class="clearfix" style="line-height:1.9;">
|
||||
<label class="panel-form-label fl"> 预备知识:</label>
|
||||
<div id="shixuns_propaedeutics" class="new_li fl" style="margin-bottom: 0px">
|
||||
<textarea name="shixun[propaedeutics]"><%= @shixun.propaedeutics %></textarea>
|
||||
<textarea name="challenge[ready_knowledge]"><%= @challenge.ready_knowledge %></textarea>
|
||||
</div>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<a href="javascript:void(0);" class="task-btn task-btn-green fr" onclick="$('#challenge_shixun_propaedeutics').submit();">保存</a>
|
||||
<% if @shixun.propaedeutics %>
|
||||
<% if@challenge.ready_knowledge %>
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 6) %>" class="task-btn fr mr10" id="answer_cancel">取消</a>
|
||||
<% end %>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
<div class="fit -scroll">
|
||||
<div class="-layout-v -fit">
|
||||
<div class="-flex -scroll task-padding16 panel-box-sizing new_li read_only" unselectable="on" id="game_ready_knowledge">
|
||||
<textarea style="display:none;"><%= @shixun.propaedeutics %></textarea>
|
||||
<textarea style="display:none;"><%= @game_challenge.ready_knowledge %></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
class ModifiedYubeiForChallenge < ActiveRecord::Migration
|
||||
def up
|
||||
Shixun.includes(:challenges).each do |shixun|
|
||||
shixun.challenges.each do |challenge|
|
||||
challenge.update_column(:ready_knowledge, shixun.try(:propaedeutics))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue