MDL-73683 core_courseformat: format section visible logic

Move the section visible logic to the format base class. This way format
plugins can decide whenever a section is visible or not instead of using
format custom settings from core.
This commit is contained in:
Ferran Recio
2022-02-15 13:15:09 +01:00
parent c7a2e19ee0
commit d7d154bd8b
8 changed files with 34 additions and 27 deletions
@@ -1033,13 +1033,8 @@ abstract class section_renderer extends core_course_renderer {
// Activities inside this section are 'orphaned', this section will be printed as 'stealth' below.
continue;
}
// Show the section if the user is permitted to access it, OR if it's not available
// but there is some available info text which explains the reason & should display,
// OR it is hidden but the course has a setting to display hidden sections as unavilable.
$showsection = $thissection->uservisible ||
($thissection->visible && !$thissection->available && !empty($thissection->availableinfo)) ||
(!$thissection->visible && !$course->hiddensections);
if (!$showsection) {
if (!$format->is_section_visible($thissection)) {
continue;
}