|
|
|
@ -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,"问卷不存在!")
|
|
|
|
@ -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,10 +147,10 @@ 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) || poll_user_status == 3
|
|
|
|
|
elsif (poll_user.present? && poll_user.commit_status == 1) || poll_user_status == 3
|
|
|
|
|
normal_status(-1,"已提交/已结束的问卷不允许修改!")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|