Merge branch 'MDL-87657-501' of https://github.com/paulholden/moodle into MOODLE_501_STABLE

This commit is contained in:
Huong Nguyen
2026-03-05 09:22:44 +07:00
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -363,7 +363,7 @@ function cohort_can_view_cohort($cohortorid, $currentcontext) {
$cohort = $cohortorid;
}
if ($cohort && in_array($cohort->contextid, $currentcontext->get_parent_context_ids())) {
if ($cohort && in_array($cohort->contextid, $currentcontext->get_parent_context_ids(true))) {
if ($cohort->visible) {
return true;
}
+15
View File
@@ -943,6 +943,21 @@ final class lib_test extends \advanced_testcase {
}
}
/**
* Test whether user can view cohort
*
* @covers ::cohort_can_view_cohort
*/
public function test_cohort_can_view_cohort(): void {
$this->resetAfterTest();
$this->setAdminUser();
$context = \context_system::instance();
$cohort = $this->getDataGenerator()->create_cohort(['contextid' => $context->id]);
$this->assertTrue(cohort_can_view_cohort($cohort, $context));
}
/**
* Test the behaviour of cohort_get_cohort().
*