dev_ec
parent
3c76641df3
commit
9cf1de1880
@ -0,0 +1,20 @@
|
||||
class MigrateExerciseAnswerScore < ActiveRecord::Migration
|
||||
def up
|
||||
exercise = Exercise.where(:id => 1527).first
|
||||
if exercise.present?
|
||||
exercise.exercise_users.each do |exercise_user|
|
||||
score = 0
|
||||
exercise.exercise_questions.each do |question|
|
||||
ExerciseShixunAnswer.where(exercise_question_id: question.id, user_id: exercise_user.user_id).each do |answer|
|
||||
score += answer.score
|
||||
end
|
||||
end
|
||||
|
||||
exercise_user.update_attributes(objective_score: score, score: score)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
Loading…
Reference in new issue