Merge branch 'MDL-59042-master' of git://github.com/snake/moodle

This commit is contained in:
Jun Pataleta 2017-06-12 13:29:03 +08:00
commit 8363ec8637
3 changed files with 31 additions and 1 deletions

View File

@ -2864,6 +2864,28 @@ function xmldb_main_upgrade($oldversion) {
// Automatically generated Moodle v3.3.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2017060800.01) {
// Data fix any assign group override event priorities which may have been accidentally nulled due to a bug on the group
// overrides edit form.
// First, find all assign group override events having null priority (and join their corresponding assign_overrides entry).
$sql = "SELECT e.id AS id, o.sortorder AS priority
FROM {assign_overrides} o
JOIN {event} e ON (e.modulename = 'assign' AND o.assignid = e.instance AND e.groupid = o.groupid)
WHERE o.groupid IS NOT NULL AND e.priority IS NULL
ORDER BY o.id";
$affectedrs = $DB->get_recordset_sql($sql);
// Now update the event's priority based on the assign_overrides sortorder we found. This uses similar logic to
// assign_refresh_events(), except we've restricted the set of assignments and overrides we're dealing with here.
foreach ($affectedrs as $record) {
$DB->set_field('event', 'priority', $record->priority, ['id' => $record->id]);
}
$affectedrs->close();
// Main savepoint reached.
upgrade_main_savepoint(true, 2017060800.01);
}
return true;
}

View File

@ -55,6 +55,9 @@ class assign_override_form extends moodleform {
/** @var int userid, if provided. */
protected $userid;
/** @var int sortorder, if provided. */
protected $sortorder;
/**
* Constructor.
* @param moodle_url $submiturl the form action URL.
@ -72,6 +75,7 @@ class assign_override_form extends moodleform {
$this->groupmode = $groupmode;
$this->groupid = empty($override->groupid) ? 0 : $override->groupid;
$this->userid = empty($override->userid) ? 0 : $override->userid;
$this->sortorder = empty($override->sortorder) ? null : $override->sortorder;
parent::__construct($submiturl, null, 'post');
@ -97,6 +101,10 @@ class assign_override_form extends moodleform {
$mform->addElement('select', 'groupid',
get_string('overridegroup', 'assign'), $groupchoices);
$mform->freeze('groupid');
// Add a sortorder element.
$mform->addElement('hidden', 'sortorder', $this->sortorder);
$mform->setType('sortorder', PARAM_INT);
$mform->freeze('sortorder');
} else {
// Prepare the list of groups.
$groups = groups_get_all_groups($cm->course);

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2017060800.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2017060800.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.