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 M.util.js_pending('mod_assign/module.js:batch:submit');
80 checkboxes = Y.all('td.c0 input');
81 var selectedusers = [];
82 checkboxes.each(function(node) {
83 if (node.get('checked')) {
84 selectedusers[selectedusers.length] = node.get('value');
88 operation = Y.one('#id_operation');
89 usersinput = Y.one('input.selectedusers');
90 usersinput.set('value', selectedusers.join(','));
91 if (selectedusers.length == 0) {
92 alert(M.util.get_string('nousersselected', 'assign'));
95 action = operation.get('value');
96 prefix = 'plugingradingbatchoperation_';
97 if (action.indexOf(prefix) == 0) {
98 pluginaction = action.substr(prefix.length);
99 plugin = pluginaction.split('_')[0];
100 action = pluginaction.substr(plugin.length + 1);
101 confirmmessage = M.util.get_string('batchoperationconfirm' + action, 'assignfeedback_' + plugin);
103 confirmmessage = M.util.get_string('batchoperationconfirm' + operation.get('value'), 'assign');
105 if (!confirm(confirmmessage)) {
106 M.util.js_complete('mod_assign/module.js:batch:submit');
109 // Note: Do not js_complete. The page being reloaded will empty it.
114 var quickgrade = Y.all('.gradingtable .quickgrade');
115 quickgrade.each(function(quick) {
116 quick.on('change', function(e) {
117 this.get('parentNode').addClass('quickgrademodified');
123 M.mod_assign.init_grading_options = function(Y) {
124 Y.use('node', function(Y) {
125 var paginationelement = Y.one('#id_perpage');
126 paginationelement.on('change', function(e) {
127 Y.one('form.gradingoptionsform').submit();
129 var filterelement = Y.one('#id_filter');
131 filterelement.on('change', function(e) {
132 Y.one('form.gradingoptionsform').submit();
135 var markerfilterelement = Y.one('#id_markerfilter');
136 if (markerfilterelement) {
137 markerfilterelement.on('change', function(e) {
138 Y.one('form.gradingoptionsform').submit();
141 var workflowfilterelement = Y.one('#id_workflowfilter');
142 if (workflowfilterelement) {
143 workflowfilterelement.on('change', function(e) {
144 Y.one('form.gradingoptionsform').submit();
147 var quickgradingelement = Y.one('#id_quickgrading');
148 if (quickgradingelement) {
149 quickgradingelement.on('change', function(e) {
150 Y.one('form.gradingoptionsform').submit();
153 var showonlyactiveenrolelement = Y.one('#id_showonlyactiveenrol');
154 if (showonlyactiveenrolelement) {
155 showonlyactiveenrolelement.on('change', function(e) {
156 Y.one('form.gradingoptionsform').submit();
159 var downloadasfolderselement = Y.one('#id_downloadasfolders');
160 if (downloadasfolderselement) {
161 downloadasfolderselement.on('change', function(e) {
162 Y.one('form.gradingoptionsform').submit();
168 M.mod_assign.init_plugin_summary = function(Y, subtype, type, submissionid) {
169 var suffix = subtype + '_' + type + '_' + submissionid;
170 var classname = 'contract_' + suffix;
171 var contract = Y.one('.' + classname);
173 contract.on('click', function(e) {
175 var link = e.currentTarget || e.target;
176 var linkclasses = link.getAttribute('class').split(' ');
178 for (var i = 0; i < linkclasses.length; i++) {
179 classname = linkclasses[i];
180 if (classname.indexOf('contract_') == 0) {
181 thissuffix = classname.substr(9);
184 var fullclassname = 'full_' + thissuffix;
185 var full = Y.one('.' + fullclassname);
189 var summaryclassname = 'summary_' + thissuffix;
190 var summary = Y.one('.' + summaryclassname);
193 summary.one('a.expand_' + thissuffix).focus();
197 classname = 'expand_' + suffix;
198 var expand = Y.one('.' + classname);
200 var full = Y.one('.full_' + suffix);
203 full.toggleClass('hidefull');
206 expand.on('click', function(e) {
208 var link = e.currentTarget || e.target;
209 var linkclasses = link.getAttribute('class').split(' ');
211 for (var i = 0; i < linkclasses.length; i++) {
212 classname = linkclasses[i];
213 if (classname.indexOf('expand_') == 0) {
214 thissuffix = classname.substr(7);
217 var summaryclassname = 'summary_' + thissuffix;
218 var summary = Y.one('.' + summaryclassname);
222 var fullclassname = 'full_' + thissuffix;
223 full = Y.one('.' + fullclassname);
226 full.one('a.contract_' + thissuffix).focus();