From f628561ae3e1b43c637a1d6f2839f1700c8e5719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20=C3=96hlerking?= <103562092+MarvinOehlerkingCap@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:59:11 +0100 Subject: [PATCH] N21-2192 Configure teachers in partial sync (#3540) Co-authored-by: Igor Richter <93926487+IgorCapCoder@users.noreply.github.com> --- controllers/courses.js | 7 ++++++- views/courses/create-course.hbs | 4 ++-- views/courses/edit-course.hbs | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/controllers/courses.js b/controllers/courses.js index 6ab16c6d23..82f672f83a 100644 --- a/controllers/courses.js +++ b/controllers/courses.js @@ -23,6 +23,10 @@ const router = express.Router(); const { HOST } = require('../config/global'); const { isUserHidden } = require('../helpers/users'); +const SYNC_ATTRIBUTE = Object.freeze({ + TEACHERS: 'teachers', +}); + const getSelectOptions = (req, service, query) => api(req).get(`/${service}`, { qs: query, }).then((data) => data.data); @@ -81,6 +85,7 @@ const getSyncedElements = ( untilDate, syncedWithGroup, excludeFromSync: course.excludeFromSync?.join(','), + areTeachersSynced: !course.excludeFromSync?.includes(SYNC_ATTRIBUTE.TEACHERS), }; return selectedElements; }; @@ -310,7 +315,7 @@ const editCourseHandler = (req, res, next) => { const isTeacherInGroup = teacherIds.some((tid) => tid === res.locals.currentUser._id); const isTeacher = res.locals.currentUser.roles.map((role) => role.name).includes('teacher'); if (!isTeacherInGroup && isTeacher) { - course.excludeFromSync = ['teachers']; + course.excludeFromSync = [SYNC_ATTRIBUTE.TEACHERS]; course.teacherIds = [res.locals.currentUser._id]; } else { course.teacherIds = teacherIds; diff --git a/views/courses/create-course.hbs b/views/courses/create-course.hbs index ed96190856..100962e34c 100644 --- a/views/courses/create-course.hbs +++ b/views/courses/create-course.hbs @@ -109,7 +109,7 @@