From 9f8f29d61478384d56ac530cc1ab6325a4157782 Mon Sep 17 00:00:00 2001 From: mihretue Date: Mon, 24 Aug 2026 11:30:56 +0000 Subject: [PATCH] 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. --- .../src/app/features/exam/pages/ExamDetailPage.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/backoffice/src/app/features/exam/pages/ExamDetailPage.tsx b/apps/backoffice/src/app/features/exam/pages/ExamDetailPage.tsx index 8e9037840..5ce7a4ab5 100644 --- a/apps/backoffice/src/app/features/exam/pages/ExamDetailPage.tsx +++ b/apps/backoffice/src/app/features/exam/pages/ExamDetailPage.tsx @@ -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 ;