diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 2f8a26c2a..191968183 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -117,6 +117,21 @@ class PollController < ApplicationController a = 1 end + #删除单选题 + def delete_poll_question + @poll_question = PollQuestion.find params[:poll_question] + poll_questions = @poll_question.poll.poll_questions.where("question_number > #{@poll_question.question_number}") + poll_questions.each do |question| + question.question_number -= 1 + question.save + end + if @poll_question && @poll_question.destroy + respond_to do |format| + format.js + end + end + end + private def find_poll_and_course @poll = Poll.find params[:id] diff --git a/app/views/poll/_show_MC.html.erb b/app/views/poll/_show_MC.html.erb index 93077b5b3..f3fc9c8b5 100644 --- a/app/views/poll/_show_MC.html.erb +++ b/app/views/poll/_show_MC.html.erb @@ -9,7 +9,8 @@ <%end%> - + <%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), + method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>