From a069c3f76a3a5ab0d617c3460e5de5523e6d9622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Sat, 24 Nov 2012 11:11:37 +0100 Subject: [PATCH] MDL-35899 fix cohort sorting in enrol UI --- enrol/cohort/ajax.php | 2 ++ enrol/cohort/yui/quickenrolment/quickenrolment.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/enrol/cohort/ajax.php b/enrol/cohort/ajax.php index 42cc37e5aa7..e987f87fb37 100644 --- a/enrol/cohort/ajax.php +++ b/enrol/cohort/ajax.php @@ -77,6 +77,8 @@ switch ($action) { $offset = optional_param('offset', 0, PARAM_INT); $search = optional_param('search', '', PARAM_RAW); $outcome->response = enrol_cohort_search_cohorts($manager, $offset, 25, $search); + // Some browsers reorder collections by key. + $outcome->response['cohorts'] = array_values($outcome->response['cohorts']); break; case 'enrolcohort': require_capability('moodle/course:enrolconfig', $context); diff --git a/enrol/cohort/yui/quickenrolment/quickenrolment.js b/enrol/cohort/yui/quickenrolment/quickenrolment.js index 52727e64ecc..7dc8ffdec04 100644 --- a/enrol/cohort/yui/quickenrolment/quickenrolment.js +++ b/enrol/cohort/yui/quickenrolment/quickenrolment.js @@ -229,7 +229,7 @@ YUI.add('moodle-enrol_cohort-quickenrolment', function(Y) { var rawcohorts = response.cohorts; var cohorts = [], i=0; for (i in rawcohorts) { - cohorts[rawcohorts[i].cohortid] = new COHORT(rawcohorts[i]); + cohorts[i] = new COHORT(rawcohorts[i]); } this.set(COHORTS, cohorts); },