Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
@availability @availability_group
2
Feature: availability_group
3
  In order to control student access to activities
4
  As a teacher
5
  I need to set group conditions which prevent student access
6
 
7
  Background:
8
    Given the following "courses" exist:
9
      | fullname | shortname | format | enablecompletion | numsections |
10
      | Course 1 | C1        | topics | 1                | 3           |
11
    And the following "users" exist:
12
      | username |
13
      | teacher1 |
14
      | student1 |
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
      | page     | C1     | P3    |
24
 
25
  @javascript
26
  Scenario: Test condition
27
    # Basic setup.
28
    Given I am on the "P1" "page activity editing" page logged in as "teacher1"
29
    And I expand all fieldsets
30
    And I click on "Add restriction..." "button"
31
    Then "Group" "button" should not exist in the "Add restriction..." "dialogue"
32
    And I click on "Cancel" "button" in the "Add restriction..." "dialogue"
33
 
34
    # Back to course page but add groups.
35
    Given the following "groups" exist:
36
      | name     | course | idnumber |
37
      | G1       | C1     | GI1      |
38
      | G2       | C1     | GI2      |
39
    # This step used to be 'And I follow "C1"', but Chrome thinks the breadcrumb
40
    # is not clickable, so we'll go via the home page instead.
41
    And I am on the "P1" "page activity editing" page
42
    And I expand all fieldsets
43
    And I click on "Add restriction..." "button"
44
    Then "Group" "button" should exist in the "Add restriction..." "dialogue"
45
 
46
    # Page P1 any group.
47
    Given I click on "Group" "button" in the "Add restriction..." "dialogue"
48
    And I set the field "Group" to "(Any group)"
49
    And I click on ".availability-item .availability-eye img" "css_element"
50
    And I click on "Save and return to course" "button"
51
 
52
    # Page P2 with group G1.
53
    And I am on the "P2" "page activity editing" page
54
    And I expand all fieldsets
55
    And I click on "Add restriction..." "button"
56
    And I click on "Group" "button" in the "Add restriction..." "dialogue"
57
    And I set the field "Group" to "G1"
58
    And I click on ".availability-item .availability-eye img" "css_element"
59
    And I click on "Save and return to course" "button"
60
 
61
    # Page P3 with group G2
62
    And I am on the "P3" "page activity editing" page
63
    And I expand all fieldsets
64
    And I click on "Add restriction..." "button"
65
    And I click on "Group" "button" in the "Add restriction..." "dialogue"
66
    And I set the field "Group" to "G2"
67
    And I click on ".availability-item .availability-eye img" "css_element"
68
    And I click on "Save and return to course" "button"
69
 
70
    # Log back in as student.
71
    When I am on the "Course 1" "course" page logged in as "student1"
72
 
73
    # No pages should appear yet.
74
    Then I should not see "P1" in the "region-main" "region"
75
    And I should not see "P2" in the "region-main" "region"
76
    And I should not see "P3" in the "region-main" "region"
77
 
78
    # Add to groups and log out/in again.
79
    Given the following "group members" exist:
80
      | user     | group |
81
      | student1 | GI1   |
82
    And I am on "Course 1" course homepage
83
 
84
    # P1 (any groups) and P2 should show but not P3.
85
    Then I should see "P1" in the "region-main" "region"
86
    And I should see "P2" in the "region-main" "region"
87
    And I should not see "P3" in the "region-main" "region"
88
 
89
  @javascript
90
  Scenario: Condition display with filters
91
    # Teacher sets up a restriction on group G1, using multilang filter.
92
    Given the following "groups" exist:
93
      | name                                                                                        | course | idnumber |
94
      | <span lang="en" class="multilang">G-One</span><span lang="fr" class="multilang">G-Un</span> | C1     | GI1      |
95
    And the "multilang" filter is "on"
96
    And the "multilang" filter applies to "content and headings"
97
    # The activity names filter is enabled because it triggered a bug in older versions.
98
    And the "activitynames" filter is "on"
99
    And the "activitynames" filter applies to "content and headings"
100
    And I am on the "P1" "page activity editing" page logged in as "teacher1"
101
    And I expand all fieldsets
102
    And I click on "Add restriction..." "button"
103
    And I click on "Group" "button" in the "Add restriction..." "dialogue"
104
    And I set the field "Group" to "G-One"
105
    And I click on "Save and return to course" "button"
106
 
107
    # Student sees information about no access to group, with group name in correct language.
108
    When I am on the "C1" "Course" page logged in as "student1"
109
    Then I should see "Not available unless: You belong to G-One"
110
    And I should not see "G-Un"
111
 
112
  @javascript
113
  Scenario: Condition using a hidden group
114
    Given the following "groups" exist:
115
      | name         | course | idnumber | visibility |
116
      | Hidden Group | C1     | GA       | 3          |
117
    And I log in as "teacher1"
118
    And I add a page activity to course "Course 1" section "1"
119
    And I expand all fieldsets
120
 
121
    # Page P1 any group.
122
    And I am on the "P1" "page activity editing" page
123
    And I expand all fieldsets
124
    And I click on "Add restriction..." "button"
125
    And "Group" "button" should exist in the "Add restriction..." "dialogue"
126
    And I click on "Group" "button" in the "Add restriction..." "dialogue"
127
    And I set the field "Group" to "(Any group)"
128
    And I click on ".availability-item .availability-eye img" "css_element"
129
    And I click on "Save and return to course" "button"
130
 
131
    # Page P2 with hidden group.
132
    And I am on the "P2" "page activity editing" page
133
    And I expand all fieldsets
134
    And I click on "Add restriction..." "button"
135
    And I click on "Group" "button" in the "Add restriction..." "dialogue"
136
    And I set the field "Group" to "Hidden Group"
137
    And I click on "Save and return to course" "button"
138
 
139
    # Log back in as student.
140
    When I am on the "Course 1" "course" page logged in as "student1"
141
 
142
    # No pages should appear yet.
143
    Then I should not see "P1" in the "region-main" "region"
144
    And I should not see "P2" in the "region-main" "region"
145
    And I should not see "Hidden Group"
146
 
147
    # Add to groups and log out/in again.
148
    And the following "group members" exist:
149
      | user     | group |
150
      | student1 | GA    |
151
    And I am on "Course 1" course homepage
152
 
153
    # P1 (any groups) and P2 should show. The user should not see the hidden group mentioned anywhere.
154
    And I should see "P1" in the "region-main" "region"
155
    And I should see "P2" in the "region-main" "region"
156
    And I should not see "Hidden Group"