aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2026-06-03 14:01:36 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2026-06-03 14:01:36 +0200
commit66824db4120c5b61d167aeecf37df13785dc9481 (patch)
tree38a96a0b1952a1177afbe7a72bad9f29d54f7314
parent7aa92d17d30ca4e01885b8b34d922e5798138db6 (diff)
downloadbycs-sol-66824db4120c5b61d167aeecf37df13785dc9481.tar.gz
bycs-sol-66824db4120c5b61d167aeecf37df13785dc9481.zip
cockpit: fix fetching a single student and add id filtering
-rw-r--r--cockpit/js/student-common.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/cockpit/js/student-common.js b/cockpit/js/student-common.js
index 991876d..1f4d083 100644
--- a/cockpit/js/student-common.js
+++ b/cockpit/js/student-common.js
@@ -14,12 +14,13 @@ class Student {
}
}
-async function fetchStudent(nameFilter, groupFilter) {
- return await fetchStudents(nameFilter, groupFilter)[0];
+async function fetchStudent(idFilter, nameFilter, groupFilter) {
+ const students = await fetchStudents(idFilter, nameFilter, groupFilter);
+ return students[0];
}
const idRegex = /id=(\d+)/;
-async function fetchStudents(nameFilter, groupFilter) {
+async function fetchStudents(idFilter, nameFilter, groupFilter) {
const res = await fetch(getCourseParticipantsUrl());
const doc = new DOMParser().parseFromString(await res.text(), "text/html");
const table = doc.querySelector("tbody");
@@ -49,7 +50,8 @@ async function fetchStudents(nameFilter, groupFilter) {
const groupsText = groupCell.querySelector("a.quickeditlink").textContent;
const group = groupsText.trim();
- if ((!nameFilter || name.includes(nameFilter)) &&
+ if ((!idFilter || id === idFilter) &&
+ (!nameFilter || name.includes(nameFilter)) &&
(!groupFilter || groupFilter === group))
{
students.push(new Student(id, name, group));