aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/group.js35
-rw-r--r--js/student-common.js22
2 files changed, 14 insertions, 43 deletions
diff --git a/js/group.js b/js/group.js
index 7b3dfd1..f9c31a2 100644
--- a/js/group.js
+++ b/js/group.js
@@ -26,27 +26,17 @@ class Group {
}
let groups = new Map();
-let bycsGroups = new Map();
function buildGroups(students) {
for (const student of students) {
- for (const groupName of student.groups) {
- let group = groups.get(groupName);
+ let group = groups.get(student.group);
- if (!group) {
- group = new Group(groupName);
- groups.set(groupName, group);
- if (groupName != student.getGroupName()) {
- bycsGroups.set(groupName, group);
- }
- }
-
- group.addStudent(student);
-
- // Create the individual student group
- const sGroupName = student.getGroupName();
- groups.set(sGroupName, new Group(sGroupName, [student]));
+ if (!group) {
+ group = new Group(student.group);
+ groups.set(student.group, group);
}
+
+ group.addStudent(student);
}
}
@@ -64,15 +54,4 @@ async function fetchGroups() {
return groups;
}
-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 };
+export { Group, buildGroups, fetchGroups };
diff --git a/js/student-common.js b/js/student-common.js
index f0d8ed3..c89b818 100644
--- a/js/student-common.js
+++ b/js/student-common.js
@@ -6,25 +6,18 @@ import { fetchGraduation } from "./graduation-common.js";
class Student {
graduation = null;
- constructor(id, name, groups) {
+ constructor(id, name, group) {
this.id = id;
this.name = name;
- this.groups = groups;
+ this.group = group;
}
async getIconUrl() {
return await getUserIconUrl(this.id);
}
- getGroupName() {
- return `g${this.id}${this.name.replace(' ', '')}`;
- }
-
- getRealGroups() {
- if(typeof this.groups === "string") {
- return [this.groups];
- }
- return this.groups.filter((g) => g !== this.getGroupName());
+ getGroup() {
+ return this.group;
}
async getGraduation() {
@@ -75,14 +68,13 @@ async function fetchStudents(idFilter, nameFilter, groupFilter) {
const id = match[1];
const groupCell = row.querySelector(".c5");
- const groupsText = groupCell.querySelector("a.quickeditlink").textContent;
- const groups = groupsText.trim().split(", ");
+ const group = groupCell.querySelector("a.quickeditlink").textContent;
if ((!idFilter || id === idFilter) &&
(!nameFilter || name.includes(nameFilter)) &&
- (!groupFilter || groups.filter((g) => g.includes(groupFilter))))
+ (!groupFilter || group.includes(groupFilter)))
{
- students.push(new Student(id, name, groups));
+ students.push(new Student(id, name, group));
}
});
return students;