mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-47162 core_message: Add course id to message eventdata
This commit is contained in:
parent
577bd70d38
commit
cc350fd9c8
34 changed files with 345 additions and 76 deletions
|
@ -5475,7 +5475,8 @@ class assign {
|
|||
$assignmentname);
|
||||
}
|
||||
|
||||
$eventdata = new stdClass();
|
||||
$eventdata = new \core\message\message();
|
||||
$eventdata->courseid = $course->id;
|
||||
$eventdata->modulename = 'assign';
|
||||
$eventdata->userfrom = $userfrom;
|
||||
$eventdata->userto = $userto;
|
||||
|
|
|
@ -1246,6 +1246,39 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
|
|||
$this->assertEquals($assign->get_instance()->name, $messages[0]->contexturlname);
|
||||
}
|
||||
|
||||
public function test_cron_message_includes_courseid() {
|
||||
// First run cron so there are no messages waiting to be sent (from other tests).
|
||||
cron_setup_user();
|
||||
assign::cron();
|
||||
|
||||
// Now create an assignment.
|
||||
$this->setUser($this->editingteachers[0]);
|
||||
$assign = $this->create_instance(array('sendstudentnotifications' => 1));
|
||||
|
||||
// Simulate adding a grade.
|
||||
$this->setUser($this->teachers[0]);
|
||||
$data = new stdClass();
|
||||
$data->grade = '50.0';
|
||||
$assign->testable_apply_grade_to_user($data, $this->students[0]->id, 0);
|
||||
|
||||
$this->preventResetByRollback();
|
||||
$sink = $this->redirectEvents();
|
||||
|
||||
assign::cron();
|
||||
|
||||
$events = $sink->get_events();
|
||||
// Two messages are sent, one to student and one to teacher. This generates
|
||||
// four events:
|
||||
// core\event\message_sent
|
||||
// core\event\message_viewed
|
||||
// core\event\message_sent
|
||||
// core\event\message_viewed.
|
||||
$event = reset($events);
|
||||
$this->assertInstanceOf('\core\event\message_sent', $event);
|
||||
$this->assertEquals($assign->get_course()->id, $event->other['courseid']);
|
||||
$sink->close();
|
||||
}
|
||||
|
||||
public function test_is_graded() {
|
||||
$this->setUser($this->editingteachers[0]);
|
||||
$assign = $this->create_instance();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue