Skip to content

Commit

Permalink
Compromise with the Course Index that it will always refer to the mai…
Browse files Browse the repository at this point in the history
…n course page and the format implement its own single page access and navigation.

Fix single section page navigation visibility.
  • Loading branch information
gjb2048 committed Sep 9, 2024
1 parent 4beaf73 commit 17e7e3f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Version 404.1.1 - Development started
----------------------------
1. Show section zero if the section has meaningful content.
2. Fix single section page navigation.
3. Compromise with the Course Index that it will always refer to the main course page and the format
implement its own single page access and navigation.
4. Fix single section page navigation visibility.

Version 404.1.0 - 01/07/2024
----------------------------
Expand Down
4 changes: 2 additions & 2 deletions classes/output/courseformat/content/sectionnavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function export_for_template(\renderer_base $output): \stdClass {

$back = $this->sectionno - 1;
while ($back > 0 && empty($data->previousurl)) {
if ($canviewhidden || $sections[$back]->uservisible) {
if ($canviewhidden || $format->is_section_visible($back)) {
if (!$sections[$back]->visible) {
$data->previoushidden = true;
}
Expand All @@ -82,7 +82,7 @@ public function export_for_template(\renderer_base $output): \stdClass {
$forward = $this->sectionno + 1;
$numsections = $format->get_last_section_number();
while ($forward <= $numsections && empty($data->nexturl)) {
if ($canviewhidden || $sections[$forward]->uservisible) {
if ($canviewhidden || $format->is_section_visible($forward)) {
if (!$sections[$forward]->visible) {
$data->nexthidden = true;
}
Expand Down
6 changes: 4 additions & 2 deletions classes/output/courseformat/content/sectionselector.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ public function export_for_template(\renderer_base $output): \stdClass {
while ($section <= $numsections) {
$thissection = $modinfo->get_section_info($section);
$url = $format->get_view_url($section, ['navigation' => false]);
if ($thissection->uservisible && $url && $section != $data->currentsection) {
$sectionmenu[$url->out(false)] = get_section_name($course, $section);
if ($url && $section != $data->currentsection) {
if ($format->is_section_visible($thissection)) {
$sectionmenu[$url->out(false)] = get_section_name($course, $section);
}
}
$section++;
}
Expand Down
8 changes: 3 additions & 5 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,9 @@ public function get_view_url($section, $options = []) {
$sectionno = $section;
}
if ((!empty($options['navigation'])) && $sectionno !== null) {
// Display section on separate page.
$sectioninfo = $this->get_section($sectionno);
return new moodle_url('/course/section.php', ['id' => $sectioninfo->id]);
}
if ($this->uses_sections() && $sectionno !== null) {
// Unlike core, navigate to section on course page.
$url->set_anchor('section-'.$sectionno);
} else if ($this->uses_sections() && $sectionno !== null) {
if ($this->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
$url->param('section', $sectionno);
} else {
Expand Down

0 comments on commit 17e7e3f

Please sign in to comment.