aboutsummaryrefslogtreecommitdiff
path: root/js/student-common.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/student-common.js')
-rw-r--r--js/student-common.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/js/student-common.js b/js/student-common.js
index c89b818..778ff8d 100644
--- a/js/student-common.js
+++ b/js/student-common.js
@@ -1,4 +1,4 @@
-import { getUserIconUrl, getCourseParticipantsUrl } from "./config.js";
+import { getCourseId, getUserIconUrl, getCourseParticipantsUrl } from "./config.js";
import { fetchGraduation } from "./graduation-common.js";
/**
* Class to represent Students.
@@ -27,6 +27,26 @@ class Student {
}
return this.graduation;
}
+
+ static async fetchById(id) {
+ 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);
+ }
}
async function fetchStudent(idFilter, nameFilter, groupFilter) {