Skip to content

Commit

Permalink
trying to work through a rare edge case:
Browse files Browse the repository at this point in the history
- a professor creates an exam with two versions, that start at different times
- after the first version is complete, the professor begins grading
- ...but then realizes that a student in the first version ought to have been in the second, and moves the student
- ...who actually had never started taking the exam, and who had not yet been actually graded

In that case, instead of creating a spurious grading lock for the student, and causing grading to get wedged (requiring database manipulation to resolve), this will erase the prior (unused) grading locks and allow the student to be moved between versions successfully.
  • Loading branch information
Ben Lerner committed Apr 15, 2024
1 parent 6c3866c commit d72805a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/graphql/mutations/update_version_registrations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@ def assign_student!(exam, version, student)
err = "Cannot update already started student '#{student.display_name}'"
raise GraphQL::ExecutionError, err if student_reg.started?

# If a student hasn't really started, and hasn't really been graded,
# then should they really be prevented from switching versions?
if (!student_reg.started? &&
student_reg.final? &&
student_reg.snapshots.empty? &&
student_reg.grading_comments.empty? &&
student_reg.grading_checks.empty?)
student_reg.start_time = nil
student_reg.grading_locks.destroy_all
end

err = "Cannot update already-finalized and graded student '#{student.display_name}'"
finalized = student_reg.final?
graded = student_reg.grading_locks.where.not(completed_by: nil).any?
raise GraphQL::ExecutionError, err if (finalized && graded)

student_reg.exam_version = version
saved = student_reg.save
raise GraphQL::ExecutionError, student_reg.errors.full_messages.to_sentence unless saved
Expand Down

0 comments on commit d72805a

Please sign in to comment.