mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 10:56:56 +02:00
Merge branch 'MDL-43252-m26' of git://github.com/sammarshallou/moodle into MOODLE_26_STABLE
This commit is contained in:
commit
9f00dabf86
2 changed files with 39 additions and 1 deletions
|
@ -993,7 +993,13 @@ function groups_cache_groupdata($courseid, cache $cache = null) {
|
|||
|
||||
if (!empty($groupings)) {
|
||||
// Finally get the mappings between the two.
|
||||
$mappings = $DB->get_records_list('groupings_groups', 'groupingid', array_keys($groupings), '', 'id,groupingid,groupid');
|
||||
list($insql, $params) = $DB->get_in_or_equal(array_keys($groupings));
|
||||
$mappings = $DB->get_records_sql("
|
||||
SELECT gg.id, gg.groupingid, gg.groupid
|
||||
FROM {groupings_groups} gg
|
||||
JOIN {groups} g ON g.id = gg.groupid
|
||||
WHERE gg.groupingid $insql
|
||||
ORDER BY g.name ASC", $params);
|
||||
} else {
|
||||
$mappings = array();
|
||||
}
|
||||
|
|
|
@ -735,4 +735,36 @@ class core_grouplib_testcase extends advanced_testcase {
|
|||
groups_allgroups_course_menu($course, 'someurl.php', true, 256);
|
||||
$this->assertEquals($group1->id, $SESSION->activegroup[$course->id][VISIBLEGROUPS][$course->defaultgroupingid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* This unit test checks that groups_get_all_groups returns groups in
|
||||
* alphabetical order even if they are in a grouping.
|
||||
*/
|
||||
public function test_groups_ordering() {
|
||||
$generator = $this->getDataGenerator();
|
||||
$this->resetAfterTest();
|
||||
|
||||
// Create a course category and course.
|
||||
$cat = $generator->create_category(array('parent' => 0));
|
||||
$course = $generator->create_course(array('category' => $cat->id));
|
||||
$grouping = $generator->create_grouping(array('courseid' => $course->id, 'name' => 'Grouping'));
|
||||
|
||||
// Create groups in reverse order.
|
||||
$group2 = $generator->create_group(array('courseid' => $course->id, 'name' => 'Group 2'));
|
||||
$group1 = $generator->create_group(array('courseid' => $course->id, 'name' => 'Group 1'));
|
||||
|
||||
// Assign the groups to the grouping in reverse order.
|
||||
$this->assertTrue(groups_assign_grouping($grouping->id, $group2->id));
|
||||
$this->assertTrue(groups_assign_grouping($grouping->id, $group1->id));
|
||||
|
||||
// Get all groups and check they are alphabetical.
|
||||
$groups = array_values(groups_get_all_groups($course->id, 0));
|
||||
$this->assertEquals('Group 1', $groups[0]->name);
|
||||
$this->assertEquals('Group 2', $groups[1]->name);
|
||||
|
||||
// Now check the same is true when accessed by grouping.
|
||||
$groups = array_values(groups_get_all_groups($course->id, 0, $grouping->id));
|
||||
$this->assertEquals('Group 1', $groups[0]->name);
|
||||
$this->assertEquals('Group 2', $groups[1]->name);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue