试卷成绩迁移

dev_forge
cxt 5 years ago
parent 7552d59603
commit f8cf185ce1

@ -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 exercise_user && exercise_user.commit_status == 1
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 user_choice_position && (user_choice_position.to_i == question.exercise_standard_answers.take&.exercise_choice_id.to_i)
answer.update!(score: question.question_score) answer.update!(score: question.question_score)
if exercise_user && exercise_user.commit_status == 1
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)

Loading…
Cancel
Save