blob: a76a8168a66b94fe91113791bc4dcd6d2ad16341 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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);
}
*/
}
|