mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
Merge branch 'MDL-71183' of https://github.com/paulholden/moodle
This commit is contained in:
commit
d91a9d5117
@ -404,144 +404,10 @@ class core_course_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders html for completion box on course page
|
||||
*
|
||||
* If completion is disabled, returns empty string
|
||||
* If completion is automatic, returns an icon of the current completion state
|
||||
* If completion is manual, returns a form (with an icon inside) that allows user to
|
||||
* toggle completion
|
||||
*
|
||||
* @deprecated since Moodle 3.11
|
||||
* @todo MDL-71183 Final deprecation in Moodle 4.3.
|
||||
* @see \core_renderer::activity_information
|
||||
*
|
||||
* @param stdClass $course course object
|
||||
* @param completion_info $completioninfo completion info for the course, it is recommended
|
||||
* to fetch once for all modules in course/section for performance
|
||||
* @param cm_info $mod module to show completion for
|
||||
* @param array $displayoptions display options, not used in core
|
||||
* @return string
|
||||
*/
|
||||
public function course_section_cm_completion($course, &$completioninfo, cm_info $mod, $displayoptions = array()) {
|
||||
global $CFG, $DB, $USER;
|
||||
|
||||
debugging(__FUNCTION__ . ' is deprecated and is being replaced by the activity_information output component.',
|
||||
DEBUG_DEVELOPER);
|
||||
|
||||
$output = '';
|
||||
|
||||
$istrackeduser = $completioninfo->is_tracked_user($USER->id);
|
||||
$isediting = $this->page->user_is_editing();
|
||||
|
||||
if (!empty($displayoptions['hidecompletion']) || !isloggedin() || isguestuser() || !$mod->uservisible) {
|
||||
return $output;
|
||||
}
|
||||
if ($completioninfo === null) {
|
||||
$completioninfo = new completion_info($course);
|
||||
}
|
||||
$completion = $completioninfo->is_enabled($mod);
|
||||
|
||||
if ($completion == COMPLETION_TRACKING_NONE) {
|
||||
if ($isediting) {
|
||||
$output .= html_writer::span(' ', 'filler');
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
$completionicon = '';
|
||||
|
||||
if ($isediting || !$istrackeduser) {
|
||||
switch ($completion) {
|
||||
case COMPLETION_TRACKING_MANUAL :
|
||||
$completionicon = 'manual-enabled'; break;
|
||||
case COMPLETION_TRACKING_AUTOMATIC :
|
||||
$completionicon = 'auto-enabled'; break;
|
||||
}
|
||||
} else {
|
||||
$completiondata = $completioninfo->get_data($mod, true);
|
||||
if ($completion == COMPLETION_TRACKING_MANUAL) {
|
||||
switch($completiondata->completionstate) {
|
||||
case COMPLETION_INCOMPLETE:
|
||||
$completionicon = 'manual-n' . ($completiondata->overrideby ? '-override' : '');
|
||||
break;
|
||||
case COMPLETION_COMPLETE:
|
||||
$completionicon = 'manual-y' . ($completiondata->overrideby ? '-override' : '');
|
||||
break;
|
||||
}
|
||||
} else { // Automatic
|
||||
switch($completiondata->completionstate) {
|
||||
case COMPLETION_INCOMPLETE:
|
||||
$completionicon = 'auto-n' . ($completiondata->overrideby ? '-override' : '');
|
||||
break;
|
||||
case COMPLETION_COMPLETE:
|
||||
$completionicon = 'auto-y' . ($completiondata->overrideby ? '-override' : '');
|
||||
break;
|
||||
case COMPLETION_COMPLETE_PASS:
|
||||
$completionicon = 'auto-pass'; break;
|
||||
case COMPLETION_COMPLETE_FAIL:
|
||||
$completionicon = 'auto-fail'; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($completionicon) {
|
||||
$formattedname = html_entity_decode($mod->get_formatted_name(), ENT_QUOTES, 'UTF-8');
|
||||
if (!$isediting && $istrackeduser && $completiondata->overrideby) {
|
||||
$args = new stdClass();
|
||||
$args->modname = $formattedname;
|
||||
$overridebyuser = \core_user::get_user($completiondata->overrideby, '*', MUST_EXIST);
|
||||
$args->overrideuser = fullname($overridebyuser);
|
||||
$imgalt = get_string('completion-alt-' . $completionicon, 'completion', $args);
|
||||
} else {
|
||||
$imgalt = get_string('completion-alt-' . $completionicon, 'completion', $formattedname);
|
||||
}
|
||||
|
||||
if ($isediting || !$istrackeduser || !has_capability('moodle/course:togglecompletion', $mod->context)) {
|
||||
// When editing, the icon is just an image.
|
||||
$completionpixicon = new pix_icon('i/completion-'.$completionicon, $imgalt, '',
|
||||
array('title' => $imgalt, 'class' => 'iconsmall'));
|
||||
$output .= html_writer::tag('span', $this->output->render($completionpixicon),
|
||||
array('class' => 'autocompletion'));
|
||||
} else if ($completion == COMPLETION_TRACKING_MANUAL) {
|
||||
$newstate =
|
||||
$completiondata->completionstate == COMPLETION_COMPLETE
|
||||
? COMPLETION_INCOMPLETE
|
||||
: COMPLETION_COMPLETE;
|
||||
// In manual mode the icon is a toggle form...
|
||||
|
||||
// If this completion state is used by the
|
||||
// conditional activities system, we need to turn
|
||||
// off the JS.
|
||||
$extraclass = '';
|
||||
if (!empty($CFG->enableavailability) &&
|
||||
core_availability\info::completion_value_used($course, $mod->id)) {
|
||||
$extraclass = ' preventjs';
|
||||
}
|
||||
$output .= html_writer::start_tag('form', array('method' => 'post',
|
||||
'action' => new moodle_url('/course/togglecompletion.php'),
|
||||
'class' => 'togglecompletion'. $extraclass));
|
||||
$output .= html_writer::start_tag('div');
|
||||
$output .= html_writer::empty_tag('input', array(
|
||||
'type' => 'hidden', 'name' => 'id', 'value' => $mod->id));
|
||||
$output .= html_writer::empty_tag('input', array(
|
||||
'type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
|
||||
$output .= html_writer::empty_tag('input', array(
|
||||
'type' => 'hidden', 'name' => 'modulename', 'value' => $formattedname));
|
||||
$output .= html_writer::empty_tag('input', array(
|
||||
'type' => 'hidden', 'name' => 'completionstate', 'value' => $newstate));
|
||||
$output .= html_writer::tag('button',
|
||||
$this->output->pix_icon('i/completion-' . $completionicon, $imgalt),
|
||||
array('class' => 'btn btn-link', 'aria-live' => 'assertive'));
|
||||
$output .= html_writer::end_tag('div');
|
||||
$output .= html_writer::end_tag('form');
|
||||
} else {
|
||||
// In auto mode, the icon is just an image.
|
||||
$completionpixicon = new pix_icon('i/completion-'.$completionicon, $imgalt, '',
|
||||
array('title' => $imgalt));
|
||||
$output .= html_writer::tag('span', $this->output->render($completionpixicon),
|
||||
array('class' => 'autocompletion'));
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
public function course_section_cm_completion() {
|
||||
throw new coding_exception(__FUNCTION__ . ' is deprecated. Use the activity_information output component instead.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,9 @@
|
||||
This files describes API changes in /course/*,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 4.3 ===
|
||||
* The `core_course_renderer::course_section_cm_completion` method has been removed, and can no longer be used
|
||||
|
||||
=== 4.2 ===
|
||||
* course/mod.php now accepts parameter beforemod for adding course modules. It contains the course module id
|
||||
of an existing course module. The new module is inserted before this module.
|
||||
|
Loading…
x
Reference in New Issue
Block a user