fix: refuse review writes while a test attempt is open

WR-02: Confirm and SetScore answer ErrAttemptOpen (409 attempt_open,
an admin refusal) for an answer of a running test, ConfirmBulk skips
such attempts, and the default open queue leaves them out, so
AnswerReviewed never fires before the test ends.
This commit is contained in:
Jakub Zych
2026-11-09 22:47:47 +01:00
parent adc02d7e0c
commit 34b0966819
6 changed files with 37 additions and 9 deletions

View File

@@ -33,6 +33,8 @@ func writeReview(w http.ResponseWriter, status int, data any, err error) {
reviewConflict(w, "The answer is already reviewed; set the score instead.", "already_reviewed")
case errors.Is(err, classes.ErrGraderManual):
reviewConflict(w, "The quiz's grader is manual or not available, so nothing can be graded again.", "grader_manual")
case errors.Is(err, classes.ErrAttemptOpen):
reviewConflict(w, "The test attempt is still open; review its answers once it ends.", "attempt_open")
case errors.Is(err, classes.ErrNotFound):
wire.WriteJSON(w, http.StatusNotFound, map[string]any{"error": true, "message": "Open answer, attempt or quiz not found."})
default:

View File

@@ -245,6 +245,8 @@ func reviewError(err error) error {
return &cabana.ForbiddenError{Message: reviewsLang + "already_reviewed"}
case errors.Is(err, classes.ErrGraderManual):
return &cabana.ForbiddenError{Message: reviewsLang + "grader_manual"}
case errors.Is(err, classes.ErrAttemptOpen):
return &cabana.ForbiddenError{Message: reviewsLang + "attempt_open"}
case errors.Is(err, classes.ErrNotFound):
return &cabana.ForbiddenError{Message: reviewsLang + "not_found"}
}