fix(exam): step the exam form, derive portal status, drop queue overrides

Four screens were telling the applicant things that were not true, and two
back-office actions were writing state nobody should be able to write by hand.

The exam form is a stepper. Basic Info and Settings each answer only for their
own fields, and a third step reviews the whole thing before anything is sent —
"Create Exam" exists on that step alone, so there is no path from an earlier
one into the API. Clicking it from Basic Info used to report the Settings
fields as missing: a correct error the user could not act on, since that step
had not been shown yet. The rules move to ./validation, which is what the
per-step check and the final whole-payload check both read, so the two cannot
drift apart. Back keeps everything entered — state lives in the component.

The portal derives the examination stage from the records rather than from the
application status alone. Registering, attendance and the sitting itself all
happen on the registration and the attempt, and the portal read none of them —
which is how an application still said "Awaiting Exam Date" after the back
office had already evaluated the paper. examStageFor() names what the records
add up to: eligible to register, registered, attendance confirmed, sitting,
under evaluation, passed, failed. Both the applications list and the
certificates page use it, and both poll the registrations they read it from,
because attendance is recorded by an invigilator while the candidate is
watching the screen.

EXAM_PAID is no longer a waiting state. Nobody assigns a date: the fee having
cleared is exactly what makes the candidate eligible to pick a published
sitting, so that row now offers Register rather than a disabled button.

Schedule Exam and Record Exam Outcome are gone from the COC queue — actions,
modals, RTK endpoints and strings. Their server endpoints are gone too, so
this is not a hidden button over a live route.
This commit is contained in:
mihretue
2026-08-31 07:14:59 +00:00
parent 9bb47f2d2b
commit 6f4878d300
21 changed files with 623 additions and 380 deletions

View File

@@ -22,7 +22,6 @@ import type {
AssignableOfficer,
DocumentDecision,
DocumentReview,
EligibleExam,
ExportResult,
LicenseTemplate,
Paginated,
@@ -650,45 +649,11 @@ export const licensingApi = baseApi
error ? [] : [itemTag('LicenseApplication', id), listTag('ApplicationQueue')],
}),
/**
* Exam sittings valid for this application's rank — what the
* schedule-exam picker offers, instead of every exam in the system.
*/
getEligibleExams: builder.query<EligibleExam[], string>({
query: (id) => ({ url: `/license-application-review/${id}/eligible-exams` }),
providesTags: (_r, _e, id) => [itemTag('LicenseApplication', id)],
}),
/** Places a candidate who has paid the examination fee into a sitting. */
scheduleExam: builder.mutation<
LicenseApplication,
{ id: string; examId: string; admissionNumber?: string; examDate?: string }
>({
query: ({ id, examDate: _examDate, ...body }) => ({
// Matches the controller's `:id/exam-scheduled` route — `examDate`
// is UI-only context for the confirmation toast, not part of
// `MarkExamScheduledDto`, so it never goes on the wire.
url: `/license-application-review/${id}/exam-scheduled`,
method: 'POST',
body,
}),
invalidatesTags: (_r, error, { id }) =>
error ? [] : [itemTag('LicenseApplication', id), listTag('ApplicationQueue')],
}),
/** Records a published examination result (pass or fail). */
recordExamOutcome: builder.mutation<
LicenseApplication,
{ id: string; passed: boolean; score?: number }
>({
query: ({ id, ...body }) => ({
url: `/license-application-review/${id}/exam-outcome`,
method: 'POST',
body,
}),
invalidatesTags: (_r, error, { id }) =>
error ? [] : [itemTag('LicenseApplication', id), listTag('ApplicationQueue')],
}),
// No `getEligibleExams`, `scheduleExam` or `recordExamOutcome`: the
// endpoints behind them are gone. Sittings are published as master
// schedules and candidates register for one themselves, and an outcome
// is what the exam engine computed and a supervisor approved — neither
// is the COC queue's to write.
/**
* A failed candidate asks for another sitting. Re-opens the examination
@@ -1144,9 +1109,6 @@ export const {
useApproveDocumentsMutation,
useFinalApproveMutation,
useRejectApplicationMutation,
useGetEligibleExamsQuery,
useScheduleExamMutation,
useRecordExamOutcomeMutation,
useRetakeExamMutation,
useConfirmPaymentMutation,
useScheduleIssuanceMutation,

View File

@@ -82,7 +82,9 @@ export const STATUS_LABELS: Record<LicenseStatus, string> = {
ELIGIBILITY_PAYMENT_PENDING: 'Eligibility Fee Due',
ELIGIBILITY_PAID: 'Eligibility Under Review',
EXAM_PAYMENT_PENDING: 'Exam Fee Due',
EXAM_PAID: 'Awaiting Exam Date',
// Nobody assigns a date any more — the fee clearing is what makes the
// candidate eligible to register for a published sitting themselves.
EXAM_PAID: 'Eligible to Register',
EXAM_SCHEDULED: 'Exam Scheduled',
EXAM_PASSED: 'Exam Passed',
EXAM_FAILED: 'Exam Not Passed',

View File

@@ -748,12 +748,3 @@ export interface IssuedLicense {
certificateFileKey: string | null;
}
/** One sitting offered to a claimed examined-certificate application, scoped to its rank. */
export interface EligibleExam {
id: string;
title: { en: string; am: string };
date: string;
venue: string;
status: string;
certification?: { id: string; name: { en: string; am: string }; rankKey: string | null };
}