Skip to content

Commit

Permalink
Revert "remove deep clone of teachers"
Browse files Browse the repository at this point in the history
This reverts commit dbea425.
  • Loading branch information
MarvinOehlerkingCap committed Dec 12, 2024
1 parent dbea425 commit 7fb7ccd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions controllers/courses.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const getSyncedElements = (
classesAndGroups,
classAndGroupIdsOfCourse,
teachers,
substitutions,
students,
res,
syncedWithGroup,
Expand All @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -327,6 +331,7 @@ const editCourseHandler = (req, res, next) => {
classesAndGroups,
classAndGroupIdsOfCourse,
teachers,
substitutions,
students,
res,
syncedGroupId,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 7fb7ccd

Please sign in to comment.