lml / ost

OpenStax Tutor
Other
7 stars 8 forks source link

next_student_exercise helper is broken #353

Open jpslav opened 10 years ago

jpslav commented 10 years ago

I believe that the next_student_exercise and friends are broken because student_assignment.student_exercises is not guaranteed to give those SEs in the correct order (though it likely is the case that they are normally returned in order).

Something more like this will work:

next_ae = @student_exercise.assignment_exercise.next
next_se = next_ae.nil? ?
          nil :
          StudentExercise.where{student_assignment_id == my{@student_exercise.student_assignment_id}}.where{assignment_exercise_id == my{next_ae.id}}.first