3 M.mod_assign.init_tree = function(Y, expand_all, htmlid) {
4 Y.use('yui2-treeview', function(Y) {
5 var tree = new Y.YUI2.widget.TreeView(htmlid);
7 tree.subscribe("clickEvent", function(node, event) {
8 // We want normal clicking which redirects to url.
19 M.mod_assign.init_grading_table = function(Y) {
20 Y.use('node', function(Y) {
21 checkboxes = Y.all('td.c0 input');
22 checkboxes.each(function(node) {
23 node.on('change', function(e) {
24 rowelement = e.currentTarget.get('parentNode').get('parentNode');
25 if (e.currentTarget.get('checked')) {
26 rowelement.removeClass('unselectedrow');
27 rowelement.addClass('selectedrow');
29 rowelement.removeClass('selectedrow');
30 rowelement.addClass('unselectedrow');
34 rowelement = node.get('parentNode').get('parentNode');
35 if (node.get('checked')) {
36 rowelement.removeClass('unselectedrow');
37 rowelement.addClass('selectedrow');
39 rowelement.removeClass('selectedrow');
40 rowelement.addClass('unselectedrow');
44 var selectall = Y.one('th.c0 input');
46 selectall.on('change', function(e) {
47 if (e.currentTarget.get('checked')) {
48 checkboxes = Y.all('td.c0 input[type="checkbox"]');
49 checkboxes.each(function(node) {
50 rowelement = node.get('parentNode').get('parentNode');
51 node.set('checked', true);
52 rowelement.removeClass('unselectedrow');
53 rowelement.addClass('selectedrow');
56 checkboxes = Y.all('td.c0 input[type="checkbox"]');
57 checkboxes.each(function(node) {
58 rowelement = node.get('parentNode').get('parentNode');
59 node.set('checked', false);
60 rowelement.removeClass('selectedrow');
61 rowelement.addClass('unselectedrow');
67 var batchform = Y.one('form.gradingbatchoperationsform');
69 batchform.on('submit', function(e) {
70 checkboxes = Y.all('td.c0 input');
71 var selectedusers = [];
72 checkboxes.each(function(node) {
73 if (node.get('checked')) {
74 selectedusers[selectedusers.length] = node.get('value');
78 operation = Y.one('#id_operation');
79 usersinput = Y.one('input.selectedusers');
80 usersinput.set('value', selectedusers.join(','));
81 if (selectedusers.length == 0) {
82 alert(M.util.get_string('nousersselected', 'assign'));
85 action = operation.get('value');
86 prefix = 'plugingradingbatchoperation_';
87 if (action.indexOf(prefix) == 0) {
88 pluginaction = action.substr(prefix.length);
89 plugin = pluginaction.split('_')[0];
90 action = pluginaction.substr(plugin.length + 1);
91 confirmmessage = M.util.get_string('batchoperationconfirm' + action, 'assignfeedback_' + plugin);
93 confirmmessage = M.util.get_string('batchoperationconfirm' + operation.get('value'), 'assign');
95 if (!confirm(confirmmessage)) {
102 var quickgrade = Y.all('.gradingtable .quickgrade');
103 quickgrade.each(function(quick) {
104 quick.on('change', function(e) {
105 this.get('parentNode').addClass('quickgrademodified');
111 M.mod_assign.init_grading_options = function(Y) {
112 Y.use('node', function(Y) {
113 var paginationelement = Y.one('#id_perpage');
114 paginationelement.on('change', function(e) {
115 Y.one('form.gradingoptionsform').submit();
117 var filterelement = Y.one('#id_filter');
119 filterelement.on('change', function(e) {
120 Y.one('form.gradingoptionsform').submit();
123 var markerfilterelement = Y.one('#id_markerfilter');
124 if (markerfilterelement) {
125 markerfilterelement.on('change', function(e) {
126 Y.one('form.gradingoptionsform').submit();
129 var workflowfilterelement = Y.one('#id_workflowfilter');
130 if (workflowfilterelement) {
131 workflowfilterelement.on('change', function(e) {
132 Y.one('form.gradingoptionsform').submit();
135 var quickgradingelement = Y.one('#id_quickgrading');
136 if (quickgradingelement) {
137 quickgradingelement.on('change', function(e) {
138 Y.one('form.gradingoptionsform').submit();
141 var showonlyactiveenrolelement = Y.one('#id_showonlyactiveenrol');
142 if (showonlyactiveenrolelement) {
143 showonlyactiveenrolelement.on('change', function(e) {
144 Y.one('form.gradingoptionsform').submit();
150 M.mod_assign.init_grade_change = function(Y) {
151 var gradenode = Y.one('#id_grade');
153 var originalvalue = gradenode.get('value');
154 gradenode.on('change', function() {
155 if (gradenode.get('value') != originalvalue) {
156 alert(M.util.get_string('changegradewarning', 'mod_assign'));
162 M.mod_assign.init_plugin_summary = function(Y, subtype, type, submissionid) {
163 suffix = subtype + '_' + type + '_' + submissionid;
164 classname = 'contract_' + suffix;
165 contract = Y.one('.' + classname);
167 contract.on('click', function(e) {
169 imgclasses = img.getAttribute('class').split(' ');
170 for (i = 0; i < imgclasses.length; i++) {
171 classname = imgclasses[i];
172 if (classname.indexOf('contract_') == 0) {
173 thissuffix = classname.substr(9);
176 fullclassname = 'full_' + thissuffix;
177 full = Y.one('.' + fullclassname);
181 summaryclassname = 'summary_' + thissuffix;
182 summary = Y.one('.' + summaryclassname);
188 classname = 'expand_' + suffix;
189 expand = Y.one('.' + classname);
191 full = Y.one('.full_' + suffix);
194 full.toggleClass('hidefull');
197 expand.on('click', function(e) {
199 imgclasses = img.getAttribute('class').split(' ');
200 for (i = 0; i < imgclasses.length; i++) {
201 classname = imgclasses[i];
202 if (classname.indexOf('expand_') == 0) {
203 thissuffix = classname.substr(7);
206 summaryclassname = 'summary_' + thissuffix;
207 summary = Y.one('.' + summaryclassname);
211 fullclassname = 'full_' + thissuffix;
212 full = Y.one('.' + fullclassname);