MDL-61405 assign: Multiple pdfs are expected

In the same page it is normal (expected) to have multiple links to different annotated pdfs.

In the grading page, we also abort pending ajax progress when the current user is changed.
This commit is contained in:
Damyon Wiese
2019-02-06 09:36:27 +08:00
parent 2188da9eed
commit fc5d655fa4
7 changed files with 55 additions and 88 deletions
+1 -1
View File
@@ -1 +1 @@
define(["jquery","core/notification","core/ajax","core/templates"],function(a,b,c,d){var e=function(b){this._regionSelector=b,this._region=a(b),this._userCache={},a(document).on("user-changed",this._refreshUserInfo.bind(this))};return e.prototype._regionSelector=null,e.prototype._userCache=null,e.prototype._region=null,e.prototype._lastUserId=0,e.prototype._getAssignmentId=function(){return this._region.attr("data-assignmentid")},e.prototype._refreshUserInfo=function(e,f){var g=a.Deferred();this._lastUserId!=f&&(this._lastUserId=f,d.render("mod_assign/loading",{}).done(function(e,h){if(this._region.fadeOut("fast",function(){d.replaceNodeContents(this._region,e,h),this._region.fadeIn("fast")}.bind(this)),f<0)return void d.render("mod_assign/grading_navigation_no_users",{}).done(function(a,b){this._region.fadeOut("fast",function(){d.replaceNodeContents(this._region,a,b),this._region.fadeIn("fast")}.bind(this))}.bind(this)).fail(b.exception);if("undefined"!=typeof this._userCache[f])g.resolve(this._userCache[f]);else{var i=this._getAssignmentId(),j=c.call([{methodname:"mod_assign_get_participant",args:{userid:f,assignid:i,embeduser:!0}}]);j[0].done(function(a){a.hasOwnProperty("id")?(this._userCache[f]=a,g.resolve(this._userCache[f])):g.reject("No users")}.bind(this)).fail(b.exception)}g.done(function(c){var e=a("[data-showuseridentity]").data("showuseridentity").split(","),f=[];c.courseid=a('[data-region="grading-navigation-panel"]').attr("data-courseid"),c.user&&(a.each(e,function(a,b){"undefined"!=typeof c.user[b]&&""!==c.user[b]&&(c.hasidentity=!0,f.push(c.user[b]))}),c.identity=f.join(", "),c.user.profileimageurl&&(c.profileimageurl=c.user.profileimageurl)),d.render("mod_assign/grading_navigation_user_summary",c).done(function(a,b){this._region.fadeOut("fast",function(){d.replaceNodeContents(this._region,a,b),this._region.fadeIn("fast")}.bind(this))}.bind(this)).fail(b.exception)}.bind(this)).fail(function(){d.render("mod_assign/grading_navigation_no_users",{}).done(function(a,b){this._region.fadeOut("fast",function(){d.replaceNodeContents(this._region,a,b),this._region.fadeIn("fast")}.bind(this))}.bind(this)).fail(b.exception)}.bind(this))}.bind(this)).fail(b.exception))},e});
define(["jquery","core/notification","core/ajax","core/templates"],function(a,b,c,d){var e=function(b){this._regionSelector=b,this._region=a(b),this._userCache={},a(document).on("user-changed",this._refreshUserInfo.bind(this))};return e.prototype._regionSelector=null,e.prototype._userCache=null,e.prototype._region=null,e.prototype._lastUserId=0,e.prototype._getAssignmentId=function(){return this._region.attr("data-assignmentid")},e.prototype._refreshUserInfo=function(e,f){var g=a.Deferred();this._region.attr("data-userid",f),this._lastUserId!=f&&(this._lastUserId=f,d.render("mod_assign/loading",{}).done(function(e,h){if(this._region.fadeOut("fast",function(){d.replaceNodeContents(this._region,e,h),this._region.fadeIn("fast")}.bind(this)),f<0)return void d.render("mod_assign/grading_navigation_no_users",{}).done(function(a,b){this._region.fadeOut("fast",function(){d.replaceNodeContents(this._region,a,b),this._region.fadeIn("fast")}.bind(this))}.bind(this)).fail(b.exception);if("undefined"!=typeof this._userCache[f])g.resolve(this._userCache[f]);else{var i=this._getAssignmentId(),j=c.call([{methodname:"mod_assign_get_participant",args:{userid:f,assignid:i,embeduser:!0}}]);j[0].done(function(a){a.hasOwnProperty("id")?(this._userCache[f]=a,g.resolve(this._userCache[f])):g.reject("No users")}.bind(this)).fail(b.exception)}g.done(function(c){var e=a("[data-showuseridentity]").data("showuseridentity").split(","),f=[];c.courseid=a('[data-region="grading-navigation-panel"]').attr("data-courseid"),c.user&&(a.each(e,function(a,b){"undefined"!=typeof c.user[b]&&""!==c.user[b]&&(c.hasidentity=!0,f.push(c.user[b]))}),c.identity=f.join(", "),c.user.profileimageurl&&(c.profileimageurl=c.user.profileimageurl)),d.render("mod_assign/grading_navigation_user_summary",c).done(function(a,b){this._region.fadeOut("fast",function(){d.replaceNodeContents(this._region,a,b),this._region.fadeIn("fast")}.bind(this))}.bind(this)).fail(b.exception)}.bind(this)).fail(function(){d.render("mod_assign/grading_navigation_no_users",{}).done(function(a,b){this._region.fadeOut("fast",function(){d.replaceNodeContents(this._region,a,b),this._region.fadeIn("fast")}.bind(this))}.bind(this)).fail(b.exception)}.bind(this))}.bind(this)).fail(b.exception))},e});
@@ -73,6 +73,9 @@ define(['jquery', 'core/notification', 'core/ajax', 'core/templates'], function(
UserInfo.prototype._refreshUserInfo = function(event, userid) {
var promise = $.Deferred();
// Put the current user ID in the DOM so yui can access it.
this._region.attr('data-userid', userid);
// Skip reloading if it is the same user.
if (this._lastUserId == userid) {
return;
@@ -46,6 +46,7 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdf/ajax.php',
UNSAVEDCHANGESDIV: '.assignfeedback_editpdf_unsavedchanges',
UNSAVEDCHANGESINPUT: 'input[name="assignfeedback_editpdf_haschanges"]',
STAMPSBUTTON: '.currentstampbutton',
USERINFOREGION: '[data-region="user-info"]',
DIALOGUE: '.' + CSS.DIALOGUE
},
SELECTEDBORDERCOLOUR = 'rgba(200, 200, 255, 0.9)',
@@ -3730,9 +3731,7 @@ EDITOR.prototype = {
* @method poll_document_conversion_status
*/
poll_document_conversion_status: function() {
if (this.get('destroyed')) {
return;
}
var requestUserId = this.get('userid');
Y.io(AJAXBASE, {
method: 'get',
@@ -3748,6 +3747,15 @@ EDITOR.prototype = {
},
on: {
success: function(tid, response) {
var currentUserRegion = Y.one(SELECTOR.USERINFOREGION);
if (currentUserRegion) {
var currentUserId = currentUserRegion.getAttribute('data-userid');
if (currentUserId && (currentUserId != requestUserId)) {
// Polling conversion status needs to abort because
// the current user changed.
return;
}
}
var data = this.handle_response_data(response),
poll = false;
if (data) {
@@ -3796,9 +3804,6 @@ EDITOR.prototype = {
* @method get_images_for_documents
*/
start_document_to_image_conversion: function() {
if (this.get('destroyed')) {
return;
}
Y.io(AJAXBASE, {
method: 'get',
context: this,
@@ -3883,9 +3888,6 @@ EDITOR.prototype = {
* @method update_page_load_progress
*/
update_page_load_progress: function() {
if (this.get('destroyed')) {
return;
}
var checkconversionstatus,
ajax_error_total = 0,
progressbar = this.get_dialogue_element(SELECTOR.PROGRESSBARCONTAINER + ' .bar');
@@ -3908,9 +3910,6 @@ EDITOR.prototype = {
},
on: {
success: function(tid, response) {
if (this.get('destroyed')) {
return;
}
ajax_error_total = 0;
var progress = 0;
@@ -3932,9 +3931,6 @@ EDITOR.prototype = {
}
},
failure: function(tid, response) {
if (this.get('destroyed')) {
return;
}
ajax_error_total = ajax_error_total + 1;
// We only continue on error if the all pages were not generated,
// and if the ajax call did not produce 5 errors in the row.
@@ -3967,9 +3963,6 @@ EDITOR.prototype = {
* @return {object}
*/
handle_response_data: function(response) {
if (this.get('destroyed')) {
return;
}
var data;
try {
data = Y.JSON.parse(response.responseText);
@@ -4454,9 +4447,6 @@ EDITOR.prototype = {
* @method save_current_page
*/
save_current_page: function() {
if (this.get('destroyed')) {
return;
}
var ajaxurl = AJAXBASE,
config;
@@ -4591,7 +4581,9 @@ EDITOR.prototype = {
}
page = this.pages[this.currentpage];
this.loadingicon.hide();
if (this.loadingicon) {
this.loadingicon.hide();
}
drawingcanvas.setStyle('backgroundImage', 'url("' + page.url + '")');
drawingcanvas.setStyle('width', page.width + 'px');
drawingcanvas.setStyle('height', page.height + 'px');
@@ -4795,10 +4787,6 @@ M.assignfeedback_editpdf.editor = M.assignfeedback_editpdf.editor || {};
* @param {Object} params
*/
M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || function(params) {
if (typeof M.assignfeedback_editpdf.instance !== 'undefined') {
M.assignfeedback_editpdf.instance.destroy();
}
M.assignfeedback_editpdf.instance = new EDITOR(params);
return M.assignfeedback_editpdf.instance;
};
File diff suppressed because one or more lines are too long
@@ -46,6 +46,7 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdf/ajax.php',
UNSAVEDCHANGESDIV: '.assignfeedback_editpdf_unsavedchanges',
UNSAVEDCHANGESINPUT: 'input[name="assignfeedback_editpdf_haschanges"]',
STAMPSBUTTON: '.currentstampbutton',
USERINFOREGION: '[data-region="user-info"]',
DIALOGUE: '.' + CSS.DIALOGUE
},
SELECTEDBORDERCOLOUR = 'rgba(200, 200, 255, 0.9)',
@@ -3730,9 +3731,7 @@ EDITOR.prototype = {
* @method poll_document_conversion_status
*/
poll_document_conversion_status: function() {
if (this.get('destroyed')) {
return;
}
var requestUserId = this.get('userid');
Y.io(AJAXBASE, {
method: 'get',
@@ -3748,6 +3747,15 @@ EDITOR.prototype = {
},
on: {
success: function(tid, response) {
var currentUserRegion = Y.one(SELECTOR.USERINFOREGION);
if (currentUserRegion) {
var currentUserId = currentUserRegion.getAttribute('data-userid');
if (currentUserId && (currentUserId != requestUserId)) {
// Polling conversion status needs to abort because
// the current user changed.
return;
}
}
var data = this.handle_response_data(response),
poll = false;
if (data) {
@@ -3796,9 +3804,6 @@ EDITOR.prototype = {
* @method get_images_for_documents
*/
start_document_to_image_conversion: function() {
if (this.get('destroyed')) {
return;
}
Y.io(AJAXBASE, {
method: 'get',
context: this,
@@ -3883,9 +3888,6 @@ EDITOR.prototype = {
* @method update_page_load_progress
*/
update_page_load_progress: function() {
if (this.get('destroyed')) {
return;
}
var checkconversionstatus,
ajax_error_total = 0,
progressbar = this.get_dialogue_element(SELECTOR.PROGRESSBARCONTAINER + ' .bar');
@@ -3908,9 +3910,6 @@ EDITOR.prototype = {
},
on: {
success: function(tid, response) {
if (this.get('destroyed')) {
return;
}
ajax_error_total = 0;
var progress = 0;
@@ -3932,9 +3931,6 @@ EDITOR.prototype = {
}
},
failure: function(tid, response) {
if (this.get('destroyed')) {
return;
}
ajax_error_total = ajax_error_total + 1;
// We only continue on error if the all pages were not generated,
// and if the ajax call did not produce 5 errors in the row.
@@ -3967,9 +3963,6 @@ EDITOR.prototype = {
* @return {object}
*/
handle_response_data: function(response) {
if (this.get('destroyed')) {
return;
}
var data;
try {
data = Y.JSON.parse(response.responseText);
@@ -4454,9 +4447,6 @@ EDITOR.prototype = {
* @method save_current_page
*/
save_current_page: function() {
if (this.get('destroyed')) {
return;
}
var ajaxurl = AJAXBASE,
config;
@@ -4591,7 +4581,9 @@ EDITOR.prototype = {
}
page = this.pages[this.currentpage];
this.loadingicon.hide();
if (this.loadingicon) {
this.loadingicon.hide();
}
drawingcanvas.setStyle('backgroundImage', 'url("' + page.url + '")');
drawingcanvas.setStyle('width', page.width + 'px');
drawingcanvas.setStyle('height', page.height + 'px');
@@ -4795,10 +4787,6 @@ M.assignfeedback_editpdf.editor = M.assignfeedback_editpdf.editor || {};
* @param {Object} params
*/
M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || function(params) {
if (typeof M.assignfeedback_editpdf.instance !== 'undefined') {
M.assignfeedback_editpdf.instance.destroy();
}
M.assignfeedback_editpdf.instance = new EDITOR(params);
return M.assignfeedback_editpdf.instance;
};
+13 -26
View File
@@ -457,9 +457,7 @@ EDITOR.prototype = {
* @method poll_document_conversion_status
*/
poll_document_conversion_status: function() {
if (this.get('destroyed')) {
return;
}
var requestUserId = this.get('userid');
Y.io(AJAXBASE, {
method: 'get',
@@ -475,6 +473,15 @@ EDITOR.prototype = {
},
on: {
success: function(tid, response) {
var currentUserRegion = Y.one(SELECTOR.USERINFOREGION);
if (currentUserRegion) {
var currentUserId = currentUserRegion.getAttribute('data-userid');
if (currentUserId && (currentUserId != requestUserId)) {
// Polling conversion status needs to abort because
// the current user changed.
return;
}
}
var data = this.handle_response_data(response),
poll = false;
if (data) {
@@ -523,9 +530,6 @@ EDITOR.prototype = {
* @method get_images_for_documents
*/
start_document_to_image_conversion: function() {
if (this.get('destroyed')) {
return;
}
Y.io(AJAXBASE, {
method: 'get',
context: this,
@@ -610,9 +614,6 @@ EDITOR.prototype = {
* @method update_page_load_progress
*/
update_page_load_progress: function() {
if (this.get('destroyed')) {
return;
}
var checkconversionstatus,
ajax_error_total = 0,
progressbar = this.get_dialogue_element(SELECTOR.PROGRESSBARCONTAINER + ' .bar');
@@ -635,9 +636,6 @@ EDITOR.prototype = {
},
on: {
success: function(tid, response) {
if (this.get('destroyed')) {
return;
}
ajax_error_total = 0;
var progress = 0;
@@ -659,9 +657,6 @@ EDITOR.prototype = {
}
},
failure: function(tid, response) {
if (this.get('destroyed')) {
return;
}
ajax_error_total = ajax_error_total + 1;
// We only continue on error if the all pages were not generated,
// and if the ajax call did not produce 5 errors in the row.
@@ -694,9 +689,6 @@ EDITOR.prototype = {
* @return {object}
*/
handle_response_data: function(response) {
if (this.get('destroyed')) {
return;
}
var data;
try {
data = Y.JSON.parse(response.responseText);
@@ -1181,9 +1173,6 @@ EDITOR.prototype = {
* @method save_current_page
*/
save_current_page: function() {
if (this.get('destroyed')) {
return;
}
var ajaxurl = AJAXBASE,
config;
@@ -1318,7 +1307,9 @@ EDITOR.prototype = {
}
page = this.pages[this.currentpage];
this.loadingicon.hide();
if (this.loadingicon) {
this.loadingicon.hide();
}
drawingcanvas.setStyle('backgroundImage', 'url("' + page.url + '")');
drawingcanvas.setStyle('width', page.width + 'px');
drawingcanvas.setStyle('height', page.height + 'px');
@@ -1522,10 +1513,6 @@ M.assignfeedback_editpdf.editor = M.assignfeedback_editpdf.editor || {};
* @param {Object} params
*/
M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || function(params) {
if (typeof M.assignfeedback_editpdf.instance !== 'undefined') {
M.assignfeedback_editpdf.instance.destroy();
}
M.assignfeedback_editpdf.instance = new EDITOR(params);
return M.assignfeedback_editpdf.instance;
};
@@ -44,6 +44,7 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdf/ajax.php',
UNSAVEDCHANGESDIV: '.assignfeedback_editpdf_unsavedchanges',
UNSAVEDCHANGESINPUT: 'input[name="assignfeedback_editpdf_haschanges"]',
STAMPSBUTTON: '.currentstampbutton',
USERINFOREGION: '[data-region="user-info"]',
DIALOGUE: '.' + CSS.DIALOGUE
},
SELECTEDBORDERCOLOUR = 'rgba(200, 200, 255, 0.9)',