diff --git a/Changes.md b/Changes.md index e2e0e665..03acfaea 100644 --- a/Changes.md +++ b/Changes.md @@ -5,6 +5,7 @@ Version 404.0.2 - TBR ---------------------------- 1. Fix updating of course when adding or removing sections. Note: Known issue of the section not looking as it should. 2. Section navigation visibility improvements. +3. Fix display of section zero on a single section page. Version 404.0.1 - 22/04/2024 ---------------------------- diff --git a/classes/output/courseformat/content.php b/classes/output/courseformat/content.php index 586f0957..9a5594b2 100644 --- a/classes/output/courseformat/content.php +++ b/classes/output/courseformat/content.php @@ -84,7 +84,7 @@ public function export_for_template(\renderer_base $output) { 'sectionreturn' => null, ]; - $singlesection = $this->format->get_sectionnum(); + $singlesectionid = $this->format->get_sectionid(); $sections = $this->export_sections($output); $initialsection = ''; $course = $format->get_course(); @@ -93,13 +93,13 @@ public function export_for_template(\renderer_base $output) { if (!empty($sections)) { // Is first entry section 0? if ($sections[0]->num === 0) { - // Most formats uses section 0 as a separate section so we remove from the list. - $initialsection = array_shift($sections); - if (!$singlesection) { + if (!$singlesectionid) { + // Most formats uses section 0 as a separate section so we remove from the list. + $initialsection = array_shift($sections); $data->initialsection = $initialsection; } } - if (($editing) || ($singlesection)) { // This triggers the display of the standard list of section(s). + if (($editing) || ($singlesectionid)) { // This triggers the display of the standard list of section(s). $data->sections = $sections; } if (!empty($course->marker)) { @@ -113,15 +113,16 @@ public function export_for_template(\renderer_base $output) { } // The single section format has extra navigation. - if ($singlesection) { - $sectionnavigation = new $this->sectionnavigationclass($format, $singlesection); + if ($singlesectionid) { + $singlesectionno = $this->format->get_sectionnum(); + $sectionnavigation = new $this->sectionnavigationclass($format, $singlesectionno); $data->sectionnavigation = $sectionnavigation->export_for_template($output); $sectionselector = new $this->sectionselectorclass($format, $sectionnavigation); $data->sectionselector = $sectionselector->export_for_template($output); $data->hasnavigation = true; $data->singlesection = array_shift($data->sections); - $data->sectionreturn = $singlesection; + $data->sectionreturn = $singlesectionno; $data->maincoursepage = new \moodle_url('/course/view.php', ['id' => $course->id]); } else { $coursesettings = $format->get_settings();