mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-67410 Enrolments: Casting the perpage parameter to INT
On the course's Participants page, when manually enrolling users the AJAX call might get excesively slow, due to the treatment of the perpage parameter as a string, which gets concatenated with the number 1 (perpage: parseInt(perpage) + 1) instead of performing a numerical addition. If there are for example 1500+ users on the site, the method core_enrol_get_potential_users will be executed with a value of 15001 for the perpage parameter, rendering painfully slow.
This commit is contained in:
parent
6aacd8d6d1
commit
4a4a73467c
@ -1,2 +1,2 @@
|
||||
define ("enrol_manual/form-potential-user-selector",["jquery","core/ajax","core/templates","core/str"],function(a,b,c,d){return{processResults:function processResults(b,c){var d=[];if(a.isArray(c)){a.each(c,function(a,b){d.push({value:b.id,label:b._label})});return d}else{return c}},transport:function transport(e,f,g,h){var i,j=a(e).attr("courseid"),k=a(e).attr("userfields").split(",");if("undefined"==typeof j){j="1"}var l=a(e).attr("enrolid");if("undefined"==typeof l){l=""}var m=a(e).attr("perpage");if("undefined"==typeof m){m=100}i=b.call([{methodname:"core_enrol_get_potential_users",args:{courseid:j,enrolid:l,search:f,searchanywhere:!0,page:0,perpage:m+1}}]);i[0].then(function(b){var e=[],f=0;if(b.length<=m){a.each(b,function(b,d){var f=d,g=[];a.each(k,function(a,b){if("undefined"!=typeof d[b]&&""!==d[b]){f.hasidentity=!0;g.push(d[b])}});f.identity=g.join(", ");e.push(c.render("enrol_manual/form-user-selector-suggestion",f))});return a.when.apply(a.when,e).then(function(){var c=arguments;a.each(b,function(a,b){b._label=c[f];f++});g(b)})}else{return d.get_string("toomanyuserstoshow","core",">"+m).then(function(a){g(a)})}}).fail(h)}}});
|
||||
define ("enrol_manual/form-potential-user-selector",["jquery","core/ajax","core/templates","core/str"],function(a,b,c,d){return{processResults:function processResults(b,c){var d=[];if(a.isArray(c)){a.each(c,function(a,b){d.push({value:b.id,label:b._label})});return d}else{return c}},transport:function transport(e,f,g,h){var i,j=a(e).attr("courseid"),k=a(e).attr("userfields").split(",");if("undefined"==typeof j){j="1"}var l=a(e).attr("enrolid");if("undefined"==typeof l){l=""}var m=parseInt(a(e).attr("perpage"));if(isNaN(m)){m=100}i=b.call([{methodname:"core_enrol_get_potential_users",args:{courseid:j,enrolid:l,search:f,searchanywhere:!0,page:0,perpage:m+1}}]);i[0].then(function(b){var e=[],f=0;if(b.length<=m){a.each(b,function(b,d){var f=d,g=[];a.each(k,function(a,b){if("undefined"!=typeof d[b]&&""!==d[b]){f.hasidentity=!0;g.push(d[b])}});f.identity=g.join(", ");e.push(c.render("enrol_manual/form-user-selector-suggestion",f))});return a.when.apply(a.when,e).then(function(){var c=arguments;a.each(b,function(a,b){b._label=c[f];f++});g(b)})}else{return d.get_string("toomanyuserstoshow","core",">"+m).then(function(a){g(a)})}}).fail(h)}}});
|
||||
//# sourceMappingURL=form-potential-user-selector.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@ -54,8 +54,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], function($, Ajax,
|
||||
if (typeof enrolid === "undefined") {
|
||||
enrolid = '';
|
||||
}
|
||||
var perpage = $(selector).attr('perpage');
|
||||
if (typeof perpage === "undefined") {
|
||||
var perpage = parseInt($(selector).attr('perpage'));
|
||||
if (isNaN(perpage)) {
|
||||
perpage = 100;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user