fix: add some better detection logic for assements widget #429

This commit is contained in:
2026-04-23 17:26:58 +09:30
parent fcc856e798
commit 01cd5d1428
2 changed files with 20 additions and 3 deletions
@@ -28,9 +28,17 @@ async function fetchJSON(url: string, body: any) {
async function loadSubjects() {
const res = await fetchJSON("/seqta/student/load/subjects?", {});
return res.payload
.filter((s: any) => s.active === 1)
const activeGroup = res.payload.find((s: any) => s.active === 1);
const activeYear = activeGroup?.year;
const allSubjects = res.payload
.filter((s: any) => s.year === activeYear)
.flatMap((s: any) => s.subjects);
const seen = new Set<string>();
return allSubjects.filter((s: Subject) => {
if (seen.has(s.code)) return false;
seen.add(s.code);
return true;
});
}
async function loadPrefs(student: number) {