Skip to content
Snippets Groups Projects
Commit 8e5a67c4 authored by Kathrin's avatar Kathrin
Browse files

Fix to issue LMS-882: Verify active teacher enrolment

Verify active teacher enrolment
parent 340e1a65
No related branches found
No related tags found
No related merge requests found
...@@ -463,20 +463,40 @@ class block_course_overview_campus extends block_base { ...@@ -463,20 +463,40 @@ class block_course_overview_campus extends block_base {
// Teacher information // Teacher information
if ($coc_config->teachercoursefilter == true || $coc_config->secondrowshowteachername == true) { if ($coc_config->teachercoursefilter == true || $coc_config->secondrowshowteachername == true) {
$now1 = round(time(), -2); // improves db caching
$now2 = $now1;
$statussuspended = 0;
$enrolmentactive = 0;
$extrawhere = 'ue.status = '.$statussuspended.' AND e.status = '.$enrolmentactive.' AND ue.timestart < '.$now1.' AND (ue.timeend = 0 OR ue.timeend > '.$now2.')';
// Get course teachers based on global teacher roles // Get course teachers based on global teacher roles
if (count($teacherroles) > 0) { if (count($teacherroles) > 0) {
// Check if we have to include teacher roles from parent contexts // Check if we have to include teacher roles from parent contexts
// If yes // If yes
if ($coc_config->teacherrolesparent == 1) { if ($coc_config->teacherrolesparent == 1) {
if ($coc_config->teacherroleshidesuspendedteacher == 0) { // also show suspended teachers
$courseteachers = get_role_users($teacherroles, $context, true, 'ra.id, u.id, u.lastname, u.firstname, r.sortorder', 'u.lastname, u.firstname'); $courseteachers = get_role_users($teacherroles, $context, true, 'ra.id, u.id, u.lastname, u.firstname, r.sortorder', 'u.lastname, u.firstname');
} else { // hide suspended teachers
$courseteachers = get_role_users($teacherroles, $context, true, 'ra.id, u.id, u.lastname, u.firstname, r.sortorder', 'u.lastname, u.firstname', false, '', '', '', $extrawhere);
}
} }
// If no // If no
else if ($coc_config->teacherrolesparent == 2) { else if ($coc_config->teacherrolesparent == 2) {
if ($coc_config->teacherroleshidesuspendedteacher == 0) { // also show suspended teachers
$courseteachers = get_role_users($teacherroles, $context, false, 'ra.id, u.id, u.lastname, u.firstname, r.sortorder', 'u.lastname, u.firstname'); $courseteachers = get_role_users($teacherroles, $context, false, 'ra.id, u.id, u.lastname, u.firstname, r.sortorder', 'u.lastname, u.firstname');
} else { // hide suspended teachers
$courseteachers = get_role_users($teacherroles, $context, false, 'ra.id, u.id, u.lastname, u.firstname, r.sortorder', 'u.lastname, u.firstname', false, '', '', '', $extrawhere);
}
} }
// If depending on moodle/course:reviewotherusers capability // If depending on moodle/course:reviewotherusers capability
else if ($coc_config->teacherrolesparent == 3) { else if ($coc_config->teacherrolesparent == 3) {
if ($coc_config->teacherroleshidesuspendedteacher == 0) { // also show suspended teachers
$courseteachers = get_role_users($teacherroles, $context, has_capability('moodle/course:reviewotherusers', $context), 'ra.id, u.id, u.lastname, u.firstname, r.sortorder', 'u.lastname, u.firstname'); $courseteachers = get_role_users($teacherroles, $context, has_capability('moodle/course:reviewotherusers', $context), 'ra.id, u.id, u.lastname, u.firstname, r.sortorder', 'u.lastname, u.firstname');
} else { // hide suspended teachers
$courseteachers = get_role_users($teacherroles, $context, has_capability('moodle/course:reviewotherusers', $context), 'ra.id, u.id, u.lastname, u.firstname, r.sortorder', 'u.lastname, u.firstname', false, '', '', '', $extrawhere);
}
} }
// Should not happen // Should not happen
else { else {
......
...@@ -109,6 +109,8 @@ $string['teachernamestylefullnamedisplay'] = 'Teacher name style according to Mo ...@@ -109,6 +109,8 @@ $string['teachernamestylefullnamedisplay'] = 'Teacher name style according to Mo
$string['teacherrolessettingheading'] = 'Teacher roles'; $string['teacherrolessettingheading'] = 'Teacher roles';
$string['teacherroles'] = 'Teacher roles'; $string['teacherroles'] = 'Teacher roles';
$string['teacherroles_desc'] = 'Define which roles are handled as teacher roles by this plugin<br /><em>This setting is only processed when show teacher name is activated or when the teacher filter is activated or when the priorization of courses in which I teach is activated</em>'; $string['teacherroles_desc'] = 'Define which roles are handled as teacher roles by this plugin<br /><em>This setting is only processed when show teacher name is activated or when the teacher filter is activated or when the priorization of courses in which I teach is activated</em>';
$string['teacherroleshidesuspendedteacher'] = 'Verify active teacher enrolment';
$string['teacherrolessuspendedteacher_desc'] = 'If this option is active, it will check for suspended but enroled teachers and will NOT display them as teachers in the course information. This will cause a little higher load on the database. So just activate if you are sure that you really need this feature.';
$string['teacherrolesparent'] = 'Include parent context teacher roles'; $string['teacherrolesparent'] = 'Include parent context teacher roles';
$string['teacherrolesparent_desc'] = 'When looking for teachers with the specified teacher roles, include teachers who have their role assigned in parent contexts (course category or system level)<br /><em>This setting is only processed when show teacher name is activated or when the teacher filter is activated.</em><br /><em>Warning: If you set this to "No" or "Depending on the user\'s moodle/course:reviewotherusers capability", the "Prioritize courses in which I teach" function will also be influenced and will not priorize courses where the user has his teacher role assigned in parent contexts.</em>'; $string['teacherrolesparent_desc'] = 'When looking for teachers with the specified teacher roles, include teachers who have their role assigned in parent contexts (course category or system level)<br /><em>This setting is only processed when show teacher name is activated or when the teacher filter is activated.</em><br /><em>Warning: If you set this to "No" or "Depending on the user\'s moodle/course:reviewotherusers capability", the "Prioritize courses in which I teach" function will also be influenced and will not priorize courses where the user has his teacher role assigned in parent contexts.</em>';
$string['teacherrolesparentcapability'] = 'Depending on the user\'s moodle/course:reviewotherusers capability'; $string['teacherrolesparentcapability'] = 'Depending on the user\'s moodle/course:reviewotherusers capability';
......
...@@ -202,6 +202,8 @@ else if ($ADMIN->fulltree) { ...@@ -202,6 +202,8 @@ else if ($ADMIN->fulltree) {
$settingspage->add(new admin_setting_configselect('block_course_overview_campus/teacherrolesparent', get_string('teacherrolesparent', 'block_course_overview_campus'), $settingspage->add(new admin_setting_configselect('block_course_overview_campus/teacherrolesparent', get_string('teacherrolesparent', 'block_course_overview_campus'),
get_string('teacherrolesparent_desc', 'block_course_overview_campus'), $teacherrolesparentmodes[1], $teacherrolesparentmodes)); get_string('teacherrolesparent_desc', 'block_course_overview_campus'), $teacherrolesparentmodes[1], $teacherrolesparentmodes));
$settingspage->add(new admin_setting_configcheckbox('block_course_overview_campus/teacherroleshidesuspendedteacher', get_string('teacherroleshidesuspendedteacher', 'block_course_overview_campus'),
get_string('teacherrolessuspendedteacher_desc', 'block_course_overview_campus'), 0));
// Add settings page to the admin settings category // Add settings page to the admin settings category
$ADMIN->add('block_course_overview_campus', $settingspage); $ADMIN->add('block_course_overview_campus', $settingspage);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment