mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-60002-save-and-show-next' of https://github.com/abalbanyan/moodle
This commit is contained in:
commit
70aeddcaf4
2
mod/assign/amd/build/grading_actions.min.js
vendored
2
mod/assign/amd/build/grading_actions.min.js
vendored
@ -1 +1 @@
|
||||
define(["jquery","mod_assign/grading_events"],function(a,b){var c=function(b){this._regionSelector=b,this._region=a(b),this.registerEventListeners()};return c.prototype._regionSelector=null,c.prototype._lastUserId=0,c.prototype._region=null,c.prototype._showActionsForm=function(a,b){var c=this._region.find("[data-region=grading-actions-form]");b!=this._lastUserId&&b>0&&(this._lastUserId=b),b>0?c.removeClass("hide"):c.addClass("hide")},c.prototype._trigger=function(b){a(document).trigger(b)},c.prototype.getReviewPanelElement=function(){return a('[data-region="review-panel"]')},c.prototype.hasReviewPanelElement=function(){return this.getReviewPanelElement().length>0},c.prototype.getCollapseGradePanelButton=function(){return a('[data-region="grade-actions"] .collapse-grade-panel')},c.prototype.getCollapseReviewPanelButton=function(){return a('[data-region="grade-actions"] .collapse-review-panel')},c.prototype.getExpandAllPanelsButton=function(){return a('[data-region="grade-actions"] .collapse-none')},c.prototype.resetLayoutButtons=function(){this.getCollapseGradePanelButton().removeClass("active"),this.getCollapseReviewPanelButton().removeClass("active"),this.getExpandAllPanelsButton().removeClass("active")},c.prototype.collapseReviewPanel=function(){a(document).trigger(b.COLLAPSE_REVIEW_PANEL),a(document).trigger(b.EXPAND_GRADE_PANEL),this.resetLayoutButtons(),this.getCollapseReviewPanelButton().addClass("active")},c.prototype.collapseGradePanel=function(){a(document).trigger(b.COLLAPSE_GRADE_PANEL),a(document).trigger(b.EXPAND_REVIEW_PANEL),this.resetLayoutButtons(),this.getCollapseGradePanelButton().addClass("active")},c.prototype.expandAllPanels=function(){a(document).trigger(b.EXPAND_GRADE_PANEL),a(document).trigger(b.EXPAND_REVIEW_PANEL),this.resetLayoutButtons(),this.getExpandAllPanelsButton().addClass("active")},c.prototype.registerEventListeners=function(){if(this.hasReviewPanelElement()){var b=this.getCollapseReviewPanelButton();b.click(function(a){this.collapseReviewPanel(),a.preventDefault()}.bind(this)),b.keydown(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||13!==a.keyCode&&32!==a.keyCode||(this.collapseReviewPanel(),a.preventDefault())}.bind(this));var c=this.getCollapseGradePanelButton();c.click(function(a){this.collapseGradePanel(),a.preventDefault()}.bind(this)),c.keydown(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||13!==a.keyCode&&32!==a.keyCode||(this.collapseGradePanel(),a.preventDefault())}.bind(this));var d=this.getExpandAllPanelsButton();d.click(function(a){this.expandAllPanels(),a.preventDefault()}.bind(this)),d.keydown(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||13!==a.keyCode&&32!==a.keyCode||(this.expandAllPanels(),a.preventDefault())}.bind(this))}a(document).on("user-changed",this._showActionsForm.bind(this)),this._region.find('[name="savechanges"]').on("click",this._trigger.bind(this,"save-changes")),this._region.find('[name="resetbutton"]').on("click",this._trigger.bind(this,"reset")),this._region.find("form").on("submit",function(a){a.preventDefault()})},c});
|
||||
define(["jquery","mod_assign/grading_events"],function(a,b){var c=function(b){this._regionSelector=b,this._region=a(b),this.registerEventListeners()};return c.prototype._regionSelector=null,c.prototype._lastUserId=0,c.prototype._region=null,c.prototype._showActionsForm=function(a,b){var c=this._region.find("[data-region=grading-actions-form]");b!=this._lastUserId&&b>0&&(this._lastUserId=b),b>0?c.removeClass("hide"):c.addClass("hide")},c.prototype._trigger=function(b){a(document).trigger(b)},c.prototype.getReviewPanelElement=function(){return a('[data-region="review-panel"]')},c.prototype.hasReviewPanelElement=function(){return this.getReviewPanelElement().length>0},c.prototype.getCollapseGradePanelButton=function(){return a('[data-region="grade-actions"] .collapse-grade-panel')},c.prototype.getCollapseReviewPanelButton=function(){return a('[data-region="grade-actions"] .collapse-review-panel')},c.prototype.getExpandAllPanelsButton=function(){return a('[data-region="grade-actions"] .collapse-none')},c.prototype.resetLayoutButtons=function(){this.getCollapseGradePanelButton().removeClass("active"),this.getCollapseReviewPanelButton().removeClass("active"),this.getExpandAllPanelsButton().removeClass("active")},c.prototype.collapseReviewPanel=function(){a(document).trigger(b.COLLAPSE_REVIEW_PANEL),a(document).trigger(b.EXPAND_GRADE_PANEL),this.resetLayoutButtons(),this.getCollapseReviewPanelButton().addClass("active")},c.prototype.collapseGradePanel=function(){a(document).trigger(b.COLLAPSE_GRADE_PANEL),a(document).trigger(b.EXPAND_REVIEW_PANEL),this.resetLayoutButtons(),this.getCollapseGradePanelButton().addClass("active")},c.prototype.expandAllPanels=function(){a(document).trigger(b.EXPAND_GRADE_PANEL),a(document).trigger(b.EXPAND_REVIEW_PANEL),this.resetLayoutButtons(),this.getExpandAllPanelsButton().addClass("active")},c.prototype.registerEventListeners=function(){if(this.hasReviewPanelElement()){var b=this.getCollapseReviewPanelButton();b.click(function(a){this.collapseReviewPanel(),a.preventDefault()}.bind(this)),b.keydown(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||13!==a.keyCode&&32!==a.keyCode||(this.collapseReviewPanel(),a.preventDefault())}.bind(this));var c=this.getCollapseGradePanelButton();c.click(function(a){this.collapseGradePanel(),a.preventDefault()}.bind(this)),c.keydown(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||13!==a.keyCode&&32!==a.keyCode||(this.collapseGradePanel(),a.preventDefault())}.bind(this));var d=this.getExpandAllPanelsButton();d.click(function(a){this.expandAllPanels(),a.preventDefault()}.bind(this)),d.keydown(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||13!==a.keyCode&&32!==a.keyCode||(this.expandAllPanels(),a.preventDefault())}.bind(this))}a(document).on("user-changed",this._showActionsForm.bind(this)),this._region.find('[name="savechanges"]').on("click",this._trigger.bind(this,"save-changes")),this._region.find('[name="saveandshownext"]').on("click",this._trigger.bind(this,"save-and-show-next")),this._region.find('[name="resetbutton"]').on("click",this._trigger.bind(this,"reset")),this._region.find("form").on("submit",function(a){a.preventDefault()})},c});
|
File diff suppressed because one or more lines are too long
2
mod/assign/amd/build/grading_panel.min.js
vendored
2
mod/assign/amd/build/grading_panel.min.js
vendored
File diff suppressed because one or more lines are too long
@ -234,6 +234,7 @@ define(['jquery', 'mod_assign/grading_events'], function($, GradingEvents) {
|
||||
$(document).on('user-changed', this._showActionsForm.bind(this));
|
||||
|
||||
this._region.find('[name="savechanges"]').on('click', this._trigger.bind(this, 'save-changes'));
|
||||
this._region.find('[name="saveandshownext"]').on('click', this._trigger.bind(this, 'save-and-show-next'));
|
||||
this._region.find('[name="resetbutton"]').on('click', this._trigger.bind(this, 'reset'));
|
||||
this._region.find('form').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
@ -50,6 +50,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
|
||||
this._region.find('[data-region="user-filters"]').on('click', this._toggleExpandFilters.bind(this));
|
||||
|
||||
$(document).on('user-changed', this._refreshSelector.bind(this));
|
||||
$(document).on('done-saving-show-next', this._handleNextUser.bind(this));
|
||||
|
||||
// Position the configure filters panel under the link that expands it.
|
||||
var toggleLink = this._region.find('[data-region="user-filters"]');
|
||||
@ -361,8 +362,9 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
|
||||
* Change to the next user in the grading list.
|
||||
*
|
||||
* @param {Event} e
|
||||
* @param {Boolean} saved Has the form already been saved? Skips checking for changes if true.
|
||||
*/
|
||||
GradingNavigation.prototype._handleNextUser = function(e) {
|
||||
GradingNavigation.prototype._handleNextUser = function(e, saved) {
|
||||
e.preventDefault();
|
||||
var select = this._region.find('[data-action=change-user]');
|
||||
var currentUserId = select.attr('data-selected');
|
||||
@ -379,7 +381,15 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
|
||||
var count = this._filteredUsers.length;
|
||||
var newIndex = (currentIndex + 1) % count;
|
||||
|
||||
if (count) {
|
||||
if (saved && count) {
|
||||
// If we've already saved the grade, skip checking if we've made any changes.
|
||||
var userid = this._filteredUsers[newIndex].id;
|
||||
var useridnumber = parseInt(userid, 10);
|
||||
select.attr('data-selected', userid);
|
||||
if (!isNaN(useridnumber) && useridnumber > 0) {
|
||||
$(document).trigger('user-changed', userid);
|
||||
}
|
||||
} else if (count) {
|
||||
this._selectUserById(this._filteredUsers[newIndex].id);
|
||||
}
|
||||
};
|
||||
|
@ -99,9 +99,10 @@ define(['jquery', 'core/yui', 'core/notification', 'core/templates', 'core/fragm
|
||||
* @private
|
||||
* @param {Object} event
|
||||
* @param {Integer} nextUserId
|
||||
* @param {Boolean} nextUser optional. Load next user in the grading list.
|
||||
* @method _submitForm
|
||||
*/
|
||||
GradingPanel.prototype._submitForm = function(event, nextUserId) {
|
||||
GradingPanel.prototype._submitForm = function(event, nextUserId, nextUser) {
|
||||
// The form was submitted - send it via ajax instead.
|
||||
var form = $(this._region.find('form.gradeform'));
|
||||
|
||||
@ -118,7 +119,7 @@ define(['jquery', 'core/yui', 'core/notification', 'core/templates', 'core/fragm
|
||||
ajax.call([{
|
||||
methodname: 'mod_assign_submit_grading_form',
|
||||
args: {assignmentid: assignmentid, userid: this._lastUserId, jsonformdata: JSON.stringify(data)},
|
||||
done: this._handleFormSubmissionResponse.bind(this, data, nextUserId),
|
||||
done: this._handleFormSubmissionResponse.bind(this, data, nextUserId, [], nextUser),
|
||||
fail: notification.exception
|
||||
}]);
|
||||
};
|
||||
@ -131,8 +132,9 @@ define(['jquery', 'core/yui', 'core/notification', 'core/templates', 'core/fragm
|
||||
* @param {Array} formdata - submitted values
|
||||
* @param {Integer} nextUserId - optional. The id of the user to load after the form is saved.
|
||||
* @param {Array} response List of errors.
|
||||
* @param {Boolean} nextUser - optional. If true, switch to next user in the grading list.
|
||||
*/
|
||||
GradingPanel.prototype._handleFormSubmissionResponse = function(formdata, nextUserId, response) {
|
||||
GradingPanel.prototype._handleFormSubmissionResponse = function(formdata, nextUserId, response, nextUser) {
|
||||
if (typeof nextUserId === "undefined") {
|
||||
nextUserId = this._lastUserId;
|
||||
}
|
||||
@ -152,6 +154,8 @@ define(['jquery', 'core/yui', 'core/notification', 'core/templates', 'core/fragm
|
||||
});
|
||||
if (nextUserId == this._lastUserId) {
|
||||
$(document).trigger('reset', nextUserId);
|
||||
} else if (nextUser) {
|
||||
$(document).trigger('done-saving-show-next', true);
|
||||
} else {
|
||||
$(document).trigger('user-changed', nextUserId);
|
||||
}
|
||||
@ -353,6 +357,7 @@ define(['jquery', 'core/yui', 'core/notification', 'core/templates', 'core/fragm
|
||||
|
||||
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('reset', this._resetForm.bind(this));
|
||||
|
||||
docElement.on('save-form-state', this._saveFormState.bind(this));
|
||||
|
@ -36,6 +36,7 @@
|
||||
{{#defaultsendnotifications}}checked="checked"{{/defaultsendnotifications}} />
|
||||
</label>
|
||||
<button type="submit" class="btn btn-primary" name="savechanges">{{#str}}savechanges{{/str}}</button>
|
||||
<button type="submit" class="btn btn-primary" name="saveandshownext">{{#str}}saveandnext{{/str}}</button>
|
||||
<button type="submit" class="btn" name="resetbutton">{{#str}}reset{{/str}}</button>
|
||||
</form>
|
||||
{{#showreview}}
|
||||
|
@ -45,6 +45,7 @@
|
||||
{{#defaultsendnotifications}}checked="checked"{{/defaultsendnotifications}} />
|
||||
</label>
|
||||
<button type="submit" class="btn btn-primary" name="savechanges">{{#str}}savechanges{{/str}}</button>
|
||||
<button type="submit" class="btn btn-primary" name="saveandshownext">{{#str}}saveandnext{{/str}}</button>
|
||||
<button type="submit" class="btn btn-secondary" name="resetbutton">{{#str}}reset{{/str}}</button>
|
||||
</form>
|
||||
{{#js}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user