From 58963baba465f5b9ba72806ac8a38a8e2c8d2016 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Wed, 12 Jul 2023 14:03:59 +0100 Subject: [PATCH] MDL-77645 course: ensure active enrolments are considered for drawer. Otherwise the enrolment index page tries to load the course index drawer, which doesn't exist at this point and triggers exceptions in the editor module. Co-authored-by: Tim Volckmann --- course/lib.php | 2 +- course/tests/behat/course_browsing.feature | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/course/lib.php b/course/lib.php index 89b3c638997..407c4c6addd 100644 --- a/course/lib.php +++ b/course/lib.php @@ -3846,7 +3846,7 @@ function core_course_drawer(): string { } // Show course index to users can access the course only. - if (!can_access_course($PAGE->course)) { + if (!can_access_course($PAGE->course, null, '', true)) { return ''; } diff --git a/course/tests/behat/course_browsing.feature b/course/tests/behat/course_browsing.feature index 2cacc8c8661..a8b375bd31d 100644 --- a/course/tests/behat/course_browsing.feature +++ b/course/tests/behat/course_browsing.feature @@ -102,3 +102,11 @@ Feature: Restricting access to course lists And I follow "Biology Y1" And I should see "You cannot enrol yourself in this course." And I log out + + @javascript + Scenario: Browse courses as a user who has a disabled enrolment in them + Given the following "course enrolments" exist: + | user | course | role | status | + | usere | ENG1 | student | 1 | + When I am on the "ENG1" course page logged in as usere + Then I should see "You cannot enrol yourself in this course."