diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 58b43a737..ca5944f40 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -2,12 +2,12 @@ class ChallengesController < ApplicationController layout "base_shixun" before_filter :check_authentication - before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build] - before_filter :find_challenge, :only => [:show, :edit, :update, :challenge_build, :index_up, :index_down, :destroy] + before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build, :update_evaluation] + before_filter :find_challenge, :only => [:show, :edit, :update, :challenge_build, :index_up, :index_down, :destroy, :update_evaluation] before_filter :build_challege_from_params, :only => [:new, :create] before_filter :tpi_manager_allowed, :only => [:challenge_build, :destroy, :edit, :new, :create] before_filter :allowed_view, :only => [:show] - before_filter :query_challeges, :only => [:show, :edit, :update] + before_filter :query_challeges, :only => [:show, :edit, :update, :update_evaluation] before_filter :find_shixun_language, :only => [:show, :new, :edit] include ApplicationHelper @@ -26,6 +26,13 @@ class ChallengesController < ApplicationController @challenge.position = challenge_count + 1 @challenge.shixun = @shixun @challenge.user = User.current + @challenge.save! + + respond_to do |format| + format.html {redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun)} + end + +=begin ActiveRecord::Base.transaction do begin @challenge.save! @@ -53,6 +60,7 @@ class ChallengesController < ApplicationController raise ActiveRecord::Rollback end end +=end end # 处理新建challenge返回的pipeline片段 @@ -84,6 +92,7 @@ class ChallengesController < ApplicationController end def edit + @tab = params[:tab].blank? ? 1 : params[:tab].to_i end def destroy @@ -94,6 +103,9 @@ class ChallengesController < ApplicationController end def update + @challenge.update_attributes(params[:challenge]) + redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => params[:tab]) +=begin respond_to do |format| ActiveRecord::Base.transaction do @challenge.update_attributes(params[:challenge]) @@ -123,6 +135,40 @@ class ChallengesController < ApplicationController end end end +=end + end + + def update_evaluation + ActiveRecord::Base.transaction do + @challenge.update_attributes(params[:challenge]) + begin + if params[:tab].to_i == 2 + @test_sets.delete_all unless @test_sets.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 + elsif params[:tab].to_i == 5 + @challenge_tags.delete_all unless @challenge_tags.blank? + unless params[:knowledge].blank? + params[:knowledge][:input].each do |input| + ChallengeTag.create(:name => input, :challenge_id => @challenge.id) + end + end + end + # 向jenkins端发送请求,构建公共测试用例 + add_shixun_modify_status(@shixun, 1) + redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => params[:tab]) + rescue Exception => e + flash[:error] = "#{e.message}" + redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => params[:tab]) + raise ActiveRecord::Rollback + end + end end def index_down diff --git a/app/models/challenge.rb b/app/models/challenge.rb index e37a91360..82b776c86 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -9,7 +9,7 @@ class Challenge < ActiveRecord::Base has_many :games, :dependent => :destroy validates_presence_of :subject - validates_presence_of :score + # validates_presence_of :score validates_presence_of :task_pass validates_length_of :subject, :maximum => 255 diff --git a/app/views/challenges/_answer_form.html.erb b/app/views/challenges/_answer_form.html.erb new file mode 100644 index 000000000..d3be65ee3 --- /dev/null +++ b/app/views/challenges/_answer_form.html.erb @@ -0,0 +1,31 @@ +<%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %> +<%= javascript_include_tag '/editormd/editormd.min.js','/editormd/examples/js/jquery.min.js' %> + +
+
  • + +
    + +
    +
  • +
  • + 保存 + 取消 +
  • +
    + \ No newline at end of file diff --git a/app/views/challenges/_edit_answer.html.erb b/app/views/challenges/_edit_answer.html.erb new file mode 100644 index 000000000..e1027e9a0 --- /dev/null +++ b/app/views/challenges/_edit_answer.html.erb @@ -0,0 +1,88 @@ +
    +
    +
    +

    + <% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %> + 编辑 + <% end %> +

    +
    + +
    + +
    + \ No newline at end of file diff --git a/app/views/challenges/_edit_evaluating.html.erb b/app/views/challenges/_edit_evaluating.html.erb new file mode 100644 index 000000000..bbc795b3a --- /dev/null +++ b/app/views/challenges/_edit_evaluating.html.erb @@ -0,0 +1,66 @@ + +
    +
    "> +
    +

    + <% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %> + 编辑 + <% end %> +

    +
    + +
    + +
    + \ No newline at end of file diff --git a/app/views/challenges/_edit_scoring.html.erb b/app/views/challenges/_edit_scoring.html.erb new file mode 100644 index 000000000..4c19ce5bd --- /dev/null +++ b/app/views/challenges/_edit_scoring.html.erb @@ -0,0 +1,37 @@ + +
    +
    "> +
    +

    + <% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %> + 编辑 + <% end %> +

    +
    + +
    + +
    + \ No newline at end of file diff --git a/app/views/challenges/_edit_skill.html.erb b/app/views/challenges/_edit_skill.html.erb new file mode 100644 index 000000000..2a00676bd --- /dev/null +++ b/app/views/challenges/_edit_skill.html.erb @@ -0,0 +1,36 @@ +
    +
    "> +
    +

    + <% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %> + 编辑 + <% end %> +

    +
    + +
    + +
    + diff --git a/app/views/challenges/_edit_task_pass.html.erb b/app/views/challenges/_edit_task_pass.html.erb new file mode 100644 index 000000000..bbaf8f006 --- /dev/null +++ b/app/views/challenges/_edit_task_pass.html.erb @@ -0,0 +1,95 @@ +
    +
    +
    +

    + <% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %> + 编辑 + <% end %> +

    +
    + +
    + +
    + \ No newline at end of file diff --git a/app/views/challenges/_evaluating_form.html.erb b/app/views/challenges/_evaluating_form.html.erb new file mode 100644 index 000000000..83fb35cc1 --- /dev/null +++ b/app/views/challenges/_evaluating_form.html.erb @@ -0,0 +1,167 @@ + + +
    +
  • + + <%= f.text_field :path, :class => "panel-form-width-690 panel-box-sizing fl", :no_label => true, :placeholder => "进入实训后将默认打开该文件,如:src/test/welcome.java", :maxlength => "256" %> +
  • +
  • + + <%= f.text_field :exec_path, :class => "panel-form-width-690 panel-box-sizing fl", :no_label => true, :placeholder => "输入关卡需要执行的文件路径,如:src/test/main.java", :maxlength => "256" %> +
  • +
  • + + <%= select_tag :evaluation_way, options_for_select([["输入输出", 1]]), :name => 'challenge[evaluation_way]', :class => " fl", :style => "height: 40px; width:200px;" %> + 请选择自动检测学员是否完成本任务的评测标准 +
  • +
  • + <% if params[:action] == "edit" && @challenge.test_sets.count > 0 %> + + + <% else %> + + + <% end %> +
  • +
  • + 保存 + 取消 +
  • +
    + + diff --git a/app/views/challenges/_score_form.html.erb b/app/views/challenges/_score_form.html.erb new file mode 100644 index 000000000..7f8e66622 --- /dev/null +++ b/app/views/challenges/_score_form.html.erb @@ -0,0 +1,81 @@ +
    +
  • + + <%= radio_button_tag("challenge[difficulty]", 1, checked = (@challenge.difficulty ==1 ? true : false)) %>简单 + <%= radio_button_tag("challenge[difficulty]", 2, checked = (@challenge.difficulty ==2 ? true : false)) %>中等 + <%= radio_button_tag("challenge[difficulty]", 3, checked = (@challenge.difficulty ==3 ? true : false)) %>困难 + +
  • + +
  • + + <%#= f.text_field :score, :class => "panel-form-height-30 fl", :no_label => true, :style => "padding:5px;", :placeholder => "请输入分值(只能是数字)" %> + <%= select_tag :challenge_score, options_for_select([100, 200]), :name => 'challenge[score]', :class => " fl", :style => "height: 40px; width:170px;" %> +
    + +
  • + +
    +
      +
    1. 如果学员查看了参考答案,则不能得到相应的经验值
    2. +
    3. 如果学员成功得到经验值,那么将同时获得等值的金币奖励,如:+100经验值、+100金币
    4. +
    +
    + +
  • + 保存 + 取消 +
  • +
    + + diff --git a/app/views/challenges/_skill_form.html.erb b/app/views/challenges/_skill_form.html.erb new file mode 100644 index 000000000..e7f0f81b9 --- /dev/null +++ b/app/views/challenges/_skill_form.html.erb @@ -0,0 +1,63 @@ +
    +
  • + +
    + <% if params[:action] == "edit" && @challenge_tags.count > 0 %> + <% @challenge_tags.each do |tag| %> +
    + + +
    + <% end %> + <% end %> + +
    + + +
    + +添加 +
    +
  • +

    +
    +
      +
    1. 学员为参考答案通过了本阶段的评测时将获得技能,否则不能获得技能
    2. +
    +
    + +
  • + 保存 + 取消 +
  • +
    + + diff --git a/app/views/challenges/_task_pass_form.html.erb b/app/views/challenges/_task_pass_form.html.erb new file mode 100644 index 000000000..e1849fc65 --- /dev/null +++ b/app/views/challenges/_task_pass_form.html.erb @@ -0,0 +1,107 @@ +<%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %> +<%= javascript_include_tag '/editormd/editormd.min.js','/editormd/examples/js/jquery.min.js' %> + + + +
    +
  • + + <%= f.text_field :subject, :class => "panel-form-width-690 fl panel-box-sizing", :no_label => true, :placeholder => "请输入当前任务的名称(此信息将提前泄露给学员)" %> + +
  • +
  • + +
    + +
    + +
  • +
  • + 保存 + 取消 +
  • +
    + + diff --git a/app/views/challenges/edit.html.erb b/app/views/challenges/edit.html.erb index bf88b7a80..5ca77ad4d 100644 --- a/app/views/challenges/edit.html.erb +++ b/app/views/challenges/edit.html.erb @@ -1,22 +1,54 @@ -<%= content_for(:header_tags) do %> - <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> - <%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %> - <%= stylesheet_link_tag "/assets/codemirror/codemirror" %> -<% end %> +<%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %> +<%= stylesheet_link_tag "/assets/codemirror/codemirror" %> + +<%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %> +<%= javascript_include_tag '/editormd/lib/marked.min.js','/editormd/lib/prettify.min.js','/editormd/lib/raphael.min.js','/editormd/lib/underscore.min.js','/editormd/lib/sequence-diagram.min.js', + '/editormd/lib/flowchart.min.js','/editormd/lib/jquery.flowchart.min.js','/editormd/editormd.js' %> +
    -

    编辑阶段(第<%= @challenge.position %>关)

    +

    阶段编辑(第<%= @challenge.position %>关)

    -
    -
      - <%= labelled_form_for @challenge, :url => shixun_challenge_path(@challenge, :shixun_id => @shixun) do |f| %> - <%= render :partial => "form", :locals => {:f => f} %> - <% end %> -
    -
    - +
    + +
    + <% if @tab == 1 || @tab.blank? %> + <%= render :partial => "edit_task_pass" %> + <% elsif @tab == 2 %> + <%= render :partial => "edit_evaluating" %> + <% elsif @tab == 3 %> + <%= render :partial => "edit_answer" %> + <% elsif @tab == 4 %> + <%= render :partial => "edit_scoring" %> + <% elsif @tab == 5 %> + <%= render :partial => "edit_skill" %> + <% end %>
    - diff --git a/app/views/challenges/new.html.erb b/app/views/challenges/new.html.erb index a5234ce72..a01035538 100644 --- a/app/views/challenges/new.html.erb +++ b/app/views/challenges/new.html.erb @@ -1,5 +1,24 @@ <%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %> <%= stylesheet_link_tag "/assets/codemirror/codemirror" %> + + +
    +
    +

    新建阶段

    +
    +
    + +
    +
    + + + + +<% if false %>

    新建阶段

    @@ -12,6 +31,6 @@
    - +<% end %> diff --git a/config/routes.rb b/config/routes.rb index f7f5da845..87ecd788b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -92,6 +92,7 @@ RedmineApp::Application.routes.draw do match 'game_build_result', :via => [:get, :post] get 'index_up' get 'index_down' + match 'update_evaluation', :via => [:get, :post, :put] end end diff --git a/public/stylesheets/css/edu-common.css b/public/stylesheets/css/edu-common.css index fda3ebc33..d143301bf 100644 --- a/public/stylesheets/css/edu-common.css +++ b/public/stylesheets/css/edu-common.css @@ -161,6 +161,7 @@ a.course-bth-blue{cursor: pointer;background-color:#199ed8 ;color: #ffffff;displ .pr {position:relative;} .w100{width: 100px;} .w150{width: 150px;} +.w850{width: 850px;} .with10{ width: 10%;}.with15{ width: 15%;} .with20{ width: 20%;}.with25{ width: 25%;} .with30{ width: 30%;}.with35{ width: 35%;} diff --git a/public/stylesheets/css/edu-public.css b/public/stylesheets/css/edu-public.css index 235a68806..f7dd72849 100644 --- a/public/stylesheets/css/edu-public.css +++ b/public/stylesheets/css/edu-public.css @@ -269,3 +269,6 @@ a:hover.task-btn-line{ border:1px solid #3498db;background:#3498db;color: #fff;} /*新增的公用样式*/ .box-boxshadow{box-shadow: 3px 3px 10px rgba(146, 153, 169, 0.2);} +.prop-notice-info{padding: 10px;border:1px solid #F3DDB3;background-color: #FFFEF4;} +.prop-notice-info ol{list-style-type: disc;list-style-position:inside} +.prop-notice-info ol li{list-style-type: disc;color: #ff6532;margin-bottom:0!important;} \ No newline at end of file