From bb78b2fd22574259c377e3fcfb12bebc5324f529 Mon Sep 17 00:00:00 2001 From: sam marshall Date: Mon, 15 May 2017 17:45:45 +0100 Subject: [PATCH] MDL-58947 Search: Label URLs not correctly calculated --- mod/label/classes/search/activity.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mod/label/classes/search/activity.php b/mod/label/classes/search/activity.php index 95821b52781..2ddd70684cd 100644 --- a/mod/label/classes/search/activity.php +++ b/mod/label/classes/search/activity.php @@ -45,9 +45,14 @@ class activity extends \core_search\base_activity { * @return \moodle_url */ public function get_doc_url(\core_search\document $doc) { + // Get correct URL to section that contains label, from course format. $cminfo = $this->get_cm($this->get_module_name(), strval($doc->get('itemid')), $doc->get('courseid')); - return new \moodle_url('/course/view.php', array('id' => $doc->get('courseid')), 'module-' . $cminfo->id); + $format = course_get_format($cminfo->get_course()); + $url = $format->get_view_url($cminfo->sectionnum); + // Add the ID of the label to the section URL. + $url->set_anchor('module-' . $cminfo->id); + return $url; } /**