Skip to content

Commit

Permalink
Fix single section page navigation.
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Aug 1, 2024
1 parent 26b58b2 commit 4beaf73
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------------------------
Expand Down
6 changes: 3 additions & 3 deletions classes/output/courseformat/content/sectionnavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
3 changes: 2 additions & 1 deletion classes/output/courseformat/content/sectionselector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -76,6 +76,7 @@ public function export_for_template(\renderer_base $output): \stdClass {
$select->formid = 'sectionmenu';

$data->selector = $output->render($select);

return $data;
}
}

0 comments on commit 4beaf73

Please sign in to comment.