Merge branch 'develop' of https://bdgit.educoder.net/Hjqreturn/pgfqe6ch8 into develop
commit
584da88eca
@ -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