#176 Only get users details who are enrolled within the course

This commit is contained in:
Tristan Mackay 2018-04-10 11:53:46 +08:00 committed by Mark Nelson
parent 9440dea72c
commit 9f2a36d983

View file

@ -71,8 +71,7 @@ class email_certificate_task extends \core\task\scheduled_task {
// Get the person we are going to send this email on behalf of.
// Look through the teachers.
if ($teachers = get_users_by_capability($context, 'moodle/course:update', 'u.*', 'u.id ASC',
'', '', '', '', false, true)) {
if ($teachers = get_enrolled_users($context, 'moodle/course:update')) {
$teachers = sort_by_roleassignment_authority($teachers, $context);
$userfrom = reset($teachers);
} else { // Ok, no teachers, use administrator name.