From 34c452afb42f66b41e88e7ff4e5e0dd52be0892d Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Tue, 14 Mar 2023 15:39:42 +0000 Subject: [PATCH] MDL-72124 question: Fix system-level URLs in question events --- lib/classes/event/question_base.php | 6 +++--- lib/classes/event/question_category_base.php | 4 ++-- lib/classes/event/question_moved.php | 6 +++--- lib/classes/event/questions_exported.php | 6 +++--- lib/classes/event/questions_imported.php | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/classes/event/question_base.php b/lib/classes/event/question_base.php index efa5c8d58c5..0db7da5d7a0 100644 --- a/lib/classes/event/question_base.php +++ b/lib/classes/event/question_base.php @@ -50,8 +50,8 @@ abstract class question_base extends base { * @return \moodle_url */ public function get_url() { + $cat = $this->other['categoryid'] . ',' . $this->contextid; if ($this->courseid) { - $cat = $this->other['categoryid'] . ',' . $this->contextid; if ($this->contextlevel == CONTEXT_MODULE) { return new \moodle_url('/question/edit.php', ['cmid' => $this->contextinstanceid, 'cat' => $cat, 'lastchanged' => $this->objectid]); @@ -60,8 +60,8 @@ abstract class question_base extends base { ['courseid' => $this->courseid, 'cat' => $cat, 'lastchanged' => $this->objectid]); } // Lets try viewing from the frontpage for contexts above course. - return new \moodle_url('/question/bank/managecategories/category.php', - ['courseid' => SITEID, 'edit' => $this->other['categoryid'], 'lastchanged' => $this->objectid]); + return new \moodle_url('/question/edit.php', + ['courseid' => SITEID, 'edit' => $cat, 'lastchanged' => $this->objectid]); } /** diff --git a/lib/classes/event/question_category_base.php b/lib/classes/event/question_category_base.php index e022a351d1b..c3b082c1a10 100644 --- a/lib/classes/event/question_category_base.php +++ b/lib/classes/event/question_category_base.php @@ -50,15 +50,15 @@ abstract class question_category_base extends base { * @return \moodle_url */ public function get_url() { + $cat = $this->objectid . ',' . $this->contextid; if ($this->courseid) { - $cat = $this->objectid . ',' . $this->contextid; if ($this->contextlevel == CONTEXT_MODULE) { return new \moodle_url('/question/edit.php', ['cmid' => $this->contextinstanceid, 'cat' => $cat]); } return new \moodle_url('/question/edit.php', ['courseid' => $this->courseid, 'cat' => $cat]); } // Lets try viewing from the frontpage for contexts above course. - return new \moodle_url('/question/bank/managecategories/category.php', ['courseid' => SITEID, 'edit' => $this->objectid]); + return new \moodle_url('/question/edit.php', ['courseid' => SITEID, 'cat' => $cat, 'edit' => $this->objectid]); } /** diff --git a/lib/classes/event/question_moved.php b/lib/classes/event/question_moved.php index 3f5df468767..6956d930f61 100644 --- a/lib/classes/event/question_moved.php +++ b/lib/classes/event/question_moved.php @@ -77,8 +77,8 @@ class question_moved extends question_base { * @return \moodle_url */ public function get_url() { + $cat = $this->other['newcategoryid'] . ',' . $this->contextid; if ($this->courseid) { - $cat = $this->other['newcategoryid'] . ',' . $this->contextid; if ($this->contextlevel == CONTEXT_MODULE) { return new \moodle_url('/question/edit.php', ['cmid' => $this->contextinstanceid, 'cat' => $cat, 'lastchanged' => $this->objectid]); @@ -87,8 +87,8 @@ class question_moved extends question_base { ['courseid' => $this->courseid, 'cat' => $cat, 'lastchanged' => $this->objectid]); } // Lets try viewing from the frontpage for contexts above course. - return new \moodle_url('/question/bank/managecategories/category.php', - ['courseid' => SITEID, 'edit' => $this->other['newcategoryid'], 'lastchanged' => $this->objectid]); + return new \moodle_url('/question/edit.php', + ['courseid' => SITEID, 'cat' => $cat, 'lastchanged' => $this->objectid]); } /** diff --git a/lib/classes/event/questions_exported.php b/lib/classes/event/questions_exported.php index 4ffe5f8bddf..46c608be5e4 100644 --- a/lib/classes/event/questions_exported.php +++ b/lib/classes/event/questions_exported.php @@ -76,15 +76,15 @@ class questions_exported extends question_base { * @return \moodle_url */ public function get_url() { + $cat = $this->other['categoryid'] . ',' . $this->contextid; if ($this->courseid) { - $cat = $this->other['categoryid'] . ',' . $this->contextid; if ($this->contextlevel == CONTEXT_MODULE) { return new \moodle_url('/question/edit.php', ['cmid' => $this->contextinstanceid, 'cat' => $cat]); } return new \moodle_url('/question/edit.php', ['courseid' => $this->courseid, 'cat' => $cat]); } - return new \moodle_url('/question/bank/managecategories/category.php', - ['courseid' => SITEID, 'edit' => $this->other['categoryid']]); + return new \moodle_url('/question/edit.php', + ['courseid' => SITEID, 'cat' => $cat]); } /** diff --git a/lib/classes/event/questions_imported.php b/lib/classes/event/questions_imported.php index 26861403135..ef0e0bd0c93 100644 --- a/lib/classes/event/questions_imported.php +++ b/lib/classes/event/questions_imported.php @@ -76,15 +76,15 @@ class questions_imported extends question_base { * @return \moodle_url */ public function get_url() { + $cat = $this->other['categoryid'] . ',' . $this->contextid; if ($this->courseid) { - $cat = $this->other['categoryid'] . ',' . $this->contextid; if ($this->contextlevel == CONTEXT_MODULE) { return new \moodle_url('/question/edit.php', ['cmid' => $this->contextinstanceid, 'cat' => $cat]); } return new \moodle_url('/question/edit.php', ['courseid' => $this->courseid, 'cat' => $cat]); } - return new \moodle_url('/question/bank/managecategories/category.php', - ['courseid' => SITEID, 'edit' => $this->other['categoryid']]); + return new \moodle_url('/question/edit.php', + ['courseid' => SITEID, 'cat' => $cat]); } /**