global $CFG, $PAGE;
require_once($CFG->dirroot.'/cohort/lib.php');
+ static $called = false;
+
$instance = null;
- $instances = array();
foreach ($manager->get_enrolment_instances() as $tempinstance) {
if ($tempinstance->enrol == 'manual') {
if ($instance === null) {
$instance = $tempinstance;
}
- $instances[] = array('id' => $tempinstance->id, 'name' => $this->get_instance_name($tempinstance));
}
}
if (empty($instance)) {
$context = context_course::instance($instance->courseid);
$arguments = array('contextid' => $context->id);
- $PAGE->requires->js_call_amd('enrol_manual/quickenrolment', 'init', array($arguments));
+ if (!$called) {
+ $called = true;
+ // Calling the following more than once will cause unexpected results.
+ $PAGE->requires->js_call_amd('enrol_manual/quickenrolment', 'init', array($arguments));
+ }
return $button;
}
*/
public static function script($jscode, $url=null) {
if ($jscode) {
- $attributes = array('type'=>'text/javascript');
- return self::tag('script', "\n//<![CDATA[\n$jscode\n//]]>\n", $attributes) . "\n";
+ return self::tag('script', "\n//<![CDATA[\n$jscode\n//]]>\n") . "\n";
} else if ($url) {
- $attributes = array('type'=>'text/javascript', 'src'=>$url);
- return self::tag('script', '', $attributes) . "\n";
+ return self::tag('script', '', ['src' => $url]) . "\n";
} else {
return '';
);
if ($this->yui3loader->combine) {
- return '<script type="text/javascript" src="' .
+ return '<script src="' .
$this->yui3loader->local_comboBase .
implode('&', $baserollups) .
'"></script>';
} else {
$code = '';
foreach ($baserollups as $rollup) {
- $code .= '<script type="text/javascript" src="'.$this->yui3loader->local_comboBase.$rollup.'"></script>';
+ $code .= '<script src="'.$this->yui3loader->local_comboBase.$rollup.'"></script>';
}
return $code;
}
function __construct($uniqueid) {
parent::__construct($uniqueid);
// some sensible defaults
- $this->set_attribute('cellspacing', '0');
$this->set_attribute('class', 'generaltable generalbox');
}
$this->define_columns($columns);
$this->define_headers($headers);
+ // The name column is a header.
+ $this->define_header_column('fullname');
+
// Make this table sorted by last name by default.
$this->sortable(true, 'lastname');
if ($participanttable->get_page_size() < $participanttable->totalrows) {
// Select all users, refresh page showing all users and mark them all selected.
$label = get_string('selectalluserswithcount', 'moodle', $participanttable->totalrows);
- echo html_writer::tag('input', "", array('type' => 'button', 'id' => 'checkall', 'class' => 'btn btn-secondary',
+ echo html_writer::empty_tag('input', array('type' => 'button', 'id' => 'checkall', 'class' => 'btn btn-secondary',
'value' => $label, 'data-showallink' => $showalllink));
}
echo html_writer::end_tag('div');
'data-toggle' => 'action',
'disabled' => empty($selectall)
);
- echo html_writer::tag('div', html_writer::tag('label', get_string("withselectedusers"),
- array('for' => 'formactionid', 'class' => 'col-form-label d-inline')) .
- html_writer::select($displaylist, 'formaction', '', array('' => 'choosedots'), $selectactionparams));
-
- echo '<input type="hidden" name="id" value="'.$course->id.'" />';
- echo '<noscript style="display:inline">';
- echo '<div><input type="submit" value="'.get_string('ok').'" /></div>';
- echo '</noscript>';
+ $label = html_writer::tag('label', get_string("withselectedusers"),
+ ['for' => 'formactionid', 'class' => 'col-form-label d-inline']);
+ $select = html_writer::select($displaylist, 'formaction', '', ['' => 'choosedots'], $selectactionparams);
+ echo html_writer::tag('div', $label . $select);
+
+ echo '<input type="hidden" name="id" value="' . $course->id . '" />';
echo '</div></div></div>';
echo '</form>';
$enrolrenderer = $PAGE->get_renderer('core_enrol');
echo '<div class="float-right">';
+// Need to re-generate the buttons to avoid having elements with duplicate ids on the page.
+$enrolbuttons = $manager->get_manual_enrol_buttons();
foreach ($enrolbuttons as $enrolbutton) {
echo $enrolrenderer->render($enrolbutton);
}