mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-52805 core: Plugins with removed tests due to old events
This commit is contained in:
parent
e5ca7766e7
commit
5dace7abc8
@ -93,35 +93,6 @@ abstract class base extends \core\event\base {
|
||||
$this->data['objecttable'] = 'bigbluebuttonbn';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy data for add_to_log().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
if (isset($this->legacylogdata)) {
|
||||
return $this->legacylogdata;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the legacy event log data.
|
||||
*
|
||||
* @param string $action The current action
|
||||
* @param string $info A detailed description of the change. But no more than 255 characters.
|
||||
* @param string $url The url to the assign module instance.
|
||||
*/
|
||||
public function set_legacy_logdata($action = '', $info = '', $url = '') {
|
||||
$fullurl = 'view.php?id=' . $this->contextinstanceid;
|
||||
if ($url != '') {
|
||||
$fullurl .= '&' . $url;
|
||||
}
|
||||
|
||||
$this->legacylogdata = [$this->courseid, 'bigbluebuttonbn', $action, $fullurl, $info, $this->contextinstanceid];
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
@ -283,7 +283,7 @@ trait testcase_helper_trait {
|
||||
* @param bool $withremoterecordings create recording on the mock server ?
|
||||
* @return array
|
||||
*/
|
||||
protected function create_legacy_log_entries(
|
||||
protected function create_log_entries(
|
||||
instance $instance,
|
||||
int $userid,
|
||||
int $count = 30,
|
||||
@ -304,10 +304,10 @@ trait testcase_helper_trait {
|
||||
// Create a recording.
|
||||
$starttime = time() - random_int(HOURSECS, WEEKSECS);
|
||||
$recording = $plugingenerator->create_recording([
|
||||
'bigbluebuttonbnid' => $instance->get_instance_id(),
|
||||
'groupid' => $instance->get_group_id(),
|
||||
'starttime' => $starttime,
|
||||
'endtime' => $starttime + HOURSECS,
|
||||
'bigbluebuttonbnid' => $instance->get_instance_id(),
|
||||
'groupid' => $instance->get_group_id(),
|
||||
'starttime' => $starttime,
|
||||
'endtime' => $starttime + HOURSECS,
|
||||
], true); // Create them on the server only.
|
||||
|
||||
$baselogdata['meetingid'] = $instance->get_meeting_id();
|
||||
@ -323,7 +323,7 @@ trait testcase_helper_trait {
|
||||
$data = [];
|
||||
}
|
||||
$baselogdata['meta'] = json_encode(array_merge([
|
||||
'recording' => array_diff_key($data, $metaonly),
|
||||
'recording' => array_diff_key($data, $metaonly),
|
||||
], $metaonly));
|
||||
|
||||
} else {
|
||||
|
@ -197,8 +197,8 @@ class upgrade_recordings_task_test extends advanced_testcase {
|
||||
$plugingenerator = $this->getDataGenerator()->get_plugin_generator('mod_bigbluebuttonbn');
|
||||
[$teacher, $groups, $instance, $groupedinstance, $deletedinstance] = $this->setup_basic_course_and_meeting();
|
||||
|
||||
$this->create_legacy_log_entries($instance, $teacher->id, 5, false);
|
||||
$this->create_legacy_log_entries($instance, $teacher->id, 5, false, false);
|
||||
$this->create_log_entries($instance, $teacher->id, 5);
|
||||
$this->create_log_entries($instance, $teacher->id, 5, false, false);
|
||||
$this->assertEquals(10, $DB->count_records('bigbluebuttonbn_logs', ['log' => 'Create']));
|
||||
|
||||
// Schedule the run.
|
||||
@ -257,7 +257,7 @@ class upgrade_recordings_task_test extends advanced_testcase {
|
||||
'instanceid' => $this->instance->get_instance_id(),
|
||||
'groupid' => $this->instance->get_group_id(),
|
||||
]);
|
||||
$this->create_legacy_log_entries($this->instance, $user->id, 5, false);
|
||||
$this->create_log_entries($this->instance, $user->id, 5);
|
||||
$plugingenerator->create_recording([
|
||||
'bigbluebuttonbnid' => $this->instance->get_instance_id(),
|
||||
'groupid' => $this->instance->get_group_id(),
|
||||
@ -292,12 +292,12 @@ class upgrade_recordings_task_test extends advanced_testcase {
|
||||
global $DB;
|
||||
[$teacher, $groups, $instance, $groupedinstance, $deletedinstance] = $this->setup_basic_course_and_meeting();
|
||||
|
||||
$this->create_legacy_log_entries($instance, $teacher->id, 30, $importedrecording);
|
||||
$this->create_log_entries($instance, $teacher->id, 30, $importedrecording);
|
||||
foreach ($groups as $group) {
|
||||
$groupinstance = instance::get_group_instance_from_instance($groupedinstance, $group->id);
|
||||
$this->create_legacy_log_entries($groupinstance, $teacher->id, 15, $importedrecording);
|
||||
$this->create_log_entries($groupinstance, $teacher->id, 15, $importedrecording);
|
||||
}
|
||||
$this->create_legacy_log_entries($deletedinstance, $teacher->id, 15, $importedrecording);
|
||||
$this->create_log_entries($deletedinstance, $teacher->id, 15, $importedrecording);
|
||||
course_delete_module($deletedinstance->get_cm_id());
|
||||
// Truncate the recordings table to reflect what it would have looked like before this version.
|
||||
$DB->delete_records('bigbluebuttonbn_recordings');
|
||||
|
@ -77,16 +77,6 @@ class attempt_deleted extends \core\event\base {
|
||||
return new \moodle_url('/mod/scorm/report.php', array('id' => $this->contextinstanceid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'scorm', 'delete attempts', 'report.php?id=' . $this->contextinstanceid,
|
||||
$this->other['attemptid'], $this->contextinstanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
@ -44,16 +44,6 @@ class course_module_viewed extends \core\event\course_module_viewed {
|
||||
$this->data['objecttable'] = 'scorm';
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'scorm', 'pre-view', 'view.php?id=' . $this->contextinstanceid, $this->objectid,
|
||||
$this->contextinstanceid);
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'scorm', 'restore' => 'scorm');
|
||||
}
|
||||
|
@ -83,17 +83,6 @@ class interactions_viewed extends \core\event\base {
|
||||
return new \moodle_url('/mod/scorm/userreportinteractions.php', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'scorm', 'userreportinteractions', 'report/userreportinteractions.php?id=' .
|
||||
$this->contextinstanceid . '&user=' . $this->relateduserid . '&attempt=' . $this->other['attemptid'],
|
||||
$this->other['instanceid'], $this->contextinstanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
@ -78,16 +78,6 @@ class report_viewed extends \core\event\base {
|
||||
return new \moodle_url('/mod/scorm/report.php', array('id' => $this->contextinstanceid, 'mode' => $this->other['mode']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'scorm', 'report', 'report.php?id=' . $this->contextinstanceid .
|
||||
'&mode=' . $this->other['mode'], $this->other['scormid'], $this->contextinstanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
@ -79,16 +79,6 @@ class sco_launched extends \core\event\base {
|
||||
return new \moodle_url('/mod/scorm/player.php', array('cm' => $this->contextinstanceid, 'scoid' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'scorm', 'launch', 'view.php?id=' . $this->contextinstanceid,
|
||||
$this->other['loadedcontent'], $this->contextinstanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
@ -85,17 +85,6 @@ class tracks_viewed extends \core\event\base {
|
||||
return new \moodle_url('/mod/scorm/userreporttracks.php', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'scorm', 'userreporttracks', 'report/userreporttracks.php?id=' . $this->contextinstanceid
|
||||
. '&user=' . $this->relateduserid . '&attempt=' . $this->other['attemptid'] . '&scoid=' . $this->other['scoid']
|
||||
. '&mode=' . $this->other['mode'], $this->other['instanceid'], $this->contextinstanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
@ -82,17 +82,6 @@ class user_report_viewed extends \core\event\base {
|
||||
return new \moodle_url('/mod/scorm/userreport.php', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'scorm', 'userreport', 'report/userreport.php?id=' .
|
||||
$this->contextinstanceid . '&user=' . $this->relateduserid . '&attempt=' . $this->other['attemptid'],
|
||||
$this->other['instanceid'], $this->contextinstanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
@ -83,9 +83,6 @@ class events_test extends \advanced_testcase {
|
||||
$this->assertEquals(\context_module::instance($this->eventcm->id), $event->get_context());
|
||||
$this->assertEquals(4, $event->other['attemptid']);
|
||||
$this->assertEquals(2, $event->relateduserid);
|
||||
$expected = array($this->eventcourse->id, 'scorm', 'delete attempts', 'report.php?id=' . $this->eventcm->id,
|
||||
4, $this->eventcm->id);
|
||||
$this->assertEventLegacyLogData($expected, $events[0]);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
|
||||
// Test event validations.
|
||||
@ -96,83 +93,6 @@ class events_test extends \advanced_testcase {
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for course module viewed event.
|
||||
*
|
||||
* There is no api involved so the best we can do is test legacy data by triggering event manually.
|
||||
*/
|
||||
public function test_course_module_viewed_event() {
|
||||
$this->resetAfterTest();
|
||||
$event = \mod_scorm\event\course_module_viewed::create(array(
|
||||
'objectid' => $this->eventscorm->id,
|
||||
'context' => \context_module::instance($this->eventcm->id),
|
||||
'courseid' => $this->eventcourse->id
|
||||
));
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
$event->trigger();
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
|
||||
// Check that the legacy log data is valid.
|
||||
$expected = array($this->eventcourse->id, 'scorm', 'pre-view', 'view.php?id=' . $this->eventcm->id,
|
||||
$this->eventscorm->id, $this->eventcm->id);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for instance list viewed event.
|
||||
*
|
||||
* There is no api involved so the best we can do is test legacy data by triggering event manually.
|
||||
*/
|
||||
public function test_course_module_instance_list_viewed_event() {
|
||||
$this->resetAfterTest();
|
||||
$event = \mod_scorm\event\course_module_instance_list_viewed::create(array(
|
||||
'context' => \context_course::instance($this->eventcourse->id),
|
||||
'courseid' => $this->eventcourse->id
|
||||
));
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
$event->trigger();
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
|
||||
// Check that the legacy log data is valid.
|
||||
$expected = array($this->eventcourse->id, 'scorm', 'view all', 'index.php?id=' . $this->eventcourse->id, '');
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for interactions viewed.
|
||||
*
|
||||
* There is no api involved so the best we can do is test legacy data by triggering event manually and test validations.
|
||||
*/
|
||||
public function test_interactions_viewed_event() {
|
||||
$this->resetAfterTest();
|
||||
$event = \mod_scorm\event\interactions_viewed::create(array(
|
||||
'relateduserid' => 5,
|
||||
'context' => \context_module::instance($this->eventcm->id),
|
||||
'courseid' => $this->eventcourse->id,
|
||||
'other' => array('attemptid' => 2, 'instanceid' => $this->eventscorm->id)
|
||||
));
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
$event->trigger();
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
|
||||
// Check that the legacy log data is valid.
|
||||
$expected = array($this->eventcourse->id, 'scorm', 'userreportinteractions', 'report/userreportinteractions.php?id=' .
|
||||
$this->eventcm->id . '&user=5&attempt=' . 2, $this->eventscorm->id, $this->eventcm->id);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for interactions viewed validations.
|
||||
*/
|
||||
@ -202,96 +122,6 @@ class events_test extends \advanced_testcase {
|
||||
}
|
||||
}
|
||||
|
||||
/** Tests for report viewed.
|
||||
*
|
||||
* There is no api involved so the best we can do is test legacy data and validations by triggering event manually.
|
||||
*/
|
||||
public function test_report_viewed_event() {
|
||||
$this->resetAfterTest();
|
||||
$event = \mod_scorm\event\report_viewed::create(array(
|
||||
'context' => \context_module::instance($this->eventcm->id),
|
||||
'courseid' => $this->eventcourse->id,
|
||||
'other' => array(
|
||||
'scormid' => $this->eventscorm->id,
|
||||
'mode' => 'basic'
|
||||
)
|
||||
));
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
$event->trigger();
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
|
||||
// Check that the legacy log data is valid.
|
||||
$expected = array($this->eventcourse->id, 'scorm', 'report', 'report.php?id=' . $this->eventcm->id . '&mode=basic',
|
||||
$this->eventscorm->id, $this->eventcm->id);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
/** Tests for sco launched event.
|
||||
*
|
||||
* There is no api involved so the best we can do is test legacy data and validations by triggering event manually.
|
||||
*/
|
||||
public function test_sco_launched_event() {
|
||||
$this->resetAfterTest();
|
||||
$event = \mod_scorm\event\sco_launched::create(array(
|
||||
'objectid' => 2,
|
||||
'context' => \context_module::instance($this->eventcm->id),
|
||||
'courseid' => $this->eventcourse->id,
|
||||
'other' => array('loadedcontent' => 'url_to_content_that_was_laoded.php')
|
||||
));
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
$event->trigger();
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
|
||||
// Check that the legacy log data is valid.
|
||||
$expected = array($this->eventcourse->id, 'scorm', 'launch', 'view.php?id=' . $this->eventcm->id,
|
||||
'url_to_content_that_was_laoded.php', $this->eventcm->id);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
|
||||
// Test validations.
|
||||
$this->expectException(\coding_exception::class);
|
||||
\mod_scorm\event\sco_launched::create(array(
|
||||
'objectid' => $this->eventscorm->id,
|
||||
'context' => \context_module::instance($this->eventcm->id),
|
||||
'courseid' => $this->eventcourse->id,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for tracks viewed event.
|
||||
*
|
||||
* There is no api involved so the best we can do is test validations by triggering event manually.
|
||||
*/
|
||||
public function test_tracks_viewed_event() {
|
||||
$this->resetAfterTest();
|
||||
$event = \mod_scorm\event\tracks_viewed::create(array(
|
||||
'relateduserid' => 5,
|
||||
'context' => \context_module::instance($this->eventcm->id),
|
||||
'courseid' => $this->eventcourse->id,
|
||||
'other' => array('attemptid' => 2, 'instanceid' => $this->eventscorm->id, 'scoid' => 3, 'mode' => 'interactions')
|
||||
));
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
$event->trigger();
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
|
||||
// Check that the legacy log data is valid.
|
||||
$expected = array($this->eventcourse->id, 'scorm', 'userreporttracks', 'report/userreporttracks.php?id=' .
|
||||
$this->eventcm->id . '&user=5&attempt=' . 2 . '&scoid=3' . '&mode=interactions',
|
||||
$this->eventscorm->id, $this->eventcm->id);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for tracks viewed event validations.
|
||||
*/
|
||||
@ -333,33 +163,6 @@ class events_test extends \advanced_testcase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for userreport viewed event.
|
||||
*
|
||||
* There is no api involved so the best we can do is test validations and legacy log by triggering event manually.
|
||||
*/
|
||||
public function test_user_report_viewed_event() {
|
||||
$this->resetAfterTest();
|
||||
$event = \mod_scorm\event\user_report_viewed::create(array(
|
||||
'relateduserid' => 5,
|
||||
'context' => \context_module::instance($this->eventcm->id),
|
||||
'courseid' => $this->eventcourse->id,
|
||||
'other' => array('attemptid' => 2, 'instanceid' => $this->eventscorm->id)
|
||||
));
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
$event->trigger();
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
|
||||
// Check that the legacy log data is valid.
|
||||
$expected = array($this->eventcourse->id, 'scorm', 'userreport', 'report/userreport.php?id=' .
|
||||
$this->eventcm->id . '&user=5&attempt=' . 2, $this->eventscorm->id, $this->eventcm->id);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for userreport viewed event validations.
|
||||
*/
|
||||
@ -413,40 +216,6 @@ class events_test extends \advanced_testcase {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for score submitted event.
|
||||
*
|
||||
* There is no api involved so the best we can do is test data by triggering event manually.
|
||||
*
|
||||
* @dataProvider get_scoreraw_submitted_event_provider
|
||||
*
|
||||
* @param string $cmielement a valid CMI raw score element
|
||||
* @param string $cmivalue a valid CMI raw score value
|
||||
*/
|
||||
public function test_scoreraw_submitted_event($cmielement, $cmivalue) {
|
||||
$this->resetAfterTest();
|
||||
$event = \mod_scorm\event\scoreraw_submitted::create(array(
|
||||
'other' => array('attemptid' => '2', 'cmielement' => $cmielement, 'cmivalue' => $cmivalue),
|
||||
'objectid' => $this->eventscorm->id,
|
||||
'context' => \context_module::instance($this->eventcm->id),
|
||||
'relateduserid' => $this->eventuser->id
|
||||
));
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
$event->trigger();
|
||||
$events = $sink->get_events();
|
||||
$sink->close();
|
||||
$event = reset($events);
|
||||
$this->assertEquals(2, $event->other['attemptid']);
|
||||
$this->assertEquals($cmielement, $event->other['cmielement']);
|
||||
$this->assertEquals($cmivalue, $event->other['cmivalue']);
|
||||
|
||||
// Check that no legacy log data is provided.
|
||||
$this->assertEventLegacyLogData(null, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* dataProvider for test_scoreraw_submitted_event_validations().
|
||||
*/
|
||||
@ -534,40 +303,6 @@ class events_test extends \advanced_testcase {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for status submitted event.
|
||||
*
|
||||
* There is no api involved so the best we can do is test data by triggering event manually.
|
||||
*
|
||||
* @dataProvider get_status_submitted_event_provider
|
||||
*
|
||||
* @param string $cmielement a valid CMI status element
|
||||
* @param string $cmivalue a valid CMI status value
|
||||
*/
|
||||
public function test_status_submitted_event($cmielement, $cmivalue) {
|
||||
$this->resetAfterTest();
|
||||
$event = \mod_scorm\event\status_submitted::create(array(
|
||||
'other' => array('attemptid' => '2', 'cmielement' => $cmielement, 'cmivalue' => $cmivalue),
|
||||
'objectid' => $this->eventscorm->id,
|
||||
'context' => \context_module::instance($this->eventcm->id),
|
||||
'relateduserid' => $this->eventuser->id
|
||||
));
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
$event->trigger();
|
||||
$events = $sink->get_events();
|
||||
$sink->close();
|
||||
$event = reset($events);
|
||||
$this->assertEquals(2, $event->other['attemptid']);
|
||||
$this->assertEquals($cmielement, $event->other['cmielement']);
|
||||
$this->assertEquals($cmivalue, $event->other['cmivalue']);
|
||||
|
||||
// Check that no legacy log data is provided.
|
||||
$this->assertEventLegacyLogData(null, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* dataProvider for test_status_submitted_event_validations().
|
||||
*/
|
||||
|
@ -53,43 +53,6 @@ class assessable_uploaded extends \core\event\assessable_uploaded {
|
||||
"to the workshop activity with course module id '$this->contextinstanceid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data if get_legacy_eventname() is not empty.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
$eventdata = new \stdClass();
|
||||
$eventdata->modulename = 'workshop';
|
||||
$eventdata->cmid = $this->contextinstanceid;
|
||||
$eventdata->itemid = $this->objectid;
|
||||
$eventdata->courseid = $this->courseid;
|
||||
$eventdata->userid = $this->userid;
|
||||
$eventdata->content = $this->other['content'];
|
||||
if ($this->other['pathnamehashes']) {
|
||||
$eventdata->pathnamehashes = $this->other['pathnamehashes'];
|
||||
}
|
||||
return $eventdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'assessable_content_uploaded';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy log data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return $this->legacylogdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
@ -119,16 +82,6 @@ class assessable_uploaded extends \core\event\assessable_uploaded {
|
||||
$this->data['objecttable'] = 'workshop_submissions';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the legacy log data.
|
||||
*
|
||||
* @param array $legacylogdata
|
||||
* @return void
|
||||
*/
|
||||
public function set_legacy_logdata($legacylogdata) {
|
||||
$this->legacylogdata = $legacylogdata;
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'workshop_submissions', 'restore' => 'workshop_submission');
|
||||
}
|
||||
|
@ -62,16 +62,6 @@ class assessment_evaluations_reset extends \core\event\base {
|
||||
"'$this->contextinstanceid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'workshop', 'update clear aggregated grade', 'view.php?id=' . $this->contextinstanceid,
|
||||
$this->other['workshopid'], $this->contextinstanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
|
@ -63,16 +63,6 @@ class assessment_reevaluated extends \core\event\base {
|
||||
"course module id '$this->contextinstanceid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'workshop', 'update aggregate grade', 'view.php?id=' . $this->contextinstanceid,
|
||||
$this->objectid, $this->contextinstanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
|
@ -61,16 +61,6 @@ class assessments_reset extends \core\event\base {
|
||||
"'$this->contextinstanceid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'workshop', 'update clear assessments', 'view.php?id=' . $this->contextinstanceid,
|
||||
$this->other['workshopid'], $this->contextinstanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
|
@ -48,30 +48,6 @@ class course_module_viewed extends \core\event\course_module_viewed {
|
||||
$this->data['objecttable'] = 'workshop';
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this event replace a legacy event?
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'workshop_viewed';
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data if get_legacy_eventname() is not empty.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
global $USER;
|
||||
|
||||
$workshop = $this->get_record_snapshot('workshop', $this->objectid);
|
||||
$course = $this->get_record_snapshot('course', $this->courseid);
|
||||
$cm = $this->get_record_snapshot('course_modules', $this->contextinstanceid);
|
||||
$workshop = new \workshop($workshop, $cm, $course);
|
||||
return (object)array('workshop' => $workshop, 'user' => $USER);
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'workshop', 'restore' => 'workshop');
|
||||
}
|
||||
|
@ -62,16 +62,6 @@ class phase_switched extends \core\event\base {
|
||||
"'$this->contextinstanceid' to '{$this->other['workshopphase']}'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'workshop', 'update switch phase', 'view.php?id=' . $this->contextinstanceid,
|
||||
$this->other['workshopphase'], $this->contextinstanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
|
@ -63,16 +63,6 @@ class submission_assessed extends \core\event\base {
|
||||
"id '$this->relateduserid' in the workshop with course module id '$this->contextinstanceid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'workshop', 'add assessment ', 'assessment.php?asid=' . $this->objectid,
|
||||
$this->other['submissionid'], $this->contextinstanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
|
@ -78,17 +78,6 @@ class submission_created extends \core\event\base {
|
||||
array('cmid' => $this->contextinstanceid, 'id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'workshop', 'add submission',
|
||||
'submission.php?cmid=' . $this->contextinstanceid . '&id=' . $this->objectid,
|
||||
$this->objectid, $this->contextinstanceid);
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'workshop_submissions', 'restore' => 'workshop_submission');
|
||||
}
|
||||
|
@ -79,17 +79,6 @@ class submission_deleted extends \core\event\base {
|
||||
array('cmid' => $this->contextinstanceid, 'id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'workshop', 'delete submission',
|
||||
'submission.php?cmid=' . $this->contextinstanceid . '&id=' . $this->objectid,
|
||||
$this->objectid, $this->contextinstanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines mapping of the 'objectid' property when restoring course logs.
|
||||
*
|
||||
|
@ -64,16 +64,6 @@ class submission_reassessed extends \core\event\base {
|
||||
"id '$this->relateduserid' in the workshop with course module id '$this->contextinstanceid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'workshop', 'update assessment', 'assessment.php?asid=' . $this->objectid,
|
||||
$this->other['submissionid'], $this->contextinstanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
|
@ -78,17 +78,6 @@ class submission_updated extends \core\event\base {
|
||||
array('cmid' => $this->contextinstanceid, 'id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'workshop', 'update submission',
|
||||
'submission.php?cmid=' . $this->contextinstanceid . '&id=' . $this->objectid,
|
||||
$this->objectid, $this->contextinstanceid);
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'workshop_submissions', 'restore' => 'workshop_submission');
|
||||
}
|
||||
|
@ -78,17 +78,6 @@ class submission_viewed extends \core\event\base {
|
||||
array('cmid' => $this->contextinstanceid, 'id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'workshop', 'view submission',
|
||||
'submission.php?cmid=' . $this->contextinstanceid . '&id=' . $this->objectid,
|
||||
$this->objectid, $this->contextinstanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
@ -3027,7 +3027,6 @@ class workshop {
|
||||
$params['other']['pathnamehashes'] = array_keys($files);
|
||||
|
||||
$event = \mod_workshop\event\assessable_uploaded::create($params);
|
||||
$event->set_legacy_logdata($logdata);
|
||||
$event->trigger();
|
||||
|
||||
return $submission->id;
|
||||
|
@ -95,10 +95,6 @@ class events_test extends \advanced_testcase {
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
|
||||
// Check that the legacy log data is valid.
|
||||
$expected = array($this->course->id, 'workshop', 'update switch phase', 'view.php?id=' . $this->cm->id,
|
||||
$newphase, $this->cm->id);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
|
||||
$sink->close();
|
||||
@ -151,9 +147,6 @@ class events_test extends \advanced_testcase {
|
||||
$this->assertInstanceOf('\mod_workshop\event\assessment_reevaluated', $event);
|
||||
$this->assertEquals('workshop_aggregations', $event->objecttable);
|
||||
$this->assertEquals(\context_module::instance($cm->id), $event->get_context());
|
||||
$expected = array($this->course->id, 'workshop', 'update aggregate grade',
|
||||
'view.php?id=' . $event->get_context()->instanceid, $event->objectid, $event->get_context()->instanceid);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
|
||||
$sink->close();
|
||||
@ -178,11 +171,6 @@ class events_test extends \advanced_testcase {
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
|
||||
// Check that the legacy log data is valid.
|
||||
$expected = array($this->course->id, 'workshop', 'update clear aggregated grade', 'view.php?id=' . $this->cm->id,
|
||||
$this->workshop->id, $this->cm->id);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
|
||||
$sink->close();
|
||||
}
|
||||
|
||||
@ -203,9 +191,6 @@ class events_test extends \advanced_testcase {
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
|
||||
// Check that the legacy log data is valid.
|
||||
$expected = array($this->course->id, 'workshop', 'view all', 'index.php?id=' . $this->course->id, '');
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
|
||||
$sink->close();
|
||||
@ -238,82 +223,6 @@ class events_test extends \advanced_testcase {
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
|
||||
// Check that the legacy log data is valid.
|
||||
$expected = array($this->course->id, 'workshop', 'add submission',
|
||||
'submission.php?cmid=' . $this->cm->id . '&id=' . $submissionid, $submissionid, $this->cm->id);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
|
||||
$sink->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* There is no api involved so the best we can do is test legacy data by triggering event manually.
|
||||
*/
|
||||
public function test_submission_updated_event() {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$submissionid = 48;
|
||||
|
||||
$event = \mod_workshop\event\submission_updated::create(array(
|
||||
'objectid' => $submissionid,
|
||||
'context' => $this->context,
|
||||
'courseid' => $this->course->id,
|
||||
'relateduserid' => $user->id,
|
||||
'other' => array(
|
||||
'submissiontitle' => 'The submission title'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
$event->trigger();
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
|
||||
// Check that the legacy log data is valid.
|
||||
$expected = array($this->course->id, 'workshop', 'update submission',
|
||||
'submission.php?cmid=' . $this->cm->id . '&id=' . $submissionid, $submissionid, $this->cm->id);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
|
||||
$sink->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* There is no api involved so the best we can do is test legacy data by triggering event manually.
|
||||
*/
|
||||
public function test_submission_viewed_event() {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$submissionid = 48;
|
||||
|
||||
$event = \mod_workshop\event\submission_viewed::create(array(
|
||||
'objectid' => $submissionid,
|
||||
'context' => $this->context,
|
||||
'courseid' => $this->course->id,
|
||||
'relateduserid' => $user->id,
|
||||
'other' => array(
|
||||
'workshopid' => $this->workshop->id
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Trigger and capture the event.
|
||||
$sink = $this->redirectEvents();
|
||||
$event->trigger();
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
|
||||
// Check that the legacy log data is valid.
|
||||
$expected = array($this->course->id, 'workshop', 'view submission',
|
||||
'submission.php?cmid=' . $this->cm->id . '&id=' . $submissionid, $submissionid, $this->cm->id);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
|
||||
$sink->close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user