From 12362eef07cb47443107ab88ac381854f0459912 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Sat, 12 Oct 2024 16:06:29 +0100 Subject: [PATCH] Only get teachers when emailing certificates if required (#531) --- classes/task/email_certificate_task.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/classes/task/email_certificate_task.php b/classes/task/email_certificate_task.php index f75d8812..c376ca36 100644 --- a/classes/task/email_certificate_task.php +++ b/classes/task/email_certificate_task.php @@ -73,9 +73,6 @@ public function execute() { // Get the person we are going to send this email on behalf of. $userfrom = \core_user::get_noreply_user(); - // Store teachers for later. - $teachers = get_enrolled_users($context, 'moodle/course:update'); - $courseshortname = format_string($customcert->courseshortname, true, ['context' => $context]); $coursefullname = format_string($customcert->coursefullname, true, ['context' => $context]); $certificatename = format_string($customcert->name, true, ['context' => $context]); @@ -140,6 +137,8 @@ public function execute() { } if ($customcert->emailteachers) { + $teachers = get_enrolled_users($context, 'moodle/course:update'); + $renderable = new \mod_customcert\output\email_certificate(false, $userfullname, $courseshortname, $coursefullname, $certificatename, $context->instanceid);