Merge branch 'MDL-68148-master' of git://github.com/rezaies/moodle

This commit is contained in:
Andrew Nicols 2020-04-08 11:20:39 +08:00
commit 7aa6398830
6 changed files with 22 additions and 18 deletions

View File

@ -197,14 +197,14 @@ class enrol_manual_plugin extends enrol_plugin {
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)) {
@ -222,7 +222,11 @@ class enrol_manual_plugin extends enrol_plugin {
$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;
}

View File

@ -2089,12 +2089,10 @@ class html_writer {
*/
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 '';

View File

@ -1467,14 +1467,14 @@ class page_requirements_manager {
);
if ($this->yui3loader->combine) {
return '<script type="text/javascript" src="' .
return '<script src="' .
$this->yui3loader->local_comboBase .
implode('&amp;', $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;
}

View File

@ -1668,7 +1668,6 @@ class table_sql extends flexible_table {
function __construct($uniqueid) {
parent::__construct($uniqueid);
// some sensible defaults
$this->set_attribute('cellspacing', '0');
$this->set_attribute('class', 'generaltable generalbox');
}

View File

@ -211,6 +211,9 @@ class participants_table extends \table_sql implements dynamic_table {
$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');

View File

@ -327,7 +327,7 @@ if ($bulkoperations) {
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');
@ -387,14 +387,12 @@ if ($bulkoperations) {
'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));
$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 '<noscript style="display:inline">';
echo '<div><input type="submit" value="'.get_string('ok').'" /></div>';
echo '</noscript>';
echo '<input type="hidden" name="id" value="' . $course->id . '" />';
echo '</div></div></div>';
echo '</form>';
@ -409,6 +407,8 @@ echo '</div>'; // Userlist.
$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);
}