fix: end grading when a question stops being open
WR-06: a Question save hook clears grading_status on the answers of a question that changed type away from open, in the save's transaction, so they leave the review queue and needs_review. GradeAnswer ignores a question that is no longer open, and a choice or self-check re-answer clears the text, grade and review columns of its row.
This commit is contained in:
@@ -187,9 +187,9 @@ func fireAfterCommit[T any](ctx context.Context, s *Service, tx *gorm.DB, name s
|
||||
// open and no row lock held, so a slow grader blocks no student.
|
||||
//
|
||||
// A missing answer, one that is no longer pending (graded, failed or
|
||||
// reviewed by the owner) and one whose grading_seq differs from seq (the
|
||||
// student wrote a newer text) are left alone, as is an answer whose quiz
|
||||
// has no registered grader. Each run counts an attempt for the current
|
||||
// reviewed by the owner), one whose grading_seq differs from seq (the
|
||||
// student wrote a newer text) and one whose question is no longer open are
|
||||
// left alone, as is an answer whose quiz has no registered grader. Each run counts an attempt for the current
|
||||
// text first. A grader error, or a score ClampOpenPoints refuses, is
|
||||
// returned for River to retry while fewer than GradeMaxAttempts attempts
|
||||
// were made; the last one marks the answer failed with the error and
|
||||
@@ -215,6 +215,10 @@ func (s *Service) GradeAnswer(ctx context.Context, answerID uint, seq int) error
|
||||
}
|
||||
return err
|
||||
}
|
||||
if question.Type != models.TypeOpen {
|
||||
// The question stopped being open after the job was queued.
|
||||
return nil
|
||||
}
|
||||
var attempt models.Attempt
|
||||
if err := db.Preload("Quiz").Where("id = ?", row.AttemptID).Take(&attempt).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
|
||||
Reference in New Issue
Block a user