Skip to content

Commit

Permalink
Fix display of section zero on a single section page.
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed May 23, 2024
1 parent dd85acb commit 1ad8934
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------------------------
Expand Down
17 changes: 9 additions & 8 deletions classes/output/courseformat/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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)) {
Expand All @@ -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();
Expand Down

0 comments on commit 1ad8934

Please sign in to comment.