diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 834e6b302..7bbef79a1 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -2,8 +2,8 @@ class ChallengesController < ApplicationController layout "base_shixun" before_filter :check_authentication - 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 :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build, :update_evaluation, :add_choose_question, :new_or_edit_choose_question] + before_filter :find_challenge, :only => [:show, :edit, :update, :challenge_build, :index_up, :index_down, :destroy, :update_evaluation, :add_choose_question, :new_or_edit_choose_question] 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] @@ -103,6 +103,20 @@ class ChallengesController < ApplicationController end end + def new_or_edit_choose_question + + respond_to do |format| + format.js + end + end + + def add_choose_question + @type = params[:type].to_i + respond_to do |format| + format.js + end + end + def destroy next_challenges = @shixun.challenges.where("position > #{@challenge.position}") next_challenges.update_all("position = position - 1") diff --git a/app/views/challenges/_choose_type.html.erb b/app/views/challenges/_choose_type.html.erb index 5590def69..a4e320270 100644 --- a/app/views/challenges/_choose_type.html.erb +++ b/app/views/challenges/_choose_type.html.erb @@ -35,7 +35,7 @@
- <%= render :partial => "single_or_multiple_question" %> + <%#= render :partial => "single_or_multiple_question" %>
<%= render :partial => 'single_or_multiple_question_show'%> @@ -50,5 +50,57 @@ sequenceDiagram: true // 默认不解析 }); }); + //添加单选、多选tab + $(".addoption-btn").on("click",function(){ + var length= $(".stage-part-2").find(".nav_check_item li").length; + if(length<11){ + var title=$(this).html(); + var type = title.indexOf("多选")>0 ? 2 : 1; + if(title.indexOf("多选")>0){//多选 + title="多选题"; + }else{ + title="单选题"; + } + var li_con=length+"."+title+""; + var html="
  • "+li_con+"
  • "; + $(".stage-part-2").find(".nav_check_item li").removeClass("check_nav"); + $(".stage-part-2").find(".nav_check_item li").eq(length-1).after(html); + $.ajax({ + url: "<%= add_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun) %>", + dateType: "script", + data: {type: type}, + success: function(){ + + } + }) + } + // editor_tigan(); + }); + //删除单选、多选tab + $(".deloption-btn").on("click",function(){ + var index=0; + for(var i=1;i<$(".stage-part-2").find(".nav_check_item li").length;i++){ + var length=$(".stage-part-2").find(".nav_check_item li").length; + var item=$(".stage-part-2").find(".nav_check_item li"); + if(item.eq(i).hasClass("check_nav")){ + if(length>1){ + item.eq(0).addClass("check_nav"); + item.eq(i).remove(); + } + + } + } + for(var i=1;i<$(".stage-part-2").find(".nav_check_item li").length;i++){ + var item=$(".stage-part-2").find(".nav_check_item li"); + item.eq(i).html(i+"."+item.eq(i).find("span").html()+""); + } + }) + //第二个ul tab的切换事件 + $(".stage-part-2").find(".nav_check_item li").live("click",function(){ + if($(".nav_check_item li").length>1){ + $(".nav_check_item li").removeClass("check_nav"); + $(this).addClass("check_nav"); + } + }) \ No newline at end of file diff --git a/app/views/challenges/_single_or_multiple_question.html.erb b/app/views/challenges/_single_or_multiple_question.html.erb index 5c76a2f99..19b9b14fa 100644 --- a/app/views/challenges/_single_or_multiple_question.html.erb +++ b/app/views/challenges/_single_or_multiple_question.html.erb @@ -1,77 +1,76 @@ -
  • - 编辑 - 删除 -
  • -
    -
    -
  • - -
    - +<%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %> +<%= javascript_include_tag '/editormd/editormd.min.js','/editormd/examples/js/jquery.min.js' %> +<%= labelled_form_for @challenge, :url => new_or_edit_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun), :html => {:id => "challenge_choose_update", :remote => true } do |f| %> +
  • + 编辑 + 删除 +
  • +
    +
    +
  • + +
    + +
    +
  • + +
  • + + + + +
  • +
  • + + + + +
  • +
  • + + + + +
  • +
  • + + + + +
  • +
      +
    • + + +
    • + +
    • +
    +
    +

    + +
  • + +
    + +
    +

    +

  • - -
  • - - - - -
  • -
  • - - - - -
  • -
  • - - - - -
  • -
  • - - - - -
  • - -
    -
    -

    - -
    -
    - -
    -
    -

    - -
    -
    -
  • - +

    + +
    +
    +
  • + > @@ -85,154 +84,157 @@
  • -
  • - - <%= select_tag :challenge_score, options_for_select([100, 200]), :name => 'challenge[score]', :class => " fl", :style => "height: 40px; width:170px;" %> -
    - -
  • +
  • + + <%= select_tag :challenge_score, options_for_select([100, 200]), :name => 'challenge[score]', :class => " fl", :style => "height: 40px; width:170px;" %> +
    + +
  • -
    -
      - <% if @st == 0 %> -
    1. 如果学员查看了参考答案,则不能得到相应的经验值
    2. -
    3. 如果学员成功得到经验值,那么将同时获得等值的金币奖励,如:+100经验值、+100金币
    4. - <% else %> +
      +
      1. 如果学员答题错误,则不能得到相应的经验值
      2. 如果学员成功得到经验值,那么将同时获得等值的金币奖励,如:+10经验值、+10金币
      3. - <% end %> -
      -
      -
    -
    -

    - -
    -
    -
  • - -
    - <% if params[:action] == "edit" && @challenge_tags.count > 0 %> - <% @challenge_tags.each do |tag| %> -
    - - -
    - <% end %> - <% end %> - -
    " id="add_shixun_skill"> - - + +
    +
    +
  • +

    + +
    +
    +
  • + +
    + <% if params[:action] == "edit" && @challenge_tags.count > 0 %> + <% @challenge_tags.each do |tag| %> +
    + + +
    + <% end %> + <% end %> +
    " id="add_shixun_skill"> + + +
    + +添加 +
    +
  • +

    +
    +
      +
    1. 学员答题正确将获得技能,否则不能获得技能
    2. +
    - +添加
    - -

    -
    -
      - <% if @st == 0 %> -
    1. 学员未参考答案通过了本阶段的评测时将获得技能,否则不能获得技能
    2. - <% else %> -
    3. 学员答题正确将获得技能,否则不能获得技能
    4. - <% end %> -
    -
    -
    -
  • - 保存 - 取消 -
  • +
  • + 保存 + 取消 +
  • +<% end %>