|
|
@ -5,11 +5,11 @@ class MigrateExerciseSingleQuestionScore < ActiveRecord::Migration[5.2]
|
|
|
|
|
|
|
|
|
|
|
|
question = answer.exercise_question
|
|
|
|
question = answer.exercise_question
|
|
|
|
exercise_user = ExerciseUser.find_by(exercise_id: question.exercise_id, user_id: answer.user_id)
|
|
|
|
exercise_user = ExerciseUser.find_by(exercise_id: question.exercise_id, user_id: answer.user_id)
|
|
|
|
user_choice_position = answer.exercise_choice&.choice_position
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if user_choice_position && (user_choice_position.to_i == question.exercise_standard_answers.take&.exercise_choice_id.to_i)
|
|
|
|
if exercise_user && exercise_user.commit_status == 1
|
|
|
|
answer.update!(score: question.question_score)
|
|
|
|
user_choice_position = answer.exercise_choice&.choice_position
|
|
|
|
if exercise_user && exercise_user.commit_status == 1
|
|
|
|
if user_choice_position && (user_choice_position.to_i == question.exercise_standard_answers.take&.exercise_choice_id.to_i)
|
|
|
|
|
|
|
|
answer.update!(score: question.question_score)
|
|
|
|
score = exercise_user.score + question.question_score
|
|
|
|
score = exercise_user.score + question.question_score
|
|
|
|
objective_score = exercise_user.objective_score + question.question_score
|
|
|
|
objective_score = exercise_user.objective_score + question.question_score
|
|
|
|
exercise_user.update!(score: score, objective_score: objective_score)
|
|
|
|
exercise_user.update!(score: score, objective_score: objective_score)
|
|
|
|