Skip to content

Commit

Permalink
filter users in query
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinOehlerkingCap committed Dec 10, 2024
1 parent b9ad882 commit cf76d89
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions controllers/courses.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,13 @@ const editCourseHandler = (req, res, next) => {

const teachersPromise = getSelectOptions(req, 'users', {
roles: ['teacher'],
schoolId: res.locals.currentSchool,
$limit: false,
$sort: 'lastName',
});
const studentsPromise = getSelectOptions(req, 'users', {
roles: ['student'],
schoolId: res.locals.currentSchool,
$limit: false,
$sort: 'lastName',
});
Expand All @@ -230,7 +232,7 @@ const editCourseHandler = (req, res, next) => {
studentsPromise,
scopePermissions,
groupPromise,
]).then(([course, _classesAndGroups, _teachers, _students, _scopePermissions, group]) => {
]).then(([course, _classesAndGroups, teachers, students, _scopePermissions, group]) => {
// these 3 might not change anything because hooks allow just ownSchool results by now, but to be sure:
let classesAndGroups = [];
if (FEATURE_GROUPS_IN_COURSE_ENABLED) {
Expand All @@ -241,12 +243,6 @@ const editCourseHandler = (req, res, next) => {
).sort();
}

const teachers = _teachers.filter(
(t) => t.schoolId === res.locals.currentSchool,
);
const students = _students.filter(
(s) => s.schoolId === res.locals.currentSchool,
);
teachers.forEach((teacher) => {
teacher.isHidden = isUserHidden(teacher, res.locals.currentSchoolData);
});
Expand Down

0 comments on commit cf76d89

Please sign in to comment.