diff --git a/course/lib.php b/course/lib.php index 4955bd382a1..3344e64de91 100644 --- a/course/lib.php +++ b/course/lib.php @@ -3768,7 +3768,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."