From eb2498c62c6af8f3af92641d6bd5796964ec56cf Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 14 Jan 2015 14:23:41 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E6=96=B0=E5=A2=9E=E5=8D=95?= =?UTF-8?q?=E9=80=89=E9=A2=98=E3=80=81=E6=96=B0=E5=A2=9E=E9=80=89=E9=A1=B9?= =?UTF-8?q?=E3=80=81=E5=88=A0=E9=99=A4=E9=80=89=E9=A1=B9=E7=AD=89js=202.?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=AE=E5=8D=B7layout=E5=A2=9E=E5=8A=A0=20?= =?UTF-8?q?3.=E5=A2=9E=E5=8A=A0=E6=96=B0=E5=A2=9E=E5=8D=95=E9=80=89?= =?UTF-8?q?=E9=A2=98=E7=A1=AE=E5=AE=9A=E6=8C=89=E9=92=AE=E7=9A=84=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E4=BB=A5=E5=8F=8A=E7=9B=B8=E5=85=B3action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 8 ++-- app/views/poll/_edit_MC.html.erb | 55 +++++++++++------------- app/views/poll/_poll_form.html.erb | 17 ++++++++ app/views/poll/_question_answer.html.erb | 11 +++++ config/routes.rb | 2 +- 5 files changed, 58 insertions(+), 35 deletions(-) create mode 100644 app/views/poll/_question_answer.html.erb 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