Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-37396 User Enrollment: fixed missing user from enrolment sub-menu

  • Loading branch information...
commit 1989bb2ed8e09a0816eb3a8c981dbe106a061c30 1 parent bbcf8da
rwijaya rwijaya authored
5 enrol/locallib.php
@@ -272,9 +272,10 @@ public function get_other_users($sort, $direction='ASC', $page=0, $perpage=25) {
272 272 * @param bool $searchanywhere
273 273 * @param int $page Defaults to 0
274 274 * @param int $perpage Defaults to 25
  275 + * @param int $addedenrollment Defaults to 0
275 276 * @return array Array(totalusers => int, users => array)
276 277 */
277   - public function get_potential_users($enrolid, $search='', $searchanywhere=false, $page=0, $perpage=25) {
  278 + public function get_potential_users($enrolid, $search='', $searchanywhere=false, $page=0, $perpage=25, $addedenrollment=0) {
278 279 global $DB, $CFG;
279 280
280 281 // Add some additional sensible conditions
@@ -312,7 +313,7 @@ public function get_potential_users($enrolid, $search='', $searchanywhere=false,
312 313 $order = ' ORDER BY u.lastname ASC, u.firstname ASC';
313 314 $params['enrolid'] = $enrolid;
314 315 $totalusers = $DB->count_records_sql($countfields . $sql, $params);
315   - $availableusers = $DB->get_records_sql($fields . $sql . $order, $params, $page*$perpage, $perpage);
  316 + $availableusers = $DB->get_records_sql($fields . $sql . $order, $params, ($page*$perpage) - $addedenrollment, $perpage);
316 317 return array('totalusers'=>$totalusers, 'users'=>$availableusers);
317 318 }
318 319
4 enrol/manual/ajax.php
@@ -67,7 +67,9 @@
67 67 $enrolid = required_param('enrolid', PARAM_INT);
68 68 $search = optional_param('search', '', PARAM_RAW);
69 69 $page = optional_param('page', 0, PARAM_INT);
70   - $outcome->response = $manager->get_potential_users($enrolid, $search, true, $page);
  70 + $addedenrollment = optional_param('enrolcount', 0, PARAM_INT);
  71 + $perpage = 25; // This value is hard-coded to 25 in quickenrolment.js
  72 + $outcome->response = $manager->get_potential_users($enrolid, $search, true, $page, $perpage, $addedenrollment);
71 73 $extrafields = get_extra_user_fields($context);
72 74 foreach ($outcome->response['users'] as &$user) {
73 75 $user->picture = $OUTPUT->user_picture($user);
13 enrol/manual/yui/quickenrolment/quickenrolment.js
@@ -22,7 +22,8 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
22 22 DEFAULTDURATION : 'defaultDuration',
23 23 ASSIGNABLEROLES : 'assignableRoles',
24 24 DISABLEGRADEHISTORY : 'disableGradeHistory',
25   - RECOVERGRADESDEFAULT : 'recoverGradesDefault'
  25 + RECOVERGRADESDEFAULT : 'recoverGradesDefault',
  26 + ENROLCOUNT : 'enrolCount'
26 27 };
27 28 /** CSS classes for nodes in structure **/
28 29 var CSS = {
@@ -304,6 +305,8 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
304 305 params['action'] = 'searchusers';
305 306 params['search'] = this.get(UEP.SEARCH).get('value');
306 307 params['page'] = this.get(UEP.PAGE);
  308 + params['enrolcount'] = this.get(UEP.ENROLCOUNT);
  309 +
307 310 if (this.get(UEP.MULTIPLE)) {
308 311 alert('oh no there are multiple');
309 312 } else {
@@ -415,6 +418,8 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
415 418 args.userNode.addClass(CSS.ENROLLED);
416 419 args.userNode.one('.'+CSS.ENROL).remove();
417 420 this.set(UEP.REQUIREREFRESH, true);
  421 + var countenrol = this.get(UEP.ENROLCOUNT)+1;
  422 + this.set(UEP.ENROLCOUNT, countenrol);
418 423 }
419 424 } catch (e) {
420 425 new M.core.exception(e);
@@ -527,7 +532,11 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
527 532 },
528 533 recoverGradesDefault : {
529 534 value : ''
530   - }
  535 + },
  536 + enrolCount : {
  537 + value : 0,
  538 + validator : Y.Lang.isNumber
  539 + }
531 540 }
532 541 });
533 542 Y.augment(USERENROLLER, Y.EventTarget);

0 comments on commit 1989bb2

Please sign in to comment.
Something went wrong with that request. Please try again.