Merge branch 'MDL-60430-master' of https://github.com/mihailges/moodle

This commit is contained in:
David Monllao 2017-10-26 10:27:34 +02:00
commit 7ec04e0e09
4 changed files with 49 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -130,6 +130,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
} else { } else {
this._selectNoUser(); this._selectNoUser();
} }
this._triggerNextUserEvent();
}; };
/** /**
@ -233,6 +234,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
} else { } else {
this._selectNoUser(); this._selectNoUser();
} }
this._triggerNextUserEvent();
}; };
/** /**
@ -447,6 +449,20 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
this._refreshCount(); this._refreshCount();
}; };
/**
* Trigger the next user event depending on the number of filtered users
*
* @private
* @method _triggerNextUserEvent
*/
GradingNavigation.prototype._triggerNextUserEvent = function() {
if (this._filteredUsers.length > 1) {
$(document).trigger('next-user', {nextUserId: null, nextUser: true});
} else {
$(document).trigger('next-user', {nextUser: false});
}
};
/** /**
* Change to a different user in the grading list. * Change to a different user in the grading list.
* *

View file

@ -54,6 +54,12 @@ define(['jquery', 'core/yui', 'core/notification', 'core/templates', 'core/fragm
/** @type {JQuery} JQuery node for the page region containing the user navigation. */ /** @type {JQuery} JQuery node for the page region containing the user navigation. */
GradingPanel.prototype._region = null; GradingPanel.prototype._region = null;
/** @type {Integer} The id of the next user in the grading list */
GradingPanel.prototype.nextUserId = null;
/** @type {Boolean} Next user exists in the grading list */
GradingPanel.prototype.nextUser = false;
/** /**
* Fade the dom node out, update it, and fade it back. * Fade the dom node out, update it, and fade it back.
* *
@ -314,6 +320,29 @@ define(['jquery', 'core/yui', 'core/notification', 'core/templates', 'core/fragm
}.bind(this)).fail(notification.exception); }.bind(this)).fail(notification.exception);
}; };
/**
* Get next user data and store it in global variables
*
* @private
* @method _getNextUser
* @param {Event} event
* @param {Object} data Next user's data
*/
GradingPanel.prototype._getNextUser = function(event, data) {
this.nextUserId = data.nextUserId;
this.nextUser = data.nextUser;
};
/**
* Handle the save-and-show-next event
*
* @private
* @method _handleSaveAndShowNext
*/
GradingPanel.prototype._handleSaveAndShowNext = function() {
this._submitForm(null, this.nextUserId, this.nextUser);
};
/** /**
* Get the grade panel element. * Get the grade panel element.
* *
@ -355,9 +384,10 @@ define(['jquery', 'core/yui', 'core/notification', 'core/templates', 'core/fragm
e.preventDefault(); e.preventDefault();
}); });
docElement.on('next-user', this._getNextUser.bind(this));
docElement.on('user-changed', this._refreshGradingPanel.bind(this)); docElement.on('user-changed', this._refreshGradingPanel.bind(this));
docElement.on('save-changes', this._submitForm.bind(this)); docElement.on('save-changes', this._submitForm.bind(this));
docElement.on('save-and-show-next', this._submitForm.bind(this, null, null, true)); docElement.on('save-and-show-next', this._handleSaveAndShowNext.bind(this));
docElement.on('reset', this._resetForm.bind(this)); docElement.on('reset', this._resetForm.bind(this));
docElement.on('save-form-state', this._saveFormState.bind(this)); docElement.on('save-form-state', this._saveFormState.bind(this));