Naalya Handbook
School featuresCBT exams

Student runtime and grading

The attempt lifecycle, start/resume, lazy expiry, all-or-nothing auto-grading, teacher finalise, and the write-through to the gradebook.

The student routes live under cbt/student and need Feature.CBT and user type student.

Eligibility (CbtStudentAccessService.assertEligible): an active enrolment in the exam term's academic year, with a stream, a current subject row for the exam's subject, and an assignment of the exam to that stream. Otherwise This exam is not assigned to your stream (403). A missing term is Exam term not found; a missing student profile is Student profile not found.

Attempt lifecycle

Auto-grading runs when an attempt leaves in_progress. Only a teacher sets graded, and only graded reaches the gradebook.

Student routes

RouteoperationIdDoes
POST /cbt/student/examinations/:examinationId/attemptsstartCbtAttemptReturns the live in_progress attempt if one hasn't expired; otherwise starts a new one
GET /cbt/student/attempts/:attemptIdgetCbtAttemptAttempt, saved answers and student-safe questions (no isCorrect, no accepted answers). MCQ options are shuffled with a seed of attemptId:questionId, so order is stable across refreshes
PUT /cbt/student/attempts/:attemptId/answers/:questionIdsaveCbtAnswerUpserts on (attemptId, questionId); doesn't extend the clock
POST /cbt/student/attempts/:attemptId/submitsubmitCbtAttemptFinalises as submitted (even if past expiresAt); a non-in_progress attempt is returned unchanged

Time budget. durationMinutes if set; otherwise, for per_question timing, the sum of each question's timeLimitSeconds. expiresAt is startedAt plus the budget.

RouteWhenMessage
StartExam missingExamination not found
Not publishedExamination is not open
Outside the assignment's availableFrom to availableToExamination is not available right now
Every non-voided attempt counts against maxAttemptsNo attempts remaining
No duration and no per-question limitsExamination has no configured time budget
SaveQuestion not on this examQuestion does not belong to this exam
Not in_progress, or past expiresAt (it is expired first)attempt is closed
AnyMissing or someone else's attemptAttempt not found, This attempt does not belong to you

Expiry is lazy

No scheduler sweeps attempts. An attempt past expiresAt becomes expired only when getAttempt or saveAnswer next touches it, and it counts against maxAttempts either way. Walking away is not a free retry.

Finalising claims the row with UPDATE ... WHERE status = 'in_progress', so a racing call matches nothing and just reloads. The winner sets submitted or expired and submitted_at, stores unanswered questions as empty, auto-grades, writes autoScore, and publishes CBT_ATTEMPT_SUBMIT. The student's response leaves out autoScore and finalScore.

Auto-grading

Runs inside finalize (at submit or lazy expiry), all-or-nothing, full marks or zero, no partial credit:

TypeAuto-graded?Correct when
mcq_single / mcq_multiYesThe selected ids, sorted, equal the correct option ids, sorted. An empty correct set is never correct
short_textYesOne of acceptedAnswers matches. exact compares the raw text. trimmed trims both sides. case_insensitive trims and lowercases. An empty accepted list is never correct
long_text / mathNo, left ungraded (awardedMarks: null)Teacher marks manually

finalize upserts every objective answer with awardedMarks / isCorrect / autoGraded: true, sets the provisional autoScore (against maxAutoScore = Σ marks of objective questions), and parks the attempt in submitted or expired. It never sets graded.

Teacher grading

Staff routes are under cbt/examinations/:examinationId/attempts/:attemptId:

RouteoperationIdDoes
GETgetCbtAttemptForStaffAnswers with awardedMarks and isCorrect
PUT .../gradessaveCbtGradesDraft marks for long_text and math, each 0 to the question's marks; status unchanged
POST .../finalisefinaliseCbtAttemptSets graded, finalScore (all awarded marks), gradedAt, gradedById. Can be repeated after a correction
POST .../void, .../reopenvoidCbtAttempt, reopenCbtAttemptVoid needs submitted, expired or graded; reopen needs voided. See CBT operations

Gradebook write-through

Only teacher finalise writes a score. AssessmentGradeSyncService.syncFromCbtAttempt returns early without gradedById, which a student submit never sets.

Pick the attempt. Only the student's latest graded attempt (highest attemptNumber) counts. A missing exam or totalMarks of 0 stops here.

Find the enrolment and assessment. The first active enrolment in the term's year whose stream takes the subject (not checked against the exam's stream assignment), and the assessment with sourceCbtExaminationId equal to the exam. No enrolment logs No active enrollment found for CBT score sync; no assessment stops silently.

Write the score. finalScore / totalMarks × maxScore, two decimals, upserted on (assessmentId, enrollmentId) with enteredBy = gradedById, then the subject-term grade is recomputed. Errors are logged as CBT grade sync failed and swallowed.

clearFromCbtAttempt (on void) soft-deletes that score and recomputes (CBT grade clear failed on error). Deleting an exam runs releaseExamLinks, which unlinks its assessments but keeps the scores already written.

Where to go next

On this page