fix(exam): stop hiding non-CHOICE questions from OFFLINE assignment picker

eligibleQuestions filtered by q.form === exam.form, which matched the
backend's own restriction (assertUsable) only for ONLINE exams. Once
exam.form gained the "BOTH" value for OFFLINE mixed papers, no question
ever has form "BOTH", so the picker silently emptied out or, for a
plain CHOICE-form exam, looked CHOICE-only regardless of administration
method. Now mirrors the backend: CHOICE-only gate applies only when
administrationMethod is ONLINE.
This commit is contained in:
mihretue
2026-08-24 11:30:56 +00:00
parent 97ebff3b21
commit 9f8f29d614

View File

@@ -121,18 +121,25 @@ export function ExamDetailPage() {
// Only approved bank items may go on a paper (US-EXAM-003), so the picker
// must not offer drafts or retired questions either.
//
// Form restriction mirrors the backend's assertUsable: ONLINE exams are
// CHOICE-only (auto-grading needs it), OFFLINE exams have no form
// restriction at all — mixing ESSAY and CHOICE by hand (exam.form
// "BOTH") is the sanctioned, only way to build a mixed paper. Matching
// `q.form === exam.form` here used to hide every question once "BOTH"
// became a real exam.form value, since no question itself is "BOTH".
const eligibleQuestions = useMemo(() => {
if (!exam) return [];
return allQuestions
.filter(
(q) =>
q.certificationId === exam.certificationId &&
q.form === exam.form &&
q.status === 'APPROVED',
q.status === 'APPROVED' &&
(exam.administrationMethod !== 'ONLINE' || q.form === 'CHOICE'),
)
.map((q) => ({ id: q.id, title: q.title, form: q.form, points: q.points }));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [allQuestions, exam?.certificationId, exam?.form]);
}, [allQuestions, exam?.certificationId, exam?.administrationMethod]);
if (isLoading)
return <PageLoader label="Loading Exam Details…" height={400} />;