Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions classes/output/courseformat/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ public function export_for_template(renderer_base $output) {
$data->singlesection = array_shift($data->sections);
$data->sectionreturn = $singlesectionno;
$data->maincoursepage = new url('/course/view.php', ['id' => $course->id]);

// Override the visibility if the user can see the section.
// Reference: lib/modinfolib.php with regards to 'uservisible'.
$section = $format->get_section($singlesectionno);
if (!$section->visible && $section->uservisible) {
$data->singlesection->visibility->notavailable = false;
$data->singlesection->visibility->hiddenfromstudents = true;
}

} else {
$toolbox = toolbox::get_instance();
$coursesectionimages = $DB->get_records('format_grid_image', ['courseid' => $course->id]);
Expand Down Expand Up @@ -261,6 +270,14 @@ public function export_for_template(renderer_base $output) {
// Visibility information.
$sectionimages[$section->id]->ishidden = $sectionvisiblity[$section->id]->ishidden;
if ($sectionimages[$section->id]->ishidden) {

// Override the visibility if the user can see the section.
// Reference: lib/modinfolib.php with regards to 'uservisible'.
if ($section->uservisible) {
$sectionvisiblity[$section->id]->visibility->notavailable = false;
$sectionvisiblity[$section->id]->visibility->hiddenfromstudents = true;
}

$sectionimages[$section->id]->visibility = $sectionvisiblity[$section->id]->visibility;
$sectionimages[$section->id]->hiddenfromstudents =
(!empty($sectionimages[$section->id]->visibility->hiddenfromstudents));
Expand Down