MDL-77174 mod_quiz: Update toolbox to drop YUI confirm module
This commit is contained in:
+83
-80
@@ -407,39 +407,42 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, {
|
||||
ev.preventDefault();
|
||||
|
||||
// Get the element we're working on.
|
||||
var element = activity,
|
||||
// Create confirm string (different if element has or does not have name)
|
||||
confirmstring = '',
|
||||
qtypename = M.util.get_string('pluginname',
|
||||
'qtype_' + element.getAttribute('class').match(/qtype_([^\s]*)/)[1]);
|
||||
confirmstring = M.util.get_string('confirmremovequestion', 'quiz', qtypename);
|
||||
var element = activity;
|
||||
// Create confirm string (different if element has or does not have name)
|
||||
var qtypename = M.util.get_string(
|
||||
'pluginname',
|
||||
'qtype_' + element.getAttribute('class').match(/qtype_([^\s]*)/)[1]
|
||||
);
|
||||
|
||||
// Create the confirmation dialogue.
|
||||
var confirm = new M.core.confirm({
|
||||
question: confirmstring,
|
||||
modal: true
|
||||
});
|
||||
|
||||
// If it is confirmed.
|
||||
confirm.on('complete-yes', function() {
|
||||
var spinner = this.add_spinner(element);
|
||||
var data = {
|
||||
'class': 'resource',
|
||||
'action': 'DELETE',
|
||||
'id': Y.Moodle.mod_quiz.util.slot.getId(element)
|
||||
};
|
||||
this.send_request(data, spinner, function(response) {
|
||||
if (response.deleted) {
|
||||
// Actually remove the element.
|
||||
Y.Moodle.mod_quiz.util.slot.remove(element);
|
||||
this.reorganise_edit_page();
|
||||
if (M.core.actionmenu && M.core.actionmenu.instance) {
|
||||
M.core.actionmenu.instance.hideMenu(ev);
|
||||
require(['core/notification'], function(Notification) {
|
||||
Notification.saveCancelPromise(
|
||||
M.util.get_string('confirmation', 'admin'),
|
||||
M.util.get_string('confirmremovequestion', 'quiz', qtypename),
|
||||
M.util.get_string('yes', 'moodle')
|
||||
).then(function() {
|
||||
var spinner = this.add_spinner(element);
|
||||
var data = {
|
||||
'class': 'resource',
|
||||
'action': 'DELETE',
|
||||
'id': Y.Moodle.mod_quiz.util.slot.getId(element)
|
||||
};
|
||||
this.send_request(data, spinner, function(response) {
|
||||
if (response.deleted) {
|
||||
// Actually remove the element.
|
||||
Y.Moodle.mod_quiz.util.slot.remove(element);
|
||||
this.reorganise_edit_page();
|
||||
if (M.core.actionmenu && M.core.actionmenu.instance) {
|
||||
M.core.actionmenu.instance.hideMenu(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}, this);
|
||||
return;
|
||||
}.bind(this)).catch(function() {
|
||||
// User cancelled.
|
||||
});
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -517,37 +520,39 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the confirmation dialogue.
|
||||
var confirm = new M.core.confirm({
|
||||
question: M.util.get_string('areyousureremoveselected', 'quiz'),
|
||||
modal: true
|
||||
});
|
||||
require(['core/notification'], function(Notification) {
|
||||
Notification.saveCancelPromise(
|
||||
M.util.get_string('confirmation', 'admin'),
|
||||
M.util.get_string('areyousureremoveselected', 'quiz'),
|
||||
M.util.get_string('yes', 'moodle')
|
||||
).then(function() {
|
||||
var spinner = this.add_spinner(element);
|
||||
var data = {
|
||||
'class': 'resource',
|
||||
field: 'deletemultiple',
|
||||
ids: ids
|
||||
};
|
||||
// Delete items on server.
|
||||
this.send_request(data, spinner, function(response) {
|
||||
// Delete locally if deleted on server.
|
||||
if (response.deleted) {
|
||||
// Actually remove the element.
|
||||
Y.all(SELECTOR.SELECTMULTIPLECHECKBOX + ':checked').each(function(node) {
|
||||
Y.Moodle.mod_quiz.util.slot.remove(node.ancestor('li.activity'));
|
||||
});
|
||||
// Update the page numbers and sections.
|
||||
this.reorganise_edit_page();
|
||||
|
||||
// If it is confirmed.
|
||||
confirm.on('complete-yes', function() {
|
||||
var spinner = this.add_spinner(element);
|
||||
var data = {
|
||||
'class': 'resource',
|
||||
field: 'deletemultiple',
|
||||
ids: ids
|
||||
};
|
||||
// Delete items on server.
|
||||
this.send_request(data, spinner, function(response) {
|
||||
// Delete locally if deleted on server.
|
||||
if (response.deleted) {
|
||||
// Actually remove the element.
|
||||
Y.all(SELECTOR.SELECTMULTIPLECHECKBOX + ':checked').each(function(node) {
|
||||
Y.Moodle.mod_quiz.util.slot.remove(node.ancestor('li.activity'));
|
||||
});
|
||||
// Update the page numbers and sections.
|
||||
this.reorganise_edit_page();
|
||||
// Remove the select multiple options.
|
||||
Y.one('body').removeClass(CSS.SELECTMULTIPLE);
|
||||
}
|
||||
});
|
||||
|
||||
// Remove the select multiple options.
|
||||
Y.one('body').removeClass(CSS.SELECTMULTIPLE);
|
||||
}
|
||||
return;
|
||||
}.bind(this)).catch(function() {
|
||||
// User cancelled.
|
||||
});
|
||||
|
||||
}, this);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -924,31 +929,29 @@ Y.extend(SECTIONTOOLBOX, TOOLBOX, {
|
||||
* @chainable
|
||||
*/
|
||||
delete_section_with_confirmation: function(ev, button, activity) {
|
||||
// Prevent the default button action.
|
||||
ev.preventDefault();
|
||||
require(['core/notification'], function(Notification) {
|
||||
Notification.saveCancelPromise(
|
||||
M.util.get_string('confirmation', 'admin'),
|
||||
M.util.get_string('confirmremovesectionheading', 'quiz', activity.getData('sectionname')),
|
||||
M.util.get_string('yes', 'moodle')
|
||||
).then(function() {
|
||||
var spinner = M.util.add_spinner(Y, activity.one(SELECTOR.ACTIONAREA));
|
||||
var data = {
|
||||
'class': 'section',
|
||||
'action': 'DELETE',
|
||||
'id': activity.get('id').replace('section-', '')
|
||||
};
|
||||
this.send_request(data, spinner, function(response) {
|
||||
if (response.deleted) {
|
||||
window.location.reload(true);
|
||||
}
|
||||
});
|
||||
|
||||
// Create the confirmation dialogue.
|
||||
var confirm = new M.core.confirm({
|
||||
question: M.util.get_string('confirmremovesectionheading', 'quiz', activity.getData('sectionname')),
|
||||
modal: true
|
||||
});
|
||||
|
||||
// If it is confirmed.
|
||||
confirm.on('complete-yes', function() {
|
||||
|
||||
var spinner = M.util.add_spinner(Y, activity.one(SELECTOR.ACTIONAREA));
|
||||
var data = {
|
||||
'class': 'section',
|
||||
'action': 'DELETE',
|
||||
'id': activity.get('id').replace('section-', '')
|
||||
};
|
||||
this.send_request(data, spinner, function(response) {
|
||||
if (response.deleted) {
|
||||
window.location.reload(true);
|
||||
}
|
||||
return;
|
||||
}.bind(this)).catch(function() {
|
||||
// User cancelled.
|
||||
});
|
||||
|
||||
}, this);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
File diff suppressed because one or more lines are too long
+83
-80
@@ -407,39 +407,42 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, {
|
||||
ev.preventDefault();
|
||||
|
||||
// Get the element we're working on.
|
||||
var element = activity,
|
||||
// Create confirm string (different if element has or does not have name)
|
||||
confirmstring = '',
|
||||
qtypename = M.util.get_string('pluginname',
|
||||
'qtype_' + element.getAttribute('class').match(/qtype_([^\s]*)/)[1]);
|
||||
confirmstring = M.util.get_string('confirmremovequestion', 'quiz', qtypename);
|
||||
var element = activity;
|
||||
// Create confirm string (different if element has or does not have name)
|
||||
var qtypename = M.util.get_string(
|
||||
'pluginname',
|
||||
'qtype_' + element.getAttribute('class').match(/qtype_([^\s]*)/)[1]
|
||||
);
|
||||
|
||||
// Create the confirmation dialogue.
|
||||
var confirm = new M.core.confirm({
|
||||
question: confirmstring,
|
||||
modal: true
|
||||
});
|
||||
|
||||
// If it is confirmed.
|
||||
confirm.on('complete-yes', function() {
|
||||
var spinner = this.add_spinner(element);
|
||||
var data = {
|
||||
'class': 'resource',
|
||||
'action': 'DELETE',
|
||||
'id': Y.Moodle.mod_quiz.util.slot.getId(element)
|
||||
};
|
||||
this.send_request(data, spinner, function(response) {
|
||||
if (response.deleted) {
|
||||
// Actually remove the element.
|
||||
Y.Moodle.mod_quiz.util.slot.remove(element);
|
||||
this.reorganise_edit_page();
|
||||
if (M.core.actionmenu && M.core.actionmenu.instance) {
|
||||
M.core.actionmenu.instance.hideMenu(ev);
|
||||
require(['core/notification'], function(Notification) {
|
||||
Notification.saveCancelPromise(
|
||||
M.util.get_string('confirmation', 'admin'),
|
||||
M.util.get_string('confirmremovequestion', 'quiz', qtypename),
|
||||
M.util.get_string('yes', 'moodle')
|
||||
).then(function() {
|
||||
var spinner = this.add_spinner(element);
|
||||
var data = {
|
||||
'class': 'resource',
|
||||
'action': 'DELETE',
|
||||
'id': Y.Moodle.mod_quiz.util.slot.getId(element)
|
||||
};
|
||||
this.send_request(data, spinner, function(response) {
|
||||
if (response.deleted) {
|
||||
// Actually remove the element.
|
||||
Y.Moodle.mod_quiz.util.slot.remove(element);
|
||||
this.reorganise_edit_page();
|
||||
if (M.core.actionmenu && M.core.actionmenu.instance) {
|
||||
M.core.actionmenu.instance.hideMenu(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}, this);
|
||||
return;
|
||||
}.bind(this)).catch(function() {
|
||||
// User cancelled.
|
||||
});
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -517,37 +520,39 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the confirmation dialogue.
|
||||
var confirm = new M.core.confirm({
|
||||
question: M.util.get_string('areyousureremoveselected', 'quiz'),
|
||||
modal: true
|
||||
});
|
||||
require(['core/notification'], function(Notification) {
|
||||
Notification.saveCancelPromise(
|
||||
M.util.get_string('confirmation', 'admin'),
|
||||
M.util.get_string('areyousureremoveselected', 'quiz'),
|
||||
M.util.get_string('yes', 'moodle')
|
||||
).then(function() {
|
||||
var spinner = this.add_spinner(element);
|
||||
var data = {
|
||||
'class': 'resource',
|
||||
field: 'deletemultiple',
|
||||
ids: ids
|
||||
};
|
||||
// Delete items on server.
|
||||
this.send_request(data, spinner, function(response) {
|
||||
// Delete locally if deleted on server.
|
||||
if (response.deleted) {
|
||||
// Actually remove the element.
|
||||
Y.all(SELECTOR.SELECTMULTIPLECHECKBOX + ':checked').each(function(node) {
|
||||
Y.Moodle.mod_quiz.util.slot.remove(node.ancestor('li.activity'));
|
||||
});
|
||||
// Update the page numbers and sections.
|
||||
this.reorganise_edit_page();
|
||||
|
||||
// If it is confirmed.
|
||||
confirm.on('complete-yes', function() {
|
||||
var spinner = this.add_spinner(element);
|
||||
var data = {
|
||||
'class': 'resource',
|
||||
field: 'deletemultiple',
|
||||
ids: ids
|
||||
};
|
||||
// Delete items on server.
|
||||
this.send_request(data, spinner, function(response) {
|
||||
// Delete locally if deleted on server.
|
||||
if (response.deleted) {
|
||||
// Actually remove the element.
|
||||
Y.all(SELECTOR.SELECTMULTIPLECHECKBOX + ':checked').each(function(node) {
|
||||
Y.Moodle.mod_quiz.util.slot.remove(node.ancestor('li.activity'));
|
||||
});
|
||||
// Update the page numbers and sections.
|
||||
this.reorganise_edit_page();
|
||||
// Remove the select multiple options.
|
||||
Y.one('body').removeClass(CSS.SELECTMULTIPLE);
|
||||
}
|
||||
});
|
||||
|
||||
// Remove the select multiple options.
|
||||
Y.one('body').removeClass(CSS.SELECTMULTIPLE);
|
||||
}
|
||||
return;
|
||||
}.bind(this)).catch(function() {
|
||||
// User cancelled.
|
||||
});
|
||||
|
||||
}, this);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -924,31 +929,29 @@ Y.extend(SECTIONTOOLBOX, TOOLBOX, {
|
||||
* @chainable
|
||||
*/
|
||||
delete_section_with_confirmation: function(ev, button, activity) {
|
||||
// Prevent the default button action.
|
||||
ev.preventDefault();
|
||||
require(['core/notification'], function(Notification) {
|
||||
Notification.saveCancelPromise(
|
||||
M.util.get_string('confirmation', 'admin'),
|
||||
M.util.get_string('confirmremovesectionheading', 'quiz', activity.getData('sectionname')),
|
||||
M.util.get_string('yes', 'moodle')
|
||||
).then(function() {
|
||||
var spinner = M.util.add_spinner(Y, activity.one(SELECTOR.ACTIONAREA));
|
||||
var data = {
|
||||
'class': 'section',
|
||||
'action': 'DELETE',
|
||||
'id': activity.get('id').replace('section-', '')
|
||||
};
|
||||
this.send_request(data, spinner, function(response) {
|
||||
if (response.deleted) {
|
||||
window.location.reload(true);
|
||||
}
|
||||
});
|
||||
|
||||
// Create the confirmation dialogue.
|
||||
var confirm = new M.core.confirm({
|
||||
question: M.util.get_string('confirmremovesectionheading', 'quiz', activity.getData('sectionname')),
|
||||
modal: true
|
||||
});
|
||||
|
||||
// If it is confirmed.
|
||||
confirm.on('complete-yes', function() {
|
||||
|
||||
var spinner = M.util.add_spinner(Y, activity.one(SELECTOR.ACTIONAREA));
|
||||
var data = {
|
||||
'class': 'section',
|
||||
'action': 'DELETE',
|
||||
'id': activity.get('id').replace('section-', '')
|
||||
};
|
||||
this.send_request(data, spinner, function(response) {
|
||||
if (response.deleted) {
|
||||
window.location.reload(true);
|
||||
}
|
||||
return;
|
||||
}.bind(this)).catch(function() {
|
||||
// User cancelled.
|
||||
});
|
||||
|
||||
}, this);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
+62
-57
@@ -174,39 +174,42 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, {
|
||||
ev.preventDefault();
|
||||
|
||||
// Get the element we're working on.
|
||||
var element = activity,
|
||||
// Create confirm string (different if element has or does not have name)
|
||||
confirmstring = '',
|
||||
qtypename = M.util.get_string('pluginname',
|
||||
'qtype_' + element.getAttribute('class').match(/qtype_([^\s]*)/)[1]);
|
||||
confirmstring = M.util.get_string('confirmremovequestion', 'quiz', qtypename);
|
||||
var element = activity;
|
||||
// Create confirm string (different if element has or does not have name)
|
||||
var qtypename = M.util.get_string(
|
||||
'pluginname',
|
||||
'qtype_' + element.getAttribute('class').match(/qtype_([^\s]*)/)[1]
|
||||
);
|
||||
|
||||
// Create the confirmation dialogue.
|
||||
var confirm = new M.core.confirm({
|
||||
question: confirmstring,
|
||||
modal: true
|
||||
});
|
||||
|
||||
// If it is confirmed.
|
||||
confirm.on('complete-yes', function() {
|
||||
var spinner = this.add_spinner(element);
|
||||
var data = {
|
||||
'class': 'resource',
|
||||
'action': 'DELETE',
|
||||
'id': Y.Moodle.mod_quiz.util.slot.getId(element)
|
||||
};
|
||||
this.send_request(data, spinner, function(response) {
|
||||
if (response.deleted) {
|
||||
// Actually remove the element.
|
||||
Y.Moodle.mod_quiz.util.slot.remove(element);
|
||||
this.reorganise_edit_page();
|
||||
if (M.core.actionmenu && M.core.actionmenu.instance) {
|
||||
M.core.actionmenu.instance.hideMenu(ev);
|
||||
require(['core/notification'], function(Notification) {
|
||||
Notification.saveCancelPromise(
|
||||
M.util.get_string('confirmation', 'admin'),
|
||||
M.util.get_string('confirmremovequestion', 'quiz', qtypename),
|
||||
M.util.get_string('yes', 'moodle')
|
||||
).then(function() {
|
||||
var spinner = this.add_spinner(element);
|
||||
var data = {
|
||||
'class': 'resource',
|
||||
'action': 'DELETE',
|
||||
'id': Y.Moodle.mod_quiz.util.slot.getId(element)
|
||||
};
|
||||
this.send_request(data, spinner, function(response) {
|
||||
if (response.deleted) {
|
||||
// Actually remove the element.
|
||||
Y.Moodle.mod_quiz.util.slot.remove(element);
|
||||
this.reorganise_edit_page();
|
||||
if (M.core.actionmenu && M.core.actionmenu.instance) {
|
||||
M.core.actionmenu.instance.hideMenu(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}, this);
|
||||
return;
|
||||
}.bind(this)).catch(function() {
|
||||
// User cancelled.
|
||||
});
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -284,37 +287,39 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the confirmation dialogue.
|
||||
var confirm = new M.core.confirm({
|
||||
question: M.util.get_string('areyousureremoveselected', 'quiz'),
|
||||
modal: true
|
||||
});
|
||||
require(['core/notification'], function(Notification) {
|
||||
Notification.saveCancelPromise(
|
||||
M.util.get_string('confirmation', 'admin'),
|
||||
M.util.get_string('areyousureremoveselected', 'quiz'),
|
||||
M.util.get_string('yes', 'moodle')
|
||||
).then(function() {
|
||||
var spinner = this.add_spinner(element);
|
||||
var data = {
|
||||
'class': 'resource',
|
||||
field: 'deletemultiple',
|
||||
ids: ids
|
||||
};
|
||||
// Delete items on server.
|
||||
this.send_request(data, spinner, function(response) {
|
||||
// Delete locally if deleted on server.
|
||||
if (response.deleted) {
|
||||
// Actually remove the element.
|
||||
Y.all(SELECTOR.SELECTMULTIPLECHECKBOX + ':checked').each(function(node) {
|
||||
Y.Moodle.mod_quiz.util.slot.remove(node.ancestor('li.activity'));
|
||||
});
|
||||
// Update the page numbers and sections.
|
||||
this.reorganise_edit_page();
|
||||
|
||||
// If it is confirmed.
|
||||
confirm.on('complete-yes', function() {
|
||||
var spinner = this.add_spinner(element);
|
||||
var data = {
|
||||
'class': 'resource',
|
||||
field: 'deletemultiple',
|
||||
ids: ids
|
||||
};
|
||||
// Delete items on server.
|
||||
this.send_request(data, spinner, function(response) {
|
||||
// Delete locally if deleted on server.
|
||||
if (response.deleted) {
|
||||
// Actually remove the element.
|
||||
Y.all(SELECTOR.SELECTMULTIPLECHECKBOX + ':checked').each(function(node) {
|
||||
Y.Moodle.mod_quiz.util.slot.remove(node.ancestor('li.activity'));
|
||||
});
|
||||
// Update the page numbers and sections.
|
||||
this.reorganise_edit_page();
|
||||
// Remove the select multiple options.
|
||||
Y.one('body').removeClass(CSS.SELECTMULTIPLE);
|
||||
}
|
||||
});
|
||||
|
||||
// Remove the select multiple options.
|
||||
Y.one('body').removeClass(CSS.SELECTMULTIPLE);
|
||||
}
|
||||
return;
|
||||
}.bind(this)).catch(function() {
|
||||
// User cancelled.
|
||||
});
|
||||
|
||||
}, this);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
+21
-23
@@ -108,31 +108,29 @@ Y.extend(SECTIONTOOLBOX, TOOLBOX, {
|
||||
* @chainable
|
||||
*/
|
||||
delete_section_with_confirmation: function(ev, button, activity) {
|
||||
// Prevent the default button action.
|
||||
ev.preventDefault();
|
||||
require(['core/notification'], function(Notification) {
|
||||
Notification.saveCancelPromise(
|
||||
M.util.get_string('confirmation', 'admin'),
|
||||
M.util.get_string('confirmremovesectionheading', 'quiz', activity.getData('sectionname')),
|
||||
M.util.get_string('yes', 'moodle')
|
||||
).then(function() {
|
||||
var spinner = M.util.add_spinner(Y, activity.one(SELECTOR.ACTIONAREA));
|
||||
var data = {
|
||||
'class': 'section',
|
||||
'action': 'DELETE',
|
||||
'id': activity.get('id').replace('section-', '')
|
||||
};
|
||||
this.send_request(data, spinner, function(response) {
|
||||
if (response.deleted) {
|
||||
window.location.reload(true);
|
||||
}
|
||||
});
|
||||
|
||||
// Create the confirmation dialogue.
|
||||
var confirm = new M.core.confirm({
|
||||
question: M.util.get_string('confirmremovesectionheading', 'quiz', activity.getData('sectionname')),
|
||||
modal: true
|
||||
});
|
||||
|
||||
// If it is confirmed.
|
||||
confirm.on('complete-yes', function() {
|
||||
|
||||
var spinner = M.util.add_spinner(Y, activity.one(SELECTOR.ACTIONAREA));
|
||||
var data = {
|
||||
'class': 'section',
|
||||
'action': 'DELETE',
|
||||
'id': activity.get('id').replace('section-', '')
|
||||
};
|
||||
this.send_request(data, spinner, function(response) {
|
||||
if (response.deleted) {
|
||||
window.location.reload(true);
|
||||
}
|
||||
return;
|
||||
}.bind(this)).catch(function() {
|
||||
// User cancelled.
|
||||
});
|
||||
|
||||
}, this);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user