diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2026-06-14 09:05:14 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2026-06-14 09:09:38 +0200 |
| commit | 279b90dfb86b821a647b3c6b487a351e49de8f14 (patch) | |
| tree | e6cd6344cff8bc5621e6327bbbadfb6428ae528d /js | |
| parent | 07cda46bae630210bb903fb7c4b721dee334e851 (diff) | |
| download | bycs-sol-279b90dfb86b821a647b3c6b487a351e49de8f14.tar.gz bycs-sol-279b90dfb86b821a647b3c6b487a351e49de8f14.zip | |
fix group building and track bycs groups separately
Diffstat (limited to 'js')
| -rw-r--r-- | js/group.js | 31 | ||||
| -rw-r--r-- | js/mock.js | 6 |
2 files changed, 28 insertions, 9 deletions
diff --git a/js/group.js b/js/group.js index 103f368..7b3dfd1 100644 --- a/js/group.js +++ b/js/group.js @@ -21,19 +21,27 @@ class Group { } async getStudents() { - return students; + return this.students; } } let groups = new Map(); +let bycsGroups = new Map(); function buildGroups(students) { for (const student of students) { for (const groupName of student.groups) { - if (!groups.has(groupName)) { - groups.set(groupName, new Group(groupName)); + let group = groups.get(groupName); + + if (!group) { + group = new Group(groupName); + groups.set(groupName, group); + if (groupName != student.getGroupName()) { + bycsGroups.set(groupName, group); + } } - groups.get(groupName).addStudent(student); + + group.addStudent(student); // Create the individual student group const sGroupName = student.getGroupName(); @@ -51,9 +59,20 @@ async function fetchGroups() { } // Fetch all students and build the groups from them - const students = fetchStudents(); + const students = await fetchStudents(); buildGroups(students); return groups; } -export { Group, buildGroups, fetchGroups }; +async function fetchBycsGroups() { + if (bycsGroups.size) { + return bycsGroups; + } + + // Fetch all students and build the groups from them + const students = await fetchStudents(); + buildGroups(students); + return bycsGroups; +} + +export { Group, buildGroups, fetchGroups, fetchBycsGroups }; @@ -3,9 +3,9 @@ import { Student } from "./student-common.js"; import { buildGroups } from "./group.js"; const students = [ - new Student(1, 'foo bar', 'test'), - new Student(2, 'maxi mustermensch', 'test'), - new Student(3, 'b b b', '5a') + new Student(1, 'foo bar', ['test']), + new Student(2, 'maxi mustermensch', ['test']), + new Student(3, 'b b b', ['5a']) ]; // Build the groups from our mock students |
