diff options
Diffstat (limited to 'js/group.js')
| -rw-r--r-- | js/group.js | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/js/group.js b/js/group.js deleted file mode 100644 index ba5e1a0..0000000 --- a/js/group.js +++ /dev/null @@ -1,57 +0,0 @@ -import { getCourseParticipantsUrl } from "./utils-ENV.js"; -import { fetchStudents } from "./student-ENV.js"; - -/** - * Class to represent a Group of Students. - */ -class Group { - constructor(name, students) { - this.name = name; - if (!students) { - this.students = []; - } - } - - setStudents(students) { - this.students = students; - } - - addStudent(student) { - this.students.push(student); - } - - async getStudents() { - return this.students; - } -} - -let groups = new Map(); - -function buildGroups(students) { - for (const student of students) { - let group = groups.get(student.group); - - if (!group) { - group = new Group(student.group); - groups.set(student.group, group); - } - - group.addStudent(student); - } -} - -/** - * Fetch all Groups and return them as a map. - */ -async function fetchGroups() { - if (groups.size) { - return groups; - } - - // Fetch all students and build the groups from them - const students = await fetchStudents(); - buildGroups(students); - return groups; -} - -export { Group, buildGroups, fetchGroups }; |
