|
|
|
@ -1760,19 +1760,12 @@ class ExercisesController < ApplicationController
|
|
|
|
|
else
|
|
|
|
|
ques_number = q.question_number
|
|
|
|
|
end
|
|
|
|
|
ques_status = 0
|
|
|
|
|
if q.question_type != Exercise::PRACTICAL
|
|
|
|
|
ques_vote = q.exercise_answers.select{|answer| answer.user_id == user_id}
|
|
|
|
|
else
|
|
|
|
|
ques_vote = q.exercise_shixun_answers.select{|answer| answer.user_id == user_id}
|
|
|
|
|
end
|
|
|
|
|
ques_status = 0
|
|
|
|
|
if ques_vote.present?
|
|
|
|
|
if q.question_type == Exercise::PRACTICAL
|
|
|
|
|
if ques_vote.pluck(:exercise_shixun_challenge_id).sort == q.exercise_shixun_challenges.pluck(:id).sort #用户的总得分等于问题的分数
|
|
|
|
|
ques_status = 1 #全部回答了,才算已答
|
|
|
|
|
question_answered += 1
|
|
|
|
|
end
|
|
|
|
|
else #其他题目,需回答的有内容,才会为已答,否则如内容为空,视为未答
|
|
|
|
|
|
|
|
|
|
if ques_vote.present?
|
|
|
|
|
#其他题目,需回答的有内容,才会为已答,否则如内容为空,视为未答
|
|
|
|
|
vote_answer_id = ques_vote.pluck(:exercise_choice_id).reject(&:blank?)
|
|
|
|
|
vote_text_count = ques_vote.pluck(:answer_text).reject(&:blank?).size
|
|
|
|
|
if q.question_type <= Exercise::JUDGMENT #选择题和判断题的时候,需要有选项,才算回答
|
|
|
|
@ -1780,11 +1773,6 @@ class ExercisesController < ApplicationController
|
|
|
|
|
ques_status = 1
|
|
|
|
|
question_answered += 1
|
|
|
|
|
end
|
|
|
|
|
elsif q.question_type == Exercise::COMPLETION #填空题的时候,需要有选项和内容,才算回答
|
|
|
|
|
if vote_answer_id.uniq.sort == q.exercise_standard_answers.pluck(:exercise_choice_id).uniq.sort
|
|
|
|
|
ques_status = 1
|
|
|
|
|
question_answered += 1
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if vote_text_count > 0 #主观题,必选有内容,才算回答
|
|
|
|
|
ques_status = 1
|
|
|
|
@ -1792,6 +1780,11 @@ class ExercisesController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if Myshixun.exists?(user_id: user_id, shixun_id: q.shixun_id)
|
|
|
|
|
ques_status = 1
|
|
|
|
|
question_answered += 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
question_status = {
|
|
|
|
|
:ques_id => q.id,
|
|
|
|
|