// Get course teachers based on global teacher roles
// Get course teachers based on global teacher roles
...
@@ -478,14 +477,16 @@ class block_course_overview_campus extends block_base {
...
@@ -478,14 +477,16 @@ class block_course_overview_campus extends block_base {
// Get all user name fields for SQL query in a proper way
// Get all user name fields for SQL query in a proper way
$allnames=get_all_user_name_fields(true,'u');
$allnames=get_all_user_name_fields(true,'u');
$teacherfields='ra.id AS raid, u.id, '.$allnames.', r.sortorder';
$teacherfields='ra.id AS raid, u.id, '.$allnames.', r.sortorder';// Moodle would complain about two columns called id with a "Did you remember to make the first column something unique in your call to get_records? Duplicate value 'xxx' found in column 'id'." debug message. That's why we alias one column to a name different than id.
$teachersortfields='u.lastname, u.firstname';
// Check if we have to check for suspended teachers
// Check if we have to check for suspended teachers
$extrawhere='';
if($coc_config->teacherroleshidesuspended==1){
if($coc_config->teacherroleshidesuspended==1){
// Build extra where clause for SQL query
// Build extra where clause for SQL query
$now=round(time(),-2);// improves db caching
$now=round(time(),-2);// improves db caching
$extrawhere='ue.status = '.ENROL_USER_ACTIVE.' AND e.status = '.ENROL_INSTANCE_ENABLED.' AND ue.timestart < '.$now.' AND (ue.timeend = 0 OR ue.timeend > '.$now.')';
$extrawhere='ue.status = '.ENROL_USER_ACTIVE.' AND e.status = '.ENROL_INSTANCE_ENABLED.' AND ue.timestart < '.$now.' AND (ue.timeend = 0 OR ue.timeend > '.$now.')';
}else{
$extrawhere='';
}
}
// Check if we have to include teacher roles from parent contexts
// Check if we have to include teacher roles from parent contexts
...
@@ -493,56 +494,42 @@ class block_course_overview_campus extends block_base {
...
@@ -493,56 +494,42 @@ class block_course_overview_campus extends block_base {