From e22ec14690dbaa202cf44c8f9ab1a32b1413918d Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 26 Jun 2019 12:26:07 +0800 Subject: [PATCH 1/3] fix bug --- app/controllers/poll_votes_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/poll_votes_controller.rb b/app/controllers/poll_votes_controller.rb index 789d5748e..644cc8949 100644 --- a/app/controllers/poll_votes_controller.rb +++ b/app/controllers/poll_votes_controller.rb @@ -123,7 +123,7 @@ class PollVotesController < ApplicationController if @poll_question.blank? normal_status(-1,"问卷试题不存在!") else - @poll = @poll_question.poll.includes(:poll_users) + @poll = @poll_question.poll @course = @poll.course if @poll.blank? normal_status(-1,"问卷不存在!") From 650df60bedfe4291b563a4cf12a7cb3173353978 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 26 Jun 2019 12:28:53 +0800 Subject: [PATCH 2/3] fix bug --- app/controllers/poll_votes_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/poll_votes_controller.rb b/app/controllers/poll_votes_controller.rb index 644cc8949..813e35bba 100644 --- a/app/controllers/poll_votes_controller.rb +++ b/app/controllers/poll_votes_controller.rb @@ -156,7 +156,7 @@ class PollVotesController < ApplicationController if question_max_choices > 0 && user_vote_count > question_max_choices normal_status(-1,"多选题答案超过最大限制!") end - elsif (poll_user.present? && poll_user&.commit_status) || poll_user_status == 3 + elsif (poll_user.present? && poll_user.commit_status == 1) || poll_user_status == 3 normal_status(-1,"已提交/已结束的问卷不允许修改!") end end From 102226efdf58584d941bc96665ce8309b4ccc234 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 26 Jun 2019 12:32:00 +0800 Subject: [PATCH 3/3] fix bug --- app/controllers/poll_votes_controller.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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