From 03af4debd127d9b86885cbcb9f3b6155d8023981 Mon Sep 17 00:00:00 2001 From: Leon Stringer Date: Tue, 18 Feb 2025 10:29:13 +0000 Subject: [PATCH] MDL-84097 mod_quiz: Suspended account error Change get_users_within_quiz() to exclude both suspended users and users with auth='nologin'. This prevents the failure of notification tasks when such users are enrolled in the course. --- mod/quiz/classes/notification_helper.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mod/quiz/classes/notification_helper.php b/mod/quiz/classes/notification_helper.php index 4f4982d2fd52e..624a570538301 100644 --- a/mod/quiz/classes/notification_helper.php +++ b/mod/quiz/classes/notification_helper.php @@ -76,13 +76,18 @@ public static function get_users_within_quiz(int $quizid): array { $users = get_enrolled_users( context: \context_module::instance($quizobj->get_cm()->id), withcapability: 'mod/quiz:attempt', - userfields: 'u.id, u.firstname', + userfields: 'u.id, u.firstname, u.suspended, u.auth', ); // Check for any override dates. $overrides = $quizobj->get_override_manager()->get_all_overrides(); foreach ($users as $key => $user) { + if ($user->suspended || ($user->auth == 'nologin')) { + unset($users[$key]); + continue; + } + // Time open and time close dates can be user specific with an override. // We begin by assuming it is the same as recorded in the quiz. $user->timeopen = $quiz->timeopen;