MDL-61015 course: consistently display hidden sections

When section is hidden but the course setting says to show hidden sections display the hidden
sections consistently with how we display the sections with access restriction.

The only difference is that we didn't previously display the summary of the hidden section
in this case, the new logic repeats this behavior
This commit is contained in:
Marina Glancy 2018-04-09 14:51:31 +08:00 committed by Luca Bösch
parent 46574904af
commit c8663da1a9

View file

@ -231,7 +231,12 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
$o .= $this->section_availability($section); $o .= $this->section_availability($section);
$o .= html_writer::start_tag('div', array('class' => 'summary')); $o .= html_writer::start_tag('div', array('class' => 'summary'));
$o .= $this->format_summary_text($section); if ($section->uservisible || $section->visible) {
// Show summary if section is available or has availability restriction information.
// Do not show summary if section is hidden but we still display it because of course setting
// "Hidden sections are shown in collapsed form".
$o .= $this->format_summary_text($section);
}
$o .= html_writer::end_tag('div'); $o .= html_writer::end_tag('div');
return $o; return $o;
@ -444,7 +449,12 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
$o .= $this->output->heading($title, 3, 'section-title'); $o .= $this->output->heading($title, 3, 'section-title');
$o.= html_writer::start_tag('div', array('class' => 'summarytext')); $o.= html_writer::start_tag('div', array('class' => 'summarytext'));
$o.= $this->format_summary_text($section); if ($section->uservisible || $section->visible) {
// Show summary if section is available or has availability restriction information.
// Do not show summary if section is hidden but we still display it because of course setting
// "Hidden sections are shown in collapsed form".
$o .= $this->format_summary_text($section);
}
$o.= html_writer::end_tag('div'); $o.= html_writer::end_tag('div');
$o.= $this->section_activity_summary($section, $course, null); $o.= $this->section_activity_summary($section, $course, null);
@ -552,6 +562,10 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
if (!$section->visible) { if (!$section->visible) {
if ($canviewhidden) { if ($canviewhidden) {
$o .= $this->courserenderer->availability_info(get_string('hiddenfromstudents'), 'ishidden'); $o .= $this->courserenderer->availability_info(get_string('hiddenfromstudents'), 'ishidden');
} else {
// We are here because of the setting "Hidden sections are shown in collapsed form".
// Student can not see the section contents but can see its name.
$o .= $this->courserenderer->availability_info(get_string('notavailable'), 'ishidden');
} }
} else if (!$section->uservisible) { } else if (!$section->uservisible) {
if ($section->availableinfo) { if ($section->availableinfo) {
@ -769,20 +783,11 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
$course = course_get_format($course)->get_course(); $course = course_get_format($course)->get_course();
// Can we view the section in question? // Can we view the section in question?
if (!($sectioninfo = $modinfo->get_section_info($displaysection))) { if (!($sectioninfo = $modinfo->get_section_info($displaysection)) || !$sectioninfo->uservisible) {
// This section doesn't exist // This section doesn't exist or is not available for the user.
print_error('unknowncoursesection', 'error', null, $course->fullname); // We actually already check this in course/view.php but just in case exit from this function as well.
return; print_error('unknowncoursesection', 'error', course_get_url($course),
} format_string($course->fullname));
if (!$sectioninfo->uservisible) {
if (!$course->hiddensections) {
echo $this->start_section_list();
echo $this->section_hidden($displaysection, $course->id);
echo $this->end_section_list();
}
// Can't view this section.
return;
} }
// Copy activity clipboard.. // Copy activity clipboard..
@ -891,18 +896,12 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
continue; continue;
} }
// Show the section if the user is permitted to access it, OR if it's not available // 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. // 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 || $showsection = $thissection->uservisible ||
($thissection->visible && !$thissection->available && ($thissection->visible && !$thissection->available && !empty($thissection->availableinfo)) ||
!empty($thissection->availableinfo)); (!$thissection->visible && !$course->hiddensections);
if (!$showsection) { if (!$showsection) {
// If the hiddensections option is set to 'show hidden sections in collapsed
// form', then display the hidden section message - UNLESS the section is
// hidden by the availability system, which is set to hide the reason.
if (!$course->hiddensections && $thissection->available) {
echo $this->section_hidden($section, $course->id);
}
continue; continue;
} }