Commit 7ec04e0e authored by David Monllaó's avatar David Monllaó
Browse files

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

parents 1fc64232 6a633d36
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -130,6 +130,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
} else {
this._selectNoUser();
}
this._triggerNextUserEvent();
};
/**
......@@ -233,6 +234,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
} else {
this._selectNoUser();
}
this._triggerNextUserEvent();
};
/**
......@@ -447,6 +449,20 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
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.
*
......
......@@ -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. */
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.
*
......@@ -314,6 +320,29 @@ define(['jquery', 'core/yui', 'core/notification', 'core/templates', 'core/fragm
}.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.
*
......@@ -355,9 +384,10 @@ define(['jquery', 'core/yui', 'core/notification', 'core/templates', 'core/fragm
e.preventDefault();
});
docElement.on('next-user', this._getNextUser.bind(this));
docElement.on('user-changed', this._refreshGradingPanel.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('save-form-state', this._saveFormState.bind(this));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment