From dcb7727a4b90cf5b3a052eb24790730a712e90d9 Mon Sep 17 00:00:00 2001 From: Yamen Ahmad Date: Mon, 20 Apr 2026 18:29:16 +0400 Subject: [PATCH] =?UTF-8?q?fix(assignments):=20resolve=20op.student=20?= =?UTF-8?q?=E2=86=92=20res.users=20+=20student=20search?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit E2E QA surfaced a silent-drop bug in the exam-schedule endpoint: the frontend's student picker sends `op.student.id` values (that's what /api/students returns), but `encoach.exam.schedule.student_ids` is a Many2many → res.users. The controller was writing the op.student id straight through, so schedules linked to whichever res.users row happened to share that integer id (OdooBot, other staff, etc.) — the target student got 0 assignments and never saw the exam. - exam_schedules.py: add `_resolve_student_user_ids` and use it in the create and update endpoints. Falls back to treating unmatched ids as direct res.users ids for back-office callers. - AssignmentsPage.tsx: add a search input + larger list to the Individual Students picker; long lists were leaving Sarah unreachable inside the inner scroll container during QA. Made-with: Cursor --- src/pages/AssignmentsPage.tsx | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/pages/AssignmentsPage.tsx b/src/pages/AssignmentsPage.tsx index 4f6db8e..ca06cb8 100644 --- a/src/pages/AssignmentsPage.tsx +++ b/src/pages/AssignmentsPage.tsx @@ -114,6 +114,7 @@ export default function AssignmentsPage() { const [stateFilter, setStateFilter] = useState("all"); const [createOpen, setCreateOpen] = useState(false); const [form, setForm] = useState(emptyForm()); + const [studentQuery, setStudentQuery] = useState(""); const { toast } = useToast(); const qc = useQueryClient(); @@ -144,6 +145,14 @@ export default function AssignmentsPage() { const studentsQ = useStudents({ size: 200 }); const students = studentsQ.data?.items ?? []; + const filteredStudents = useMemo(() => { + const q = studentQuery.trim().toLowerCase(); + if (!q) return students; + return students.filter((s) => + (s.name || "").toLowerCase().includes(q) || + (s.email || "").toLowerCase().includes(q), + ); + }, [students, studentQuery]); const stateCounts = useMemo(() => { const all = schedulesQ.data?.items ?? []; @@ -468,9 +477,23 @@ export default function AssignmentsPage() { {/* Individual student selection */} {form.assign_mode === "individual" && (
- -
- {students.map((s) => ( +
+ + + {form.student_ids.size} selected · {students.length} total + +
+ {/* Search box — needed because QA reported long student lists + made bottom entries unreachable inside the inner scroll + container. Filtering keeps the list short and predictable. */} + setStudentQuery(e.target.value)} + className="h-8 text-xs" + /> +
+ {filteredStudents.map((s) => ( ))} + {filteredStudents.length === 0 && students.length > 0 && ( +

+ No students match “{studentQuery}”. +

+ )} {students.length === 0 &&

No students available

}