From 7fb7ccdfd0d0fee4aaadbbbfd574a6a41c02d9e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20=C3=96hlerking?= Date: Thu, 12 Dec 2024 16:15:40 +0100 Subject: [PATCH] Revert "remove deep clone of teachers" This reverts commit dbea425647314557a034c13c1aba9f7d526719ec. --- controllers/courses.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/controllers/courses.js b/controllers/courses.js index 144601e9a0..c253f67592 100644 --- a/controllers/courses.js +++ b/controllers/courses.js @@ -64,6 +64,7 @@ const getSyncedElements = ( classesAndGroups, classAndGroupIdsOfCourse, teachers, + substitutions, students, res, syncedWithGroup, @@ -77,7 +78,7 @@ const getSyncedElements = ( const selectedElements = { teachersSelected: selectedElementIdsToString(markSelected(teachers, course.teacherIds)), - substitutionSelected: selectedElementIdsToString(markSelected(teachers, course.substitutionIds)), + substitutionSelected: selectedElementIdsToString(markSelected(substitutions, course.substitutionIds)), classesAndGroupsSelected: selectedElementIdsToString(markSelected(classesAndGroups, classAndGroupIdsOfCourse)), studentsSelected: selectedElementIdsToString(filterStudents(res, markSelected(students, course.userIds))), startDate, @@ -248,6 +249,9 @@ const editCourseHandler = (req, res, next) => { students.forEach((student) => { student.isHidden = isUserHidden(student, res.locals.currentSchoolData); }); + const substitutions = _.cloneDeep( + teachers, + ); // decode course name to display it properly in an input field if (course.name) { @@ -327,6 +331,7 @@ const editCourseHandler = (req, res, next) => { classesAndGroups, classAndGroupIdsOfCourse, teachers, + substitutions, students, res, syncedGroupId, @@ -344,7 +349,7 @@ const editCourseHandler = (req, res, next) => { colors, classesAndGroups: markSelected(classesAndGroups, classAndGroupIdsOfCourse), teachers: markSelected(teachers, course.teacherIds), - substitutions: markSelected(teachers, course.substitutionIds), + substitutions: markSelected(substitutions, course.substitutionIds), students: filterStudents(res, markSelected(students, course.userIds)), scopePermissions: _scopePermissions, schoolData: res.locals.currentSchoolData, @@ -361,7 +366,7 @@ const editCourseHandler = (req, res, next) => { colors, classesAndGroups: markSelected(classesAndGroups, classAndGroupIdsOfCourse), teachers: markSelected(teachers, course.teacherIds), - substitutions: markSelected(teachers, course.substitutionIds), + substitutions: markSelected(substitutions, course.substitutionIds), students: filterStudents(res, markSelected(students, course.userIds)), redirectUrl: req.query.redirectUrl || '/courses', schoolData: res.locals.currentSchoolData,