diff options
| -rw-r--r-- | cockpit/js/cockpit.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/cockpit/js/cockpit.js b/cockpit/js/cockpit.js index 62d57b8..8041e77 100644 --- a/cockpit/js/cockpit.js +++ b/cockpit/js/cockpit.js @@ -9,7 +9,7 @@ import { submitGraduationChange } from "./graduation-ENV.js"; -import { Student, fetchStudents } from "./student-ENV.js"; +import { fetchStudent, fetchStudents } from "./student-ENV.js"; import { isTeacher as getIsTeacher } from "../../utils-ENV.js"; let isTeacher; @@ -24,8 +24,8 @@ function initCurrentName() { autoNameDiv.remove(); } -async function loadNewStudent(name, group) { - student = new Student(0, name, group); +async function loadNewStudent(id, name, group) { + student = await fetchStudent(id, name, group); await loadStudent(student); } @@ -288,9 +288,13 @@ async function updateStudentGraduation() { async function initCockpit() { if (isTeacher) { - await initStudentSelection(); + initStudentSelection(); + const params = new URLSearchParams(location.search); + const userId = params.get("userToLoad"); + if (userId) + loadNewStudent(userId); } else { - loadNewStudent(firstname + " " + lastname); + loadNewStudent(null, firstname + " " + lastname); } return; } |
