diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2026-08-05 11:51:51 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2026-08-05 11:51:51 +0200 |
| commit | 582df8885a3573a728394b473b826616f8969316 (patch) | |
| tree | 9c21db03f4fbfd9956ee398e0d9194ebfa5b3234 /src/student-common.ts | |
| parent | 46ac53e11b49a7f9cdb92c3559b05f41ce90122f (diff) | |
| download | bycs-sol-582df8885a3573a728394b473b826616f8969316.tar.gz bycs-sol-582df8885a3573a728394b473b826616f8969316.zip | |
convert a lot of js to typescript and use a single graduation DB
Diffstat (limited to 'src/student-common.ts')
| -rw-r--r-- | src/student-common.ts | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/student-common.ts b/src/student-common.ts new file mode 100644 index 0000000..a76a816 --- /dev/null +++ b/src/student-common.ts @@ -0,0 +1,42 @@ +import type { Graduation } from "./graduation-common.ts"; +/** + * Class to represent Students. + */ +export class Student { + id: number; + name: string; + group: string; + graduation: Graduation | null = null; + + constructor(id: number, name: string, group: 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"); + + name = doc.querySelector("div.page-header-headings > h2")!.textContent; + + const cards = doc.querySelectorAll("div.card-body dl"); + 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); + } + */ +} |
