From df9a6c0114c23d3a0aeb94765215e7f9ea433abb Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Mon, 24 Feb 2014 15:08:22 +0800 Subject: [PATCH] MDL-44272 events: Fix incorrect urls in course module events --- course/tests/courselib_test.php | 8 ++++---- lib/classes/event/course_module_created.php | 4 ++-- lib/classes/event/course_module_updated.php | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/course/tests/courselib_test.php b/course/tests/courselib_test.php index f2f1a693677..176ec89413d 100644 --- a/course/tests/courselib_test.php +++ b/course/tests/courselib_test.php @@ -1945,7 +1945,7 @@ class core_course_courselib_testcase extends advanced_testcase { $this->assertEquals($cm->id, $event->objectid); $this->assertEquals($USER->id, $event->userid); $this->assertEquals('course_modules', $event->objecttable); - $url = new moodle_url('/mod/assign/view.php', array('id' => $mod->id)); + $url = new moodle_url('/mod/assign/view.php', array('id' => $cm->id)); $this->assertEquals($url, $event->get_url()); // Test legacy data. @@ -1958,7 +1958,7 @@ class core_course_courselib_testcase extends advanced_testcase { $eventdata->userid = $USER->id; $this->assertEventLegacyData($eventdata, $event); - $arr = array($cm->course, "course", "add mod", "../mod/assign/view.php?id=$mod->id", "assign $cm->instance"); + $arr = array($cm->course, "course", "add mod", "../mod/assign/view.php?id=$cm->id", "assign $cm->instance"); $this->assertEventLegacyLogData($arr, $event); $this->assertEventContextNotUsed($event); @@ -2051,7 +2051,7 @@ class core_course_courselib_testcase extends advanced_testcase { $this->assertEquals($cm->id, $event->objectid); $this->assertEquals($USER->id, $event->userid); $this->assertEquals('course_modules', $event->objecttable); - $url = new moodle_url('/mod/forum/view.php', array('id' => $mod->id)); + $url = new moodle_url('/mod/forum/view.php', array('id' => $cm->id)); $this->assertEquals($url, $event->get_url()); // Test legacy data. @@ -2064,7 +2064,7 @@ class core_course_courselib_testcase extends advanced_testcase { $eventdata->userid = $USER->id; $this->assertEventLegacyData($eventdata, $event); - $arr = array($cm->course, "course", "update mod", "../mod/forum/view.php?id=$mod->id", "forum $cm->instance"); + $arr = array($cm->course, "course", "update mod", "../mod/forum/view.php?id=$cm->id", "forum $cm->instance"); $this->assertEventLegacyLogData($arr, $event); $this->assertEventContextNotUsed($event); } diff --git a/lib/classes/event/course_module_created.php b/lib/classes/event/course_module_created.php index bc4d75fcc93..e4b7b3d005f 100644 --- a/lib/classes/event/course_module_created.php +++ b/lib/classes/event/course_module_created.php @@ -77,7 +77,7 @@ class course_module_created extends base { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/' . $this->other['modulename'] . '/view.php', array('id' => $this->other['instanceid'])); + return new \moodle_url('/mod/' . $this->other['modulename'] . '/view.php', array('id' => $this->objectid)); } /** @@ -111,7 +111,7 @@ class course_module_created extends base { */ protected function get_legacy_logdata() { return array ($this->courseid, "course", "add mod", "../mod/" . $this->other['modulename'] . "/view.php?id=" . - $this->other['instanceid'], $this->other['modulename'] . " " . $this->other['instanceid']); + $this->objectid, $this->other['modulename'] . " " . $this->other['instanceid']); } /** diff --git a/lib/classes/event/course_module_updated.php b/lib/classes/event/course_module_updated.php index 9c4e1cfb988..9ac5594e291 100644 --- a/lib/classes/event/course_module_updated.php +++ b/lib/classes/event/course_module_updated.php @@ -77,7 +77,7 @@ class course_module_updated extends base { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/' . $this->other['modulename'] . '/view.php', array('id' => $this->other['instanceid'])); + return new \moodle_url('/mod/' . $this->other['modulename'] . '/view.php', array('id' => $this->objectid)); } /** @@ -111,7 +111,7 @@ class course_module_updated extends base { */ protected function get_legacy_logdata() { return array ($this->courseid, "course", "update mod", "../mod/" . $this->other['modulename'] . "/view.php?id=" . - $this->other['instanceid'], $this->other['modulename'] . " " . $this->other['instanceid']); + $this->objectid, $this->other['modulename'] . " " . $this->other['instanceid']); } /**