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

Last change on this file since 1331 was 1331, checked in by jrpelegrina, 3 years ago

Updated to moodle 3.0.3

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.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 config values are set as admin:
20      | enableavailability  | 1 |
21
22  @javascript
23  Scenario: Test condition
24    # Basic setup.
25    Given I log in as "teacher1"
26    And I am on site homepage
27    And I follow "Course 1"
28    And I turn editing mode on
29
30    # Add
31    And I add a "Page" to section "1"
32    And I set the following fields to these values:
33      | Name         | P1 |
34      | Description  | x  |
35      | Page content | x  |
36    And I expand all fieldsets
37    And I click on "Add restriction..." "button"
38    And I click on "User profile" "button"
39    And I set the field "User profile field" to "Email address"
40    And I set the field "Value to compare against" to "s@example.com"
41    And I click on ".availability-item .availability-eye img" "css_element"
42    And I click on "Save and return to course" "button"
43
44    # Add
45    And I add a "Page" to section "2"
46    And I set the following fields to these values:
47      | Name         | P2 |
48      | Description  | x  |
49      | Page content | x  |
50    And I expand all fieldsets
51    And I click on "Add restriction..." "button"
52    And I click on "User profile" "button"
53    And I set the field "User profile field" to "Email address"
54    And I set the field "Value to compare against" to "q@example.com"
55    And I click on ".availability-item .availability-eye img" "css_element"
56    And I click on "Save and return to course" "button"
57
58    # Log back in as student.
59    When I log out
60    And I log in as "student1"
61    And I am on site homepage
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.com" "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 site 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 am on site homepage
115    And I follow "Course 1"
116    Then I should see "P1" in the "region-main" "region"
Note: See TracBrowser for help on using the repository browser.