diff options
| -rw-r--r-- | cockpit/index.html | 5 | ||||
| -rw-r--r-- | cockpit/js/cockpit.js | 25 |
2 files changed, 14 insertions, 16 deletions
diff --git a/cockpit/index.html b/cockpit/index.html index ddf8005..dab2c89 100644 --- a/cockpit/index.html +++ b/cockpit/index.html @@ -9,11 +9,6 @@ </head> <body> -<div id="auto-name" style="display: none"> - <div id="auto-firstname">{firstname}</div> - <div id="auto-lastname">{lastname}</div> -</div> - <div id="student-selection-container" data-availability="if-lehrer"> <div id="student-selection-search-container"> <input diff --git a/cockpit/js/cockpit.js b/cockpit/js/cockpit.js index 7503f32..c0b20c2 100644 --- a/cockpit/js/cockpit.js +++ b/cockpit/js/cockpit.js @@ -7,20 +7,20 @@ import { LEVEL_NAMES, GraduationChange, fetchGraduation, + fetchPublicGraduation, submitGraduationChange } from "../../js/graduation-ENV.js"; import { fetchStudent, fetchStudents } from "../../js/student-ENV.js"; import { isTeacher as getIsTeacher, - getFirstAndLastname, + getName, getUserId, } from "../../js/utils-ENV.js"; import { initSelection } from "../../js/selection.js"; let isTeacher; -let firstname; -let lastname; +let name; let student; async function loadStudent(studentToLoad) { @@ -41,7 +41,7 @@ function initStudentSelection() { initSelection( "student-selection", fetchStudents, - (student) => `${student.name} ${student.getRealGroups().join(", ")}`, + (student) => `${student.name} ${student.getGroup()}`, loadStudent ); } @@ -69,20 +69,19 @@ function pointClickHandler(color) { textareaDiv.style.display = "block"; textarea.focus(); - // Can not use string interpolation because of Moodle's firstname filter. - const coach = firstname + " " + lastname; + const coach = name; let submit = function() { let change; switch (color) { case "green": - change = GraduationChange.newGreenPointChange(student, textarea.value, coach); + change = GraduationChange.newGreenPointChange(textarea.value, coach); break; case "orange": - change = GraduationChange.newOrangePointChange(student, textarea.value, coach); + change = GraduationChange.newOrangePointChange(textarea.value, coach); break; case "red": - change = GraduationChange.newRedPointChange(student, textarea.value, coach); + change = GraduationChange.newRedPointChange(textarea.value, coach); break; default: alert("Invalid color"); @@ -106,7 +105,11 @@ function pointClickHandler(color) { } async function fetchAndUpdateStudentInfo() { - student.graduation = await fetchGraduation(student); + if (isTeacher) + student.graduation = await fetchGraduation(student); + else + student.graduation = await fetchPublicGraduation(student); + updateStudentInfo(); } @@ -293,6 +296,6 @@ async function initCockpit() { window.onload = function() { isTeacher = getIsTeacher(); DEFAULT_STUDENT_ICON = document.getElementById("student-info-icon").src; - [firstname, lastname] = getFirstAndLastname(); + name = getName(); initCockpit(); } |
