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);