1 |
efrain |
1 |
M.mod_assign = {};
|
|
|
2 |
|
|
|
3 |
M.mod_assign.init_tree = function(Y, expand_all, htmlid) {
|
|
|
4 |
var treeElement = Y.one('#'+htmlid);
|
|
|
5 |
if (treeElement) {
|
|
|
6 |
Y.use('yui2-treeview', 'node-event-simulate', function(Y) {
|
|
|
7 |
var tree = new Y.YUI2.widget.TreeView(htmlid);
|
|
|
8 |
|
|
|
9 |
tree.subscribe("clickEvent", function(node, event) {
|
|
|
10 |
// We want normal clicking which redirects to url.
|
|
|
11 |
return false;
|
|
|
12 |
});
|
|
|
13 |
|
|
|
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');
|
|
|
17 |
return false;
|
|
|
18 |
});
|
|
|
19 |
|
|
|
20 |
if (expand_all) {
|
|
|
21 |
tree.expandAll();
|
|
|
22 |
}
|
|
|
23 |
tree.render();
|
|
|
24 |
});
|
|
|
25 |
}
|
|
|
26 |
};
|
|
|
27 |
|
|
|
28 |
M.mod_assign.init_grading_table = function(Y) {
|
|
|
29 |
Y.use('node', function(Y) {
|
|
|
30 |
const checkboxes = Y.all('td.c0 input');
|
|
|
31 |
let rowelement;
|
|
|
32 |
checkboxes.each(function(node) {
|
|
|
33 |
node.on('change', function(e) {
|
|
|
34 |
rowelement = e.currentTarget.get('parentNode').get('parentNode');
|
|
|
35 |
if (e.currentTarget.get('checked')) {
|
|
|
36 |
rowelement.removeClass('unselectedrow');
|
|
|
37 |
rowelement.addClass('selectedrow');
|
|
|
38 |
} else {
|
|
|
39 |
rowelement.removeClass('selectedrow');
|
|
|
40 |
rowelement.addClass('unselectedrow');
|
|
|
41 |
}
|
|
|
42 |
});
|
|
|
43 |
|
|
|
44 |
rowelement = node.get('parentNode').get('parentNode');
|
|
|
45 |
if (node.get('checked')) {
|
|
|
46 |
rowelement.removeClass('unselectedrow');
|
|
|
47 |
rowelement.addClass('selectedrow');
|
|
|
48 |
} else {
|
|
|
49 |
rowelement.removeClass('selectedrow');
|
|
|
50 |
rowelement.addClass('unselectedrow');
|
|
|
51 |
}
|
|
|
52 |
});
|
|
|
53 |
|
|
|
54 |
const selectall = Y.one('th.c0 input');
|
|
|
55 |
if (selectall) {
|
|
|
56 |
selectall.on('change', function(e) {
|
|
|
57 |
Y.all('td.c0 input[type="checkbox"]').each(function(node) {
|
|
|
58 |
rowelement = node.get('parentNode').get('parentNode');
|
|
|
59 |
if (e.currentTarget.get('checked')) {
|
|
|
60 |
node.set('checked', true);
|
|
|
61 |
rowelement.removeClass('unselectedrow');
|
|
|
62 |
rowelement.addClass('selectedrow');
|
|
|
63 |
} else {
|
|
|
64 |
node.set('checked', false);
|
|
|
65 |
rowelement.removeClass('selectedrow');
|
|
|
66 |
rowelement.addClass('unselectedrow');
|
|
|
67 |
}
|
|
|
68 |
});
|
|
|
69 |
});
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
const batchform = Y.one('form.gradingbatchoperationsform');
|
|
|
73 |
if (batchform) {
|
|
|
74 |
batchform.on('submit', function(e) {
|
|
|
75 |
M.util.js_pending('mod_assign/module.js:batch:submit');
|
|
|
76 |
let selectedusers = [];
|
|
|
77 |
checkboxes.each(function(node) {
|
|
|
78 |
if (node.get('checked')) {
|
|
|
79 |
selectedusers.push(node.get('value'));
|
|
|
80 |
}
|
|
|
81 |
});
|
|
|
82 |
|
|
|
83 |
const operation = Y.one('#id_operation');
|
|
|
84 |
const usersinput = Y.one('input.selectedusers');
|
|
|
85 |
usersinput.set('value', selectedusers.join(','));
|
|
|
86 |
if (selectedusers.length === 0) {
|
|
|
87 |
alert(M.util.get_string('nousersselected', 'assign'));
|
|
|
88 |
e.preventDefault();
|
|
|
89 |
} else {
|
|
|
90 |
let action = operation.get('value');
|
|
|
91 |
const prefix = 'plugingradingbatchoperation_';
|
|
|
92 |
let confirmmessage = false;
|
|
|
93 |
if (action.indexOf(prefix) === 0) {
|
|
|
94 |
const pluginaction = action.slice(prefix.length);
|
|
|
95 |
const plugin = pluginaction.split('_')[0];
|
|
|
96 |
action = pluginaction.slice(plugin.length + 1);
|
|
|
97 |
confirmmessage = M.util.get_string('batchoperationconfirm' + action, 'assignfeedback_' + plugin);
|
|
|
98 |
} else if (action === 'message') {
|
|
|
99 |
e.preventDefault();
|
|
|
100 |
require(['core_message/message_send_bulk'], function(BulkSender) {
|
|
|
101 |
BulkSender.showModal(selectedusers, function() {
|
|
|
102 |
document.getElementById('page-header').scrollIntoView();
|
|
|
103 |
});
|
|
|
104 |
});
|
|
|
105 |
} else {
|
|
|
106 |
confirmmessage = M.util.get_string('batchoperationconfirm' + operation.get('value'), 'assign');
|
|
|
107 |
}
|
|
|
108 |
// Complete here the action (js_complete event) when we send a bulk message, or we have a confirmation message.
|
|
|
109 |
// When the confirmation dialogue is completed, the event is fired.
|
|
|
110 |
if (action === 'message' || confirmmessage !== false && !confirm(confirmmessage)) {
|
|
|
111 |
M.util.js_complete('mod_assign/module.js:batch:submit');
|
|
|
112 |
e.preventDefault();
|
|
|
113 |
}
|
|
|
114 |
// Note: Do not js_complete. The page being reloaded will empty it.
|
|
|
115 |
}
|
|
|
116 |
});
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
var quickgrade = Y.all('.gradingtable .quickgrade');
|
|
|
120 |
quickgrade.each(function(quick) {
|
|
|
121 |
quick.on('change', function(e) {
|
|
|
122 |
this.get('parentNode').addClass('quickgrademodified');
|
|
|
123 |
});
|
|
|
124 |
});
|
|
|
125 |
});
|
|
|
126 |
};
|
|
|
127 |
|
|
|
128 |
M.mod_assign.init_grading_options = function(Y) {
|
|
|
129 |
Y.use('node', function(Y) {
|
|
|
130 |
var paginationelement = Y.one('#id_perpage');
|
|
|
131 |
paginationelement.on('change', function(e) {
|
|
|
132 |
Y.one('form.gradingoptionsform').submit();
|
|
|
133 |
});
|
|
|
134 |
var filterelement = Y.one('#id_filter');
|
|
|
135 |
if (filterelement) {
|
|
|
136 |
filterelement.on('change', function(e) {
|
|
|
137 |
Y.one('form.gradingoptionsform').submit();
|
|
|
138 |
});
|
|
|
139 |
}
|
|
|
140 |
var markerfilterelement = Y.one('#id_markerfilter');
|
|
|
141 |
if (markerfilterelement) {
|
|
|
142 |
markerfilterelement.on('change', function(e) {
|
|
|
143 |
Y.one('form.gradingoptionsform').submit();
|
|
|
144 |
});
|
|
|
145 |
}
|
|
|
146 |
var workflowfilterelement = Y.one('#id_workflowfilter');
|
|
|
147 |
if (workflowfilterelement) {
|
|
|
148 |
workflowfilterelement.on('change', function(e) {
|
|
|
149 |
Y.one('form.gradingoptionsform').submit();
|
|
|
150 |
});
|
|
|
151 |
}
|
|
|
152 |
var quickgradingelement = Y.one('#id_quickgrading');
|
|
|
153 |
if (quickgradingelement) {
|
|
|
154 |
quickgradingelement.on('change', function(e) {
|
|
|
155 |
Y.one('form.gradingoptionsform').submit();
|
|
|
156 |
});
|
|
|
157 |
}
|
|
|
158 |
var showonlyactiveenrolelement = Y.one('#id_showonlyactiveenrol');
|
|
|
159 |
if (showonlyactiveenrolelement) {
|
|
|
160 |
showonlyactiveenrolelement.on('change', function(e) {
|
|
|
161 |
Y.one('form.gradingoptionsform').submit();
|
|
|
162 |
});
|
|
|
163 |
}
|
|
|
164 |
var downloadasfolderselement = Y.one('#id_downloadasfolders');
|
|
|
165 |
if (downloadasfolderselement) {
|
|
|
166 |
downloadasfolderselement.on('change', function(e) {
|
|
|
167 |
Y.one('form.gradingoptionsform').submit();
|
|
|
168 |
});
|
|
|
169 |
}
|
|
|
170 |
});
|
|
|
171 |
};
|
|
|
172 |
|
|
|
173 |
M.mod_assign.init_plugin_summary = function(Y, subtype, type, submissionid) {
|
|
|
174 |
var suffix = subtype + '_' + type + '_' + submissionid;
|
|
|
175 |
var classname = 'contract_' + suffix;
|
|
|
176 |
var contract = Y.one('.' + classname);
|
|
|
177 |
if (contract) {
|
|
|
178 |
contract.on('click', function(e) {
|
|
|
179 |
e.preventDefault();
|
|
|
180 |
var link = e.currentTarget || e.target;
|
|
|
181 |
var linkclasses = link.getAttribute('class').split(' ');
|
|
|
182 |
var thissuffix = '';
|
|
|
183 |
for (var i = 0; i < linkclasses.length; i++) {
|
|
|
184 |
classname = linkclasses[i];
|
|
|
185 |
if (classname.indexOf('contract_') == 0) {
|
|
|
186 |
thissuffix = classname.substr(9);
|
|
|
187 |
}
|
|
|
188 |
}
|
|
|
189 |
var fullclassname = 'full_' + thissuffix;
|
|
|
190 |
var full = Y.one('.' + fullclassname);
|
|
|
191 |
if (full) {
|
|
|
192 |
full.hide(false);
|
|
|
193 |
}
|
|
|
194 |
var summaryclassname = 'summary_' + thissuffix;
|
|
|
195 |
var summary = Y.one('.' + summaryclassname);
|
|
|
196 |
if (summary) {
|
|
|
197 |
summary.show(false);
|
|
|
198 |
summary.one('a.expand_' + thissuffix).focus();
|
|
|
199 |
}
|
|
|
200 |
});
|
|
|
201 |
}
|
|
|
202 |
classname = 'expand_' + suffix;
|
|
|
203 |
var expand = Y.one('.' + classname);
|
|
|
204 |
|
|
|
205 |
var full = Y.one('.full_' + suffix);
|
|
|
206 |
if (full) {
|
|
|
207 |
full.hide(false);
|
|
|
208 |
full.toggleClass('hidefull');
|
|
|
209 |
}
|
|
|
210 |
if (expand) {
|
|
|
211 |
expand.on('click', function(e) {
|
|
|
212 |
e.preventDefault();
|
|
|
213 |
var link = e.currentTarget || e.target;
|
|
|
214 |
var linkclasses = link.getAttribute('class').split(' ');
|
|
|
215 |
var thissuffix = '';
|
|
|
216 |
for (var i = 0; i < linkclasses.length; i++) {
|
|
|
217 |
classname = linkclasses[i];
|
|
|
218 |
if (classname.indexOf('expand_') == 0) {
|
|
|
219 |
thissuffix = classname.substr(7);
|
|
|
220 |
}
|
|
|
221 |
}
|
|
|
222 |
var summaryclassname = 'summary_' + thissuffix;
|
|
|
223 |
var summary = Y.one('.' + summaryclassname);
|
|
|
224 |
if (summary) {
|
|
|
225 |
summary.hide(false);
|
|
|
226 |
}
|
|
|
227 |
var fullclassname = 'full_' + thissuffix;
|
|
|
228 |
full = Y.one('.' + fullclassname);
|
|
|
229 |
if (full) {
|
|
|
230 |
full.show(false);
|
|
|
231 |
full.one('a.contract_' + thissuffix).focus();
|
|
|
232 |
}
|
|
|
233 |
});
|
|
|
234 |
}
|
|
|
235 |
};
|