aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2026-09-14 17:34:14 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2026-09-14 17:35:34 +0200
commit9876d989b52528574861ef44409a5b680e542340 (patch)
tree763f0517114edbee346bf49b4f4e640b99d2cc21 /src
parentd18d5f869d57d31c987b4b7fe0c7feae9aba8b2e (diff)
downloadbycs-sol-9876d989b52528574861ef44409a5b680e542340.tar.gz
bycs-sol-9876d989b52528574861ef44409a5b680e542340.zip
remove groups
Diffstat (limited to 'src')
-rw-r--r--src/cockpit.js2
-rw-r--r--src/group-fetch.ts18
-rw-r--r--src/group.ts45
-rw-r--r--src/mass-graduation.js18
-rw-r--r--src/mock.ts11
-rw-r--r--src/student-common.ts12
-rw-r--r--src/student-mock.ts2
-rw-r--r--src/student-prod.ts16
8 files changed, 17 insertions, 107 deletions
diff --git a/src/cockpit.js b/src/cockpit.js
index 6830fbb..900d843 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -26,7 +26,7 @@ function initStudentSelection() {
initSelection(
"student-selection",
fetchStudents,
- (student) => `${student.name} ${student.getGroup()}`,
+ (student) => `${student.name}`,
loadStudent,
);
}
diff --git a/src/group-fetch.ts b/src/group-fetch.ts
deleted file mode 100644
index de0991d..0000000
--- a/src/group-fetch.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { fetchStudents } from "./student-ENV.ts";
-import { Group, buildGroups, _groups } from "./group.ts";
-
-/**
- * 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 };
diff --git a/src/group.ts b/src/group.ts
deleted file mode 100644
index e840ffd..0000000
--- a/src/group.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import type { Student } from "./student-common.ts";
-
-/**
- * Class to represent a Group of Students.
- */
-class Group {
- name: string;
- students: Array<Student> = [];
-
- constructor(name: string, students?: Array<Student>) {
- this.name = name;
- if (typeof students !== "undefined") {
- this.students = students;
- }
- }
-
- setStudents(students: Array<Student>) {
- this.students = students;
- }
-
- addStudent(student: Student) {
- this.students.push(student);
- }
-
- async getStudents() {
- return this.students;
- }
-}
-
-const groups = new Map();
-
-function buildGroups(students: Array<Student>) {
- 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);
- }
-}
-
-export { Group, buildGroups, groups as _groups };
diff --git a/src/mass-graduation.js b/src/mass-graduation.js
index b62a34a..9bb85af 100644
--- a/src/mass-graduation.js
+++ b/src/mass-graduation.js
@@ -1,10 +1,8 @@
import { GraduationChange, submitGraduationChange } from "./graduation-ENV.ts";
+import { fetchStudents } from "./student-ENV.ts";
-import { fetchGroups } from "./group-fetch.ts";
-import { initSelection } from "./selection.js";
import { getName } from "./utils-ENV.js";
-let group;
let name;
function toggle(btn) {
@@ -56,9 +54,8 @@ function chooseMandatory(graduations) {
return chosen;
}
-async function loadGroup(selected) {
- group = selected;
- const students = await group.getStudents();
+async function loadGroup() {
+ const students = await fetchStudents();
const graduationPromises = [];
document.getElementById("group-content").style.display = "block";
@@ -178,14 +175,7 @@ async function init() {
document.getElementById("submit-mass-graduation").addEventListener("click", submitMassGraduation);
name = getName();
- initSelection(
- "group-selection",
- async function () {
- return (await fetchGroups()).values();
- },
- (group) => `${group.name}`,
- loadGroup,
- );
+ loadGroup();
}
if (document.readyState === "loading") {
diff --git a/src/mock.ts b/src/mock.ts
index 3ffcc53..125c73f 100644
--- a/src/mock.ts
+++ b/src/mock.ts
@@ -1,17 +1,12 @@
import { Graduation, GraduationChange } from "./graduation-common.ts";
import { Student } from "./student-common.ts";
-import { buildGroups } from "./group.ts";
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"),
+ new Student(2, "maxi mustermensch"),
];
-// Build the groups from our mock students
-buildGroups(students);
-
-async function fetchStudentsMock(_id?: number, _name?: string, _group?: string) {
+async function fetchStudentsMock(_id?: number, _name?: string) {
return students;
}
diff --git a/src/student-common.ts b/src/student-common.ts
index a76a816..56dab43 100644
--- a/src/student-common.ts
+++ b/src/student-common.ts
@@ -5,23 +5,16 @@ import type { Graduation } from "./graduation-common.ts";
export class Student {
id: number;
name: string;
- group: string;
graduation: Graduation | null = null;
- constructor(id: number, name: string, group: string) {
+ constructor(id: number, name: string) {
this.id = id;
this.name = name;
- this.group = group;
- }
-
- getGroup() {
- return this.group;
}
/**
static async fetchById(id: number) {
let name = "";
- let group = "";
const res = await fetch(`/user/view.php?id=${id}&course=${getCourseId()}`);
const doc = new DOMParser().parseFromString(await res.text(), "text/html");
@@ -32,11 +25,10 @@ export class Student {
for (const card of cards) {
if (card.querySelector("dt")!.textContent !== "Gruppe")
continue;
- group = card.querySelector("dd > a")!.textContent;
break;
}
- return new Student(id, name, group);
+ return new Student(id, name);
}
*/
}
diff --git a/src/student-mock.ts b/src/student-mock.ts
index bf817d2..7c22130 100644
--- a/src/student-mock.ts
+++ b/src/student-mock.ts
@@ -16,7 +16,7 @@ Student.prototype.getIconUrl = async function () {
return "";
};
-async function fetchStudent(_idFilter?: number, _nameFilter?: string, _groupFilter?: string) {
+async function fetchStudent(_idFilter?: number, _nameFilter?: string) {
const students = await fetchStudents();
return students[0];
}
diff --git a/src/student-prod.ts b/src/student-prod.ts
index 5a1673e..90398c9 100644
--- a/src/student-prod.ts
+++ b/src/student-prod.ts
@@ -50,15 +50,12 @@ async function _fetchStudents() {
}
const id = match[1];
- const groupCell = row.querySelector(".c5")!;
- const group = groupCell.querySelector<HTMLElement>("a.quickeditlink")!.textContent;
-
- fetchedStudents.push(new Student(Number(id), name, group));
+ fetchedStudents.push(new Student(Number(id), name));
});
return fetchedStudents;
}
-async function fetchStudents(idFilter?: number, nameFilter?: string, groupFilter?: string) {
+async function fetchStudents(idFilter?: number, nameFilter?: string) {
if (students === null) {
const studentsPromise = _fetchStudents();
const storedStudents = localStorage.getItem("students");
@@ -66,7 +63,7 @@ async function fetchStudents(idFilter?: number, nameFilter?: string, groupFilter
studentsPromise.then((fetched) => localStorage.setItem("students", JSON.stringify(fetched)));
students = [];
for (const o of JSON.parse(storedStudents)) {
- students.push(new Student(o.id, o.name, o.group));
+ students.push(new Student(o.id, o.name));
}
} else {
students = await studentsPromise;
@@ -77,13 +74,12 @@ async function fetchStudents(idFilter?: number, nameFilter?: string, groupFilter
return students.filter(
(s) =>
(typeof idFilter === "undefined" || s.id === idFilter) &&
- (typeof nameFilter === "undefined" || s.name.includes(nameFilter)) &&
- (typeof groupFilter === "undefined" || s.group.includes(groupFilter)),
+ (typeof nameFilter === "undefined" || s.name.includes(nameFilter))
);
}
-async function fetchStudent(idFilter?: number, nameFilter?: string, groupFilter?: string) {
- const students = await fetchStudents(idFilter, nameFilter, groupFilter);
+async function fetchStudent(idFilter?: number, nameFilter?: string) {
+ const students = await fetchStudents(idFilter, nameFilter);
return students[0];
}