MDL-44070 Conditional availability enhancements (8): display

Includes theme and renderer changes required for the new feature.
There are two parts: style required for the display as part of the
course page (when showing the list of conditions for an activity),
and style required for the settings form.

This change supports both the bootstrapbase theme (which was the
main theme used during development) and the old base theme.
This commit is contained in:
sam marshall 2014-03-26 13:24:58 +00:00
parent 400c0fd229
commit 00c832d7a1
5 changed files with 343 additions and 39 deletions

View file

@ -428,20 +428,18 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
global $CFG;
$o = '';
if (!$section->uservisible) {
$o .= html_writer::start_tag('div', array('class' => 'availabilityinfo'));
// Note: We only get to this function if availableinfo is non-empty,
// so there is definitely something to print.
$o .= $section->availableinfo;
$o .= html_writer::end_tag('div');
$formattedinfo = \core_availability\info::format_info(
$section->availableinfo, $section->course);
$o .= html_writer::div($formattedinfo, 'availabilityinfo');
} else if ($canviewhidden && !empty($CFG->enableavailability) && $section->visible) {
$ci = new condition_info_section($section);
$ci = new \core_availability\info_section($section);
$fullinfo = $ci->get_full_information();
if ($fullinfo) {
$o .= html_writer::start_tag('div', array('class' => 'availabilityinfo'));
$o .= get_string(
($section->showavailability ? 'userrestriction_visible' : 'userrestriction_hidden'),
'condition', $fullinfo);
$o .= html_writer::end_tag('div');
$formattedinfo = \core_availability\info::format_info(
$fullinfo, $section->course);
$o .= html_writer::div($formattedinfo, 'availabilityinfo');
}
}
return $o;
@ -737,13 +735,14 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
continue;
}
// Show the section if the user is permitted to access it, OR if it's not available
// but showavailability is turned on (and there is some available info text).
// but there is some available info text which explains the reason & should display.
$showsection = $thissection->uservisible ||
($thissection->visible && !$thissection->available && $thissection->showavailability
&& !empty($thissection->availableinfo));
($thissection->visible && !$thissection->available &&
!empty($thissection->availableinfo));
if (!$showsection) {
// Hidden section message is overridden by 'unavailable' control
// (showavailability option).
// 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);
}