diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 9177e044b..e1439b7f9 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -54,7 +54,9 @@ class PollController < ApplicationController end def edit - + respond_to do |format| + format.html{render :layout => 'base_courses'} + end end def update @@ -82,8 +84,8 @@ class PollController < ApplicationController end #添加单选题 - def add_mc - + def create_poll_question + a = 1 end private diff --git a/app/views/poll/_edit_MC.html.erb b/app/views/poll/_edit_MC.html.erb index 73d967ca9..492126827 100644 --- a/app/views/poll/_edit_MC.html.erb +++ b/app/views/poll/_edit_MC.html.erb @@ -1,33 +1,26 @@ -
-
-
- - - - -
-
-
    -
  • - - - - -
  • -
    -
  • - - - - -
  • +<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%> +
    + +
    +
    + + + + +
    +
    +
      + <%= render :partial => 'question_answer'%> + <%= render :partial => 'question_answer'%> + <%= render :partial => 'question_answer'%> +
    +
    +
    -
-
- +
-
-
- \ No newline at end of file +<% end%> \ No newline at end of file diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb index 0387bb9c6..a8ad46694 100644 --- a/app/views/poll/_poll_form.html.erb +++ b/app/views/poll/_poll_form.html.erb @@ -10,6 +10,22 @@ function add_MCQ(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_MCQ') %>");} function add_single(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_single') %>");} function add_mulit(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_mulit') %>");} + //单选题 + function add_single_answer(doc) + { + doc.parent().after("<%= escape_javascript(render :partial => 'question_answer') %>"); + } + function remove_single_answer(doc) + { + if(doc.parent().siblings("li").length == 0) + { + doc.parent().parent().parent().parent().parent().parent().remove(); + } + else + { + doc.parent().remove(); + } + } @@ -45,6 +61,7 @@ <%= render :partial => 'edit_head'%>
+ <%#= render :partial => 'edit_MC'%>
diff --git a/app/views/poll/_question_answer.html.erb b/app/views/poll/_question_answer.html.erb new file mode 100644 index 000000000..765d71787 --- /dev/null +++ b/app/views/poll/_question_answer.html.erb @@ -0,0 +1,11 @@ +
  • + + + + +
  • +
    \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index af0b75ae7..d2d0c73a8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -61,7 +61,7 @@ RedmineApp::Application.routes.draw do resources :poll do member do get 'statistics_result' - get 'add_mc' + post 'create_poll_question' end end