You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
class AddOldExerciseTiankongChoiceId < ActiveRecord :: Migration [ 5 . 2 ]
def up
#类型为3 的问题答案及标准答案更新exercise_choice_id 为1, 即表示第一空
exercise_question_ids = ExerciseQuestion . where ( " question_type = 3 " ) . pluck ( :id )
ExerciseAnswer . where ( exercise_question_id : exercise_question_ids , exercise_choice_id : nil ) . update_all ( exercise_choice_id : 1 )
ExerciseStandardAnswer . where ( exercise_question_id : exercise_question_ids , exercise_choice_id : nil ) . update_all ( exercise_choice_id : 1 )
exercise_bank_question_ids = ExerciseBankQuestion . where ( " question_type =3 " ) . pluck ( :id )
ExerciseBankStandardAnswer . where ( exercise_bank_question_id : exercise_bank_question_ids ) . update_all ( exercise_bank_choice_id : 1 )
end
def down
#类型为3 的问题答案及标准答案更新exercise_choice_id 为1, 即表示第一空
exercise_question_ids = ExerciseQuestion . where ( " question_type = 3 " ) . pluck ( :id )
ExerciseAnswer . where ( exercise_question_id : exercise_question_ids , exercise_choice_id : 1 ) . update_all ( exercise_choice_id : nil )
ExerciseStandardAnswer . where ( exercise_question_id : exercise_question_ids , exercise_choice_id : 1 ) . update_all ( exercise_choice_id : nil )
exercise_bank_question_ids = ExerciseBankQuestion . where ( " question_type =3 " ) . pluck ( :id )
ExerciseBankStandardAnswer . where ( exercise_bank_question_id : exercise_bank_question_ids ) . update_all ( exercise_bank_choice_id : nil )
end
end