This commit is contained in:
Huong Nguyen 2024-02-08 11:04:52 +07:00 committed by Andrew Nicols
commit 5f3729eb63
No known key found for this signature in database
GPG key ID: 6D1E3157C8CFBF14

View file

@ -52,9 +52,7 @@ class content_notification_task extends adhoc_task {
// Get only active users. // Get only active users.
$coursecontext = \context_course::instance($course->id); $coursecontext = \context_course::instance($course->id);
$modcontext = \context_module::instance($cm->id);
$users = get_enrolled_users($coursecontext, '', 0, 'u.*', null, 0, 0, true); $users = get_enrolled_users($coursecontext, '', 0, 'u.*', null, 0, 0, true);
if (empty($users)) { if (empty($users)) {
return; return;
} }
@ -80,9 +78,9 @@ class content_notification_task extends adhoc_task {
// Get module names in the user's language. // Get module names in the user's language.
$modnames = get_module_types_names(); $modnames = get_module_types_names();
$a = [ $a = [
'coursename' => format_string(get_course_display_name_for_list($course), true, ['context' => $modcontext]), 'coursename' => format_string(get_course_display_name_for_list($course), true, ['context' => $coursecontext]),
'courselink' => (new \moodle_url('/course/view.php', ['id' => $course->id]))->out(false), 'courselink' => (new \moodle_url('/course/view.php', ['id' => $course->id]))->out(false),
'modulename' => format_string($cm->name, $modcontext->id), 'modulename' => $cm->get_formatted_name(),
'moduletypename' => $modnames[$cm->modname], 'moduletypename' => $modnames[$cm->modname],
'link' => (new \moodle_url('/mod/' . $cm->modname . '/view.php', ['id' => $cm->id]))->out(false), 'link' => (new \moodle_url('/mod/' . $cm->modname . '/view.php', ['id' => $cm->id]))->out(false),
'notificationpreferenceslink' => 'notificationpreferenceslink' =>
@ -109,7 +107,7 @@ class content_notification_task extends adhoc_task {
$eventdata->fullmessagehtml = $messagebody; $eventdata->fullmessagehtml = $messagebody;
$eventdata->smallmessage = strip_tags($eventdata->fullmessagehtml); $eventdata->smallmessage = strip_tags($eventdata->fullmessagehtml);
$eventdata->contexturl = (new \moodle_url('/mod/' . $cm->modname . '/view.php', ['id' => $cm->id]))->out(false); $eventdata->contexturl = (new \moodle_url('/mod/' . $cm->modname . '/view.php', ['id' => $cm->id]))->out(false);
$eventdata->contexturlname = $cm->name; $eventdata->contexturlname = $cm->get_formatted_name();
$eventdata->notification = 1; $eventdata->notification = 1;
// Add notification custom data. // Add notification custom data.