MDL-43736 Events: event->contextinstanceid should be used where possible

While restoring event context might not be present (deleted)
So before using context api's check context or use event properties
This commit is contained in:
Rajesh Taneja
2014-01-29 11:39:44 +08:00
parent fefcd9abab
commit fdc729ea57
73 changed files with 154 additions and 136 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ abstract class assessable_submitted extends \core\event\base {
* @return void
*/
protected function validate_data() {
if (!$this->context->contextlevel === CONTEXT_MODULE) {
if (!$this->contextlevel === CONTEXT_MODULE) {
throw new \coding_exception('Content level must be CONTEXT_MODULE.');
}
}
+1 -1
View File
@@ -66,7 +66,7 @@ abstract class assessable_uploaded extends \core\event\base {
* @return void
*/
protected function validate_data() {
if (!$this->context->contextlevel === CONTEXT_MODULE) {
if (!$this->contextlevel === CONTEXT_MODULE) {
throw new \coding_exception('Content level must be CONTEXT_MODULE.');
} else if (!isset($this->other['pathnamehashes']) || !is_array($this->other['pathnamehashes'])) {
throw new \coding_exception('pathnamehashes must be set in $other and must be an array.');
+1 -1
View File
@@ -355,7 +355,7 @@ abstract class base implements \IteratorAggregate {
if (isset($this->context)) {
return $this->context;
}
$this->context = \context::instance_by_id($this->data['contextid'], false);
$this->context = \context::instance_by_id($this->data['contextid'], IGNORE_MISSING);
return $this->context;
}
@@ -69,8 +69,8 @@ class blog_association_created extends \core\event\base {
* @return string
*/
public function get_description() {
return "Blog association added between entry id $this->other['blogid'] and $this->other['associatetype'] with id
$this->other['associateid']";
return "Blog association added between entry id {$this->other['blogid']} and {$this->other['associatetype']} with id
{$this->other['associateid']}";
}
/**
+6 -1
View File
@@ -79,7 +79,12 @@ abstract class comment_created extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return $this->context->get_url();
$context = $this->get_context();
if ($context) {
return $context->get_url();
} else {
return null;
}
}
/**
+6 -1
View File
@@ -79,7 +79,12 @@ abstract class comment_deleted extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return $this->context->get_url();
$context = $this->get_context();
if ($context) {
return $context->get_url();
} else {
return null;
}
}
/**
+6 -1
View File
@@ -72,6 +72,11 @@ abstract class comments_viewed extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return $this->context->get_url();
$context = $this->get_context();
if ($context) {
return $context->get_url();
} else {
return null;
}
}
}
@@ -105,7 +105,7 @@ abstract class course_module_instance_list_viewed extends base{
* @return void
*/
protected function validate_data() {
if ($this->context->contextlevel !== CONTEXT_COURSE) {
if ($this->contextlevel !== CONTEXT_COURSE) {
throw new \coding_exception('The context must be a course level context.');
}
}
+3 -3
View File
@@ -72,7 +72,7 @@ abstract class course_module_viewed extends base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url("/mod/$this->objecttable/view.php", array('id' => $this->context->instanceid));
return new \moodle_url("/mod/$this->objecttable/view.php", array('id' => $this->contextinstanceid));
}
/**
@@ -81,8 +81,8 @@ abstract class course_module_viewed extends base {
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, $this->objecttable, 'view', 'view.php?id=' . $this->context->instanceid, $this->objectid,
$this->context->instanceid);
return array($this->courseid, $this->objecttable, 'view', 'view.php?id=' . $this->contextinstanceid, $this->objectid,
$this->contextinstanceid);
}
/**
@@ -75,7 +75,7 @@ class all_submissions_downloaded extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -65,7 +65,7 @@ class assessable_submitted extends \core\event\assessable_submitted {
protected function get_legacy_eventdata() {
$eventdata = new \stdClass();
$eventdata->modulename = 'assign';
$eventdata->cmid = $this->context->instanceid;
$eventdata->cmid = $this->contextinstanceid;
$eventdata->itemid = $this->objectid;
$eventdata->courseid = $this->courseid;
$eventdata->userid = $this->userid;
@@ -106,7 +106,7 @@ class assessable_submitted extends \core\event\assessable_submitted {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -75,7 +75,7 @@ class extension_granted extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -75,7 +75,7 @@ class identities_revealed extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
+1 -1
View File
@@ -81,7 +81,7 @@ class marker_updated extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -75,7 +75,7 @@ class statement_accepted extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -75,7 +75,7 @@ class submission_duplicated extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -75,7 +75,7 @@ class submission_graded extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -75,7 +75,7 @@ class submission_locked extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -81,7 +81,7 @@ class submission_status_updated extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -75,7 +75,7 @@ class submission_unlocked extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -75,7 +75,7 @@ class submission_updated extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -81,7 +81,7 @@ class workflow_state_updated extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -66,7 +66,7 @@ class assessable_uploaded extends \core\event\assessable_uploaded {
protected function get_legacy_eventdata() {
$eventdata = new \stdClass();
$eventdata->modulename = 'assign';
$eventdata->cmid = $this->context->instanceid;
$eventdata->cmid = $this->contextinstanceid;
$eventdata->itemid = $this->objectid;
$eventdata->courseid = $this->courseid;
$eventdata->userid = $this->userid;
@@ -102,7 +102,7 @@ class assessable_uploaded extends \core\event\assessable_uploaded {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -60,7 +60,7 @@ class assessable_uploaded extends \core\event\assessable_uploaded {
protected function get_legacy_eventdata() {
$eventdata = new \stdClass();
$eventdata->modulename = 'assign';
$eventdata->cmid = $this->context->instanceid;
$eventdata->cmid = $this->contextinstanceid;
$eventdata->itemid = $this->objectid;
$eventdata->courseid = $this->courseid;
$eventdata->userid = $this->userid;
@@ -95,7 +95,7 @@ class assessable_uploaded extends \core\event\assessable_uploaded {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
+4 -4
View File
@@ -40,7 +40,7 @@ class chapter_created extends \core\event\base {
* @return string
*/
public function get_description() {
return "The chapter $this->objectid of the book $this->context->instanceid has been created.";
return "The chapter $this->objectid of the book " . $this->contextinstanceid . " has been created.";
}
/**
@@ -49,8 +49,8 @@ class chapter_created extends \core\event\base {
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'book', 'add chapter', 'view.php?id=' . $this->context->instanceid . '&chapterid=' .
$this->objectid, $this->objectid, $this->context->instanceid);
return array($this->courseid, 'book', 'add chapter', 'view.php?id=' . $this->contextinstanceid . '&chapterid=' .
$this->objectid, $this->objectid, $this->contextinstanceid);
}
/**
@@ -69,7 +69,7 @@ class chapter_created extends \core\event\base {
*/
public function get_url() {
return new \moodle_url('/mod/book/view.php', array(
'id' => $this->context->instanceid,
'id' => $this->contextinstanceid,
'chapterid' => $this->objectid
));
}
+2 -2
View File
@@ -47,7 +47,7 @@ class chapter_deleted extends \core\event\base {
* @return string
*/
public function get_description() {
return "The chapter $this->objectid of the book $this->context->instanceid has been deleted.";
return "The chapter $this->objectid of the book " . $this->contextinstanceid . " has been deleted.";
}
/**
@@ -74,7 +74,7 @@ class chapter_deleted extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/book/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/book/view.php', array('id' => $this->contextinstanceid));
}
/**
+4 -4
View File
@@ -40,7 +40,7 @@ class chapter_updated extends \core\event\base {
* @return string
*/
public function get_description() {
return "The chapter $this->objectid of the book $this->context->instanceid has been updated.";
return "The chapter $this->objectid of the book " . $this->contextinstanceid . " has been updated.";
}
/**
@@ -49,8 +49,8 @@ class chapter_updated extends \core\event\base {
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'book', 'update chapter', 'view.php?id=' . $this->context->instanceid . '&chapterid=' .
$this->objectid, $this->objectid, $this->context->instanceid);
return array($this->courseid, 'book', 'update chapter', 'view.php?id=' . $this->contextinstanceid . '&chapterid=' .
$this->objectid, $this->objectid, $this->contextinstanceid);
}
/**
@@ -69,7 +69,7 @@ class chapter_updated extends \core\event\base {
*/
public function get_url() {
return new \moodle_url('/mod/book/view.php', array(
'id' => $this->context->instanceid,
'id' => $this->contextinstanceid,
'chapterid' => $this->objectid
));
}
+4 -4
View File
@@ -40,7 +40,7 @@ class chapter_viewed extends \core\event\content_viewed {
* @return string
*/
public function get_description() {
return "The user $this->userid has viewed the chapter $this->objectid of book module $this->context->instanceid";
return "The user $this->userid has viewed the chapter $this->objectid of book module $this->contextinstanceid";
}
/**
@@ -49,8 +49,8 @@ class chapter_viewed extends \core\event\content_viewed {
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'book', 'view chapter', 'view.php?id=' . $this->context->instanceid .
'&chapterid=' . $this->objectid, $this->objectid, $this->context->instanceid);
return array($this->courseid, 'book', 'view chapter', 'view.php?id=' . $this->contextinstanceid .
'&chapterid=' . $this->objectid, $this->objectid, $this->contextinstanceid);
}
/**
@@ -68,7 +68,7 @@ class chapter_viewed extends \core\event\content_viewed {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/book/view.php', array('id' => $this->context->instanceid, 'chapterid' => $this->objectid));
return new \moodle_url('/mod/book/view.php', array('id' => $this->contextinstanceid, 'chapterid' => $this->objectid));
}
/**
@@ -49,8 +49,8 @@ class book_exported extends \core\event\base {
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'book', 'exportimscp', 'tool/exportimscp/index.php?id=' . $this->context->instanceid,
$this->objectid, $this->context->instanceid);
return array($this->courseid, 'book', 'exportimscp', 'tool/exportimscp/index.php?id=' . $this->contextinstanceid,
$this->objectid, $this->contextinstanceid);
}
/**
@@ -68,7 +68,7 @@ class book_exported extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/book/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/book/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -49,8 +49,8 @@ class book_printed extends \core\event\base {
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'book', 'print', 'tool/print/index.php?id=' . $this->context->instanceid,
$this->objectid, $this->context->instanceid);
return array($this->courseid, 'book', 'print', 'tool/print/index.php?id=' . $this->contextinstanceid,
$this->objectid, $this->contextinstanceid);
}
/**
@@ -68,7 +68,7 @@ class book_printed extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/book/tool/print/index.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/book/tool/print/index.php', array('id' => $this->contextinstanceid));
}
/**
@@ -40,7 +40,8 @@ class chapter_printed extends \core\event\base {
* @return string
*/
public function get_description() {
return "The user $this->userid has printed the chapter $this->objectid of the book module $this->context->instanceid.";
return "The user " . $this->userid . " has printed the chapter $this->objectid of the book module " .
$this->contextinstanceid;
}
/**
@@ -49,8 +50,8 @@ class chapter_printed extends \core\event\base {
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'book', 'print chapter', 'tool/print/index.php?id=' . $this->context->instanceid .
'&chapterid=' . $this->objectid, $this->objectid, $this->context->instanceid);
return array($this->courseid, 'book', 'print chapter', 'tool/print/index.php?id=' . $this->contextinstanceid .
'&chapterid=' . $this->objectid, $this->objectid, $this->contextinstanceid);
}
/**
@@ -68,7 +69,7 @@ class chapter_printed extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/book/tool/print/index.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/book/tool/print/index.php', array('id' => $this->contextinstanceid));
}
/**
+3 -3
View File
@@ -50,8 +50,8 @@ class message_sent extends \core\event\base {
*/
protected function get_legacy_logdata() {
$message = $this->get_record_snapshot('chat_messages', $this->objectid);
return array($this->courseid, 'chat', 'talk', 'view.php?id=' . $this->context->instanceid,
$message->chatid, $this->context->instanceid, $this->relateduserid);
return array($this->courseid, 'chat', 'talk', 'view.php?id=' . $this->contextinstanceid,
$message->chatid, $this->contextinstanceid, $this->relateduserid);
}
/**
@@ -69,7 +69,7 @@ class message_sent extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/chat/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/chat/view.php', array('id' => $this->contextinstanceid));
}
/**
+3 -3
View File
@@ -56,8 +56,8 @@ class sessions_viewed extends \core\event\content_viewed {
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'chat', 'report', 'report.php?id=' . $this->context->instanceid,
$this->objectid, $this->context->instanceid);
return array($this->courseid, 'chat', 'report', 'report.php?id=' . $this->contextinstanceid,
$this->objectid, $this->contextinstanceid);
}
/**
@@ -75,7 +75,7 @@ class sessions_viewed extends \core\event\content_viewed {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/chat/report.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/chat/report.php', array('id' => $this->contextinstanceid));
}
/**
@@ -60,9 +60,9 @@ class answer_submitted extends \core\event\base {
$legacylogdata = array($this->courseid,
'choice',
'choose',
'view.php?id=' . $this->context->instanceid,
'view.php?id=' . $this->contextinstanceid,
$this->other['choiceid'],
$this->context->instanceid);
$this->contextinstanceid);
return $legacylogdata;
}
@@ -82,7 +82,7 @@ class answer_submitted extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/choice/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/choice/view.php', array('id' => $this->contextinstanceid));
}
/**
+3 -3
View File
@@ -60,9 +60,9 @@ class answer_updated extends \core\event\base {
$legacylogdata = array($this->courseid,
'choice',
'choose again',
'view.php?id=' . $this->context->instanceid,
'view.php?id=' . $this->contextinstanceid,
$this->other['choiceid'],
$this->context->instanceid);
$this->contextinstanceid);
return $legacylogdata;
}
@@ -82,7 +82,7 @@ class answer_updated extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/choice/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/choice/view.php', array('id' => $this->contextinstanceid));
}
/**
+3 -3
View File
@@ -64,7 +64,7 @@ class report_viewed extends \core\event\content_viewed {
*/
public function get_url() {
$url = '/mod/choice/report.php';
return new \moodle_url($url, array('id' => $this->context->instanceid));
return new \moodle_url($url, array('id' => $this->contextinstanceid));
}
/**
@@ -73,7 +73,7 @@ class report_viewed extends \core\event\content_viewed {
* @return array of parameters to be passed to legacy add_to_log() function.
*/
protected function get_legacy_logdata() {
$url = new \moodle_url('report.php', array('id' => $this->context->instanceid));
return array($this->courseid, 'choice', 'report', $url->out(), $this->objectid, $this->context->instanceid);
$url = new \moodle_url('report.php', array('id' => $this->contextinstanceid));
return array($this->courseid, 'choice', 'report', $url->out(), $this->objectid, $this->contextinstanceid);
}
}
@@ -68,7 +68,7 @@ class response_deleted extends \core\event\base {
* @return string
*/
public function get_description() {
return 'The feedback from user ' . $this->other['relateduserid']. ' was deleted by' . $this->userid;
return 'The feedback from user ' . $this->relateduserid . ' was deleted by' . $this->userid;
}
/**
@@ -71,7 +71,7 @@ class response_submitted extends \core\event\base {
* @return string
*/
public function get_description() {
return 'The user ' . $this->other['relateduserid']. ' submited a feedback';
return 'The user ' . $this->relateduserid . ' submited a feedback';
}
/**
@@ -84,7 +84,7 @@ class response_submitted extends \core\event\base {
'do_show' => 'showoneentry' , 'userid' => $this->relateduserid));
} else {
return new \moodle_url('/mod/feedback/show_entries_anonym.php', array('id' => $this->other['cmid'],
'do_show' => 'showoneentry', 'showall', 'showcompleted' => $this->objectid));
'do_show' => 'showoneentry', 'showall' => 1, 'showcompleted' => $this->objectid));
}
}
+1
View File
@@ -130,6 +130,7 @@ class mod_feedback_events_testcase extends advanced_testcase {
$arr = array($this->eventcourse->id, 'feedback', 'delete', 'view.php?id=' . $this->eventcm->id, $this->eventfeedback->id,
$this->eventfeedback->id);
$this->assertEventLegacyLogData($arr, $event);
$this->assertEventContextNotUsed($event);
// Test can_view() .
$this->setUser($this->eventuser);
+3 -3
View File
@@ -61,7 +61,7 @@ class folder_updated extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/folder/edit.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/folder/edit.php', array('id' => $this->contextinstanceid));
}
/**
@@ -70,7 +70,7 @@ class folder_updated extends \core\event\base {
* @return array|null
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'folder', 'edit', 'edit.php?id=' . $this->context->instanceid, $this->objectid,
$this->context->instanceid);
return array($this->courseid, 'folder', 'edit', 'edit.php?id=' . $this->contextinstanceid, $this->objectid,
$this->contextinstanceid);
}
}
@@ -62,7 +62,7 @@ class assessable_uploaded extends \core\event\assessable_uploaded {
$eventdata = new \stdClass();
$eventdata->modulename = 'forum';
$eventdata->name = $this->other['triggeredfrom'];
$eventdata->cmid = $this->context->instanceid;
$eventdata->cmid = $this->contextinstanceid;
$eventdata->itemid = $this->objectid;
$eventdata->courseid = $this->courseid;
$eventdata->userid = $this->userid;
+2 -2
View File
@@ -71,7 +71,7 @@ class essay_assessed extends \core\event\base {
protected function get_legacy_logdata() {
$lesson = $this->get_record_snapshot('lesson', $this->other['lessonid']);
return array($this->courseid, 'lesson', 'update grade', 'essay.php?id=' .
$this->context->instanceid, $lesson->name, $this->context->instanceid);
$this->contextinstanceid, $lesson->name, $this->contextinstanceid);
}
/**
@@ -89,7 +89,7 @@ class essay_assessed extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/lesson/essay.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/lesson/essay.php', array('id' => $this->contextinstanceid));
}
/**
@@ -52,7 +52,7 @@ class essay_attempt_viewed extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/lesson/essay.php', array('id' => $this->context->instanceid,
return new \moodle_url('/mod/lesson/essay.php', array('id' => $this->contextinstanceid,
'mode' => 'grade', 'attemptid' => $this->objectid));
}
@@ -72,7 +72,7 @@ class essay_attempt_viewed extends \core\event\base {
* @return array of parameters to be passed to legacy add_to_log() function.
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'lesson', 'view grade', 'essay.php?id=' . $this->context->instanceid . '&mode=grade&attemptid='
. $this->objectid, get_string('manualgrading', 'lesson'), $this->context->instanceid);
return array($this->courseid, 'lesson', 'view grade', 'essay.php?id=' . $this->contextinstanceid . '&mode=grade&attemptid='
. $this->objectid, get_string('manualgrading', 'lesson'), $this->contextinstanceid);
}
}
+3 -3
View File
@@ -52,7 +52,7 @@ class highscore_added extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/lesson/highscores.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/lesson/highscores.php', array('id' => $this->contextinstanceid));
}
/**
@@ -75,7 +75,7 @@ class highscore_added extends \core\event\base {
protected function get_legacy_logdata() {
$highscore = $this->get_record_snapshot('lesson_high_scores', $this->objectid);
return array($this->courseid, 'lesson', 'update highscores', 'highscores.php?id=' . $this->context->instanceid,
$highscore->nickname, $this->context->instanceid);
return array($this->courseid, 'lesson', 'update highscores', 'highscores.php?id=' . $this->contextinstanceid,
$highscore->nickname, $this->contextinstanceid);
}
}
@@ -52,7 +52,7 @@ class highscores_viewed extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/lesson/highscores.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/lesson/highscores.php', array('id' => $this->contextinstanceid));
}
/**
@@ -72,7 +72,7 @@ class highscores_viewed extends \core\event\base {
protected function get_legacy_logdata() {
$lesson = $this->get_record_snapshot('lesson', $this->objectid);
return array($this->courseid, 'lesson', 'view highscores', 'highscores.php?id=' . $this->context->instanceid,
$lesson->name, $this->context->instanceid);
return array($this->courseid, 'lesson', 'view highscores', 'highscores.php?id=' . $this->contextinstanceid,
$lesson->name, $this->contextinstanceid);
}
}
+3 -3
View File
@@ -52,7 +52,7 @@ class lesson_ended extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/lesson/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/lesson/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -70,7 +70,7 @@ class lesson_ended extends \core\event\base {
* @return array of parameters to be passed to legacy add_to_log() function.
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'lesson', 'end', 'view.php?id=' . $this->context->instanceid, $this->objectid,
$this->context->instanceid);
return array($this->courseid, 'lesson', 'end', 'view.php?id=' . $this->contextinstanceid, $this->objectid,
$this->contextinstanceid);
}
}
+3 -3
View File
@@ -52,7 +52,7 @@ class lesson_started extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/lesson/view.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/lesson/view.php', array('id' => $this->contextinstanceid));
}
/**
@@ -70,7 +70,7 @@ class lesson_started extends \core\event\base {
* @return array of parameters to be passed to legacy add_to_log() function.
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'lesson', 'start', 'view.php?id=' . $this->context->instanceid,
$this->objectid, $this->context->instanceid);
return array($this->courseid, 'lesson', 'start', 'view.php?id=' . $this->contextinstanceid,
$this->objectid, $this->contextinstanceid);
}
}
+3 -2
View File
@@ -1512,14 +1512,15 @@ class quiz_attempt {
*/
protected function fire_state_transition_event($eventclass, $timestamp) {
global $USER;
$quizrecord = $this->get_quiz();
$params = array(
'context' => $this->get_quizobj()->get_context(),
'courseid' => $this->get_courseid(),
'objectid' => $this->attempt->id,
'relateduserid' => $this->attempt->userid,
'other' => array(
'submitterid' => CLI_SCRIPT ? null : $USER->id
'submitterid' => CLI_SCRIPT ? null : $USER->id,
'quizid' => $quizrecord->id
)
);
+1 -1
View File
@@ -99,7 +99,7 @@ class attempt_abandoned extends \core\event\base {
$legacyeventdata->timestamp = $attempt->timemodified;
$legacyeventdata->userid = $this->relateduserid;
$legacyeventdata->quizid = $attempt->quiz;
$legacyeventdata->cmid = $this->context->instanceid;
$legacyeventdata->cmid = $this->contextinstanceid;
$legacyeventdata->courseid = $this->courseid;
$legacyeventdata->submitterid = $this->other['submitterid'];
@@ -102,7 +102,7 @@ class attempt_becameoverdue extends \core\event\base {
$legacyeventdata->timestamp = $attempt->timemodified;
$legacyeventdata->userid = $this->relateduserid;
$legacyeventdata->quizid = $attempt->quiz;
$legacyeventdata->cmid = $this->context->instanceid;
$legacyeventdata->cmid = $this->contextinstanceid;
$legacyeventdata->courseid = $this->courseid;
$legacyeventdata->submitterid = $this->other['submitterid'];
+1 -1
View File
@@ -94,7 +94,7 @@ class attempt_started extends \core\event\base {
$legacyeventdata->timestamp = $attempt->timestart;
$legacyeventdata->userid = $this->relateduserid;
$legacyeventdata->quizid = $attempt->quiz;
$legacyeventdata->cmid = $this->context->instanceid;
$legacyeventdata->cmid = $this->contextinstanceid;
$legacyeventdata->courseid = $this->courseid;
return $legacyeventdata;
+1 -1
View File
@@ -99,7 +99,7 @@ class attempt_submitted extends \core\event\base {
$legacyeventdata->timestamp = $attempt->timefinish;
$legacyeventdata->userid = $this->relateduserid;
$legacyeventdata->quizid = $attempt->quiz;
$legacyeventdata->cmid = $this->context->instanceid;
$legacyeventdata->cmid = $this->contextinstanceid;
$legacyeventdata->courseid = $this->courseid;
$legacyeventdata->submitterid = $this->other['submitterid'];
$legacyeventdata->timefinish = $attempt->timefinish;
+3 -3
View File
@@ -71,7 +71,7 @@ class attempt_deleted extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/scorm/report.php', array('id' => $this->context->instanceid));
return new \moodle_url('/mod/scorm/report.php', array('id' => $this->contextinstanceid));
}
/**
@@ -80,8 +80,8 @@ class attempt_deleted extends \core\event\base {
* @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->context->instanceid,
$this->other['attemptid'], $this->context->instanceid);
return array($this->courseid, 'scorm', 'delete attempts', 'report.php?id=' . $this->contextinstanceid,
$this->other['attemptid'], $this->contextinstanceid);
}
/**
@@ -49,8 +49,8 @@ class course_module_viewed extends \core\event\course_module_viewed {
* @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->context->instanceid, $this->objectid,
$this->context->instanceid);
return array($this->courseid, 'scorm', 'pre-view', 'view.php?id=' . $this->contextinstanceid, $this->objectid,
$this->contextinstanceid);
}
}
@@ -73,7 +73,7 @@ class interactions_viewed extends \core\event\base {
*/
public function get_url() {
$params = array(
'id' => $this->context->instanceid,
'id' => $this->contextinstanceid,
'user' => $this->relateduserid,
'attempt' => $this->other['attemptid']
);
@@ -87,8 +87,8 @@ class interactions_viewed extends \core\event\base {
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'scorm', 'userreportinteractions', 'report/userreportinteractions.php?id=' .
$this->context->instanceid . '&user=' . $this->relateduserid . '&attempt=' . $this->other['attemptid'],
$this->other['instanceid'], $this->context->instanceid);
$this->contextinstanceid . '&user=' . $this->relateduserid . '&attempt=' . $this->other['attemptid'],
$this->other['instanceid'], $this->contextinstanceid);
}
/**
+3 -3
View File
@@ -73,7 +73,7 @@ class report_viewed extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/scorm/report.php', array('id' => $this->context->instanceid, 'mode' => $this->other['mode']));
return new \moodle_url('/mod/scorm/report.php', array('id' => $this->contextinstanceid, 'mode' => $this->other['mode']));
}
/**
@@ -82,8 +82,8 @@ class report_viewed extends \core\event\base {
* @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->context->instanceid .
'&mode=' . $this->other['mode'], $this->objectid, $this->context->instanceid);
return array($this->courseid, 'scorm', 'report', 'report.php?id=' . $this->contextinstanceid .
'&mode=' . $this->other['mode'], $this->objectid, $this->contextinstanceid);
}
/**
+3 -3
View File
@@ -74,7 +74,7 @@ class sco_launched extends \core\event\base {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/scorm/player.php', array('id' => $this->context->instanceid, 'scoid' => $this->objectid));
return new \moodle_url('/mod/scorm/player.php', array('id' => $this->contextinstanceid, 'scoid' => $this->objectid));
}
/**
@@ -83,8 +83,8 @@ class sco_launched extends \core\event\base {
* @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->context->instanceid,
$this->other['loadedcontent'], $this->context->instanceid);
return array($this->courseid, 'scorm', 'launch', 'view.php?id=' . $this->contextinstanceid,
$this->other['loadedcontent'], $this->contextinstanceid);
}
/**
+3 -3
View File
@@ -74,7 +74,7 @@ class tracks_viewed extends \core\event\base {
*/
public function get_url() {
$params = array(
'id' => $this->context->instanceid,
'id' => $this->contextinstanceid,
'user' => $this->relateduserid,
'attempt' => $this->other['attemptid'],
'scoid' => $this->other['scoid']
@@ -88,9 +88,9 @@ class tracks_viewed extends \core\event\base {
* @return array
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'scorm', 'userreporttracks', 'report/userreporttracks.php?id=' . $this->context->instanceid
return array($this->courseid, 'scorm', 'userreporttracks', 'report/userreporttracks.php?id=' . $this->contextinstanceid
. '&user=' . $this->relateduserid . '&attempt=' . $this->other['attemptid'] . '&scoid=' . $this->other['scoid'],
$this->other['instanceid'], $this->context->instanceid);
$this->other['instanceid'], $this->contextinstanceid);
}
/**
@@ -73,7 +73,7 @@ class user_report_viewed extends \core\event\base {
*/
public function get_url() {
$params = array(
'id' => $this->context->instanceid,
'id' => $this->contextinstanceid,
'user' => $this->relateduserid,
'attempt' => $this->other['attemptid']
);
@@ -87,8 +87,8 @@ class user_report_viewed extends \core\event\base {
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'scorm', 'userreport', 'report/userreport.php?id=' .
$this->context->instanceid . '&user=' . $this->relateduserid . '&attempt=' . $this->other['attemptid'],
$this->other['instanceid'], $this->context->instanceid);
$this->contextinstanceid . '&user=' . $this->relateduserid . '&attempt=' . $this->other['attemptid'],
$this->other['instanceid'], $this->contextinstanceid);
}
/**
+1 -1
View File
@@ -61,7 +61,7 @@ class comments_viewed extends \core\event\comments_viewed {
*/
protected function get_legacy_logdata() {
return(array($this->courseid, 'wiki', 'comments',
'comments.php?pageid=' . $this->objectid, $this->objectid, $this->context->instanceid));
'comments.php?pageid=' . $this->objectid, $this->objectid, $this->contextinstanceid));
}
/**
+1 -1
View File
@@ -69,7 +69,7 @@ class page_created extends \core\event\base {
*/
protected function get_legacy_logdata() {
return(array($this->courseid, 'wiki', 'add page',
'view.php?pageid=' . $this->objectid, $this->objectid, $this->context->instanceid));
'view.php?pageid=' . $this->objectid, $this->objectid, $this->contextinstanceid));
}
/**
+1 -1
View File
@@ -75,7 +75,7 @@ class page_deleted extends \core\event\base {
*/
protected function get_legacy_logdata() {
return(array($this->courseid, 'wiki', 'admin', 'admin.php?pageid=' . $this->objectid, $this->objectid,
$this->context->instanceid));
$this->contextinstanceid));
}
/**
+1 -1
View File
@@ -77,7 +77,7 @@ class page_diff_viewed extends \core\event\base {
protected function get_legacy_logdata() {
return(array($this->courseid, 'wiki', 'diff', 'diff.php?pageid=' . $this->objectid . '&comparewith=' .
$this->other['comparewith'] . '&compare=' . $this->other['compare'], $this->objectid,
$this->context->instanceid));
$this->contextinstanceid));
}
/**
@@ -69,7 +69,7 @@ class page_history_viewed extends \core\event\base {
*/
protected function get_legacy_logdata() {
return(array($this->courseid, 'wiki', 'history',
'history.php?pageid=' . $this->objectid, $this->objectid, $this->context->instanceid));
'history.php?pageid=' . $this->objectid, $this->objectid, $this->contextinstanceid));
}
/**
@@ -75,7 +75,7 @@ class page_locks_deleted extends \core\event\base {
*/
protected function get_legacy_logdata() {
return(array($this->courseid, 'wiki', 'overridelocks', 'view.php?pageid=' . $this->objectid, $this->objectid,
$this->context->instanceid));
$this->contextinstanceid));
}
/**
+1 -1
View File
@@ -75,7 +75,7 @@ class page_map_viewed extends \core\event\base {
*/
protected function get_legacy_logdata() {
return(array($this->courseid, 'wiki', 'map',
'map.php?pageid=' . $this->objectid, $this->objectid, $this->context->instanceid));
'map.php?pageid=' . $this->objectid, $this->objectid, $this->contextinstanceid));
}
/**
+1 -1
View File
@@ -75,7 +75,7 @@ class page_updated extends \core\event\base {
*/
protected function get_legacy_logdata() {
return(array($this->courseid, 'wiki', 'edit', 'view.php?pageid=' . $this->objectid, $this->objectid,
$this->context->instanceid));
$this->contextinstanceid));
}
/**
@@ -76,7 +76,7 @@ class page_version_deleted extends \core\event\base {
*/
protected function get_legacy_logdata() {
return(array($this->courseid, 'wiki', 'admin', 'admin.php?pageid=' . $this->other['pageid'], $this->other['pageid'],
$this->context->instanceid));
$this->contextinstanceid));
}
/**
@@ -75,7 +75,7 @@ class page_version_restored extends \core\event\base {
*/
protected function get_legacy_logdata() {
return(array($this->courseid, 'wiki', 'restore',
'view.php?pageid=' . $this->other['pageid'], $this->other['pageid'], $this->context->instanceid));
'view.php?pageid=' . $this->other['pageid'], $this->other['pageid'], $this->contextinstanceid));
}
/**
@@ -77,7 +77,7 @@ class page_version_viewed extends \core\event\base {
protected function get_legacy_logdata() {
return(array($this->courseid, 'wiki', 'history',
'viewversion.php?pageid=' . $this->objectid . '&versionid=' . $this->other['versionid'],
$this->objectid, $this->context->instanceid));
$this->objectid, $this->contextinstanceid));
}
/**
+3 -3
View File
@@ -71,13 +71,13 @@ class page_viewed extends \core\event\base {
if (!empty($this->other['wid'])) {
return(array($this->courseid, 'wiki', 'view',
'view.php?wid=' . $this->data['other']['wid'] . '&title=' . $this->data['other']['title'],
$this->data['other']['wid'], $this->context->instanceid));
$this->data['other']['wid'], $this->contextinstanceid));
} else if (!empty($this->other['prettyview'])) {
return(array($this->courseid, 'wiki', 'view',
'prettyview.php?pageid=' . $this->objectid, $this->objectid, $this->context->instanceid));
'prettyview.php?pageid=' . $this->objectid, $this->objectid, $this->contextinstanceid));
} else {
return(array($this->courseid, 'wiki', 'view',
'view.php?pageid=' . $this->objectid, $this->objectid, $this->context->instanceid));
'view.php?pageid=' . $this->objectid, $this->objectid, $this->contextinstanceid));
}
}
@@ -66,7 +66,7 @@ class assessable_uploaded extends \core\event\assessable_uploaded {
protected function get_legacy_eventdata() {
$eventdata = new \stdClass();
$eventdata->modulename = 'workshop';
$eventdata->cmid = $this->context->instanceid;
$eventdata->cmid = $this->contextinstanceid;
$eventdata->itemid = $this->objectid;
$eventdata->courseid = $this->courseid;
$eventdata->userid = $this->userid;
@@ -111,7 +111,7 @@ class assessable_uploaded extends \core\event\assessable_uploaded {
*/
public function get_url() {
return new \moodle_url('/mod/workshop/submission.php',
array('cmid' => $this->context->instanceid, 'id' => $this->objectid));
array('cmid' => $this->contextinstanceid, 'id' => $this->objectid));
}
/**
@@ -62,7 +62,7 @@ class course_module_viewed extends \core\event\course_module_viewed {
$workshop = $this->get_record_snapshot('workshop', $this->objectid);
$course = $this->get_record_snapshot('course', $this->courseid);
$cm = $this->get_record_snapshot('course_modules', $this->context->instanceid);
$cm = $this->get_record_snapshot('course_modules', $this->contextinstanceid);
$workshop = new \workshop($workshop, $cm, $course);
return (object)array('workshop' => $workshop, 'user' => $USER);
}