1 |
efrain |
1 |
@availability @availability_profile
|
|
|
2 |
Feature: availability_profile
|
|
|
3 |
In order to control student access to activities
|
|
|
4 |
As a teacher
|
|
|
5 |
I need to set profile conditions which prevent student access
|
|
|
6 |
|
|
|
7 |
Background:
|
|
|
8 |
Given the following "courses" exist:
|
|
|
9 |
| fullname | shortname | format | enablecompletion |
|
|
|
10 |
| Course 1 | C1 | topics | 1 |
|
|
|
11 |
And the following "users" exist:
|
|
|
12 |
| username | email |
|
|
|
13 |
| teacher1 | t@example.com |
|
|
|
14 |
| student1 | s@example.com |
|
|
|
15 |
And the following "course enrolments" exist:
|
|
|
16 |
| user | course | role |
|
|
|
17 |
| teacher1 | C1 | editingteacher |
|
|
|
18 |
| student1 | C1 | student |
|
|
|
19 |
And the following "activities" exist:
|
|
|
20 |
| activity | course | name |
|
|
|
21 |
| page | C1 | P1 |
|
|
|
22 |
| page | C1 | P2 |
|
|
|
23 |
|
|
|
24 |
@javascript
|
|
|
25 |
Scenario: Test condition
|
|
|
26 |
# Basic setup.
|
|
|
27 |
Given I am on the "P1" "page activity editing" page logged in as "teacher1"
|
|
|
28 |
And I expand all fieldsets
|
|
|
29 |
And I click on "Add restriction..." "button"
|
|
|
30 |
And I click on "User profile" "button"
|
|
|
31 |
And I set the field "User profile field" to "Email address"
|
|
|
32 |
And I set the field "Value to compare against" to "s@example.com"
|
|
|
33 |
And I click on ".availability-item .availability-eye img" "css_element"
|
|
|
34 |
And I click on "Save and return to course" "button"
|
|
|
35 |
|
|
|
36 |
# Add
|
|
|
37 |
And I am on the "P2" "page activity editing" page
|
|
|
38 |
And I expand all fieldsets
|
|
|
39 |
And I click on "Add restriction..." "button"
|
|
|
40 |
And I click on "User profile" "button"
|
|
|
41 |
And I set the field "User profile field" to "Email address"
|
|
|
42 |
And I set the field "Value to compare against" to "q@example.com"
|
|
|
43 |
And I click on ".availability-item .availability-eye img" "css_element"
|
|
|
44 |
And I click on "Save and return to course" "button"
|
|
|
45 |
|
|
|
46 |
# Log back in as student.
|
|
|
47 |
When I am on the "Course 1" "course" page logged in as "student1"
|
|
|
48 |
|
|
|
49 |
# I see P1 but not P2.
|
|
|
50 |
Then I should see "P1" in the "region-main" "region"
|
|
|
51 |
And I should not see "P2" in the "region-main" "region"
|
|
|
52 |
|
|
|
53 |
@javascript
|
|
|
54 |
Scenario: Test with custom user profile field
|
|
|
55 |
Given the following "custom profile fields" exist:
|
|
|
56 |
| datatype | shortname | name |
|
|
|
57 |
| text | superfield | Super field |
|
|
|
58 |
# Set field value for user.
|
|
|
59 |
And I am on the "s@example.com" "user > editing" page logged in as "admin"
|
|
|
60 |
And I expand all fieldsets
|
|
|
61 |
And I set the field "Super field" to "Bananaman"
|
|
|
62 |
And I click on "Update profile" "button"
|
|
|
63 |
|
|
|
64 |
# Set Page activity which has requirement on this field.
|
|
|
65 |
And I am on the "P1" "page activity editing" page
|
|
|
66 |
And I expand all fieldsets
|
|
|
67 |
And I click on "Add restriction..." "button"
|
|
|
68 |
And I click on "User profile" "button"
|
|
|
69 |
And I set the following fields to these values:
|
|
|
70 |
| User profile field | Super field |
|
|
|
71 |
| Value to compare against | Bananaman |
|
|
|
72 |
And I click on ".availability-item .availability-eye img" "css_element"
|
|
|
73 |
And I click on "Save and return to course" "button"
|
|
|
74 |
|
|
|
75 |
# Edit it again and check the setting still works.
|
|
|
76 |
When I am on the P1 "page activity editing" page
|
|
|
77 |
And I expand all fieldsets
|
|
|
78 |
Then the field "User profile field" matches value "Super field"
|
|
|
79 |
And the field "Value to compare against" matches value "Bananaman"
|
|
|
80 |
|
|
|
81 |
# Log out and back in as student. Should be able to see activity.
|
|
|
82 |
And I am on the "Course 1" "course" page logged in as "student1"
|
|
|
83 |
Then I should see "P1" in the "region-main" "region"
|
|
|
84 |
|
|
|
85 |
@javascript
|
|
|
86 |
Scenario: Condition display with filters
|
|
|
87 |
# Teacher sets up a restriction on group G1, using multilang filter.
|
|
|
88 |
Given the following "custom profile fields" exist:
|
|
|
89 |
| datatype | shortname | name | param2 |
|
|
|
90 |
| text | frog | <span lang="en" class="multilang">F-One</span><span lang="fr" class="multilang">F-Un</span> | 100 |
|
|
|
91 |
And the "multilang" filter is "on"
|
|
|
92 |
And the "multilang" filter applies to "content and headings"
|
|
|
93 |
# The activity names filter is enabled because it triggered a bug in older versions.
|
|
|
94 |
And the "activitynames" filter is "on"
|
|
|
95 |
And the "activitynames" filter applies to "content and headings"
|
|
|
96 |
And I am on the "P1" "page activity editing" page logged in as "teacher1"
|
|
|
97 |
And I expand all fieldsets
|
|
|
98 |
And I click on "Add restriction..." "button"
|
|
|
99 |
And I click on "User profile" "button" in the "Add restriction..." "dialogue"
|
|
|
100 |
And I set the following fields to these values:
|
|
|
101 |
| User profile field | F-One |
|
|
|
102 |
| Value to compare against | 111 |
|
|
|
103 |
And I click on "Save and return to course" "button"
|
|
|
104 |
And I log out
|
|
|
105 |
|
|
|
106 |
# Student sees information about no access to group, with group name in correct language.
|
|
|
107 |
When I am on the "C1" "Course" page logged in as "student1"
|
|
|
108 |
Then I should see "Not available unless: Your F-One is 111"
|
|
|
109 |
And I should not see "F-Un"
|