Skip to content

Commit

Permalink
Merge branch 'MDL-71682-311' of git://github.com/paulholden/moodle in…
Browse files Browse the repository at this point in the history
…to MOODLE_311_STABLE
  • Loading branch information
abgreeve committed Jun 10, 2021
2 parents 6774412 + 73ac5eb commit 02bff36
Showing 1 changed file with 20 additions and 31 deletions.
51 changes: 20 additions & 31 deletions course/renderer.php
Expand Up @@ -264,6 +264,8 @@ public function course_section_cm_edit_actions($actions, cm_info $mod = null, $d
/**
* Renders HTML for the menus to add activities and resources to the current course
*
* Renders the ajax control (the link which when clicked produces the activity chooser modal). No noscript fallback.
*
* @param stdClass $course
* @param int $section relative section number (field course_sections.section)
* @param int $sectionreturn The section to link back to
Expand All @@ -272,41 +274,28 @@ public function course_section_cm_edit_actions($actions, cm_info $mod = null, $d
* @return string
*/
function course_section_add_cm_control($course, $section, $sectionreturn = null, $displayoptions = array()) {
// The returned control HTML can be one of the following:
// - Only the non-ajax control (select menus of activities and resources) with a noscript fallback for non js clients.
// Please note that non-ajax control has been deprecated and it will be removed in the future.
$straddeither = get_string('addresourceoractivity');

// - Only the ajax control (the link which when clicked produces the activity chooser modal). No noscript fallback.
$ajaxcontrol = html_writer::start_tag('div', array('class' => 'mdl-right'));
$ajaxcontrol .= html_writer::start_tag('div', array('class' => 'section-modchooser'));

$courseajaxenabled = course_ajax_enabled($course);
$icon = $this->output->pix_icon('t/add', '');
$span = html_writer::tag('span', $straddeither, array('class' => 'section-modchooser-text'));

// Non ajax control is under deprecated, $rendernonajaxcontrol will be removed in later versions.
$rendernonajaxcontrol = !$courseajaxenabled || $course->id != $this->page->course->id;
if ($rendernonajaxcontrol) {
// The non-ajax control, which includes an entirely non-js (<noscript>) fallback too.
return $this->course_section_add_cm_control_nonajax($course, $section, $sectionreturn, $displayoptions);
} else {
// The ajax control - the 'Add an activity or resource' link.
// The module chooser link.
$straddeither = get_string('addresourceoractivity');
$ajaxcontrol = html_writer::start_tag('div', array('class' => 'mdl-right'));
$ajaxcontrol .= html_writer::start_tag('div', array('class' => 'section-modchooser'));
$icon = $this->output->pix_icon('t/add', '');
$span = html_writer::tag('span', $straddeither, array('class' => 'section-modchooser-text'));
$ajaxcontrol .= html_writer::tag('button', $icon . $span, [
'class' => 'section-modchooser-link btn btn-link',
'data-action' => 'open-chooser',
'data-sectionid' => $section,
'data-sectionreturnid' => $sectionreturn,
]
);
$ajaxcontrol .= html_writer::end_tag('div');
$ajaxcontrol .= html_writer::end_tag('div');
$ajaxcontrol .= html_writer::tag('button', $icon . $span, [
'class' => 'section-modchooser-link btn btn-link',
'data-action' => 'open-chooser',
'data-sectionid' => $section,
'data-sectionreturnid' => $sectionreturn,
]);

// Load the JS for the modal.
$this->course_activitychooser($course->id);
return $ajaxcontrol;
}
$ajaxcontrol .= html_writer::end_tag('div');
$ajaxcontrol .= html_writer::end_tag('div');

// Load the JS for the modal.
$this->course_activitychooser($course->id);

return $ajaxcontrol;
}

/**
Expand Down

0 comments on commit 02bff36

Please sign in to comment.