Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

dev_video
杨树明 5 years ago
commit 9e72cd1e59

@ -4,7 +4,7 @@ module ControllerRescueHandler
included do included do
rescue_from Exception do |e| rescue_from Exception do |e|
Util.logger_error e Util.logger_error e
render json: {status: -1, message: e.message} render json: {status: -1, message: "接口异常"}
end end
# rescue_from ActionView::MissingTemplate, with: :object_not_found # rescue_from ActionView::MissingTemplate, with: :object_not_found
# rescue_from ActiveRecord::RecordNotFound, with: :object_not_found # rescue_from ActiveRecord::RecordNotFound, with: :object_not_found

File diff suppressed because it is too large Load Diff

@ -1168,7 +1168,7 @@ class ExercisesController < ApplicationController
#班级的选择 #班级的选择
if params[:exercise_group_id].present? if params[:exercise_group_id].present?
group_id = params[:exercise_group_id] group_id = params[:exercise_group_id]
exercise_students = @course_all_members.course_find_by_ids("course_group_id", group_id) #试卷所分班的全部人数 exercise_students = @course_all_members.course_find("course_group_id", group_id) #试卷所分班的全部人数
user_ids = exercise_students.pluck(:user_id).reject(&:blank?) user_ids = exercise_students.pluck(:user_id).reject(&:blank?)
@exercise_users_list = @exercise_users_list.exercise_commit_users(user_ids) @exercise_users_list = @exercise_users_list.exercise_commit_users(user_ids)
end end

@ -1,13 +1,13 @@
class PollQuestionsController < ApplicationController class PollQuestionsController < ApplicationController
before_action :require_login, :check_auth before_action :require_login, :check_auth
before_action :get_poll,only:[:new,:create] before_action :get_poll, only: [:new, :create]
before_action :get_poll_question,except: [:new,:create] before_action :get_poll_question, except: [:new, :create]
before_action :is_course_teacher before_action :is_course_teacher
before_action :get_poll_questions_count,only:[:create] before_action :get_poll_questions_count, only: [:create]
before_action :get_poll_question_answers,only:[:edit,:update] before_action :get_poll_question_answers, only: [:edit, :update]
before_action :check_poll_status,only: [:new,:create,:delete_answer,:destroy] before_action :check_poll_status, only: [:new, :create, :delete_answer, :destroy]
before_action :validates_params,only:[:create,:update] before_action :validates_params, only: [:create, :update]
before_action :validates_update_params,only: [:update] before_action :validates_update_params, only: [:update]
def new def new
@ -25,54 +25,48 @@ class PollQuestionsController < ApplicationController
# 创建题目和选择的答案 # 创建题目和选择的答案
def create def create
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin poll_options = {
poll_options = { :question_title => params[:question_title],
:question_title => params[:question_title], :question_type => params[:question_type],
:question_type => params[:question_type], :is_necessary => params[:is_necessary].to_i,
:is_necessary => params[:is_necessary].to_i, :question_number => @poll_ques_count + 1,
:question_number => @poll_ques_count + 1, :max_choices => params[:max_choices] || nil,
:max_choices => params[:max_choices] || nil, :min_choices => params[:min_choices] || nil
:min_choices => params[:min_choices] || nil }
} @poll_question = @poll.poll_questions.new(poll_options)
@poll_question = @poll.poll_questions.new(poll_options)
if params[:insert_id].present? #插入问题时那么从插入的这个id以后的question_num都将要+1 if params[:insert_id].present? #插入问题时那么从插入的这个id以后的question_num都将要+1
insert_poll = @poll.poll_questions.find_by(id: params[:insert_id]) insert_poll = @poll.poll_questions.find_by(id: params[:insert_id])
if insert_poll.present? #如果该问题存在的话,意思是如果是第一题,那么就不存在插入 if insert_poll.present? #如果该问题存在的话,意思是如果是第一题,那么就不存在插入
ques_num = insert_poll.question_number.to_i ques_num = insert_poll.question_number.to_i
@poll_question.question_number = ques_num + 1 #更新了问题的位置 @poll_question.question_number = ques_num + 1 #更新了问题的位置
@poll.poll_questions.insert_question(ques_num).update_all("question_number = question_number + 1") @poll.poll_questions.insert_question(ques_num).update_all("question_number = question_number + 1")
end
end end
if @poll_question.save! end
if params[:question_type] != 3 if @poll_question.save!
p_answer = params[:question_answers] if params[:question_type] != 3
p_other_answer = params[:question_other_answer] p_answer = params[:question_answers]
# 新增选择题答案选择的选项 p_other_answer = params[:question_other_answer]
(1..p_answer.count).each do |i| # 新增选择题答案选择的选项
answer = p_answer[i-1] # 传入的答案的内容 (1..p_answer.count).each do |i|
question_option = { answer = p_answer[i - 1] # 传入的答案的内容
:answer_position => i, question_option = {
:answer_text => answer :answer_position => i,
} :answer_text => answer
poll_answers = @poll_question.poll_answers.new question_option }
poll_answers.save! poll_answers = @poll_question.poll_answers.new question_option
end poll_answers.save!
# 新增答案的其他选项 end
if p_other_answer # 新增答案的其他选项
question_option = { if p_other_answer
:answer_position => p_answer.count + 1, question_option = {
:answer_text => '' :answer_position => p_answer.count + 1,
} :answer_text => ''
poll_answers = @poll_question.poll_answers.new question_option }
poll_answers.save! poll_answers = @poll_question.poll_answers.new question_option
end poll_answers.save!
end end
end end
rescue Exception => e
uid_logger_error(e.message)
tip_exception("问卷的问题创建失败!")
raise ActiveRecord::Rollback
end end
end end
end end
@ -103,61 +97,55 @@ class PollQuestionsController < ApplicationController
def update def update
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin if @poll_question.question_type < 3 #当为单选题或多选题时
if @poll_question.question_type < 3 #当为单选题或多选题时 p_answer = params[:question_answers]
p_answer = params[:question_answers] p_other_answer = params[:question_other_answer]
p_other_answer = params[:question_other_answer] p_answer_count = p_answer.count
p_answer_count = p_answer.count @poll_question.poll_answers.each do |an|
@poll_question.poll_answers.each do |an| if (p_answer_count < @poll_current_answers) && (p_answer_count..@poll_current_answers).to_a.include?(an.answer_position)
if (p_answer_count < @poll_current_answers) && (p_answer_count..@poll_current_answers).to_a.include?(an.answer_position) an.destroy
an.destroy
end
end end
(1..p_answer_count).each do |i| end
answer = @poll_question.poll_answers.find_answer_by_custom("answer_position",i).first (1..p_answer_count).each do |i|
if answer # 判断该位置的answer是否存在存在则更新.不存在则跳到下一步 answer = @poll_question.poll_answers.find_answer_by_custom("answer_position", i).first
answer.answer_text = p_answer[i-1] if answer # 判断该位置的answer是否存在存在则更新.不存在则跳到下一步
answer.answer_position = i answer.answer_text = p_answer[i - 1]
answer.save! answer.answer_position = i
else answer.save!
answer_options = { else
:answer_position => i, answer_options = {
:answer_text => p_answer[i-1] :answer_position => i,
} :answer_text => p_answer[i - 1]
@poll_question.poll_answers.new answer_options }
end @poll_question.poll_answers.new answer_options
end end
if p_other_answer #判断答案的其他选项是否存在 end
other_answer = @poll_question.poll_answers.find_answer_by_custom("answer_text","").first if p_other_answer #判断答案的其他选项是否存在
if other_answer.blank? other_answer = @poll_question.poll_answers.find_answer_by_custom("answer_text", "").first
question_option = { if other_answer.blank?
:answer_position => p_answer_count + 1, question_option = {
:answer_text => '' :answer_position => p_answer_count + 1,
} :answer_text => ''
@poll_question.poll_answers.new question_option }
else @poll_question.poll_answers.new question_option
other_answer.answer_position = p_answer_count + 1 else
other_answer.save! other_answer.answer_position = p_answer_count + 1
end other_answer.save!
end end
end end
@poll_question.update!(poll_questions_params)
rescue Exception => e
uid_logger_error(e.message)
tip_exception("更新失败")
raise ActiveRecord::Rollback
end end
@poll_question.update!(poll_questions_params)
end end
end end
def delete_answer def delete_answer
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
answer_d_id = params[:answer_no].to_i # 答案的当前位置 answer_d_id = params[:answer_no].to_i # 答案的当前位置
poll_answers = @poll_question.poll_answers poll_answers = @poll_question.poll_answers
delete_answer = poll_answers.find_by(answer_position: answer_d_id) delete_answer = poll_answers.find_by(answer_position: answer_d_id)
left_answers = poll_answers.where("answer_position > ?",answer_d_id) left_answers = poll_answers.where("answer_position > ?", answer_d_id)
left_answers.update_all("answer_position = answer_position - 1") if left_answers left_answers.update_all("answer_position = answer_position - 1") if left_answers
if delete_answer.destroy if delete_answer.destroy
@ -175,7 +163,7 @@ class PollQuestionsController < ApplicationController
def destroy def destroy
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
question_d_id = @poll_question.question_number.to_i #问题的当前位置 question_d_id = @poll_question.question_number.to_i #问题的当前位置
poll_questions = @poll.poll_questions poll_questions = @poll.poll_questions
left_questions = poll_questions.insert_question(question_d_id) left_questions = poll_questions.insert_question(question_d_id)
left_questions.update_all("question_number = question_number - 1") if left_questions left_questions.update_all("question_number = question_number - 1") if left_questions
@ -192,11 +180,11 @@ class PollQuestionsController < ApplicationController
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
opr = params[:opr] opr = params[:opr]
current_q_p = @poll_question.question_number.to_i #问题的当前位置 current_q_p = @poll_question.question_number.to_i #问题的当前位置
if @poll.polls_status.to_i == 1 if @poll.polls_status.to_i == 1
if opr.present? if opr.present?
if opr.to_s == "up" if opr.to_s == "up"
last_q_p = @poll.poll_questions.find_by(question_number: (current_q_p-1)) #当前问题的前一个问题 last_q_p = @poll.poll_questions.find_by(question_number: (current_q_p - 1)) #当前问题的前一个问题
if last_q_p.present? if last_q_p.present?
@poll_question.update!(question_number: (current_q_p - 1)) @poll_question.update!(question_number: (current_q_p - 1))
last_q_p.update!(question_number: current_q_p) # 重新获取当前问题的位置 last_q_p.update!(question_number: current_q_p) # 重新获取当前问题的位置
@ -205,7 +193,7 @@ class PollQuestionsController < ApplicationController
normal_status(-1, "移动失败,已经是第一个问题了!") normal_status(-1, "移动失败,已经是第一个问题了!")
end end
elsif opr.to_s == "down" elsif opr.to_s == "down"
next_q_p = @poll.poll_questions.find_by(question_number: (current_q_p+1)) #当前问题的后一个问题 next_q_p = @poll.poll_questions.find_by(question_number: (current_q_p + 1)) #当前问题的后一个问题
if next_q_p.present? if next_q_p.present?
@poll_question.update!(question_number: (current_q_p + 1)) @poll_question.update!(question_number: (current_q_p + 1))
next_q_p.update!(question_number: current_q_p) next_q_p.update!(question_number: current_q_p)
@ -219,7 +207,7 @@ class PollQuestionsController < ApplicationController
normal_status(-1, "移动失败,请输入参数") normal_status(-1, "移动失败,请输入参数")
end end
else else
normal_status(-1,"已发布的不能移动问题") normal_status(-1, "已发布的不能移动问题")
end end
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
@ -231,7 +219,7 @@ class PollQuestionsController < ApplicationController
private private
def poll_questions_params def poll_questions_params
params.require(:poll_question).permit(:question_title,:question_type,:is_necessary,:question_number,:max_choices,:min_choices) params.require(:poll_question).permit(:question_title, :question_type, :is_necessary, :question_number, :max_choices, :min_choices)
end end
def validates_params def validates_params
@ -242,12 +230,12 @@ class PollQuestionsController < ApplicationController
normal_status(-1, "最小可选不能大于最大可选!") normal_status(-1, "最小可选不能大于最大可选!")
elsif params[:question_answers].present? && (params[:max_choices].to_i > params[:question_answers].count) elsif params[:question_answers].present? && (params[:max_choices].to_i > params[:question_answers].count)
normal_status(-1, "选择题的最大可选项不能大于答案数!") normal_status(-1, "选择题的最大可选项不能大于答案数!")
elsif [1,3].include?(params[:question_type]) && (params[:max_choices].to_i > 0 || params[:min_choices].to_i > 0) elsif [1, 3].include?(params[:question_type]) && (params[:max_choices].to_i > 0 || params[:min_choices].to_i > 0)
normal_status(-1, "单选题或主观题不能有最大或最小选择数!") normal_status(-1, "单选题或主观题不能有最大或最小选择数!")
elsif params[:question_type] == 3 && (params[:question_answers] || params[:question_other_answer]) elsif params[:question_type] == 3 && (params[:question_answers] || params[:question_other_answer])
normal_status(-1, "主观问题不需要可选答案!") normal_status(-1, "主观问题不需要可选答案!")
elsif params[:question_type] != 3 elsif params[:question_type] != 3
if params[:question_answers].present? && params[:question_answers].select{|answer| answer.blank?}.count > 0 if params[:question_answers].present? && params[:question_answers].select {|answer| answer.blank?}.count > 0
normal_status(-1, "选项不能有空值!") normal_status(-1, "选项不能有空值!")
elsif params[:question_other_answer].present? && !params[:question_other_answer].blank? elsif params[:question_other_answer].present? && !params[:question_other_answer].blank?
normal_status(-1, "其他选项不能有值!") normal_status(-1, "其他选项不能有值!")
@ -262,11 +250,11 @@ class PollQuestionsController < ApplicationController
def validates_update_params def validates_update_params
question_a_count = params[:question_answers].present? ? params[:question_answers].count : 0 question_a_count = params[:question_answers].present? ? params[:question_answers].count : 0
question_o_count = params[:question_other_answer].present? ? params[:question_other_answer].count : 0 question_o_count = params[:question_other_answer].present? ? params[:question_other_answer].count : 0
normal_status(-1, "已发布的问卷不允许增删答案!") if (((question_a_count+question_o_count) != @poll_current_answers) && (@poll.polls_status.to_i != 1)) normal_status(-1, "已发布的问卷不允许增删答案!") if (((question_a_count + question_o_count) != @poll_current_answers) && (@poll.polls_status.to_i != 1))
end end
def get_poll def get_poll
@poll = Poll.find_by(id:params[:poll_id]) @poll = Poll.find_by(id: params[:poll_id])
if @poll.blank? if @poll.blank?
tip_exception(404) tip_exception(404)
end end
@ -283,7 +271,7 @@ class PollQuestionsController < ApplicationController
def get_poll_question def get_poll_question
@poll_question = PollQuestion.find_by(id: params[:id]) @poll_question = PollQuestion.find_by(id: params[:id])
if @poll_question.present? if @poll_question.present?
@poll = Poll.find_by(id:@poll_question.poll_id) @poll = Poll.find_by(id: @poll_question.poll_id)
else else
tip_exception(404) tip_exception(404)
end end
@ -305,7 +293,7 @@ class PollQuestionsController < ApplicationController
tip_exception(404) tip_exception(404)
else else
@identity = current_user.course_identity(@course) @identity = current_user.course_identity(@course)
normal_status(-1, "权限不够") unless(@course.present? && @identity < Course::STUDENT) #课堂存在,且当前用户为教师/管理员 normal_status(-1, "权限不够") unless (@course.present? && @identity < Course::STUDENT) #课堂存在,且当前用户为教师/管理员
end end
end end
end end

@ -5,120 +5,114 @@ class PollVotesController < ApplicationController
before_action :check_answer_in_question before_action :check_answer_in_question
def create #每一次答案的点击,请求一次 def create #每一次答案的点击,请求一次
begin question_votes = @poll_question.poll_votes
question_votes = @poll_question.poll_votes question_type = @poll_question.question_type
question_type = @poll_question.question_type question_answer_id = params[:poll_answer_id] ? params[:poll_answer_id] : -1 #该答案的id
question_answer_id = params[:poll_answer_id] ? params[:poll_answer_id] : -1 #该答案的id question_answer_text = params[:vote_text].present? ? params[:vote_text] : nil #其他选项的内容
question_answer_text = params[:vote_text].present? ? params[:vote_text] : nil #其他选项的内容 user_votes = question_votes.find_current_vote("user_id", current_user.id) #当前用户的答案,可能有多个
user_votes = question_votes.find_current_vote("user_id",current_user.id) #当前用户的答案,可能有多个 # 当前用户的当前答案,如果已存在,当再次点击的时候,取消答案,即删除该答案
# 当前用户的当前答案,如果已存在,当再次点击的时候,取消答案,即删除该答案 current_vote_text = nil
current_vote_text = nil
# if user_votes.find_vote_text.present? # if user_votes.find_vote_text.present?
# current_vote_text = user_votes.find_vote_text.first # current_vote_text = user_votes.find_vote_text.first
# end # end
vote_answer_params = { vote_answer_params = {
:user_id => current_user.id, :user_id => current_user.id,
:poll_question_id => @poll_question.id, :poll_question_id => @poll_question.id,
:poll_answer_id => question_answer_id, :poll_answer_id => question_answer_id,
:vote_text => question_answer_text :vote_text => question_answer_text
} }
#begin #begin
if question_type == 1 if question_type == 1
if user_votes.present? #用户曾经回答过的,答案选择不一样,否则新建 if user_votes.present? #用户曾经回答过的,答案选择不一样,否则新建
current_user_answer = user_votes.first current_user_answer = user_votes.first
if current_user_answer&.poll_answer_id != question_answer_id #如果说更换了答案,则以前的答案删除,并新建记录 if current_user_answer&.poll_answer_id != question_answer_id #如果说更换了答案,则以前的答案删除,并新建记录
current_user_answer.destroy current_user_answer.destroy
PollVote.create!(vote_answer_params) PollVote.create!(vote_answer_params)
else else
if question_answer_text.present? if question_answer_text.present?
current_user_answer.update!(vote_text: question_answer_text) current_user_answer.update!(vote_text: question_answer_text)
end
end end
else
PollVote.create!(vote_answer_params)
end end
elsif question_type == 2 #多选题的话答案应该是1个以上 else
question_answer_ids = params[:poll_answer_id] ? params[:poll_answer_id] : [] #该答案的id PollVote.create!(vote_answer_params)
if question_answer_ids.present? end
if question_answer_text.present? #有文字输入,但是不存在其他选项的 elsif question_type == 2 #多选题的话答案应该是1个以上
ques_vote_id = question_answer_ids.map(&:to_i).max question_answer_ids = params[:poll_answer_id] ? params[:poll_answer_id] : [] #该答案的id
ques_vote = user_votes.find_by(poll_answer_id: ques_vote_id) if question_answer_ids.present?
if ques_vote.present? if question_answer_text.present? #有文字输入,但是不存在其他选项的
ques_vote.update!(vote_text: question_answer_text) ques_vote_id = question_answer_ids.map(&:to_i).max
else ques_vote = user_votes.find_by(poll_answer_id: ques_vote_id)
answer_option = { if ques_vote.present?
:user_id => current_user.id, ques_vote.update!(vote_text: question_answer_text)
:poll_question_id => @poll_question.id, else
:poll_answer_id => ques_vote_id, answer_option = {
:vote_text => question_answer_text :user_id => current_user.id,
} :poll_question_id => @poll_question.id,
PollVote.create!(answer_option) :poll_answer_id => ques_vote_id,
# 重新取一次poll_votes :vote_text => question_answer_text
user_votes = @poll_question.poll_votes.find_current_vote("user_id",current_user.id) }
end PollVote.create!(answer_option)
# if current_vote_text.present? #已有其他输入文字的选项 # 重新取一次poll_votes
# current_vote_text.update_attribute("vote_text", question_answer_text) user_votes = @poll_question.poll_votes.find_current_vote("user_id", current_user.id)
# else
#
# end
end end
# if current_vote_text.present? #已有其他输入文字的选项
# current_vote_text.update_attribute("vote_text", question_answer_text)
# else
#
# end
end
ea_ids = user_votes.pluck(:poll_answer_id) ea_ids = user_votes.pluck(:poll_answer_id)
common_answer_ids = question_answer_ids & ea_ids #已经存在的试卷选项id common_answer_ids = question_answer_ids & ea_ids #已经存在的试卷选项id
new_ids = question_answer_ids - common_answer_ids # 新增的id new_ids = question_answer_ids - common_answer_ids # 新增的id
old_ids = ea_ids - common_answer_ids #没有选择的,则删掉 old_ids = ea_ids - common_answer_ids #没有选择的,则删掉
if new_ids.size > 0 if new_ids.size > 0
new_ids.each do |e| new_ids.each do |e|
answer_option = { answer_option = {
:user_id => current_user.id, :user_id => current_user.id,
:poll_question_id => @poll_question.id, :poll_question_id => @poll_question.id,
:poll_answer_id => e, :poll_answer_id => e,
:vote_text => nil :vote_text => nil
} }
ex_a = PollVote.new(answer_option) ex_a = PollVote.new(answer_option)
ex_a.save! ex_a.save!
end
end end
if old_ids.size > 0
ea_answer = user_votes.find_current_vote("poll_answer_id",old_ids)
ea_answer.destroy_all
end
else
user_votes.destroy_all
end end
else #主观题的输入 if old_ids.size > 0
# current_vote_text = user_votes.find_vote_text ea_answer = user_votes.find_current_vote("poll_answer_id", old_ids)
if user_votes.present? ea_answer.destroy_all
user_votes.first.update!(vote_text: question_answer_text)
# if question_answer_text.present?
# user_votes.first.update_attribute("vote_text", question_answer_text)
# else
# user_votes.destroy_all
# end
else
PollVote.create!(vote_answer_params)
end end
else
user_votes.destroy_all
end end
@current_question_number = @poll_question.question_number else #主观题的输入
@current_question_necessary = @poll_question.is_necessary # current_vote_text = user_votes.find_vote_text
#问答记录存在,且有值,才会有返回值。 if user_votes.present?
@current_question_status = 0 user_votes.first.update!(vote_text: question_answer_text)
new_user_votes = question_votes.where(user_id: current_user.id) # if question_answer_text.present?
if new_user_votes.present? # user_votes.first.update_attribute("vote_text", question_answer_text)
vote_answer_id = new_user_votes.pluck(:poll_answer_id).reject(&:blank?).size # else
vote_text_count = new_user_votes.pluck(:vote_text).reject(&:blank?).size # user_votes.destroy_all
if vote_text_count > 0 || vote_answer_id > 0 # end
@current_question_status = 1 else
end PollVote.create!(vote_answer_params)
end
end
@current_question_number = @poll_question.question_number
@current_question_necessary = @poll_question.is_necessary
#问答记录存在,且有值,才会有返回值。
@current_question_status = 0
new_user_votes = question_votes.where(user_id: current_user.id)
if new_user_votes.present?
vote_answer_id = new_user_votes.pluck(:poll_answer_id).reject(&:blank?).size
vote_text_count = new_user_votes.pluck(:vote_text).reject(&:blank?).size
if vote_text_count > 0 || vote_answer_id > 0
@current_question_status = 1
end end
rescue Exception => e
uid_logger_error(e.message)
tip_exception("页面调用失败!")
raise ActiveRecord::Rollback
end end
end end
@ -128,14 +122,14 @@ class PollVotesController < ApplicationController
def get_poll_question def get_poll_question
@poll_question = PollQuestion.find_by_id(params[:poll_question_id]) @poll_question = PollQuestion.find_by_id(params[:poll_question_id])
if @poll_question.blank? if @poll_question.blank?
normal_status(-1,"问卷试题不存在!") normal_status(-1, "问卷试题不存在!")
else else
@poll = @poll_question.poll @poll = @poll_question.poll
@course = @poll.course @course = @poll.course
if @poll.blank? if @poll.blank?
normal_status(-1,"问卷不存在!") normal_status(-1, "问卷不存在!")
elsif @course.blank? elsif @course.blank?
normal_status(-1,"课堂不存在!") normal_status(-1, "课堂不存在!")
end end
end end
end end
@ -146,7 +140,7 @@ class PollVotesController < ApplicationController
question_type = @poll_question&.question_type question_type = @poll_question&.question_type
if (question_type == 1) && params[:poll_answer_id].blank? if (question_type == 1) && params[:poll_answer_id].blank?
normal_status(-1,"答案ID错误!") normal_status(-1, "答案ID错误!")
elsif question_type == 2 elsif question_type == 2
user_vote_count = params[:poll_answer_id].size user_vote_count = params[:poll_answer_id].size
if @poll_question.max_choices.present? if @poll_question.max_choices.present?
@ -155,10 +149,10 @@ class PollVotesController < ApplicationController
question_max_choices = 0 question_max_choices = 0
end 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,"多选题答案超过最大限制!") normal_status(-1, "多选题答案超过最大限制!")
end end
elsif (poll_user.present? && poll_user.commit_status == 1) || poll_user_status == 3 elsif (poll_user.present? && poll_user.commit_status == 1) || poll_user_status == 3
normal_status(-1,"已提交/已结束的问卷不允许修改!") normal_status(-1, "已提交/已结束的问卷不允许修改!")
end end
end end

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save