diff --git a/lang/en/block_completion_progress.php b/lang/en/block_completion_progress.php index 73087016673..026fb81718b 100644 --- a/lang/en/block_completion_progress.php +++ b/lang/en/block_completion_progress.php @@ -99,3 +99,5 @@ $string['why_use_icons'] = 'Why you might want to use icons?'; $string['why_use_icons_help'] = '

You may wish to add tick and cross icons in the Completion Progress to make this block more visually accessible for students with colour-blindness.

It may also make the meaning of the block clearer if you believe colours are not intuitive, either for cultural or personal reasons.

'; $string['wrapafter'] = 'When wrapping, limit rows to'; +$string['roles_to_exclude'] = 'Roles to not display and not use and the block'; +$string['roles_to_exclude_desc'] = 'Roles list to not display or not use in this block and in the overview report. If an user owns one of theses roles the user will not appear in the block informations and his progress will not be displayed.'; diff --git a/overview.php b/overview.php index dd155e65efb..93967345d6f 100644 --- a/overview.php +++ b/overview.php @@ -166,10 +166,14 @@ } // Output the roles menu. +$rolestoexclude = get_config('block_completion_progress' ,'roles_to_exclude'); $sql = "SELECT DISTINCT r.id, r.name, r.shortname FROM {role} r, {role_assignments} a WHERE a.contextid = :contextid AND r.id = a.roleid"; +if ($rolestoexclude != "") { + $sql .= " AND r.id not in ($rolestoexclude)"; +} $params = array('contextid' => $context->id); $roles = role_fix_names($DB->get_records_sql($sql, $params), $context); $rolestodisplay = array(0 => get_string('allparticipants')); @@ -206,8 +210,13 @@ FROM {user} u JOIN {role_assignments} a ON (a.contextid = :contextid AND a.userid = u.id $rolewhere) $groupjoin - LEFT JOIN {user_lastaccess} l ON (l.courseid = :courseid AND l.userid = u.id)"; + LEFT JOIN {user_lastaccess} l ON (l.courseid = :courseid AND l.userid = u.id)"; +if ($rolestoexclude != "") { + $sql .= " WHERE a.userid not in + (SELECT userid FROM {role_assignments} WHERE contextid = :subcontextid AND roleid IN ($rolestoexclude))"; +} $params['contextid'] = $context->id; +$params['subcontextid'] = $context->id; $params['courseid'] = $course->id; $userrecords = $DB->get_records_sql($sql, $params); if (get_config('block_completion_progress', 'showinactive') !== "1") { diff --git a/settings.php b/settings.php index 5b78a5401c2..b0827cc4eb3 100644 --- a/settings.php +++ b/settings.php @@ -106,4 +106,11 @@ '', DEFAULT_COMPLETIONPROGRESS_FORCEICONSINBAR) ); + + $settings->add(new admin_setting_pickroles( + 'block_completion_progress/roles_to_exclude', + get_string('roles_to_exclude', 'block_completion_progress'), + get_string('roles_to_exclude_desc', 'block_completion_progress'), + null + )); }