From 405e2cfb9b1338d7c18d7bf0fc242a33ec65fe40 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 11 Oct 2016 08:51:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E5=8D=95=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 15 ++++++ app/views/poll/_edit_MC.html.erb | 36 +++++++++---- app/views/poll/_poll_content.html.erb | 78 ++++++++++++++++++--------- app/views/poll/_show_MC.html.erb | 28 +++++----- public/stylesheets/css/common.css | 1 + 5 files changed, 113 insertions(+), 45 deletions(-) diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index bc5e5dc9e..d7b2cfa26 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -199,6 +199,21 @@ class PollController < ApplicationController @poll_question.poll_answers.new question_option end end + if params[:question_other_answer] + question = @poll_question.poll_answers.where("answer_text = ''").first + unless question + question_option = { + :answer_position => params[:question_answer].count + 1, + :answer_text => '' + } + @poll_question.poll_answers.new question_option + end + else + question = @poll_question.poll_answers.where("answer_text = ''").first + if question + question.destroy + end + end end @poll_question.save respond_to do |format| diff --git a/app/views/poll/_edit_MC.html.erb b/app/views/poll/_edit_MC.html.erb index 9209bf61d..08aeacc43 100644 --- a/app/views/poll/_edit_MC.html.erb +++ b/app/views/poll/_edit_MC.html.erb @@ -17,26 +17,44 @@ } -
+
- + />
    <% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %> -
  • - - - - -
  • -
    + <% if poll_answer.answer_text != '' %> +
  • + + + +
  • +
    + <% else %> +
  • + + + +
  • +
    + <% end %> <% end%>
+