MDL-63293 enrol_manual: observe user paging config in enrol dialog.
authorPaul Holden <pholden@greenhead.ac.uk>
Thu, 28 Mar 2019 12:58:43 +0000 (12:58 +0000)
committerPaul Holden <paulh@moodle.com>
Sun, 15 Sep 2019 20:48:03 +0000 (21:48 +0100)
enrol/manual/amd/build/form-potential-user-selector.min.js
enrol/manual/amd/build/form-potential-user-selector.min.js.map
enrol/manual/amd/src/form-potential-user-selector.js
enrol/manual/classes/enrol_users_form.php
enrol/manual/tests/behat/quickenrolment.feature

index 3ec5e2c..d5262fb 100644 (file)
Binary files a/enrol/manual/amd/build/form-potential-user-selector.min.js and b/enrol/manual/amd/build/form-potential-user-selector.min.js differ
index d4a96f3..6b9b32d 100644 (file)
Binary files a/enrol/manual/amd/build/form-potential-user-selector.min.js.map and b/enrol/manual/amd/build/form-potential-user-selector.min.js.map differ
index 7fac602..ab38b1e 100644 (file)
@@ -25,9 +25,6 @@
 
 define(['jquery', 'core/ajax', 'core/templates', 'core/str'], function($, Ajax, Templates, Str) {
 
-    /** @var {Number} Maximum number of users to show. */
-    var MAXUSERS = 100;
-
     return /** @alias module:enrol_manual/form-potential-user-selector */ {
 
         processResults: function(selector, results) {
@@ -57,6 +54,10 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], function($, Ajax,
             if (typeof enrolid === "undefined") {
                 enrolid = '';
             }
+            var perpage = $(selector).attr('perpage');
+            if (typeof perpage === "undefined") {
+                perpage = 100;
+            }
 
             promise = Ajax.call([{
                 methodname: 'core_enrol_get_potential_users',
@@ -66,7 +67,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], function($, Ajax,
                     search: query,
                     searchanywhere: true,
                     page: 0,
-                    perpage: MAXUSERS + 1
+                    perpage: perpage + 1
                 }
             }]);
 
@@ -74,7 +75,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], function($, Ajax,
                 var promises = [],
                     i = 0;
 
-                if (results.length <= MAXUSERS) {
+                if (results.length <= perpage) {
                     // Render the label.
                     $.each(results, function(index, user) {
                         var ctx = user,
@@ -101,7 +102,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], function($, Ajax,
                     });
 
                 } else {
-                    return Str.get_string('toomanyuserstoshow', 'core', '>' + MAXUSERS).then(function(toomanyuserstoshow) {
+                    return Str.get_string('toomanyuserstoshow', 'core', '>' + perpage).then(function(toomanyuserstoshow) {
                         success(toomanyuserstoshow);
                         return;
                     });
index b7fa663..171aa26 100644 (file)
@@ -92,6 +92,7 @@ class enrol_manual_enrol_users_form extends moodleform {
             'multiple' => true,
             'courseid' => $course->id,
             'enrolid' => $instance->id,
+            'perpage' => $CFG->maxusersperpage,
             'userfields' => implode(',', get_extra_user_fields($context))
         );
         $mform->addElement('autocomplete', 'userlist', get_string('selectusers', 'enrol_manual'), array(), $options);
index e44169e..2208c7c 100644 (file)
@@ -154,6 +154,16 @@ Feature: Teacher can search and enrol users one by one into the course
     And I click on ".form-autocomplete-downarrow" "css_element" in the "Select users" "form_row"
     Then I should see "Too many users (>100) to show"
 
+  @javascript
+  Scenario: Changing the Maximum users per page setting affects the enrolment pop-up.
+    Given the following config values are set as admin:
+      | maxusersperpage | 5 |
+    And I navigate to course participants
+    And I press "Enrol users"
+    When I set the field "Select users" to "student00"
+    And I click on ".form-autocomplete-downarrow" "css_element" in the "Select users" "form_row"
+    Then I should see "Too many users (>5) to show"
+
   @javascript
   Scenario: Change the Show user identity setting affects the enrolment pop-up.
     Given I log out