MDL-79734 mod_assign: Fixed send notifications for due in 7 days
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
namespace mod_assign;
|
||||
|
||||
use DateTime;
|
||||
use core\output\html_writer;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -507,19 +508,25 @@ class notification_helper {
|
||||
}
|
||||
|
||||
// Build the digest.
|
||||
$digest = '';
|
||||
$digestarray = [];
|
||||
foreach ($assignmentsfordigest as $digestitem) {
|
||||
$digest .= get_string('assignmentduedigestitem', 'mod_assign', $digestitem);
|
||||
$digestarray[] = get_string('assignmentduedigestitem', 'mod_assign', $digestitem);
|
||||
}
|
||||
|
||||
// Put the digest into list.
|
||||
$digest = html_writer::alist($digestarray);
|
||||
|
||||
// Get user's object.
|
||||
$userobject = \core_user::get_user($userid);
|
||||
|
||||
$stringparams = [
|
||||
'firstname' => $assignmentobj->get_participant($userid)->firstname,
|
||||
'firstname' => $userobject->firstname,
|
||||
'duedate' => userdate(self::get_future_time(self::INTERVAL_DUE_DIGEST), get_string('strftimedaydate', 'langconfig')),
|
||||
'digest' => $digest,
|
||||
];
|
||||
|
||||
$messagedata = [
|
||||
'user' => \core_user::get_user($userid),
|
||||
'user' => $userobject,
|
||||
'subject' => get_string('assignmentduedigestsubject', 'mod_assign'),
|
||||
'html' => get_string('assignmentduedigesthtml', 'mod_assign', $stringparams),
|
||||
];
|
||||
|
||||
@@ -54,7 +54,6 @@ class queue_all_assignment_due_digest_notification_tasks extends scheduled_task
|
||||
// Queue a task for each user.
|
||||
foreach ($users as $user) {
|
||||
$task = new send_assignment_due_digest_notification_to_user();
|
||||
$task->set_custom_data($user);
|
||||
$task->set_userid($user->id);
|
||||
\core\task\manager::queue_adhoc_task($task, true);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ class send_assignment_due_digest_notification_to_user extends adhoc_task {
|
||||
* Execute the task.
|
||||
*/
|
||||
public function execute(): void {
|
||||
$user = $this->get_custom_data();
|
||||
notification_helper::send_due_digest_notification_to_user($user->id);
|
||||
notification_helper::send_due_digest_notification_to_user($this->get_userid());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,9 +70,9 @@ $string['assignfeedbackpluginname'] = 'Feedback plugin';
|
||||
$string['assignmentduedigesthtml'] = '<p>Hi {$a->firstname},</p>
|
||||
<p>The following assignments are due on <strong>{$a->duedate}</strong>.</p>
|
||||
{$a->digest}';
|
||||
$string['assignmentduedigestitem'] = '<p><strong>{$a->assignmentname}</strong> in course {$a->coursename}<br/>
|
||||
$string['assignmentduedigestitem'] = '<strong>{$a->assignmentname}</strong> in course {$a->coursename}<br/>
|
||||
<strong>Due: {$a->duetime}</strong><br/>
|
||||
<a href="{$a->url}">Go to activity</a></p>';
|
||||
<a href="{$a->url}" aria-label="Go to {$a->assignmentname}">Go to activity</a>';
|
||||
$string['assignmentduedigestsubject'] = 'You have assignments due in 7 days';
|
||||
$string['assignmentduesoonhtml'] = '<p>Hi {$a->firstname},</p>
|
||||
<p>The assignment <strong>{$a->assignmentname}</strong> in course {$a->coursename} is due soon.</p>
|
||||
|
||||
Reference in New Issue
Block a user