Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N21-939 assign groups to course #3326

Merged
merged 19 commits into from
Oct 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions controllers/courses.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@ const editCourseHandler = (req, res, next) => {
}

let classesAndGroupsPromise;
arnegns marked this conversation as resolved.
Show resolved Hide resolved
let classesPromise;
if (FEATURE_GROUPS_IN_COURSE_ENABLED) {
arnegns marked this conversation as resolved.
Show resolved Hide resolved
classesAndGroupsPromise = api(req, { version: 'v3' })
.get('/groups/class');
} else {
classesAndGroupsPromise = api(req)
classesPromise = api(req)
.get('/classes', {
qs: {
schoolId: res.locals.currentSchool,
Expand Down Expand Up @@ -163,7 +164,7 @@ const editCourseHandler = (req, res, next) => {

Promise.all([
coursePromise,
classesAndGroupsPromise,
FEATURE_GROUPS_IN_COURSE_ENABLED ? classesAndGroupsPromise : classesPromise,
MBergCap marked this conversation as resolved.
Show resolved Hide resolved
teachersPromise,
studentsPromise,
scopePermissions,
Expand Down Expand Up @@ -251,6 +252,8 @@ const editCourseHandler = (req, res, next) => {
? s.filter(({ selected }) => selected) : s
);

const classAndGroupIds = [...(course.classIds || []), ...(course.groupIds || [])];

if (req.params.courseId) {
if (!_scopePermissions.includes('COURSE_EDIT')) return next(new Error(res.$t('global.text.403')));
return res.render('courses/edit-course', {
Expand All @@ -261,7 +264,7 @@ const editCourseHandler = (req, res, next) => {
closeLabel: res.$t('global.button.cancel'),
course,
colors,
classesAndGroups: markSelected(classesAndGroups, [...course.classIds, ...course.groupIds]),
classesAndGroups: markSelected(classesAndGroups, classAndGroupIds),
teachers: markSelected(
teachers,
course.teacherIds,
Expand All @@ -283,7 +286,7 @@ const editCourseHandler = (req, res, next) => {
closeLabel: res.$t('global.button.cancel'),
course,
colors,
classesAndGroups: markSelected(classesAndGroups, course.classIds),
classesAndGroups: markSelected(classesAndGroups, classAndGroupIds),
teachers: markSelected(
teachers,
course.teacherIds,
Expand Down