MDL-86565 courseformat: don't link to sections user cannot see.

This commit is contained in:
Paul Holden
2025-11-18 10:32:01 +00:00
parent e6593a6e73
commit 4e85aecde8
2 changed files with 5 additions and 2 deletions
@@ -84,7 +84,7 @@ class header implements named_templatable, renderable {
} else {
if (is_null($format->get_sectionid()) || $format->get_sectionid() != $section->id) {
// All sections are displayed.
if (!$data->editing) {
if (!$data->editing && $section->uservisible) {
$data->title = $output->section_title($section, $course);
} else {
$data->title = $output->section_title_without_link($section, $course);
@@ -83,7 +83,6 @@ class section implements renderable {
'rawtitle' => $section->name,
'cmlist' => [],
'visible' => !empty($section->visible),
'sectionurl' => course_get_url($course, $section->section, ['navigation' => true])?->out(false),
'current' => $format->is_section_current($section),
'indexcollapsed' => $indexcollapsed,
'contentcollapsed' => $contentcollapsed,
@@ -94,6 +93,10 @@ class section implements renderable {
'parentsectionid' => $section->get_component_instance()?->get_parent_section()?->id,
];
if ($section->uservisible) {
$data->sectionurl = course_get_url($course, $section->section, ['navigation' => true])?->out(false);
}
if (empty($modinfo->sections[$section->section])) {
return $data;
}