3 M.mod_assign.init_tree = function(Y, expand_all, htmlid) {
4 var treeElement = Y.one('#'+htmlid);
6 Y.use('yui2-treeview', 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.
22 M.mod_assign.init_grading_table = function(Y) {
23 Y.use('node', function(Y) {
24 checkboxes = Y.all('td.c0 input');
25 checkboxes.each(function(node) {
26 node.on('change', function(e) {
27 rowelement = e.currentTarget.get('parentNode').get('parentNode');
28 if (e.currentTarget.get('checked')) {
29 rowelement.removeClass('unselectedrow');
30 rowelement.addClass('selectedrow');
32 rowelement.removeClass('selectedrow');
33 rowelement.addClass('unselectedrow');
37 rowelement = node.get('parentNode').get('parentNode');
38 if (node.get('checked')) {
39 rowelement.removeClass('unselectedrow');
40 rowelement.addClass('selectedrow');
42 rowelement.removeClass('selectedrow');
43 rowelement.addClass('unselectedrow');
47 var selectall = Y.one('th.c0 input');
49 selectall.on('change', function(e) {
50 if (e.currentTarget.get('checked')) {
51 checkboxes = Y.all('td.c0 input[type="checkbox"]');
52 checkboxes.each(function(node) {
53 rowelement = node.get('parentNode').get('parentNode');
54 node.set('checked', true);
55 rowelement.removeClass('unselectedrow');
56 rowelement.addClass('selectedrow');
59 checkboxes = Y.all('td.c0 input[type="checkbox"]');
60 checkboxes.each(function(node) {
61 rowelement = node.get('parentNode').get('parentNode');
62 node.set('checked', false);
63 rowelement.removeClass('selectedrow');
64 rowelement.addClass('unselectedrow');
70 var batchform = Y.one('form.gradingbatchoperationsform');
72 batchform.on('submit', function(e) {
73 checkboxes = Y.all('td.c0 input');
74 var selectedusers = [];
75 checkboxes.each(function(node) {
76 if (node.get('checked')) {
77 selectedusers[selectedusers.length] = node.get('value');
81 operation = Y.one('#id_operation');
82 usersinput = Y.one('input.selectedusers');
83 usersinput.set('value', selectedusers.join(','));
84 if (selectedusers.length == 0) {
85 alert(M.util.get_string('nousersselected', 'assign'));
88 action = operation.get('value');
89 prefix = 'plugingradingbatchoperation_';
90 if (action.indexOf(prefix) == 0) {
91 pluginaction = action.substr(prefix.length);
92 plugin = pluginaction.split('_')[0];
93 action = pluginaction.substr(plugin.length + 1);
94 confirmmessage = M.util.get_string('batchoperationconfirm' + action, 'assignfeedback_' + plugin);
96 confirmmessage = M.util.get_string('batchoperationconfirm' + operation.get('value'), 'assign');
98 if (!confirm(confirmmessage)) {
105 var quickgrade = Y.all('.gradingtable .quickgrade');
106 quickgrade.each(function(quick) {
107 quick.on('change', function(e) {
108 this.get('parentNode').addClass('quickgrademodified');
114 M.mod_assign.init_grading_options = function(Y) {
115 Y.use('node', function(Y) {
116 var paginationelement = Y.one('#id_perpage');
117 paginationelement.on('change', function(e) {
118 Y.one('form.gradingoptionsform').submit();
120 var filterelement = Y.one('#id_filter');
122 filterelement.on('change', function(e) {
123 Y.one('form.gradingoptionsform').submit();
126 var markerfilterelement = Y.one('#id_markerfilter');
127 if (markerfilterelement) {
128 markerfilterelement.on('change', function(e) {
129 Y.one('form.gradingoptionsform').submit();
132 var workflowfilterelement = Y.one('#id_workflowfilter');
133 if (workflowfilterelement) {
134 workflowfilterelement.on('change', function(e) {
135 Y.one('form.gradingoptionsform').submit();
138 var quickgradingelement = Y.one('#id_quickgrading');
139 if (quickgradingelement) {
140 quickgradingelement.on('change', function(e) {
141 Y.one('form.gradingoptionsform').submit();
144 var showonlyactiveenrolelement = Y.one('#id_showonlyactiveenrol');
145 if (showonlyactiveenrolelement) {
146 showonlyactiveenrolelement.on('change', function(e) {
147 Y.one('form.gradingoptionsform').submit();
150 var downloadasfolderselement = Y.one('#id_downloadasfolders');
151 if (downloadasfolderselement) {
152 downloadasfolderselement.on('change', function(e) {
153 Y.one('form.gradingoptionsform').submit();
159 M.mod_assign.init_plugin_summary = function(Y, subtype, type, submissionid) {
160 suffix = subtype + '_' + type + '_' + submissionid;
161 classname = 'contract_' + suffix;
162 contract = Y.one('.' + classname);
164 contract.on('click', function(e) {
166 imgclasses = img.getAttribute('class').split(' ');
167 for (i = 0; i < imgclasses.length; i++) {
168 classname = imgclasses[i];
169 if (classname.indexOf('contract_') == 0) {
170 thissuffix = classname.substr(9);
173 fullclassname = 'full_' + thissuffix;
174 full = Y.one('.' + fullclassname);
178 summaryclassname = 'summary_' + thissuffix;
179 summary = Y.one('.' + summaryclassname);
185 classname = 'expand_' + suffix;
186 expand = Y.one('.' + classname);
188 full = Y.one('.full_' + suffix);
191 full.toggleClass('hidefull');
194 expand.on('click', function(e) {
196 imgclasses = img.getAttribute('class').split(' ');
197 for (i = 0; i < imgclasses.length; i++) {
198 classname = imgclasses[i];
199 if (classname.indexOf('expand_') == 0) {
200 thissuffix = classname.substr(7);
203 summaryclassname = 'summary_' + thissuffix;
204 summary = Y.one('.' + summaryclassname);
208 fullclassname = 'full_' + thissuffix;
209 full = Y.one('.' + fullclassname);