3 M.mod_assign.init_tree = function(Y, expand_all, htmlid) {
4 var treeElement = Y.one('#'+htmlid);
6 Y.use('yui2-treeview', 'node-event-simulate', function(Y) {
7 var tree = new Y.YUI2.widget.TreeView(htmlid);
9 tree.subscribe("clickEvent", function(node, event) {
10 // We want normal clicking which redirects to url.
14 tree.subscribe("enterKeyPressed", function(node) {
15 // We want keyboard activation to trigger a click on the first link.
16 Y.one(node.getContentEl()).one('a').simulate('click');
28 M.mod_assign.init_grading_table = function(Y) {
29 Y.use('node', function(Y) {
30 checkboxes = Y.all('td.c0 input');
31 checkboxes.each(function(node) {
32 node.on('change', function(e) {
33 rowelement = e.currentTarget.get('parentNode').get('parentNode');
34 if (e.currentTarget.get('checked')) {
35 rowelement.removeClass('unselectedrow');
36 rowelement.addClass('selectedrow');
38 rowelement.removeClass('selectedrow');
39 rowelement.addClass('unselectedrow');
43 rowelement = node.get('parentNode').get('parentNode');
44 if (node.get('checked')) {
45 rowelement.removeClass('unselectedrow');
46 rowelement.addClass('selectedrow');
48 rowelement.removeClass('selectedrow');
49 rowelement.addClass('unselectedrow');
53 var selectall = Y.one('th.c0 input');
55 selectall.on('change', function(e) {
56 if (e.currentTarget.get('checked')) {
57 checkboxes = Y.all('td.c0 input[type="checkbox"]');
58 checkboxes.each(function(node) {
59 rowelement = node.get('parentNode').get('parentNode');
60 node.set('checked', true);
61 rowelement.removeClass('unselectedrow');
62 rowelement.addClass('selectedrow');
65 checkboxes = Y.all('td.c0 input[type="checkbox"]');
66 checkboxes.each(function(node) {
67 rowelement = node.get('parentNode').get('parentNode');
68 node.set('checked', false);
69 rowelement.removeClass('selectedrow');
70 rowelement.addClass('unselectedrow');
76 var batchform = Y.one('form.gradingbatchoperationsform');
78 batchform.on('submit', function(e) {
79 checkboxes = Y.all('td.c0 input');
80 var selectedusers = [];
81 checkboxes.each(function(node) {
82 if (node.get('checked')) {
83 selectedusers[selectedusers.length] = node.get('value');
87 operation = Y.one('#id_operation');
88 usersinput = Y.one('input.selectedusers');
89 usersinput.set('value', selectedusers.join(','));
90 if (selectedusers.length == 0) {
91 alert(M.util.get_string('nousersselected', 'assign'));
94 action = operation.get('value');
95 prefix = 'plugingradingbatchoperation_';
96 if (action.indexOf(prefix) == 0) {
97 pluginaction = action.substr(prefix.length);
98 plugin = pluginaction.split('_')[0];
99 action = pluginaction.substr(plugin.length + 1);
100 confirmmessage = M.util.get_string('batchoperationconfirm' + action, 'assignfeedback_' + plugin);
102 confirmmessage = M.util.get_string('batchoperationconfirm' + operation.get('value'), 'assign');
104 if (!confirm(confirmmessage)) {
111 var quickgrade = Y.all('.gradingtable .quickgrade');
112 quickgrade.each(function(quick) {
113 quick.on('change', function(e) {
114 this.get('parentNode').addClass('quickgrademodified');
120 M.mod_assign.init_grading_options = function(Y) {
121 Y.use('node', function(Y) {
122 var paginationelement = Y.one('#id_perpage');
123 paginationelement.on('change', function(e) {
124 Y.one('form.gradingoptionsform').submit();
126 var filterelement = Y.one('#id_filter');
128 filterelement.on('change', function(e) {
129 Y.one('form.gradingoptionsform').submit();
132 var markerfilterelement = Y.one('#id_markerfilter');
133 if (markerfilterelement) {
134 markerfilterelement.on('change', function(e) {
135 Y.one('form.gradingoptionsform').submit();
138 var workflowfilterelement = Y.one('#id_workflowfilter');
139 if (workflowfilterelement) {
140 workflowfilterelement.on('change', function(e) {
141 Y.one('form.gradingoptionsform').submit();
144 var quickgradingelement = Y.one('#id_quickgrading');
145 if (quickgradingelement) {
146 quickgradingelement.on('change', function(e) {
147 Y.one('form.gradingoptionsform').submit();
150 var showonlyactiveenrolelement = Y.one('#id_showonlyactiveenrol');
151 if (showonlyactiveenrolelement) {
152 showonlyactiveenrolelement.on('change', function(e) {
153 Y.one('form.gradingoptionsform').submit();
156 var downloadasfolderselement = Y.one('#id_downloadasfolders');
157 if (downloadasfolderselement) {
158 downloadasfolderselement.on('change', function(e) {
159 Y.one('form.gradingoptionsform').submit();
165 M.mod_assign.init_plugin_summary = function(Y, subtype, type, submissionid) {
166 suffix = subtype + '_' + type + '_' + submissionid;
167 classname = 'contract_' + suffix;
168 contract = Y.one('.' + classname);
170 contract.on('click', function(e) {
172 imgclasses = img.getAttribute('class').split(' ');
173 for (i = 0; i < imgclasses.length; i++) {
174 classname = imgclasses[i];
175 if (classname.indexOf('contract_') == 0) {
176 thissuffix = classname.substr(9);
179 fullclassname = 'full_' + thissuffix;
180 full = Y.one('.' + fullclassname);
184 summaryclassname = 'summary_' + thissuffix;
185 summary = Y.one('.' + summaryclassname);
191 classname = 'expand_' + suffix;
192 expand = Y.one('.' + classname);
194 full = Y.one('.full_' + suffix);
197 full.toggleClass('hidefull');
200 expand.on('click', function(e) {
202 imgclasses = img.getAttribute('class').split(' ');
203 for (i = 0; i < imgclasses.length; i++) {
204 classname = imgclasses[i];
205 if (classname.indexOf('expand_') == 0) {
206 thissuffix = classname.substr(7);
209 summaryclassname = 'summary_' + thissuffix;
210 summary = Y.one('.' + summaryclassname);
214 fullclassname = 'full_' + thissuffix;
215 full = Y.one('.' + fullclassname);