Merge branch 'dev_shixun_project' of https://git.trustie.net/jacknudt/trustieforge into dev_shixun_project
This commit is contained in:
commit
5f2a9869f9
|
@ -41,6 +41,11 @@ class ChallengesController < ApplicationController
|
|||
end
|
||||
end
|
||||
end
|
||||
if params[:knowledge][:input].length > 0
|
||||
params[:knowledge][:input].each do |input|
|
||||
ChallengeTag.create(:name => input, :challenge_id => @challenge.id)
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun)}
|
||||
end
|
||||
|
@ -64,7 +69,9 @@ class ChallengesController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@outputs = GameOutputs.all
|
||||
@challenge_samples = @challenge.challenge_samples
|
||||
@test_sets = @challenge.test_sets
|
||||
@challenge_tags = @challenge.challenge_tags
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
|
@ -72,10 +79,13 @@ class ChallengesController < ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
|
||||
@challenge_samples = @challenge.challenge_samples
|
||||
@test_sets = @challenge.test_sets
|
||||
@challenge_tags = @challenge.challenge_tags
|
||||
end
|
||||
|
||||
def update
|
||||
@challenge = Challenge.new(params[:challenge])
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ class MyshixunsController < ApplicationController
|
|||
game.update_attribute(:status, 0)
|
||||
end
|
||||
game_outputs = GameOutputs.create(:code => status, :msg => message, :game_id => task_id, :out_put => outPut)
|
||||
render :json => {:data => "success"}
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -4,6 +4,7 @@ class Challenge < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
has_many :challenge_samples, :dependent => :destroy
|
||||
has_many :test_sets, :dependent => :destroy
|
||||
has_many :challenge_tags, :dependent => :destroy
|
||||
|
||||
validates_presence_of :subject
|
||||
validates_presence_of :score
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
class ChallengeTag < ActiveRecord::Base
|
||||
attr_accessible :challenge_id, :name
|
||||
belongs_to :challenge
|
||||
end
|
|
@ -42,7 +42,7 @@
|
|||
</li>
|
||||
<li class="clearfix">
|
||||
<% if params[:action] == "edit" && @challenge.challenge_samples.count > 0 %>
|
||||
<% @challenge.challenge_samples.each_with_index do |sample, index| %>
|
||||
<% @challenge.challenge_samples.each_with_index do |sample, index| %>
|
||||
<label class="panel-form-label fl">样例设置:</label>
|
||||
<ul class="fl task-bg-grey">
|
||||
<li class="clearfix">
|
||||
|
@ -60,7 +60,7 @@
|
|||
<input type="text" class="panel-form-width-670 panel-form-height-30" name="sample[output][]" id="textarea_sample_output_test" placeholder="样例输出" value="<%= sample.output %>" />
|
||||
</li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<label class="panel-form-label fl">样例设置:</label>
|
||||
<ul class="fl task-bg-grey">
|
||||
|
@ -77,14 +77,15 @@
|
|||
<% end %>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<% if params[:action] == "edit" && @challenge.test_sets.count > 0 %>
|
||||
<% @challenge.test_sets.each_with_index do |test, index| %>
|
||||
<label class="panel-form-label fl">测试集设置:</label>
|
||||
<ul class="fl task-bg-grey">
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl">测试集设置:</label>
|
||||
<ul class="fl task-bg-grey">
|
||||
<li class="clearfix">
|
||||
|
||||
<% if params[:action] == "edit" && @challenge.test_sets.count > 0 %>
|
||||
<% @challenge.test_sets.each_with_index do |test, index| %>
|
||||
<p class="clearfix">
|
||||
<span class="color-green fb fl" name="inputs_label">测试<%= index + 1 %></span>
|
||||
<% if index == 0%>
|
||||
<% if index == 0 %>
|
||||
<span class="color-grey fr" style="font-size:12px;">温馨提示:在学员"提交评测"时进行自动检测。</span>
|
||||
<% end %>
|
||||
<a href="javascript:void(0);" title="增加" class="test_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt12"></i></a>
|
||||
|
@ -94,13 +95,9 @@
|
|||
</p>
|
||||
<input type="text" class="panel-form-width-670 panel-form-height-30 mb10" name="program[input][]" id="textarea_input_test" value="<%= test.input %>"/>
|
||||
<input type="text" class="panel-form-width-670 panel-form-height-30" name="program[output][]" id="textarea_output_test" value="<%= test.output %>" />
|
||||
</li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<label class="panel-form-label fl">测试集设置:</label>
|
||||
<ul class="fl task-bg-grey">
|
||||
<li class="clearfix">
|
||||
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p class="clearfix">
|
||||
<span class="color-green fb fl" name="inputs_label">测试1</span>
|
||||
<span class="color-grey fr" style="font-size:12px;">温馨提示:在学员"提交评测"时进行自动检测。</span>
|
||||
|
@ -108,9 +105,9 @@
|
|||
</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="测试输出" />
|
||||
</li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<label class=" panel-form-label fl"> 知识/技能点:</label>
|
||||
|
@ -118,13 +115,19 @@
|
|||
<button class="close fl mt3 mr10" type="button" onclick="$('#add_shixun_skill').slideToggle();" id="add_knowledge">+</button>
|
||||
<div class="task-tag tag-grey mb10 mr10 fl undis" id="add_shixun_skill">
|
||||
<button data-dismiss="alert" class="close fr mt3 ml5" type="button" onclick="$('#add_shixun_skill').slideToggle();">×</button>
|
||||
<input type="text" class="task-tag-input" onblur="add_tag();" placeholder="请输入知识/技能点" />
|
||||
<% if params[:action] == "edit" && @challenge_tags.count > 0 %>
|
||||
<% @challenge_tags.each do |tag| %>
|
||||
<input type="text" class="task-tag-input" onblur="add_tag();" placeholder="请输入知识/技能点" value="<%= tag.try(:name) %>" />
|
||||
<% end %>
|
||||
<% else %>
|
||||
<input type="text" class="task-tag-input" onblur="add_tag();" placeholder="请输入知识/技能点" />
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<li class="clearfix" style="line-height:1.9;">
|
||||
<label class=" panel-form-label fl"> 参考答案:</label>
|
||||
<%= f.text_area :answer, :id => 'challenge-answer', :class => "panel-form-width-690 panel-form-height-150 fl task-textarea-pd", :no_label => true %>
|
||||
<%= f.text_area :answer, :id => 'challenge-answer', :class => "panel-form-width-690 panel-form-height-150 fl task-textarea-pd", :no_label => true, :style => "line-height:1.9;" %>
|
||||
<script>
|
||||
var text = document.getElementById("challenge-answer");
|
||||
</script>
|
||||
|
@ -137,7 +140,11 @@
|
|||
<span style="display: none" class="c_red ml90" id="new_shixun_score">分值设定不能为空</span>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<a href="javascript:void(0)" class="task-btn task-btn-green fr mr10" onclick="challenge_create()">保存</a>
|
||||
<% if params[:action] == "edit" %>
|
||||
<a href="javascript:void(0)" class="task-btn task-btn-green fr mr10" onclick="challenge_update()">保存</a>
|
||||
<% else %>
|
||||
<a href="javascript:void(0)" class="task-btn task-btn-green fr mr10" onclick="challenge_create()">保存</a>
|
||||
<% end %>
|
||||
<a href="javascript:void(0)" class="task-btn fr mr10">取消</a>
|
||||
</li>
|
||||
</div>
|
||||
|
@ -263,4 +270,16 @@
|
|||
$('#new_challenge').submit();
|
||||
}
|
||||
}
|
||||
|
||||
function challenge_update(){
|
||||
if($('#challenge_subject').val().trim() == ""){
|
||||
$("#new_shixun_name").show();
|
||||
}else if($("#challenge_task_pass").val().trim() == ""){
|
||||
$("#new_shixun_pass").show();
|
||||
}else if($("#challenge_score").val().trim()==""){
|
||||
$("#new_shixun_score").show();
|
||||
}else{
|
||||
$('#edit_challenge_48').submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -9,34 +9,35 @@
|
|||
<div class="task-pm-box mt20">
|
||||
<div class="panel-header clearfix">
|
||||
<h3 class="fl mt5">阶段详情</h3>
|
||||
<a href="<%= new_shixun_challenge_path(@shixun) %>" class=" task-btn task-btn-green fr">新建阶段</a>
|
||||
</div>
|
||||
<div class="panel-form">
|
||||
<div class="clearfix mb20">
|
||||
<h3 class="fl panel-inner-title"><span class="color-red mr10">第<%= @challenge.position %>关</span><%= @challenge.subject %></h3>
|
||||
<p class="fr">
|
||||
<a href="#" title="编辑"><i class="fa fa-pencil-square-o color-grey font-16 mr5"></i></a>
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun) %>" title="编辑"><i class="fa fa-pencil-square-o color-grey font-16 mr5"></i></a>
|
||||
<a href="#" title="删除"><i class="fa fa-trash-o color-grey font-16 mr5"></i></a>
|
||||
<a href="#" title="复制"><i class="fa fa-files-o color-grey font-16 mr5"></i></a>
|
||||
<!--<a href="#" title="复制"><i class="fa fa-files-o color-grey font-16 mr5"></i></a>-->
|
||||
</p>
|
||||
</div>
|
||||
<ul>
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl">预备知识:</label>
|
||||
<div class="fl task-bg-grey">
|
||||
<%= @challenge.ready_knowledge.blank? ? "无" : (h @challenge.ready_knowledge.html_safe) %>
|
||||
<%= @challenge.ready_knowledge.blank? ? "无" : (h @challenge.ready_knowledge) %>
|
||||
</div>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl"><span class="c_red mr5">*</span>过关任务:</label>
|
||||
<div class="fl task-bg-grey">
|
||||
<%= h @challenge.task_pass.html_safe %>
|
||||
<%= h @challenge.task_pass %>
|
||||
</div>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl">样例设置:</label>
|
||||
<ul class="fl task-bg-grey">
|
||||
<% if @challenge.challenge_samples.count > 0 %>
|
||||
<% @challenge.challenge_samples.each_with_index do |sample, index| %>
|
||||
<% if @challenge_samples.count > 0 %>
|
||||
<% @challenge_samples.each_with_index do |sample, index| %>
|
||||
<li class="clearfix">
|
||||
<p class="clearfix">
|
||||
<span class="color-green fb">样例<%= index + 1 %></span>
|
||||
|
@ -53,8 +54,8 @@
|
|||
<li class="clearfix">
|
||||
<label class="panel-form-label fl">测试集设置:</label>
|
||||
<ul class="fl task-bg-grey">
|
||||
<% if @challenge.test_sets.count > 0 %>
|
||||
<% @challenge.test_sets.each_with_index do |test, index| %>
|
||||
<% if @test_sets.count > 0 %>
|
||||
<% @test_sets.each_with_index do |test, index| %>
|
||||
<li class="clearfix">
|
||||
<p class="clearfix">
|
||||
<span class="color-green fb">测试集<%= index + 1 %></span>
|
||||
|
@ -69,26 +70,21 @@
|
|||
</ul>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl"> 知识/技能点:</label>
|
||||
<div class="fl task-bd-grey">
|
||||
<div class="task-tag tag-grey mb10 mr10 fl">
|
||||
使用交互模式的 Python3 解释器
|
||||
</div>
|
||||
<div class="task-tag tag-grey mb10 mr10 fl">
|
||||
简单使用 vim 编写脚本文件并执行这个脚本文件
|
||||
</div>
|
||||
<div class="task-tag tag-grey mb10 mr10 fl">
|
||||
Python 语法:缩进
|
||||
</div>
|
||||
<div class="task-tag tag-grey mb10 mr10 fl">
|
||||
规范代码风格和注释
|
||||
</div>
|
||||
</div>
|
||||
<% unless @challenge_tags.blank? %>
|
||||
<label class="panel-form-label fl"> 知识/技能点:</label>
|
||||
<div class="fl task-bd-grey">
|
||||
<% @challenge_tags.each do |tag| %>
|
||||
<div class="task-tag tag-grey mb10 mr10 fl">
|
||||
<%= tag.name %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<label class=" panel-form-label fl"> 参考答案:</label>
|
||||
<div class="fl task-bg-grey">
|
||||
<%= @challenge.answer.blank? ? "无" : (h @challenge.answer.html_safe) %>
|
||||
<%= @challenge.answer.blank? ? "无" : (h @challenge.answer) %>
|
||||
</div>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
|
@ -106,34 +102,4 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<% if false %>
|
||||
<div class="mt10 mb10" id ="issue_show_total">
|
||||
<div class="banner-big f16 fontGrey3">
|
||||
任务详情
|
||||
<a href="<%= new_shixun_challenge_path(@shixun) %>" class="sy_btn_green fr" >新建</a>
|
||||
</div>
|
||||
|
||||
<div class="container-big mt10" style="float:left;">
|
||||
<div class="pro_page_box">
|
||||
<div class="problem_main borderBottomNone">
|
||||
<div id="issue_detail_show">
|
||||
<%= @challenge.subject %>
|
||||
</div>
|
||||
<div>
|
||||
<%= link_to "提交评测", {:controller => 'challenges', :action => "challenge_build", :id => @challenge, :shixun_id => @shixun}, :class => "task-display-span bBlue mt10", :onclick => "training_task_submmit();", :remote => true %>
|
||||
</div>
|
||||
</div>
|
||||
<% unless @outputs.nil? %>
|
||||
<% @outputs.each do |output| %>
|
||||
<%= output %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<!--problem_main end-->
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
class CreateShixunTags < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :shixun_tags do |t|
|
||||
t.string :name
|
||||
t.integer :game_id
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
class RenameShixunTags < ActiveRecord::Migration
|
||||
def up
|
||||
rename_column :shixun_tags, :game_id, :challenge_id
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
class CreateChallengeTags < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :challenge_tags do |t|
|
||||
t.string :name
|
||||
t.integer :challenge_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
15
db/schema.rb
15
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20170321102722) do
|
||||
ActiveRecord::Schema.define(:version => 20170322033103) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -338,6 +338,13 @@ ActiveRecord::Schema.define(:version => 20170321102722) do
|
|||
t.integer "game_id"
|
||||
end
|
||||
|
||||
create_table "challenge_tags", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "challenge_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "challenges", :force => true do |t|
|
||||
t.integer "shixun_id"
|
||||
t.string "subject"
|
||||
|
@ -2130,9 +2137,9 @@ ActiveRecord::Schema.define(:version => 20170321102722) do
|
|||
|
||||
create_table "shixun_tags", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "game_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "challenge_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "shixuns", :force => true do |t|
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
FactoryGirl.define do
|
||||
factory :challenge_tag do
|
||||
name "MyString"
|
||||
challenge_id 1
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ChallengeTag, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue