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 @@
-
- 编辑
- 删除
-
-