aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2026-06-14 09:05:14 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2026-06-14 09:09:38 +0200
commit279b90dfb86b821a647b3c6b487a351e49de8f14 (patch)
treee6cd6344cff8bc5621e6327bbbadfb6428ae528d
parent07cda46bae630210bb903fb7c4b721dee334e851 (diff)
downloadbycs-sol-279b90dfb86b821a647b3c6b487a351e49de8f14.tar.gz
bycs-sol-279b90dfb86b821a647b3c6b487a351e49de8f14.zip
fix group building and track bycs groups separately
-rw-r--r--js/group.js31
-rw-r--r--js/mock.js6
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 };
diff --git a/js/mock.js b/js/mock.js
index 92bb4c6..02ff5bf 100644
--- a/js/mock.js
+++ b/js/mock.js
@@ -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