| Línea 176... |
Línea 176... |
| 176 |
GradingPanel.prototype._handleFormSubmissionResponse = function(formdata, nextUserId, nextUser, response) {
|
176 |
GradingPanel.prototype._handleFormSubmissionResponse = function(formdata, nextUserId, nextUser, response) {
|
| 177 |
if (typeof nextUserId === "undefined") {
|
177 |
if (typeof nextUserId === "undefined") {
|
| 178 |
nextUserId = this._lastUserId;
|
178 |
nextUserId = this._lastUserId;
|
| 179 |
}
|
179 |
}
|
| 180 |
if (response.length) {
|
180 |
if (response.length) {
|
| - |
|
181 |
str.get_string('errorgradechangessaveddetail', 'mod_assign')
|
| - |
|
182 |
.then(function(str) {
|
| - |
|
183 |
Toast.add(str, {type: 'danger', delay: 4000});
|
| - |
|
184 |
return str;
|
| - |
|
185 |
})
|
| - |
|
186 |
.catch(notification.exception);
|
| - |
|
187 |
|
| 181 |
// There was an error saving the grade. Re-render the form using the submitted data so we can show
|
188 |
// There was an error saving the grade. Re-render the form using the submitted data so we can show
|
| 182 |
// validation errors.
|
189 |
// validation errors.
|
| 183 |
$(document).trigger('reset', [this._lastUserId, formdata]);
|
190 |
$(document).trigger('reset', [this._lastUserId, formdata, true]);
|
| 184 |
} else {
|
191 |
} else {
|
| 185 |
str.get_string('gradechangessaveddetail', 'mod_assign')
|
192 |
str.get_string('gradechangessaveddetail', 'mod_assign')
|
| 186 |
.then(function(str) {
|
193 |
.then(function(str) {
|
| 187 |
Toast.add(str);
|
194 |
Toast.add(str);
|
| 188 |
return str;
|
195 |
return str;
|
| Línea 210... |
Línea 217... |
| 210 |
* @private
|
217 |
* @private
|
| 211 |
* @method _resetForm
|
218 |
* @method _resetForm
|
| 212 |
* @param {Event} e
|
219 |
* @param {Event} e
|
| 213 |
* @param {Integer} userid
|
220 |
* @param {Integer} userid
|
| 214 |
* @param {Array} formdata
|
221 |
* @param {Array} formdata
|
| - |
|
222 |
* @param {Boolean} unresolvederror
|
| 215 |
*/
|
223 |
*/
|
| 216 |
GradingPanel.prototype._resetForm = function(e, userid, formdata) {
|
224 |
GradingPanel.prototype._resetForm = function(e, userid, formdata, unresolvederror) {
|
| 217 |
// The form was cancelled - refresh with default values.
|
225 |
// The form was cancelled - refresh with default values.
|
| 218 |
var event = $.Event("custom");
|
226 |
var event = $.Event("custom");
|
| 219 |
if (typeof userid == "undefined") {
|
227 |
if (typeof userid == "undefined") {
|
| 220 |
userid = this._lastUserId;
|
228 |
userid = this._lastUserId;
|
| 221 |
}
|
229 |
}
|
| 222 |
this._lastUserId = 0;
|
230 |
this._lastUserId = 0;
|
| 223 |
this._refreshGradingPanel(event, userid, formdata);
|
231 |
this._refreshGradingPanel(event, userid, formdata, -1, unresolvederror);
|
| 224 |
};
|
232 |
};
|
| Línea 225... |
Línea 233... |
| 225 |
|
233 |
|
| 226 |
/**
|
234 |
/**
|
| 227 |
* Open a picker to choose an older attempt.
|
235 |
* Open a picker to choose an older attempt.
|
| Línea 264... |
Línea 272... |
| 264 |
var region = $(selector);
|
272 |
var region = $(selector);
|
| Línea 265... |
Línea 273... |
| 265 |
|
273 |
|
| 266 |
templates.render('mod_assign/popout_button', {}).done(function(html) {
|
274 |
templates.render('mod_assign/popout_button', {}).done(function(html) {
|
| 267 |
var parents = region.find('[data-fieldtype="filemanager"],[data-fieldtype="editor"],[data-fieldtype="grading"]')
|
275 |
var parents = region.find('[data-fieldtype="filemanager"],[data-fieldtype="editor"],[data-fieldtype="grading"]')
|
| 268 |
.closest('.fitem');
|
276 |
.closest('.fitem');
|
| Línea 269... |
Línea 277... |
| 269 |
parents.addClass('has-popout').find('label').parent().append(html);
|
277 |
parents.addClass('has-popout').find('label:first').parent().append(html);
|
| 270 |
|
278 |
|
| 271 |
region.on('click', '[data-region="popout-button"]', this._togglePopout.bind(this));
|
279 |
region.on('click', '[data-region="popout-button"]', this._togglePopout.bind(this));
|
| Línea 298... |
Línea 306... |
| 298 |
* @method _refreshGradingPanel
|
306 |
* @method _refreshGradingPanel
|
| 299 |
* @param {Event} event
|
307 |
* @param {Event} event
|
| 300 |
* @param {Number} userid
|
308 |
* @param {Number} userid
|
| 301 |
* @param {String} submissiondata serialised submission data.
|
309 |
* @param {String} submissiondata serialised submission data.
|
| 302 |
* @param {Integer} attemptnumber
|
310 |
* @param {Integer} attemptnumber
|
| - |
|
311 |
* @param {Boolean} unresolvederror
|
| 303 |
*/
|
312 |
*/
|
| 304 |
GradingPanel.prototype._refreshGradingPanel = function(event, userid, submissiondata, attemptnumber) {
|
313 |
GradingPanel.prototype._refreshGradingPanel = function(event, userid, submissiondata, attemptnumber, unresolvederror) {
|
| 305 |
var contextid = this._region.attr('data-contextid');
|
314 |
var contextid = this._region.attr('data-contextid');
|
| 306 |
if (typeof submissiondata === 'undefined') {
|
315 |
if (typeof submissiondata === 'undefined') {
|
| 307 |
submissiondata = '';
|
316 |
submissiondata = '';
|
| 308 |
}
|
317 |
}
|
| 309 |
if (typeof attemptnumber === 'undefined') {
|
318 |
if (typeof attemptnumber === 'undefined') {
|
| 310 |
attemptnumber = -1;
|
319 |
attemptnumber = -1;
|
| 311 |
}
|
320 |
}
|
| - |
|
321 |
if (typeof unresolvederror === 'undefined') {
|
| - |
|
322 |
unresolvederror = false;
|
| - |
|
323 |
}
|
| 312 |
// Skip reloading if it is the same user.
|
324 |
// Skip reloading if it is the same user.
|
| 313 |
if (this._lastUserId == userid && this._lastAttemptNumber == attemptnumber && submissiondata === '') {
|
325 |
if (this._lastUserId == userid && this._lastAttemptNumber == attemptnumber && submissiondata === '') {
|
| 314 |
return;
|
326 |
return;
|
| 315 |
}
|
327 |
}
|
| 316 |
this._lastUserId = userid;
|
328 |
this._lastUserId = userid;
|
| Línea 325... |
Línea 337... |
| 325 |
if (userid > 0) {
|
337 |
if (userid > 0) {
|
| 326 |
this._region.show();
|
338 |
this._region.show();
|
| 327 |
// Reload the grading form "fragment" for this user.
|
339 |
// Reload the grading form "fragment" for this user.
|
| 328 |
var params = {userid: userid, attemptnumber: attemptnumber, jsonformdata: JSON.stringify(submissiondata)};
|
340 |
var params = {userid: userid, attemptnumber: attemptnumber, jsonformdata: JSON.stringify(submissiondata)};
|
| 329 |
fragment.loadFragment('mod_assign', 'gradingpanel', contextid, params).done(function(html, js) {
|
341 |
fragment.loadFragment('mod_assign', 'gradingpanel', contextid, params).done(function(html, js) {
|
| - |
|
342 |
|
| - |
|
343 |
// Reset whole grading page when there is a failure in retrieving the html
|
| - |
|
344 |
// i.e. user no longer under "requires grading" filter when graded
|
| - |
|
345 |
if (html === '') {
|
| - |
|
346 |
$(document).trigger('reset-table', true);
|
| - |
|
347 |
}
|
| - |
|
348 |
|
| 330 |
this._niceReplaceNodeContents(this._region, html, js)
|
349 |
this._niceReplaceNodeContents(this._region, html, js)
|
| 331 |
.done(function() {
|
350 |
.done(function() {
|
| 332 |
checker.saveFormState('[data-region="grade-panel"] .gradeform');
|
351 |
checker.saveFormState('[data-region="grade-panel"] .gradeform');
|
| 333 |
$(document).on('editor-content-restored', function() {
|
352 |
$(document).on('editor-content-restored', function() {
|
| 334 |
// If the editor has some content that has been restored
|
353 |
// If the editor has some content that has been restored
|
| 335 |
// then save the form state again for comparison.
|
354 |
// then save the form state again for comparison.
|
| 336 |
checker.saveFormState('[data-region="grade-panel"] .gradeform');
|
355 |
checker.saveFormState('[data-region="grade-panel"] .gradeform');
|
| 337 |
});
|
356 |
});
|
| 338 |
$('[data-region="attempt-chooser"]').on('click', this._chooseAttempt.bind(this));
|
357 |
$('[data-region="attempt-chooser"]').on('click', this._chooseAttempt.bind(this));
|
| 339 |
this._addPopoutButtons('[data-region="grade-panel"] .gradeform');
|
358 |
this._addPopoutButtons('[data-region="grade-panel"] .gradeform');
|
| - |
|
359 |
if (unresolvederror) {
|
| - |
|
360 |
$('[data-region="grade-panel"] .gradeform').data('unresolved-error', true);
|
| - |
|
361 |
}
|
| 340 |
$(document).trigger('finish-loading-user');
|
362 |
$(document).trigger('finish-loading-user');
|
| 341 |
// Tell behat we are friends again.
|
363 |
// Tell behat we are friends again.
|
| 342 |
window.M.util.js_complete('mod-assign-loading-user');
|
364 |
window.M.util.js_complete('mod-assign-loading-user');
|
| 343 |
}.bind(this))
|
365 |
}.bind(this))
|
| 344 |
.fail(notification.exception);
|
366 |
.fail(notification.exception);
|