From d407610740ba73698f3db4a49e3573d68db6b0bd Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 18 Nov 2015 16:51:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A1=AB=E7=A9=BA=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_exercise_form.html.erb | 27 ++++++++++++++----- app/views/exercise/_new_MCQ.html.erb | 2 +- app/views/exercise/_new_single.html.erb | 11 ++++++-- app/views/exercise/_show_MC.html.erb | 6 ++--- app/views/exercise/_show_MCQ.html.erb | 6 ++--- app/views/exercise/_show_single.html.erb | 25 +++++++++++++++++ .../exercise/delete_exercise_question.js.erb | 1 + .../exercise/update_exercise_question.js.erb | 0 config/routes.rb | 1 + 9 files changed, 63 insertions(+), 16 deletions(-) create mode 100644 app/views/exercise/delete_exercise_question.js.erb create mode 100644 app/views/exercise/update_exercise_question.js.erb diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 61e288079..1d78fb435 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -61,7 +61,12 @@ function insert_MC(quest_type,quest_num,quest_id){ $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%#= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@exercise.id),:remote => true do |f|%>'+ + '<%= form_for(ExerciseQuestion.new, + :html => { :multipart => true }, + :url => {:controller => 'exercise', + :action => 'create_exercise_question', + :course_id => @course.id + },:remote=>true ) do |f|%>'+ '
'+ '
'+ ''+ @@ -107,7 +112,7 @@ '
'+ '
'+ '
'+ - '<%# end%>' + '<% end%>' ); $("#poll_questions_title").focus(); } @@ -119,7 +124,12 @@ function insert_MCQ(quest_type,quest_num,quest_id){ $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%#= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@exercise.id),:remote => true do |f|%>'+ + '<%= form_for(ExerciseQuestion.new, + :html => { :multipart => true }, + :url => {:controller => 'exercise', + :action => 'create_exercise_question', + :course_id => @course.id + },:remote=>true ) do |f|%>'+ '
'+ '
'+ ''+ @@ -165,7 +175,7 @@ '
'+ '
'+ '
'+ - '<%# end%>' + '<% end%>' ); $("#poll_questions_title").focus(); } @@ -177,7 +187,12 @@ function insert_SINGLE(quest_type,quest_num,quest_id){ $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%#= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@exercise.id),:remote => true do |f|%>'+ + '<%= form_for(ExerciseQuestion.new, + :html => { :multipart => true }, + :url => {:controller => 'exercise', + :action => 'create_exercise_question', + :course_id => @course.id + },:remote=>true ) do |f|%>'+ '
'+ '
'+ ''+ @@ -198,7 +213,7 @@ '
'+ '
'+ '
'+ - '<%# end%>' + '<% end%>' ); $("#poll_questions_title").focus(); } diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index f5a8257ca..6e58d620e 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -47,7 +47,7 @@
  • - +
  • diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index f48c7673d..e4e1db695 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -1,8 +1,14 @@ +<%= form_for(ExerciseQuestion.new, + :html => { :multipart => true }, + :url => {:controller => 'exercise', + :action => 'create_exercise_question', + :course_id => @course.id + },:remote=>true ) do |f| %>
    - +
    -
    \ No newline at end of file + +<% end %> \ No newline at end of file diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index 09575ab00..e7bf20206 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -4,7 +4,7 @@ (<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>) - <%#= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), + <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id), method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> @@ -31,8 +31,8 @@ \ 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 9a7f82f54..f69b855bd 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -3,7 +3,7 @@ <%= exercise_question.question_title %> (<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>) - <%#= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), + <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id), method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> @@ -32,9 +32,7 @@ diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index e69de29bb..07ecce94d 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -0,0 +1,25 @@ +
    +
    第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
    + <%= exercise_question.question_title %> +
    + <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id), + method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> + + +
    +
    + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + 候选答案:<%= exercise_choice.choice_text%>
    + <% end %> +
    +
    + +
    +
    + \ No newline at end of file diff --git a/app/views/exercise/delete_exercise_question.js.erb b/app/views/exercise/delete_exercise_question.js.erb new file mode 100644 index 000000000..eb6300eb5 --- /dev/null +++ b/app/views/exercise/delete_exercise_question.js.erb @@ -0,0 +1 @@ +$("#poll_content").html("<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise}) %>"); \ No newline at end of file diff --git a/app/views/exercise/update_exercise_question.js.erb b/app/views/exercise/update_exercise_question.js.erb new file mode 100644 index 000000000..e69de29bb diff --git a/config/routes.rb b/config/routes.rb index b1e4725e6..8dba79d2c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -156,6 +156,7 @@ RedmineApp::Application.routes.draw do end collection do #生成路径为 /exercise/方法名 + delete 'delete_exercise_question' end end