diff --git a/app/controllers/poll_votes_controller.rb b/app/controllers/poll_votes_controller.rb index 813e35bba..f1da3a1b2 100644 --- a/app/controllers/poll_votes_controller.rb +++ b/app/controllers/poll_votes_controller.rb @@ -134,17 +134,11 @@ class PollVotesController < ApplicationController end def check_answer_in_question - # poll_answer_ids = @poll_question.poll_answers.pluck(:id) - # if @poll_question.question_type == 1 #单选题/多选题 - # unless (params[:poll_answer_id].present? && poll_answer_ids.include?(params[:poll_answer_id].to_i)) || (params[:poll_answer_id].blank? && params[:vote_text].present?) - # normal_status(-1, "答案ID错误!") - # end - # end poll_user_status = @poll.get_poll_status(current_user.id) poll_user = @poll.poll_users.find_by(user_id: current_user.id) #当前用户 question_type = @poll_question&.question_type - if [1,2].include?(question_type) && params[:poll_answer_id].blank? + if (question_type == 1) && params[:poll_answer_id].blank? normal_status(-1,"答案ID错误!") elsif question_type == 2 user_vote_count = params[:poll_answer_id].size @@ -153,7 +147,7 @@ class PollVotesController < ApplicationController else question_max_choices = 0 end - if question_max_choices > 0 && user_vote_count > question_max_choices + if question_max_choices > 0 && (user_vote_count > question_max_choices) normal_status(-1,"多选题答案超过最大限制!") end elsif (poll_user.present? && poll_user.commit_status == 1) || poll_user_status == 3