From f8cf185ce1fd71863bc0e16346b7eb20926203a4 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 4 Dec 2019 11:51:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E6=88=90=E7=BB=A9=E8=BF=81?= =?UTF-8?q?=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...191204030230_migrate_exercise_single_question_score.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/migrate/20191204030230_migrate_exercise_single_question_score.rb b/db/migrate/20191204030230_migrate_exercise_single_question_score.rb index 463bbc8ee..3988ab3f5 100644 --- a/db/migrate/20191204030230_migrate_exercise_single_question_score.rb +++ b/db/migrate/20191204030230_migrate_exercise_single_question_score.rb @@ -5,11 +5,11 @@ class MigrateExerciseSingleQuestionScore < ActiveRecord::Migration[5.2] question = answer.exercise_question 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) - answer.update!(score: question.question_score) - if exercise_user && exercise_user.commit_status == 1 + 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) + answer.update!(score: question.question_score) score = exercise_user.score + question.question_score objective_score = exercise_user.objective_score + question.question_score exercise_user.update!(score: score, objective_score: objective_score)