Skip to content

Commit

Permalink
MDL-84097 mod_quiz: Suspended account error
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
leonstr committed Feb 18, 2025
1 parent 3c848c4 commit 03af4de
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mod/quiz/classes/notification_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 03af4de

Please sign in to comment.