From 4cd9f6a50278a9f513f31c335d6ee3341e75973b Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 19 Nov 2015 11:37:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E9=A2=98=E7=9B=AE=E6=97=B6?= =?UTF-8?q?=E5=88=86=E6=95=B0=E8=87=AA=E5=8A=A8=E8=8E=B7=E5=8F=96=E5=90=8C?= =?UTF-8?q?=E4=B8=80=E7=B1=BB=E5=9E=8B=E9=A2=98=E7=9B=AE=E7=9A=84=E6=9C=80?= =?UTF-8?q?=E5=90=8E=E4=B8=80=E4=B8=AA=E5=88=86=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_exercise_form.html.erb | 237 +----------------- app/views/exercise/_new_MC.html.erb | 3 +- app/views/exercise/_new_MCQ.html.erb | 3 +- app/views/exercise/_new_question.html.erb | 24 ++ app/views/exercise/_new_single.html.erb | 3 +- app/views/exercise/_show_MC.html.erb | 77 +++++- app/views/exercise/_show_MCQ.html.erb | 83 +++++- app/views/exercise/_show_single.html.erb | 64 ++++- .../exercise/create_exercise_question.js.erb | 1 + 9 files changed, 254 insertions(+), 241 deletions(-) create mode 100644 app/views/exercise/_new_question.html.erb diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 863f68a72..4bb2c31ab 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -54,223 +54,6 @@ } } - function add_MC(){ - $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MC') %>"); - $("#poll_questions_title").focus(); - } - - function insert_MC(quest_type,quest_num,quest_id){ - if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") { - $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>{:controller=> 'exercise',:action=>'create_exercise_question',:course_id=>@course.id},:remote=>true) do |f|%>'+ - '
'+ - '
'+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
'+ - '
'+ - '
    '+ - '
  • '+ - ''+ - '分'+ - '
  • '+ - '
  • '+ - ''+ - ''+ - ''+ - ''+ - '
  • '+ - '
    '+ - '
  • '+ - ''+ - ''+ - ''+ - ''+ - '
  • '+ - '
    '+ - '
  • '+ - ''+ - ''+ - ''+ - ''+ - '
  • '+ - '
    '+ - '
  • '+ - ''+ - ''+ - ''+ - ''+ - '
  • '+ - '
    '+ - '
  • '+ - ''+ - ''+ - '
  • '+ - '
    '+ - '
'+ - '
'+ - ''+ - '
'+ - '
'+ - '<% end%>' - ); - } - else { - $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); - } - $("#poll_questions_title").focus(); - } - - function add_MCQ(){ - $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MCQ') %>"); - $("#poll_questions_title").focus(); - } - - function insert_MCQ(quest_type,quest_num,quest_id){ - if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == ""){ - $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>{:controller=> 'exercise',:action=>'create_exercise_question',:course_id=>@course.id},:remote=>true) do |f|%>'+ - '
'+ - '
'+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
'+ - '
'+ - '
    '+ - '
  • '+ - ''+ - '分'+ - '
  • '+ - '
  • '+ - ''+ - ''+ - ''+ - ''+ - '
  • '+ - '
    '+ - '
  • '+ - ''+ - ''+ - ''+ - ''+ - '
  • '+ - '
    '+ - '
  • '+ - ''+ - ''+ - ''+ - ''+ - '
  • '+ - '
    '+ - '
  • '+ - ''+ - ''+ - ''+ - ''+ - '
  • '+ - '
    '+ - '
  • '+ - ''+ - ''+ - '
  • '+ - '
    '+ - '
'+ - '
'+ - ''+ - '
'+ - '
'+ - '<% end%>' - ); - } else { - $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); - } - $("#poll_questions_title").focus(); - } - - function add_single(){ - $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_single') %>"); - $("#poll_questions_title").focus(); - } - - function insert_SINGLE(quest_type,quest_num,quest_id){ - if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") { - $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>{:controller=> 'exercise',:action=>'create_exercise_question',:course_id=>@course.id},:remote=>true) do |f|%>'+ - '
'+ - '
'+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
'+ - '
'+ - '
    '+ - '
  • '+ - ''+ - '分'+ - '
  • '+ - '
  • '+ - ''+ - ''+ - ''+ - ''+ - '
  • '+ - '
    '+ - '
  • '+ - ''+ - ''+ - ''+ - ''+ - '
  • '+ - '
    '+ - '
  • '+ - ''+ - ''+ - ''+ - ''+ - '
  • '+ - '
    '+ - '
'+ - '
'+ - ''+ - '
'+ - '
'+ - '<% end%>' - ); - } else { - $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); - } - $("#poll_questions_title").focus(); - } - //选择导入调查问卷 function importPoll(){ importPollPopWindow = $("#import_poll"); @@ -297,10 +80,15 @@ } //添加标题时确定按钮 - function add_poll_question(doc) + function add_poll_question(doc,quest_type,quest_id) { - var title = $.trim($("#poll_questions_title").val()); - if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();} + if(arguments[1] && arguments[2]){ + var title = $.trim($("#poll_questions_title_"+quest_type+"_"+quest_id)); + if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();} + } else { + var title = $.trim($("#poll_questions_title").val()); + if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();} + } } //修改标题时确定按钮 function edit_poll_question(doc,id) @@ -394,13 +182,8 @@ <%= render :partial => 'exercise_content', :locals => {:exercise => @exercise}%> -
- -
+
+ <%= render :partial => 'new_question', :locals => {:exercise => @exercise} %>
diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb index 158f8be96..3da0021ce 100644 --- a/app/views/exercise/_new_MC.html.erb +++ b/app/views/exercise/_new_MC.html.erb @@ -13,8 +13,9 @@
  • + <% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %> - 分 +
  • diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index 6e58d620e..044ecd629 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -13,8 +13,9 @@
    • + <% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %> - 分 +
    • diff --git a/app/views/exercise/_new_question.html.erb b/app/views/exercise/_new_question.html.erb new file mode 100644 index 000000000..d41ad1ca7 --- /dev/null +++ b/app/views/exercise/_new_question.html.erb @@ -0,0 +1,24 @@ + +
      + + \ No newline at end of file diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index a8c6f57ea..ad5af1937 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -13,8 +13,9 @@
      • + <% score = exercise.exercise_questions.where("question_type=3").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %> - 分 +
      • diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index 241cc6009..1c90f6908 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -28,4 +28,79 @@
      -
      \ No newline at end of file +
    + + \ No newline at end of file diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index 7dd52b30a..08a012fd3 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -28,12 +28,77 @@
    - \ No newline at end of file + + \ No newline at end of file diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index 452a14bc4..8232e68f3 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -15,4 +15,66 @@
-
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/app/views/exercise/create_exercise_question.js.erb b/app/views/exercise/create_exercise_question.js.erb index db9468350..37199a70e 100644 --- a/app/views/exercise/create_exercise_question.js.erb +++ b/app/views/exercise/create_exercise_question.js.erb @@ -1,6 +1,7 @@ <% if @is_insert %> $("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>'); <% else %> + $("#new_exercise_question").html('<%= escape_javascript(render :partial => 'new_question', :locals => {:exercise => @exercise}) %>'); $("#new_poll_question").html(""); <%if @exercise_questions.question_type == 1%> $("#mc_question_list").show().append("
" +