From 534fc276499ee77ce93f13d4dc6c7ec48493680f Mon Sep 17 00:00:00 2001 From: Ruslan Kabalin Date: Tue, 14 Jan 2014 16:12:00 +0000 Subject: [PATCH] MDL-43693: assignment: Fix JS error on grading page. --- mod/assign/module.js | 60 +++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/mod/assign/module.js b/mod/assign/module.js index 29814649434..ba35ef0ddce 100644 --- a/mod/assign/module.js +++ b/mod/assign/module.js @@ -65,37 +65,39 @@ M.mod_assign.init_grading_table = function(Y) { } var batchform = Y.one('form.gradingbatchoperationsform'); - batchform.on('submit', function(e) { - checkboxes = Y.all('td.c0 input'); - var selectedusers = []; - checkboxes.each(function(node) { - if (node.get('checked')) { - selectedusers[selectedusers.length] = node.get('value'); + if (batchform) { + batchform.on('submit', function(e) { + checkboxes = Y.all('td.c0 input'); + var selectedusers = []; + checkboxes.each(function(node) { + if (node.get('checked')) { + selectedusers[selectedusers.length] = node.get('value'); + } + }); + + operation = Y.one('#id_operation'); + usersinput = Y.one('input.selectedusers'); + usersinput.set('value', selectedusers.join(',')); + if (selectedusers.length == 0) { + alert(M.str.assign.nousersselected); + e.preventDefault(); + } else { + action = operation.get('value'); + prefix = 'plugingradingbatchoperation_'; + if (action.indexOf(prefix) == 0) { + pluginaction = action.substr(prefix.length); + plugin = pluginaction.split('_')[0]; + action = pluginaction.substr(plugin.length + 1); + confirmmessage = eval('M.str.assignfeedback_' + plugin + '.batchoperationconfirm' + action); + } else { + confirmmessage = eval('M.str.assign.batchoperationconfirm' + operation.get('value')); + } + if (!confirm(confirmmessage)) { + e.preventDefault(); + } } }); - - operation = Y.one('#id_operation'); - usersinput = Y.one('input.selectedusers'); - usersinput.set('value', selectedusers.join(',')); - if (selectedusers.length == 0) { - alert(M.str.assign.nousersselected); - e.preventDefault(); - } else { - action = operation.get('value'); - prefix = 'plugingradingbatchoperation_'; - if (action.indexOf(prefix) == 0) { - pluginaction = action.substr(prefix.length); - plugin = pluginaction.split('_')[0]; - action = pluginaction.substr(plugin.length + 1); - confirmmessage = eval('M.str.assignfeedback_' + plugin + '.batchoperationconfirm' + action); - } else { - confirmmessage = eval('M.str.assign.batchoperationconfirm' + operation.get('value')); - } - if (!confirm(confirmmessage)) { - e.preventDefault(); - } - } - }); + } Y.use('node-menunav', function(Y) { var menus = Y.all('.gradingtable .actionmenu');