From 0ee1edd0ff9080e59fc5c8cb9787c6b8ccbccb62 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Thu, 24 Apr 2014 14:28:43 +0800 Subject: [PATCH] MDL-45080 fix question_category_created url and legacy log data --- .../event/question_category_created.php | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/classes/event/question_category_created.php b/lib/classes/event/question_category_created.php index a620065544c48..1aba878322b21 100644 --- a/lib/classes/event/question_category_created.php +++ b/lib/classes/event/question_category_created.php @@ -61,20 +61,31 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - if ($this->contextlevel == CONTEXT_MODULE) { - return new \moodle_url('/question/category.php', array('cmid' => $this->contextinstanceid)); - } else { - return new \moodle_url('/question/category.php', array('courseid' => $this->courseid)); + if ($this->courseid) { + $cat = $this->objectid . ',' . $this->contextid; + if ($this->contextlevel == CONTEXT_MODULE) { + return new \moodle_url('/question/edit.php', array('cmid' => $this->contextinstanceid, 'cat' => $cat)); + } + return new \moodle_url('/question/edit.php', array('courseid' => $this->courseid, 'cat' => $cat)); } + + // Bad luck, there does not seem to be any simple intelligent way + // to go to specific question category in context above course, + // let's try to edit it from frontpage which may surprisingly work. + return new \moodle_url('/question/category.php', array('courseid' => SITEID, 'edit' => $this->objectid)); } /** * Return the legacy event log data. * - * @return array + * @return array|null */ protected function get_legacy_logdata() { - return array($this->courseid, 'quiz', 'addcategory', 'view.php?id=' . $this->contextinstanceid, - $this->objectid, $this->contextinstanceid); + if ($this->contextlevel == CONTEXT_MODULE) { + return array($this->courseid, 'quiz', 'addcategory', 'view.php?id=' . $this->contextinstanceid, + $this->objectid, $this->contextinstanceid); + } + // This is not related to individual quiz at all. + return null; } }