2012-05-03 14:44:06 +08:00
|
|
|
M.mod_assign = {};
|
|
|
|
|
|
|
|
M.mod_assign.init_tree = function(Y, expand_all, htmlid) {
|
2013-12-05 17:00:34 +04:00
|
|
|
var treeElement = Y.one('#'+htmlid);
|
|
|
|
if (treeElement) {
|
|
|
|
Y.use('yui2-treeview', function(Y) {
|
|
|
|
var tree = new Y.YUI2.widget.TreeView(htmlid);
|
2012-05-03 14:44:06 +08:00
|
|
|
|
2013-12-05 17:00:34 +04:00
|
|
|
tree.subscribe("clickEvent", function(node, event) {
|
|
|
|
// We want normal clicking which redirects to url.
|
|
|
|
return false;
|
|
|
|
});
|
2012-05-03 14:44:06 +08:00
|
|
|
|
2013-12-05 17:00:34 +04:00
|
|
|
if (expand_all) {
|
|
|
|
tree.expandAll();
|
|
|
|
}
|
|
|
|
tree.render();
|
|
|
|
});
|
|
|
|
}
|
2012-05-03 14:44:06 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
M.mod_assign.init_grading_table = function(Y) {
|
|
|
|
Y.use('node', function(Y) {
|
|
|
|
checkboxes = Y.all('td.c0 input');
|
|
|
|
checkboxes.each(function(node) {
|
|
|
|
node.on('change', function(e) {
|
|
|
|
rowelement = e.currentTarget.get('parentNode').get('parentNode');
|
|
|
|
if (e.currentTarget.get('checked')) {
|
2013-02-08 15:16:47 +08:00
|
|
|
rowelement.removeClass('unselectedrow');
|
|
|
|
rowelement.addClass('selectedrow');
|
2012-05-03 14:44:06 +08:00
|
|
|
} else {
|
2013-02-08 15:16:47 +08:00
|
|
|
rowelement.removeClass('selectedrow');
|
|
|
|
rowelement.addClass('unselectedrow');
|
2012-05-03 14:44:06 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
rowelement = node.get('parentNode').get('parentNode');
|
|
|
|
if (node.get('checked')) {
|
2013-02-08 15:16:47 +08:00
|
|
|
rowelement.removeClass('unselectedrow');
|
|
|
|
rowelement.addClass('selectedrow');
|
2012-05-03 14:44:06 +08:00
|
|
|
} else {
|
2013-02-08 15:16:47 +08:00
|
|
|
rowelement.removeClass('selectedrow');
|
|
|
|
rowelement.addClass('unselectedrow');
|
2012-05-03 14:44:06 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var selectall = Y.one('th.c0 input');
|
2012-05-15 13:33:59 +08:00
|
|
|
if (selectall) {
|
|
|
|
selectall.on('change', function(e) {
|
|
|
|
if (e.currentTarget.get('checked')) {
|
2014-03-18 11:08:33 +10:30
|
|
|
checkboxes = Y.all('td.c0 input[type="checkbox"]');
|
2012-05-15 13:33:59 +08:00
|
|
|
checkboxes.each(function(node) {
|
|
|
|
rowelement = node.get('parentNode').get('parentNode');
|
|
|
|
node.set('checked', true);
|
2013-02-08 15:16:47 +08:00
|
|
|
rowelement.removeClass('unselectedrow');
|
|
|
|
rowelement.addClass('selectedrow');
|
2012-05-15 13:33:59 +08:00
|
|
|
});
|
|
|
|
} else {
|
2014-03-18 11:08:33 +10:30
|
|
|
checkboxes = Y.all('td.c0 input[type="checkbox"]');
|
2012-05-15 13:33:59 +08:00
|
|
|
checkboxes.each(function(node) {
|
|
|
|
rowelement = node.get('parentNode').get('parentNode');
|
|
|
|
node.set('checked', false);
|
2013-02-08 15:16:47 +08:00
|
|
|
rowelement.removeClass('selectedrow');
|
|
|
|
rowelement.addClass('unselectedrow');
|
2012-05-15 13:33:59 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2012-05-03 14:44:06 +08:00
|
|
|
|
|
|
|
var batchform = Y.one('form.gradingbatchoperationsform');
|
2014-01-14 16:12:00 +00:00
|
|
|
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');
|
|
|
|
}
|
|
|
|
});
|
2012-05-03 14:44:06 +08:00
|
|
|
|
2014-01-14 16:12:00 +00:00
|
|
|
operation = Y.one('#id_operation');
|
|
|
|
usersinput = Y.one('input.selectedusers');
|
|
|
|
usersinput.set('value', selectedusers.join(','));
|
|
|
|
if (selectedusers.length == 0) {
|
2014-11-17 14:55:19 +08:00
|
|
|
alert(M.util.get_string('nousersselected', 'assign'));
|
2012-05-03 14:44:06 +08:00
|
|
|
e.preventDefault();
|
2014-01-14 16:12:00 +00:00
|
|
|
} 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);
|
2014-11-17 14:55:19 +08:00
|
|
|
confirmmessage = M.util.get_string('batchoperationconfirm' + action, 'assignfeedback_' + plugin);
|
2014-01-14 16:12:00 +00:00
|
|
|
} else {
|
2014-11-17 14:55:19 +08:00
|
|
|
confirmmessage = M.util.get_string('batchoperationconfirm' + operation.get('value'), 'assign');
|
2014-01-14 16:12:00 +00:00
|
|
|
}
|
|
|
|
if (!confirm(confirmmessage)) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
2012-05-03 14:44:06 +08:00
|
|
|
}
|
2014-01-14 16:12:00 +00:00
|
|
|
});
|
|
|
|
}
|
2012-05-03 14:44:06 +08:00
|
|
|
|
2012-05-22 13:42:39 +12:00
|
|
|
var quickgrade = Y.all('.gradingtable .quickgrade');
|
2012-05-15 13:33:59 +08:00
|
|
|
quickgrade.each(function(quick) {
|
|
|
|
quick.on('change', function(e) {
|
2012-05-22 13:42:39 +12:00
|
|
|
this.get('parentNode').addClass('quickgrademodified');
|
2012-05-15 13:33:59 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
M.mod_assign.init_grading_options = function(Y) {
|
|
|
|
Y.use('node', function(Y) {
|
|
|
|
var paginationelement = Y.one('#id_perpage');
|
|
|
|
paginationelement.on('change', function(e) {
|
|
|
|
Y.one('form.gradingoptionsform').submit();
|
|
|
|
});
|
|
|
|
var filterelement = Y.one('#id_filter');
|
2012-11-07 16:26:26 -08:00
|
|
|
if (filterelement) {
|
|
|
|
filterelement.on('change', function(e) {
|
|
|
|
Y.one('form.gradingoptionsform').submit();
|
|
|
|
});
|
|
|
|
}
|
2013-04-02 11:59:53 +13:00
|
|
|
var markerfilterelement = Y.one('#id_markerfilter');
|
|
|
|
if (markerfilterelement) {
|
|
|
|
markerfilterelement.on('change', function(e) {
|
|
|
|
Y.one('form.gradingoptionsform').submit();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
var workflowfilterelement = Y.one('#id_workflowfilter');
|
|
|
|
if (workflowfilterelement) {
|
|
|
|
workflowfilterelement.on('change', function(e) {
|
|
|
|
Y.one('form.gradingoptionsform').submit();
|
|
|
|
});
|
|
|
|
}
|
2012-05-15 13:33:59 +08:00
|
|
|
var quickgradingelement = Y.one('#id_quickgrading');
|
2012-06-07 10:52:05 +08:00
|
|
|
if (quickgradingelement) {
|
|
|
|
quickgradingelement.on('change', function(e) {
|
|
|
|
Y.one('form.gradingoptionsform').submit();
|
|
|
|
});
|
|
|
|
}
|
2013-06-18 17:07:44 +08:00
|
|
|
var showonlyactiveenrolelement = Y.one('#id_showonlyactiveenrol');
|
2013-12-05 11:56:14 +04:00
|
|
|
if (showonlyactiveenrolelement) {
|
|
|
|
showonlyactiveenrolelement.on('change', function(e) {
|
2013-06-18 17:07:44 +08:00
|
|
|
Y.one('form.gradingoptionsform').submit();
|
2013-12-05 11:56:14 +04:00
|
|
|
});
|
|
|
|
}
|
2012-05-03 14:44:06 +08:00
|
|
|
});
|
2012-07-31 12:04:37 +08:00
|
|
|
};
|
|
|
|
|
2012-09-20 10:32:17 +08:00
|
|
|
M.mod_assign.init_plugin_summary = function(Y, subtype, type, submissionid) {
|
|
|
|
suffix = subtype + '_' + type + '_' + submissionid;
|
|
|
|
classname = 'contract_' + suffix;
|
|
|
|
contract = Y.one('.' + classname);
|
|
|
|
if (contract) {
|
|
|
|
contract.on('click', function(e) {
|
|
|
|
img = e.target;
|
|
|
|
imgclasses = img.getAttribute('class').split(' ');
|
|
|
|
for (i = 0; i < imgclasses.length; i++) {
|
|
|
|
classname = imgclasses[i];
|
|
|
|
if (classname.indexOf('contract_') == 0) {
|
|
|
|
thissuffix = classname.substr(9);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fullclassname = 'full_' + thissuffix;
|
|
|
|
full = Y.one('.' + fullclassname);
|
|
|
|
if (full) {
|
2013-03-13 11:36:23 +08:00
|
|
|
full.hide(false);
|
2012-09-20 10:32:17 +08:00
|
|
|
}
|
|
|
|
summaryclassname = 'summary_' + thissuffix;
|
|
|
|
summary = Y.one('.' + summaryclassname);
|
|
|
|
if (summary) {
|
2013-03-13 11:36:23 +08:00
|
|
|
summary.show(false);
|
2012-09-20 10:32:17 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
classname = 'expand_' + suffix;
|
|
|
|
expand = Y.one('.' + classname);
|
|
|
|
|
|
|
|
full = Y.one('.full_' + suffix);
|
|
|
|
if (full) {
|
2013-03-13 11:36:23 +08:00
|
|
|
full.hide(false);
|
2012-09-20 10:32:17 +08:00
|
|
|
full.toggleClass('hidefull');
|
|
|
|
}
|
|
|
|
if (expand) {
|
|
|
|
expand.on('click', function(e) {
|
|
|
|
img = e.target;
|
|
|
|
imgclasses = img.getAttribute('class').split(' ');
|
|
|
|
for (i = 0; i < imgclasses.length; i++) {
|
|
|
|
classname = imgclasses[i];
|
|
|
|
if (classname.indexOf('expand_') == 0) {
|
|
|
|
thissuffix = classname.substr(7);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
summaryclassname = 'summary_' + thissuffix;
|
|
|
|
summary = Y.one('.' + summaryclassname);
|
|
|
|
if (summary) {
|
2013-03-13 11:36:23 +08:00
|
|
|
summary.hide(false);
|
2012-09-20 10:32:17 +08:00
|
|
|
}
|
|
|
|
fullclassname = 'full_' + thissuffix;
|
|
|
|
full = Y.one('.' + fullclassname);
|
|
|
|
if (full) {
|
2013-03-13 11:36:23 +08:00
|
|
|
full.show(false);
|
2012-09-20 10:32:17 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|