|
|
|
@ -355,9 +355,9 @@ module ExercisesHelper
|
|
|
|
|
exercise_questions = exercise.exercise_questions.includes(:exercise_answers,:exercise_shixun_answers,:exercise_standard_answers,:exercise_shixun_challenges)
|
|
|
|
|
exercise_questions.each do |q|
|
|
|
|
|
if q.question_type != 5
|
|
|
|
|
answers_content = q.exercise_answers.search_answer_users("user_id",user.id) #学生的答案
|
|
|
|
|
answers_content = q.exercise_answers.where(user_id: user.id) #学生的答案
|
|
|
|
|
else
|
|
|
|
|
answers_content = q.exercise_shixun_answers.search_shixun_answers("user_id",user.id) #学生的答案
|
|
|
|
|
answers_content = q.exercise_shixun_answers.where(user_id: user.id) #学生的答案
|
|
|
|
|
end
|
|
|
|
|
if q.question_type <= 2 #为选择题或判断题时
|
|
|
|
|
if answers_content.present? #学生有回答时
|
|
|
|
@ -369,11 +369,11 @@ module ExercisesHelper
|
|
|
|
|
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
|
|
|
|
|
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
|
|
|
|
|
if standard_answer.count > 0
|
|
|
|
|
q_score_1 = (q.question_score / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。
|
|
|
|
|
multi_each_score = (q.question_score / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。
|
|
|
|
|
else
|
|
|
|
|
q_score_1 = 0.0
|
|
|
|
|
multi_each_score = 0.0
|
|
|
|
|
end
|
|
|
|
|
answers_content.update_all(:score => q_score_1)
|
|
|
|
|
answers_content.update_all(:score => multi_each_score)
|
|
|
|
|
score1 = score1 + q.question_score
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
@ -424,7 +424,7 @@ module ExercisesHelper
|
|
|
|
|
end
|
|
|
|
|
ex_shixun_answer_content = answers_content&.where(exercise_shixun_challenge_id: exercise_cha.id)
|
|
|
|
|
if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里
|
|
|
|
|
cha_path = challenge_path exercise_cha.challenge&.path
|
|
|
|
|
cha_path = challenge_path(exercise_cha.challenge&.path)
|
|
|
|
|
game_challenge = game.game_codes.search_challenge_path(cha_path)&.first
|
|
|
|
|
if game_challenge.present?
|
|
|
|
|
game_code = game_challenge
|
|
|
|
|