mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 05:28:30 +01:00
Merge branch 'MDL-80550' of https://github.com/paulholden/moodle
This commit is contained in:
commit
736d102dda
@ -402,7 +402,7 @@ class core_cohort_external extends external_api {
|
||||
$results = cohort_get_cohorts($context->id, $limitfrom, $limitnum, $query);
|
||||
$results = $results['cohorts'];
|
||||
if (!$context instanceof context_system) {
|
||||
$results = array_merge($results, cohort_get_available_cohorts($context, COHORT_ALL, $limitfrom, $limitnum, $query));
|
||||
$results = $results + cohort_get_available_cohorts($context, COHORT_ALL, $limitfrom, $limitnum, $query);
|
||||
}
|
||||
} else if ($includes == 'all') {
|
||||
$results = cohort_get_all_cohorts($limitfrom, $limitnum, $query);
|
||||
@ -414,7 +414,7 @@ class core_cohort_external extends external_api {
|
||||
$cohorts = array();
|
||||
|
||||
if (!empty($results)) {
|
||||
$cohortids = array_keys($results);
|
||||
$cohortids = array_column($results, 'id');
|
||||
$customfieldsdata = self::get_custom_fields_data($cohortids);
|
||||
}
|
||||
|
||||
|
@ -716,11 +716,16 @@ class externallib_test extends externallib_advanced_testcase {
|
||||
$this->assertCount(1, $result['cohorts']);
|
||||
$this->assertEquals('Cohortsearch 4', $result['cohorts'][$cohort4->id]->name);
|
||||
|
||||
$result = core_cohort_external::search_cohorts("Cohortsearch 4", $syscontext, 'parents');
|
||||
// A user with permissions in the system, searching category context.
|
||||
$result = core_cohort_external::search_cohorts("Cohortsearch 4", $catcontext, 'parents');
|
||||
$this->assertCount(1, $result['cohorts']);
|
||||
$this->assertEquals('Cohortsearch 4', $result['cohorts'][$cohort4->id]->name);
|
||||
$this->assertIsArray($result['cohorts'][$cohort4->id]->customfields);
|
||||
$this->assertCount(2, $result['cohorts'][$cohort4->id]->customfields);
|
||||
|
||||
$this->assertEqualsCanonicalizing([
|
||||
'Test value 1',
|
||||
'Test value 2',
|
||||
], array_column($result['cohorts'][$cohort4->id]->customfields, 'value'));
|
||||
|
||||
$actual = [];
|
||||
foreach ($result['cohorts'][$cohort4->id]->customfields as $customfield) {
|
||||
$this->assertArrayHasKey('name', $customfield);
|
||||
@ -730,8 +735,6 @@ class externallib_test extends externallib_advanced_testcase {
|
||||
$this->assertArrayHasKey('value', $customfield);
|
||||
$actual[$customfield['shortname']] = $customfield;
|
||||
}
|
||||
$this->assertEquals('Test value 1', $actual['testfield1']['value']);
|
||||
$this->assertEquals('Test value 2', $actual['testfield2']['value']);
|
||||
|
||||
// A user with permissions in the category.
|
||||
$this->setUser($catcreator);
|
||||
|
Loading…
x
Reference in New Issue
Block a user