source: moodle/trunk/fuentes/availability/condition/profile/tests/behat/availability_profile.feature @ 136

Last change on this file since 136 was 136, checked in by mabarracus, 3 years ago

Ported code to xenial

File size: 4.3 KB
Line 
1@availability @availability_profile
2Feature: 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.org |
14      | student1 | s@example.org |
15    And the following "course enrolments" exist:
16      | user     | course | role           |
17      | teacher1 | C1     | editingteacher |
18      | student1 | C1     | student        |
19    And I log in as "admin"
20    And I set the following administration settings values:
21      | Enable conditional access  | 1 |
22    And I log out
23
24  @javascript
25  Scenario: Test condition
26    # Basic setup.
27    Given I log in as "teacher1"
28    And I follow "Course 1"
29    And I turn editing mode on
30
31    # Add
32    And I add a "Page" to section "1"
33    And I set the following fields to these values:
34      | Name         | P1 |
35      | Description  | x  |
36      | Page content | x  |
37    And I expand all fieldsets
38    And I click on "Add restriction..." "button"
39    And I click on "User profile" "button"
40    And I set the field "User profile field" to "Email address"
41    And I set the field "Value to compare against" to "s@example.org"
42    And I click on ".availability-item .availability-eye img" "css_element"
43    And I click on "Save and return to course" "button"
44
45    # Add
46    And I add a "Page" to section "2"
47    And I set the following fields to these values:
48      | Name         | P2 |
49      | Description  | x  |
50      | Page content | x  |
51    And I expand all fieldsets
52    And I click on "Add restriction..." "button"
53    And I click on "User profile" "button"
54    And I set the field "User profile field" to "Email address"
55    And I set the field "Value to compare against" to "q@example.org"
56    And I click on ".availability-item .availability-eye img" "css_element"
57    And I click on "Save and return to course" "button"
58
59    # Log back in as student.
60    When I log out
61    And I log in as "student1"
62    And I follow "Course 1"
63
64    # I see P1 but not P2.
65    Then I should see "P1" in the "region-main" "region"
66    And I should not see "P2" in the "region-main" "region"
67
68  @javascript
69  Scenario: Test with custom user profile field
70    # Add custom field.
71    Given I log in as "admin"
72    And I navigate to "User profile fields" node in "Site administration > Users > Accounts"
73    And I set the field "datatype" to "Text input"
74    And I set the following fields to these values:
75      | Short name | superfield  |
76      | Name       | Super field |
77    And I click on "Save changes" "button"
78
79    # Set field value for user.
80    And I navigate to "Browse list of users" node in "Site administration > Users > Accounts"
81    And I click on "a[title=Edit]" "css_element" in the "s@example.org" "table_row"
82    And I expand all fieldsets
83    And I set the field "Super field" to "Bananaman"
84    And I click on "Update profile" "button"
85
86    # Set Page activity which has requirement on this field.
87    And I am on homepage
88    And I follow "Course 1"
89    And I turn editing mode on
90    And I add a "Page" to section "1"
91    And I set the following fields to these values:
92      | Name         | P1 |
93      | Description  | x  |
94      | Page content | x  |
95    And I expand all fieldsets
96    And I click on "Add restriction..." "button"
97    And I click on "User profile" "button"
98    And I set the following fields to these values:
99      | User profile field       | Super field |
100      | Value to compare against | Bananaman   |
101    And I click on ".availability-item .availability-eye img" "css_element"
102    And I click on "Save and return to course" "button"
103
104    # Edit it again and check the setting still works.
105    When I follow "P1"
106    And I navigate to "Edit settings" node in "Page module administration"
107    And I expand all fieldsets
108    Then the field "User profile field" matches value "Super field"
109    And the field "Value to compare against" matches value "Bananaman"
110
111    # Log out and back in as student. Should be able to see activity.
112    And I log out
113    And I log in as "student1"
114    And I follow "Course 1"
115    Then I should see "P1" in the "region-main" "region"
Note: See TracBrowser for help on using the repository browser.