mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
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:
parent
400c0fd229
commit
00c832d7a1
5 changed files with 343 additions and 39 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -665,7 +665,7 @@ class core_course_renderer extends plugin_renderer_base {
|
|||
// off the JS.
|
||||
$extraclass = '';
|
||||
if (!empty($CFG->enableavailability) &&
|
||||
condition_info::completion_value_used_as_condition($course, $mod)) {
|
||||
core_availability\info::completion_value_used($course, $mod->id)) {
|
||||
$extraclass = ' preventjs';
|
||||
}
|
||||
$output .= html_writer::start_tag('form', array('method' => 'post',
|
||||
|
@ -711,11 +711,8 @@ class core_course_renderer extends plugin_renderer_base {
|
|||
global $CFG;
|
||||
$conditionalhidden = false;
|
||||
if (!empty($CFG->enableavailability)) {
|
||||
$conditionalhidden = $mod->availablefrom > time() ||
|
||||
($mod->availableuntil && $mod->availableuntil < time()) ||
|
||||
count($mod->conditionsgrade) > 0 ||
|
||||
count($mod->conditionscompletion) > 0 ||
|
||||
count($mod->conditionsfield);
|
||||
$info = new \core_availability\info_module($mod);
|
||||
$conditionalhidden = !$info->is_available_for_all();
|
||||
}
|
||||
return $conditionalhidden;
|
||||
}
|
||||
|
@ -736,8 +733,7 @@ class core_course_renderer extends plugin_renderer_base {
|
|||
public function course_section_cm_name(cm_info $mod, $displayoptions = array()) {
|
||||
global $CFG;
|
||||
$output = '';
|
||||
if (!$mod->uservisible &&
|
||||
(empty($mod->showavailability) || empty($mod->availableinfo))) {
|
||||
if (!$mod->uservisible && empty($mod->availableinfo)) {
|
||||
// nothing to be displayed to the user
|
||||
return $output;
|
||||
}
|
||||
|
@ -825,8 +821,7 @@ class core_course_renderer extends plugin_renderer_base {
|
|||
*/
|
||||
public function course_section_cm_text(cm_info $mod, $displayoptions = array()) {
|
||||
$output = '';
|
||||
if (!$mod->uservisible &&
|
||||
(empty($mod->showavailability) || empty($mod->availableinfo))) {
|
||||
if (!$mod->uservisible && empty($mod->availableinfo)) {
|
||||
// nothing to be displayed to the user
|
||||
return $output;
|
||||
}
|
||||
|
@ -876,8 +871,10 @@ class core_course_renderer extends plugin_renderer_base {
|
|||
if (!$mod->uservisible) {
|
||||
// this is a student who is not allowed to see the module but might be allowed
|
||||
// to see availability info (i.e. "Available from ...")
|
||||
if (!empty($mod->showavailability) && !empty($mod->availableinfo)) {
|
||||
$output = html_writer::tag('div', $mod->availableinfo, array('class' => 'availabilityinfo'));
|
||||
if (!empty($mod->availableinfo)) {
|
||||
$formattedinfo = \core_availability\info::format_info(
|
||||
$mod->availableinfo, $mod->get_course());
|
||||
$output = html_writer::tag('div', $formattedinfo, array('class' => 'availabilityinfo'));
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
@ -892,13 +889,12 @@ class core_course_renderer extends plugin_renderer_base {
|
|||
if (!$mod->visible) {
|
||||
$hidinfoclass = 'hide';
|
||||
}
|
||||
$ci = new condition_info($mod);
|
||||
$ci = new \core_availability\info_module($mod);
|
||||
$fullinfo = $ci->get_full_information();
|
||||
if($fullinfo) {
|
||||
return '<div class="availabilityinfo '.$hidinfoclass.'">'.get_string($mod->showavailability
|
||||
? 'userrestriction_visible'
|
||||
: 'userrestriction_hidden','condition',
|
||||
$fullinfo).'</div>';
|
||||
if ($fullinfo) {
|
||||
$formattedinfo = \core_availability\info::format_info(
|
||||
$fullinfo, $mod->get_course());
|
||||
return html_writer::div($formattedinfo, 'availabilityinfo ' . $hidinfoclass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -954,15 +950,10 @@ class core_course_renderer extends plugin_renderer_base {
|
|||
// if:
|
||||
// 1) The activity is not visible to users
|
||||
// and
|
||||
// 2a) The 'showavailability' option is not set (if that is set,
|
||||
// we need to display the activity so we can show
|
||||
// availability info)
|
||||
// or
|
||||
// 2b) The 'availableinfo' is empty, i.e. the activity was
|
||||
// 2) The 'availableinfo' is empty, i.e. the activity was
|
||||
// hidden in a way that leaves no info, such as using the
|
||||
// eye icon.
|
||||
if (!$mod->uservisible &&
|
||||
(empty($mod->showavailability) || empty($mod->availableinfo))) {
|
||||
if (!$mod->uservisible && empty($mod->availableinfo)) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue