Skip to content

Commit 8b94c24

Browse files
issue#240 user with 'viewhiddensections' permission
1 parent 36d6b02 commit 8b94c24

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

classes/output/courseformat/content.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ public function export_for_template(renderer_base $output) {
130130
$data->singlesection = array_shift($data->sections);
131131
$data->sectionreturn = $singlesectionno;
132132
$data->maincoursepage = new url('/course/view.php', ['id' => $course->id]);
133+
134+
// Override the visibility if the user can see the section.
135+
// Reference: lib/modinfolib.php with regards to 'uservisible'.
136+
$section = $format->get_section($singlesectionno);
137+
if (!$section->visible && $section->uservisible) {
138+
$data->singlesection->visibility->notavailable = false;
139+
$data->singlesection->visibility->hiddenfromstudents = true;
140+
}
141+
133142
} else {
134143
$toolbox = toolbox::get_instance();
135144
$coursesectionimages = $DB->get_records('format_grid_image', ['courseid' => $course->id]);
@@ -261,6 +270,14 @@ public function export_for_template(renderer_base $output) {
261270
// Visibility information.
262271
$sectionimages[$section->id]->ishidden = $sectionvisiblity[$section->id]->ishidden;
263272
if ($sectionimages[$section->id]->ishidden) {
273+
274+
// Override the visibility if the user can see the section.
275+
// Reference: lib/modinfolib.php with regards to 'uservisible'.
276+
if ($section->uservisible) {
277+
$sectionvisiblity[$section->id]->visibility->notavailable = false;
278+
$sectionvisiblity[$section->id]->visibility->hiddenfromstudents = true;
279+
}
280+
264281
$sectionimages[$section->id]->visibility = $sectionvisiblity[$section->id]->visibility;
265282
$sectionimages[$section->id]->hiddenfromstudents =
266283
(!empty($sectionimages[$section->id]->visibility->hiddenfromstudents));

0 commit comments

Comments
 (0)