From b288570463a8f7d5dbbf9bcb8783d9b721cce0d9 Mon Sep 17 00:00:00 2001 From: Gregory Faller Date: Sat, 6 Dec 2014 08:24:08 +1030 Subject: [PATCH] MDL-46172 mod/assign: Stop suspended users getting assign group emails --- mod/assign/locallib.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index e61707071d0..0c022876362 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -1967,9 +1967,10 @@ class assign { * * @param int $groupid The id of the group whose members we want or 0 for the default group * @param bool $onlyids Whether to retrieve only the user id's + * @param bool $excludesuspended Whether to exclude suspended users * @return array The users (possibly id's only) */ - public function get_submission_group_members($groupid, $onlyids) { + public function get_submission_group_members($groupid, $onlyids, $excludesuspended = false) { $members = array(); if ($groupid != 0) { if ($onlyids) { @@ -1991,7 +1992,7 @@ class assign { } } // Exclude suspended users, if user can't see them. - if (!has_capability('moodle/course:viewsuspendedusers', $this->context)) { + if ($excludesuspended || !has_capability('moodle/course:viewsuspendedusers', $this->context)) { foreach ($members as $key => $member) { if (!$this->is_active_user($member->id)) { unset($members[$key]); @@ -6673,7 +6674,7 @@ class assign { $groupid = $group->id; } } - $members = $this->get_submission_group_members($groupid, true); + $members = $this->get_submission_group_members($groupid, true, $this->show_only_active_users()); foreach ($members as $member) { // User may exist in multple groups (which should put them in the default group). $this->apply_grade_to_user($data, $member->id, $data->attemptnumber);