Permalink
Browse files

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

  • Loading branch information...
1 parent 1dd6835 commit 4be3ed4b3d52a7e8e31e12bea8404d181b81121f Rossiani Wijaya committed Feb 12, 2013
Showing with 19 additions and 6 deletions.
  1. +6 −4 enrol/locallib.php
  2. +3 −1 enrol/manual/ajax.php
  3. +10 −1 enrol/manual/yui/quickenrolment/quickenrolment.js
View
@@ -318,19 +318,20 @@ protected function get_basic_search_conditions($search, $searchanywhere) {
* @param array $params query parameters.
* @param int $page which page number of the results to show.
* @param int $perpage number of users per page.
+ * @param int $addedenrollment number of users added to enrollment.
* @return array with two elememts:
* int total number of users matching the search.
* array of user objects returned by the query.
*/
- protected function execute_search_queries($search, $fields, $countfields, $sql, array $params, $page, $perpage) {
+ protected function execute_search_queries($search, $fields, $countfields, $sql, array $params, $page, $perpage, $addedenrollment=0) {
global $DB, $CFG;
list($sort, $sortparams) = users_order_by_sql('u', $search, $this->get_context());
$order = ' ORDER BY ' . $sort;
$totalusers = $DB->count_records_sql($countfields . $sql, $params);
$availableusers = $DB->get_records_sql($fields . $sql . $order,
- array_merge($params, $sortparams), $page*$perpage, $perpage);
+ array_merge($params, $sortparams), ($page*$perpage) - $addedenrollment, $perpage);
return array('totalusers' => $totalusers, 'users' => $availableusers);
}
@@ -344,9 +345,10 @@ protected function execute_search_queries($search, $fields, $countfields, $sql,
* @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;
list($ufields, $params, $wherecondition) = $this->get_basic_search_conditions($search, $searchanywhere);
@@ -359,7 +361,7 @@ public function get_potential_users($enrolid, $search='', $searchanywhere=false,
AND ue.id IS NULL";
$params['enrolid'] = $enrolid;
- return $this->execute_search_queries($search, $fields, $countfields, $sql, $params, $page, $perpage);
+ return $this->execute_search_queries($search, $fields, $countfields, $sql, $params, $page, $perpage, $addedenrollment);
}
/**
View
@@ -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, $searchanywhere, $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, $searchanywhere, $page, $perpage, $addedenrollment);
$extrafields = get_extra_user_fields($context);
foreach ($outcome->response['users'] as &$user) {
$user->picture = $OUTPUT->user_picture($user);
@@ -23,7 +23,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 = {
@@ -309,6 +310,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 {
@@ -420,6 +423,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);
@@ -532,6 +537,10 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
},
recoverGradesDefault : {
value : ''
+ },
+ enrolCount : {
+ value : 0,
+ validator : Y.Lang.isNumber
}
}
});

0 comments on commit 4be3ed4

Please sign in to comment.