mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Merge branch 'MDL-71402-310' of git://github.com/paulholden/moodle into MOODLE_310_STABLE
This commit is contained in:
commit
2561b61d81
5 changed files with 70 additions and 30 deletions
|
@ -198,8 +198,11 @@ M.core_availability.form = {
|
||||||
// If the groupmode and grouping id aren't set, disable it.
|
// If the groupmode and grouping id aren't set, disable it.
|
||||||
var groupmode = Y.one('#id_groupmode');
|
var groupmode = Y.one('#id_groupmode');
|
||||||
var groupingid = Y.one('#id_groupingid');
|
var groupingid = Y.one('#id_groupingid');
|
||||||
if ((!groupmode || Number(groupmode.get('value')) === 0) &&
|
var groupavailability = Number(this.restrictByGroup.getData('groupavailability')) === 1;
|
||||||
(!groupingid || Number(groupingid.get('value')) === 0)) {
|
var groupingavailability = Number(this.restrictByGroup.getData('groupingavailability')) === 1;
|
||||||
|
|
||||||
|
if ((!groupmode || Number(groupmode.get('value')) === 0 || !groupavailability) &&
|
||||||
|
(!groupingid || Number(groupingid.get('value')) === 0 || !groupingavailability)) {
|
||||||
this.restrictByGroup.set('disabled', true);
|
this.restrictByGroup.set('disabled', true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -220,22 +223,28 @@ M.core_availability.form = {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
// Add the condition.
|
// Add the condition.
|
||||||
|
var groupmode = Y.one('#id_groupmode');
|
||||||
var groupingid = Y.one('#id_groupingid');
|
var groupingid = Y.one('#id_groupingid');
|
||||||
|
var groupavailability = Number(this.restrictByGroup.getData('groupavailability')) === 1;
|
||||||
|
var groupingavailability = Number(this.restrictByGroup.getData('groupingavailability')) === 1;
|
||||||
|
|
||||||
var newChild;
|
var newChild;
|
||||||
if (groupingid && Number(groupingid.get('value')) !== 0) {
|
if (groupingid && Number(groupingid.get('value')) !== 0 && groupingavailability) {
|
||||||
// Add a grouping restriction if one is specified.
|
// Add a grouping restriction if one is specified.
|
||||||
newChild = new M.core_availability.Item(
|
newChild = new M.core_availability.Item(
|
||||||
{type: 'grouping', id: Number(groupingid.get('value'))}, true);
|
{type: 'grouping', id: Number(groupingid.get('value'))}, true);
|
||||||
} else {
|
} else if (groupmode && groupavailability) {
|
||||||
// Otherwise just add a group restriction.
|
// Otherwise just add a group restriction.
|
||||||
newChild = new M.core_availability.Item({type: 'group'}, true);
|
newChild = new M.core_availability.Item({type: 'group'}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh HTML.
|
// Refresh HTML.
|
||||||
this.rootList.addChild(newChild);
|
if (newChild !== null) {
|
||||||
this.update();
|
this.rootList.addChild(newChild);
|
||||||
this.rootList.renumber();
|
this.update();
|
||||||
this.rootList.updateHtml();
|
this.rootList.renumber();
|
||||||
|
this.rootList.updateHtml();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -198,8 +198,11 @@ M.core_availability.form = {
|
||||||
// If the groupmode and grouping id aren't set, disable it.
|
// If the groupmode and grouping id aren't set, disable it.
|
||||||
var groupmode = Y.one('#id_groupmode');
|
var groupmode = Y.one('#id_groupmode');
|
||||||
var groupingid = Y.one('#id_groupingid');
|
var groupingid = Y.one('#id_groupingid');
|
||||||
if ((!groupmode || Number(groupmode.get('value')) === 0) &&
|
var groupavailability = Number(this.restrictByGroup.getData('groupavailability')) === 1;
|
||||||
(!groupingid || Number(groupingid.get('value')) === 0)) {
|
var groupingavailability = Number(this.restrictByGroup.getData('groupingavailability')) === 1;
|
||||||
|
|
||||||
|
if ((!groupmode || Number(groupmode.get('value')) === 0 || !groupavailability) &&
|
||||||
|
(!groupingid || Number(groupingid.get('value')) === 0 || !groupingavailability)) {
|
||||||
this.restrictByGroup.set('disabled', true);
|
this.restrictByGroup.set('disabled', true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -220,22 +223,28 @@ M.core_availability.form = {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
// Add the condition.
|
// Add the condition.
|
||||||
|
var groupmode = Y.one('#id_groupmode');
|
||||||
var groupingid = Y.one('#id_groupingid');
|
var groupingid = Y.one('#id_groupingid');
|
||||||
|
var groupavailability = Number(this.restrictByGroup.getData('groupavailability')) === 1;
|
||||||
|
var groupingavailability = Number(this.restrictByGroup.getData('groupingavailability')) === 1;
|
||||||
|
|
||||||
var newChild;
|
var newChild;
|
||||||
if (groupingid && Number(groupingid.get('value')) !== 0) {
|
if (groupingid && Number(groupingid.get('value')) !== 0 && groupingavailability) {
|
||||||
// Add a grouping restriction if one is specified.
|
// Add a grouping restriction if one is specified.
|
||||||
newChild = new M.core_availability.Item(
|
newChild = new M.core_availability.Item(
|
||||||
{type: 'grouping', id: Number(groupingid.get('value'))}, true);
|
{type: 'grouping', id: Number(groupingid.get('value'))}, true);
|
||||||
} else {
|
} else if (groupmode && groupavailability) {
|
||||||
// Otherwise just add a group restriction.
|
// Otherwise just add a group restriction.
|
||||||
newChild = new M.core_availability.Item({type: 'group'}, true);
|
newChild = new M.core_availability.Item({type: 'group'}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh HTML.
|
// Refresh HTML.
|
||||||
this.rootList.addChild(newChild);
|
if (newChild !== null) {
|
||||||
this.update();
|
this.rootList.addChild(newChild);
|
||||||
this.rootList.renumber();
|
this.update();
|
||||||
this.rootList.updateHtml();
|
this.rootList.renumber();
|
||||||
|
this.rootList.updateHtml();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
25
availability/yui/src/form/js/form.js
vendored
25
availability/yui/src/form/js/form.js
vendored
|
@ -196,8 +196,11 @@ M.core_availability.form = {
|
||||||
// If the groupmode and grouping id aren't set, disable it.
|
// If the groupmode and grouping id aren't set, disable it.
|
||||||
var groupmode = Y.one('#id_groupmode');
|
var groupmode = Y.one('#id_groupmode');
|
||||||
var groupingid = Y.one('#id_groupingid');
|
var groupingid = Y.one('#id_groupingid');
|
||||||
if ((!groupmode || Number(groupmode.get('value')) === 0) &&
|
var groupavailability = Number(this.restrictByGroup.getData('groupavailability')) === 1;
|
||||||
(!groupingid || Number(groupingid.get('value')) === 0)) {
|
var groupingavailability = Number(this.restrictByGroup.getData('groupingavailability')) === 1;
|
||||||
|
|
||||||
|
if ((!groupmode || Number(groupmode.get('value')) === 0 || !groupavailability) &&
|
||||||
|
(!groupingid || Number(groupingid.get('value')) === 0 || !groupingavailability)) {
|
||||||
this.restrictByGroup.set('disabled', true);
|
this.restrictByGroup.set('disabled', true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -218,22 +221,28 @@ M.core_availability.form = {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
// Add the condition.
|
// Add the condition.
|
||||||
|
var groupmode = Y.one('#id_groupmode');
|
||||||
var groupingid = Y.one('#id_groupingid');
|
var groupingid = Y.one('#id_groupingid');
|
||||||
|
var groupavailability = Number(this.restrictByGroup.getData('groupavailability')) === 1;
|
||||||
|
var groupingavailability = Number(this.restrictByGroup.getData('groupingavailability')) === 1;
|
||||||
|
|
||||||
var newChild;
|
var newChild;
|
||||||
if (groupingid && Number(groupingid.get('value')) !== 0) {
|
if (groupingid && Number(groupingid.get('value')) !== 0 && groupingavailability) {
|
||||||
// Add a grouping restriction if one is specified.
|
// Add a grouping restriction if one is specified.
|
||||||
newChild = new M.core_availability.Item(
|
newChild = new M.core_availability.Item(
|
||||||
{type: 'grouping', id: Number(groupingid.get('value'))}, true);
|
{type: 'grouping', id: Number(groupingid.get('value'))}, true);
|
||||||
} else {
|
} else if (groupmode && groupavailability) {
|
||||||
// Otherwise just add a group restriction.
|
// Otherwise just add a group restriction.
|
||||||
newChild = new M.core_availability.Item({type: 'group'}, true);
|
newChild = new M.core_availability.Item({type: 'group'}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh HTML.
|
// Refresh HTML.
|
||||||
this.rootList.addChild(newChild);
|
if (newChild !== null) {
|
||||||
this.update();
|
this.rootList.addChild(newChild);
|
||||||
this.rootList.renumber();
|
this.update();
|
||||||
this.rootList.updateHtml();
|
this.rootList.renumber();
|
||||||
|
this.rootList.updateHtml();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -621,10 +621,23 @@ abstract class moodleform_mod extends moodleform {
|
||||||
if (!empty($CFG->enableavailability)) {
|
if (!empty($CFG->enableavailability)) {
|
||||||
// Add special button to end of previous section if groups/groupings
|
// Add special button to end of previous section if groups/groupings
|
||||||
// are enabled.
|
// are enabled.
|
||||||
if ($this->_features->groups || $this->_features->groupings) {
|
|
||||||
|
$availabilityplugins = \core\plugininfo\availability::get_enabled_plugins();
|
||||||
|
$groupavailability = $this->_features->groups && array_key_exists('group', $availabilityplugins);
|
||||||
|
$groupingavailability = $this->_features->groupings && array_key_exists('grouping', $availabilityplugins);
|
||||||
|
|
||||||
|
if ($groupavailability || $groupingavailability) {
|
||||||
|
// When creating the button, we need to set type=button to prevent it behaving as a submit.
|
||||||
$mform->addElement('static', 'restrictgroupbutton', '',
|
$mform->addElement('static', 'restrictgroupbutton', '',
|
||||||
html_writer::tag('button', get_string('restrictbygroup', 'availability'),
|
html_writer::tag('button', get_string('restrictbygroup', 'availability'), [
|
||||||
array('id' => 'restrictbygroup', 'disabled' => 'disabled', 'class' => 'btn btn-secondary')));
|
'id' => 'restrictbygroup',
|
||||||
|
'type' => 'button',
|
||||||
|
'disabled' => 'disabled',
|
||||||
|
'class' => 'btn btn-secondary',
|
||||||
|
'data-groupavailability' => $groupavailability,
|
||||||
|
'data-groupingavailability' => $groupingavailability
|
||||||
|
])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Availability field. This is just a textarea; the user interface
|
// Availability field. This is just a textarea; the user interface
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue