From 4beaf73ecf0f6503832c04a9fc27634830d62231 Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Thu, 1 Aug 2024 17:15:57 +0100 Subject: [PATCH] Fix single section page navigation. --- Changes.md | 1 + classes/output/courseformat/content/sectionnavigation.php | 6 +++--- classes/output/courseformat/content/sectionselector.php | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Changes.md b/Changes.md index a2d5982..e033654 100644 --- a/Changes.md +++ b/Changes.md @@ -4,6 +4,7 @@ Version 404.1.1 - Development started ---------------------------- 1. Show section zero if the section has meaningful content. +2. Fix single section page navigation. Version 404.1.0 - 01/07/2024 ---------------------------- diff --git a/classes/output/courseformat/content/sectionnavigation.php b/classes/output/courseformat/content/sectionnavigation.php index 2ef537d..2e0ac0b 100644 --- a/classes/output/courseformat/content/sectionnavigation.php +++ b/classes/output/courseformat/content/sectionnavigation.php @@ -73,21 +73,21 @@ public function export_for_template(\renderer_base $output): \stdClass { $data->previoushidden = true; } $data->previousname = get_section_name($course, $sections[$back]); - $data->previousurl = course_get_url($course, $back, ['navigation' => true]); + $data->previousurl = $format->get_view_url($back, ['navigation' => false]); $data->hasprevious = true; } $back--; } $forward = $this->sectionno + 1; - $numsections = course_get_format($course)->get_last_section_number(); + $numsections = $format->get_last_section_number(); while ($forward <= $numsections && empty($data->nexturl)) { if ($canviewhidden || $sections[$forward]->uservisible) { if (!$sections[$forward]->visible) { $data->nexthidden = true; } $data->nextname = get_section_name($course, $sections[$forward]); - $data->nexturl = course_get_url($course, $forward, ['navigation' => true]); + $data->nexturl = $format->get_view_url($forward, ['navigation' => false]); $data->hasnext = true; } $forward++; diff --git a/classes/output/courseformat/content/sectionselector.php b/classes/output/courseformat/content/sectionselector.php index 1e8608b..7e462a8 100644 --- a/classes/output/courseformat/content/sectionselector.php +++ b/classes/output/courseformat/content/sectionselector.php @@ -64,7 +64,7 @@ public function export_for_template(\renderer_base $output): \stdClass { $numsections = $format->get_last_section_number(); while ($section <= $numsections) { $thissection = $modinfo->get_section_info($section); - $url = course_get_url($course, $section, ['navigation' => true]); + $url = $format->get_view_url($section, ['navigation' => false]); if ($thissection->uservisible && $url && $section != $data->currentsection) { $sectionmenu[$url->out(false)] = get_section_name($course, $section); } @@ -76,6 +76,7 @@ public function export_for_template(\renderer_base $output): \stdClass { $select->formid = 'sectionmenu'; $data->selector = $output->render($select); + return $data; } }