Skip to content
Browse files

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

  • Loading branch information...
1 parent bbcf8da commit 1989bb2ed8e09a0816eb3a8c981dbe106a061c30 @rwijaya rwijaya committed Feb 12, 2013
Showing with 17 additions and 5 deletions.
  1. +3 −2 enrol/locallib.php
  2. +3 −1 enrol/manual/ajax.php
  3. +11 −2 enrol/manual/yui/quickenrolment/quickenrolment.js
View
5 enrol/locallib.php
@@ -272,9 +272,10 @@ public function get_other_users($sort, $direction='ASC', $page=0, $perpage=25) {
* @param bool $searchanywhere
* @param int $page Defaults to 0
* @param int $perpage Defaults to 25
+ * @param int $addedenrollment Defaults to 0
* @return array Array(totalusers => int, users => array)
*/
- public function get_potential_users($enrolid, $search='', $searchanywhere=false, $page=0, $perpage=25) {
+ public function get_potential_users($enrolid, $search='', $searchanywhere=false, $page=0, $perpage=25, $addedenrollment=0) {
global $DB, $CFG;
// Add some additional sensible conditions
@@ -312,7 +313,7 @@ public function get_potential_users($enrolid, $search='', $searchanywhere=false,
$order = ' ORDER BY u.lastname ASC, u.firstname ASC';
$params['enrolid'] = $enrolid;
$totalusers = $DB->count_records_sql($countfields . $sql, $params);
- $availableusers = $DB->get_records_sql($fields . $sql . $order, $params, $page*$perpage, $perpage);
+ $availableusers = $DB->get_records_sql($fields . $sql . $order, $params, ($page*$perpage) - $addedenrollment, $perpage);
return array('totalusers'=>$totalusers, 'users'=>$availableusers);
}
View
4 enrol/manual/ajax.php
@@ -67,7 +67,9 @@
$enrolid = required_param('enrolid', PARAM_INT);
$search = optional_param('search', '', PARAM_RAW);
$page = optional_param('page', 0, PARAM_INT);
- $outcome->response = $manager->get_potential_users($enrolid, $search, true, $page);
+ $addedenrollment = optional_param('enrolcount', 0, PARAM_INT);
+ $perpage = 25; // This value is hard-coded to 25 in quickenrolment.js
+ $outcome->response = $manager->get_potential_users($enrolid, $search, true, $page, $perpage, $addedenrollment);
$extrafields = get_extra_user_fields($context);
foreach ($outcome->response['users'] as &$user) {
$user->picture = $OUTPUT->user_picture($user);
View
13 enrol/manual/yui/quickenrolment/quickenrolment.js
@@ -22,7 +22,8 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
DEFAULTDURATION : 'defaultDuration',
ASSIGNABLEROLES : 'assignableRoles',
DISABLEGRADEHISTORY : 'disableGradeHistory',
- RECOVERGRADESDEFAULT : 'recoverGradesDefault'
+ RECOVERGRADESDEFAULT : 'recoverGradesDefault',
+ ENROLCOUNT : 'enrolCount'
};
/** CSS classes for nodes in structure **/
var CSS = {
@@ -304,6 +305,8 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
params['action'] = 'searchusers';
params['search'] = this.get(UEP.SEARCH).get('value');
params['page'] = this.get(UEP.PAGE);
+ params['enrolcount'] = this.get(UEP.ENROLCOUNT);
+
if (this.get(UEP.MULTIPLE)) {
alert('oh no there are multiple');
} else {
@@ -415,6 +418,8 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
args.userNode.addClass(CSS.ENROLLED);
args.userNode.one('.'+CSS.ENROL).remove();
this.set(UEP.REQUIREREFRESH, true);
+ var countenrol = this.get(UEP.ENROLCOUNT)+1;
+ this.set(UEP.ENROLCOUNT, countenrol);
}
} catch (e) {
new M.core.exception(e);
@@ -527,7 +532,11 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
},
recoverGradesDefault : {
value : ''
- }
+ },
+ enrolCount : {
+ value : 0,
+ validator : Y.Lang.isNumber
+ }
}
});
Y.augment(USERENROLLER, Y.EventTarget);

0 comments on commit 1989bb2

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