From e4ce0f0ce22720000e8858927bfde4170ee9bb8a Mon Sep 17 00:00:00 2001 From: David Herney Date: Fri, 12 Jul 2024 19:51:22 -0500 Subject: [PATCH] Fixed: conflict in section number --- classes/output/courseformat/content.php | 7 ++++--- classes/output/edition.php | 2 +- lib.php | 10 +--------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/classes/output/courseformat/content.php b/classes/output/courseformat/content.php index c2a899e..004a1e2 100644 --- a/classes/output/courseformat/content.php +++ b/classes/output/courseformat/content.php @@ -62,7 +62,7 @@ public function get_template_name(\renderer_base $renderer): string { /** * Export this data so it can be used as the context for a mustache template (core/inplace_editable). * - * @param renderer_base $output typically, the renderer that's calling this function + * @param \renderer_base $output typically, the renderer that's calling this function * @return stdClass data context for a mustache template */ public function export_for_template(\renderer_base $output) { @@ -70,7 +70,7 @@ public function export_for_template(\renderer_base $output) { $format = $this->format; $course = $format->get_course(); - $currentsection = \format_menutopic::$displaysection; + $currentsection = $format->get_section_number(); // If the section 0 is above the menu remove from the list. $sections = $this->export_sections($output); @@ -187,7 +187,8 @@ protected function export_sections(\renderer_base $output): array { */ private function get_sections_to_display(course_modinfo $modinfo): array { - $sections = [$modinfo->get_section_info(\format_menutopic::$displaysection)]; + $format = $this->format; + $sections = [$modinfo->get_section_info($format->get_section_number())]; return $sections; } diff --git a/classes/output/edition.php b/classes/output/edition.php index c913c14..300bf1f 100644 --- a/classes/output/edition.php +++ b/classes/output/edition.php @@ -75,7 +75,7 @@ public function export_for_template(renderer_base $output) { $msgs = []; - $displaysection = \format_menutopic::$displaysection; + $displaysection = $format->get_section_number(); if (!($formatdata = $DB->get_record('format_menutopic', ['course' => $this->course->id]))) { $formatdata = new \stdClass(); diff --git a/lib.php b/lib.php index 2685790..4e3b1f7 100755 --- a/lib.php +++ b/lib.php @@ -66,18 +66,12 @@ class format_menutopic extends core_courseformat\base { /** @var \stdClass Local format data */ public static $formatdata; - /** @var \stdClass Reference to current course */ - private static $localcourse; - /** @var array Messages to display */ public static $formatmsgs = []; /** @var bool Edit menu mode */ public static $editmenumode = false; - /** @var bool Current section to display */ - public static $displaysection = 0; - /** @var array Modules used in template */ public $tplcmsused = []; @@ -117,7 +111,6 @@ protected function __construct($format, $courseid) { $displaysection = $displaysection === 0 && $firstsection == 1 ? 1 : $displaysection; $this->set_section_number($displaysection); - self::$displaysection = $displaysection; $USER->display[$courseid] = $displaysection; } } @@ -285,7 +278,7 @@ public function extend_course_navigation($navigation, navigation_node $node) { global $PAGE; // If section is specified in course/view.php, make sure it is expanded in navigation. if ($navigation->includesectionnum === false) { - $selectedsection = self::$displaysection; + $selectedsection = $this->get_section_number(); if ($selectedsection !== null && (!defined('AJAX_SCRIPT') || AJAX_SCRIPT == '0') && $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) { $navigation->includesectionnum = $selectedsection; @@ -799,7 +792,6 @@ public function load_formatdata() { $section++; } - self::$localcourse = $course; self::$formatdata[$course->id] = $formatdata; return $formatdata;