mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-55929 assign: allow bulk emails in assignment userslist
This commit is contained in:
parent
5dbac075be
commit
0c8f9108c2
2 changed files with 38 additions and 27 deletions
|
@ -39,6 +39,7 @@ class mod_assign_grading_batch_operations_form extends moodleform {
|
||||||
* Define this form - called by the parent constructor.
|
* Define this form - called by the parent constructor.
|
||||||
*/
|
*/
|
||||||
public function definition() {
|
public function definition() {
|
||||||
|
global $CFG;
|
||||||
$mform = $this->_form;
|
$mform = $this->_form;
|
||||||
$instance = $this->_customdata;
|
$instance = $this->_customdata;
|
||||||
|
|
||||||
|
@ -46,6 +47,11 @@ class mod_assign_grading_batch_operations_form extends moodleform {
|
||||||
$options = array();
|
$options = array();
|
||||||
$options['lock'] = get_string('locksubmissions', 'assign');
|
$options['lock'] = get_string('locksubmissions', 'assign');
|
||||||
$options['unlock'] = get_string('unlocksubmissions', 'assign');
|
$options['unlock'] = get_string('unlocksubmissions', 'assign');
|
||||||
|
if (!empty($CFG->messaging) &&
|
||||||
|
has_all_capabilities(['moodle/site:sendmessage', 'moodle/course:bulkmessaging'], $instance['context'])
|
||||||
|
) {
|
||||||
|
$options['message'] = get_string('messageselectadd');
|
||||||
|
}
|
||||||
$options['downloadselected'] = get_string('downloadselectedsubmissions', 'assign');
|
$options['downloadselected'] = get_string('downloadselectedsubmissions', 'assign');
|
||||||
if ($instance['submissiondrafts']) {
|
if ($instance['submissiondrafts']) {
|
||||||
$options['reverttodraft'] = get_string('reverttodraft', 'assign');
|
$options['reverttodraft'] = get_string('reverttodraft', 'assign');
|
||||||
|
|
|
@ -27,7 +27,8 @@ M.mod_assign.init_tree = function(Y, expand_all, htmlid) {
|
||||||
|
|
||||||
M.mod_assign.init_grading_table = function(Y) {
|
M.mod_assign.init_grading_table = function(Y) {
|
||||||
Y.use('node', function(Y) {
|
Y.use('node', function(Y) {
|
||||||
checkboxes = Y.all('td.c0 input');
|
const checkboxes = Y.all('td.c0 input');
|
||||||
|
let rowelement;
|
||||||
checkboxes.each(function(node) {
|
checkboxes.each(function(node) {
|
||||||
node.on('change', function(e) {
|
node.on('change', function(e) {
|
||||||
rowelement = e.currentTarget.get('parentNode').get('parentNode');
|
rowelement = e.currentTarget.get('parentNode').get('parentNode');
|
||||||
|
@ -50,59 +51,63 @@ M.mod_assign.init_grading_table = function(Y) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var selectall = Y.one('th.c0 input');
|
const selectall = Y.one('th.c0 input');
|
||||||
if (selectall) {
|
if (selectall) {
|
||||||
selectall.on('change', function(e) {
|
selectall.on('change', function(e) {
|
||||||
if (e.currentTarget.get('checked')) {
|
Y.all('td.c0 input[type="checkbox"]').each(function(node) {
|
||||||
checkboxes = Y.all('td.c0 input[type="checkbox"]');
|
rowelement = node.get('parentNode').get('parentNode');
|
||||||
checkboxes.each(function(node) {
|
if (e.currentTarget.get('checked')) {
|
||||||
rowelement = node.get('parentNode').get('parentNode');
|
|
||||||
node.set('checked', true);
|
node.set('checked', true);
|
||||||
rowelement.removeClass('unselectedrow');
|
rowelement.removeClass('unselectedrow');
|
||||||
rowelement.addClass('selectedrow');
|
rowelement.addClass('selectedrow');
|
||||||
});
|
} else {
|
||||||
} else {
|
|
||||||
checkboxes = Y.all('td.c0 input[type="checkbox"]');
|
|
||||||
checkboxes.each(function(node) {
|
|
||||||
rowelement = node.get('parentNode').get('parentNode');
|
|
||||||
node.set('checked', false);
|
node.set('checked', false);
|
||||||
rowelement.removeClass('selectedrow');
|
rowelement.removeClass('selectedrow');
|
||||||
rowelement.addClass('unselectedrow');
|
rowelement.addClass('unselectedrow');
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var batchform = Y.one('form.gradingbatchoperationsform');
|
const batchform = Y.one('form.gradingbatchoperationsform');
|
||||||
if (batchform) {
|
if (batchform) {
|
||||||
batchform.on('submit', function(e) {
|
batchform.on('submit', function(e) {
|
||||||
M.util.js_pending('mod_assign/module.js:batch:submit');
|
M.util.js_pending('mod_assign/module.js:batch:submit');
|
||||||
checkboxes = Y.all('td.c0 input');
|
let selectedusers = [];
|
||||||
var selectedusers = [];
|
|
||||||
checkboxes.each(function(node) {
|
checkboxes.each(function(node) {
|
||||||
if (node.get('checked')) {
|
if (node.get('checked')) {
|
||||||
selectedusers[selectedusers.length] = node.get('value');
|
selectedusers.push(node.get('value'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
operation = Y.one('#id_operation');
|
const operation = Y.one('#id_operation');
|
||||||
usersinput = Y.one('input.selectedusers');
|
const usersinput = Y.one('input.selectedusers');
|
||||||
usersinput.set('value', selectedusers.join(','));
|
usersinput.set('value', selectedusers.join(','));
|
||||||
if (selectedusers.length == 0) {
|
if (selectedusers.length === 0) {
|
||||||
alert(M.util.get_string('nousersselected', 'assign'));
|
alert(M.util.get_string('nousersselected', 'assign'));
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
} else {
|
} else {
|
||||||
action = operation.get('value');
|
let action = operation.get('value');
|
||||||
prefix = 'plugingradingbatchoperation_';
|
const prefix = 'plugingradingbatchoperation_';
|
||||||
if (action.indexOf(prefix) == 0) {
|
let confirmmessage = false;
|
||||||
pluginaction = action.substr(prefix.length);
|
if (action.indexOf(prefix) === 0) {
|
||||||
plugin = pluginaction.split('_')[0];
|
const pluginaction = action.slice(prefix.length);
|
||||||
action = pluginaction.substr(plugin.length + 1);
|
const plugin = pluginaction.split('_')[0];
|
||||||
|
action = pluginaction.slice(plugin.length + 1);
|
||||||
confirmmessage = M.util.get_string('batchoperationconfirm' + action, 'assignfeedback_' + plugin);
|
confirmmessage = M.util.get_string('batchoperationconfirm' + action, 'assignfeedback_' + plugin);
|
||||||
|
} else if (action === 'message') {
|
||||||
|
e.preventDefault();
|
||||||
|
require(['core_message/message_send_bulk'], function(BulkSender) {
|
||||||
|
BulkSender.showModal(selectedusers, function() {
|
||||||
|
document.getElementById('page-header').scrollIntoView();
|
||||||
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
confirmmessage = M.util.get_string('batchoperationconfirm' + operation.get('value'), 'assign');
|
confirmmessage = M.util.get_string('batchoperationconfirm' + operation.get('value'), 'assign');
|
||||||
}
|
}
|
||||||
if (!confirm(confirmmessage)) {
|
// Complete here the action (js_complete event) when we send a bulk message, or we have a confirmation message.
|
||||||
|
// When the confirmation dialogue is completed, the event is fired.
|
||||||
|
if (action === 'message' || confirmmessage !== false && !confirm(confirmmessage)) {
|
||||||
M.util.js_complete('mod_assign/module.js:batch:submit');
|
M.util.js_complete('mod_assign/module.js:batch:submit');
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue