1 |
efrain |
1 |
@core @core_course
|
|
|
2 |
Feature: Restricting access to course lists
|
|
|
3 |
In order to provide more targeted content
|
|
|
4 |
As a Moodle Administrator
|
|
|
5 |
I need to be able to give/revoke capabilities to view list of courses
|
|
|
6 |
|
|
|
7 |
Background:
|
|
|
8 |
Given the following "categories" exist:
|
|
|
9 |
| name | category | idnumber |
|
|
|
10 |
| Science category | 0 | SCI |
|
|
|
11 |
| English category | 0 | ENG |
|
|
|
12 |
| Other category | 0 | MISC |
|
|
|
13 |
And the following "courses" exist:
|
|
|
14 |
| fullname | shortname | category |
|
|
|
15 |
| Biology Y1 | BIO1 | SCI |
|
|
|
16 |
| Biology Y2 | BI02 | SCI |
|
|
|
17 |
| English Y1 | ENG1 | ENG |
|
|
|
18 |
| English Y2 | ENG2 | ENG |
|
|
|
19 |
| Humanities Y1 | HUM2 | MISC |
|
|
|
20 |
And the following "users" exist:
|
|
|
21 |
| username | firstname | lastname | email |
|
|
|
22 |
| user0 | User | Z | user0@example.com |
|
|
|
23 |
| userb | User | B | userb@example.com |
|
|
|
24 |
| usere | User | E | usere@example.com |
|
|
|
25 |
And the following "roles" exist:
|
|
|
26 |
| name | shortname | description | archetype |
|
|
|
27 |
| Category viewer | coursebrowse | My custom role 1 | |
|
|
|
28 |
And the following "role capability" exist:
|
|
|
29 |
| role | moodle/category:viewcourselist |
|
|
|
30 |
| user | prevent |
|
|
|
31 |
| guest | prevent |
|
|
|
32 |
| coursebrowse | allow |
|
|
|
33 |
Given I log in as "admin"
|
|
|
34 |
And I am on site homepage
|
|
|
35 |
And I turn editing mode on
|
|
|
36 |
And the following config values are set as admin:
|
|
|
37 |
| unaddableblocks | | theme_boost|
|
|
|
38 |
And I add the "Navigation" block if not present
|
|
|
39 |
And I log out
|
|
|
40 |
And the following "role assigns" exist:
|
|
|
41 |
| user | role | contextlevel | reference |
|
|
|
42 |
| usere | coursebrowse | Category | ENG |
|
|
|
43 |
| userb | coursebrowse | Category | ENG |
|
|
|
44 |
| userb | coursebrowse | Category | SCI |
|
|
|
45 |
|
|
|
46 |
Scenario: Browse courses as a user without any browse capability
|
|
|
47 |
When I log in as "user0"
|
|
|
48 |
And I am on site homepage
|
|
|
49 |
Then I should not see "Available courses"
|
|
|
50 |
And "Courses" "link" should not exist in the "Navigation" "block"
|
|
|
51 |
And I log out
|
|
|
52 |
|
|
|
53 |
Scenario: Browse own courses as a user without any browse capability
|
|
|
54 |
Given the following "course enrolments" exist:
|
|
|
55 |
| user | course | role |
|
|
|
56 |
| user0 | BIO1 | student |
|
|
|
57 |
When I log in as "user0"
|
|
|
58 |
And I am on site homepage
|
|
|
59 |
And I should see "Available courses"
|
|
|
60 |
And I should see "Biology Y1"
|
|
|
61 |
And "Courses" "link" should not exist in the "Navigation" "block"
|
|
|
62 |
And I log out
|
|
|
63 |
|
|
|
64 |
Scenario: Browse courses as a user who has access to only one category
|
|
|
65 |
When I log in as "usere"
|
|
|
66 |
And I am on site homepage
|
|
|
67 |
Then I should see "Available courses"
|
|
|
68 |
And I should see "English Y1"
|
|
|
69 |
And I should see "English Y2"
|
|
|
70 |
And I should not see "Biology"
|
|
|
71 |
And I should not see "Humanities"
|
|
|
72 |
And I click on "Courses" "link" in the "Navigation" "block"
|
|
|
73 |
And "English category" "text" should exist in the ".breadcrumb" "css_element"
|
|
|
74 |
And I should see "English Y1"
|
|
|
75 |
And I should see "English Y2"
|
|
|
76 |
And I should not see "Biology"
|
|
|
77 |
And I should not see "Humanities"
|
|
|
78 |
And I should not see "Other category"
|
|
|
79 |
And I follow "English Y2"
|
|
|
80 |
And I should see "You cannot enrol yourself in this course."
|
|
|
81 |
And I log out
|
|
|
82 |
|
|
|
83 |
Scenario: Browse courses as a user who has access to several but not all categories
|
|
|
84 |
When I log in as "userb"
|
|
|
85 |
And I am on site homepage
|
|
|
86 |
Then I should see "Available courses"
|
|
|
87 |
And I should see "English Y1"
|
|
|
88 |
And I should see "English Y2"
|
|
|
89 |
And I should see "Biology"
|
|
|
90 |
And I should not see "Humanities"
|
|
|
91 |
And I click on "Courses" "link" in the "Navigation" "block"
|
|
|
92 |
# And "category" "text" should not exist in the ".breadcrumb" "css_element"
|
|
|
93 |
And I should see "Science category"
|
|
|
94 |
And I should see "English category"
|
|
|
95 |
And I should not see "Other category"
|
|
|
96 |
And I follow "Science category"
|
|
|
97 |
And I should see "Biology Y2"
|
|
|
98 |
And I should not see "English Y1"
|
|
|
99 |
And the "Course categories" select box should contain "Science category"
|
|
|
100 |
And the "Course categories" select box should contain "English category"
|
|
|
101 |
And the "Course categories" select box should not contain "Other category"
|
|
|
102 |
And I follow "Biology Y1"
|
|
|
103 |
And I should see "You cannot enrol yourself in this course."
|
|
|
104 |
And I log out
|
|
|
105 |
|
|
|
106 |
@javascript
|
|
|
107 |
Scenario: Browse courses as a user who has a disabled enrolment in them
|
|
|
108 |
Given the following "course enrolments" exist:
|
|
|
109 |
| user | course | role | status |
|
|
|
110 |
| usere | ENG1 | student | 1 |
|
|
|
111 |
When I am on the "ENG1" course page logged in as usere
|
|
|
112 |
Then I should see "You cannot enrol yourself in this course."
|