Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
@core @core_badges @_file_upload
2
Feature: Award badges with separate groups
3
  In order to award badges to users for their achievements
4
  As a teacher
5
  I need to award badges only to users in the groups I have access
6
 
7
  Background:
8
    Given the following "users" exist:
9
      | username | firstname | lastname | email |
10
      | teacher1 | Teacher | 1 | teacher1@example.com |
11
      | teacher2 | Teacher | 2 | teacher2@example.com |
12
      | student1 | Student | 1 | student1@example.com |
13
      | student2 | Student | 2 | student2@example.com |
14
    And the following "courses" exist:
15
      | fullname | shortname | category | groupmode |
16
      | Course 1 | C1 | 0 | 1 |
17
    And the following "course enrolments" exist:
18
      | user | course | role |
19
      | teacher1 | C1 | editingteacher |
20
      | teacher2 | C1 | teacher |
21
      | student1 | C1 | student |
22
      | student2 | C1 | student |
23
    And the following "groups" exist:
24
      | name | course | idnumber |
25
      | Class A | C1 | CA |
26
      | Class B | C1 | CB |
27
    And the following "group members" exist:
28
      | user | group |
29
      | student1 | CB |
30
      | teacher1 | CB |
31
      | student2 | CA |
32
      | teacher2 | CA |
33
    And I am on the "Course 1" "course editing" page logged in as "teacher1"
34
    And I expand all fieldsets
35
    And I set the field "Group mode" to "Separate groups"
36
    And I press "Save and display"
37
    And I navigate to "Badges > Add a new badge" in current page administration
38
    And I set the following fields to these values:
39
      | Name | Course Badge |
40
      | Description | Course badge description |
41
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
42
    And I press "Create badge"
43
    And I set the field "type" to "Manual issue by role"
44
    And I expand all fieldsets
45
    And I set the field "Teacher" to "1"
46
    And I set the field "Non-editing teacher" to "1"
47
    # Set to ANY of the roles awards badge.
48
    And I set the field "Any of the selected roles awards the badge" to "1"
49
    And I press "Save"
50
    And I press "Enable access"
51
    And I press "Continue"
52
    And I log out
53
 
54
  @javascript
55
  Scenario: Award course badge as non-editing teacher with only one group
56
    When I log in as "teacher2"
57
    And I am on "Course 1" course homepage
58
    And I navigate to "Badges > Manage badges" in current page administration
59
    And I follow "Course Badge"
60
    And I press "Award badge"
61
    And I set the field "role" to "Non-editing teacher"
62
    # Teacher 2 should see a "Separate groups" label with the group he is in
63
    Then I should see "Separate groups: Class A"
64
    # Teacher 2 should only see the users who belong to the same group as he does
65
    And I should see "Student 2"
66
    And I should not see "Student 1"
67
    # Non-editing teacher can award the badge
68
    And I set the field "potentialrecipients[]" to "Student 2 (student2@example.com)"
69
    And I press "Award badge"
70
    And I am on "Course 1" course homepage
71
    And I navigate to "Badges > Manage badges" in current page administration
72
    And I follow "Course Badge"
73
    And I should see "Recipients (1)"
74
    And I log out
75
    And I log in as "student2"
76
    And I follow "Profile" in the user menu
77
    And I click on "Course 1" "link" in the "region-main" "region"
78
    And I should see "Course Badge"
79
    And I log out
80
 
81
  @javascript
82
  Scenario: Award course badge as non-editing teacher with more than one group
83
    Given I log in as "teacher1"
84
    And I am on the "Course 1" "groups" page
85
    And I set the field "groups" to "Class B (2)"
86
    And I press "Add/remove users"
87
    And I set the field "addselect" to "Teacher 2 (teacher2@example.com)"
88
    And I press "Add"
89
    And I log out
90
    When I log in as "teacher2"
91
    And I am on "Course 1" course homepage
92
    And I navigate to "Badges > Manage badges" in current page administration
93
    And I follow "Course Badge"
94
    And I press "Award badge"
95
    And I set the field "role" to "Non-editing teacher"
96
    # Teacher 2 should see a "Separate groups" label and a dropdown menu with the groups he belongs to
97
    And I set the field "Separate groups" to "Class A"
98
    Then I should see "Student 2"
99
    And I should not see "Student 1"
100
    And I set the field "Separate groups" to "Class B"
101
    And I should see "Student 1"
102
    And I should not see "Student 2"
103
    And I log out
104
 
105
  @javascript
106
  Scenario: Award course badge as non-editing teacher without any group
107
    Given I log in as "teacher1"
108
    And I am on the "Course 1" "groups" page
109
    And I set the field "groups" to "Class A (2)"
110
    And I press "Add/remove users"
111
    And I set the field "removeselect" to "Teacher 2 (teacher2@example.com)"
112
    And I press "Remove"
113
    And I press "Back to groups"
114
    And I log out
115
    When I log in as "teacher2"
116
    And I am on "Course 1" course homepage
117
    And I navigate to "Badges > Manage badges" in current page administration
118
    And I follow "Course Badge"
119
    And I press "Award badge"
120
    # Teacher 2 shouldn't be able to go further
121
    Then I should see "Sorry, but you need to be part of a group to see this page."
122
 
123
  @javascript
124
  Scenario: Editing teacher can award badge to members of separate groups
125
    Given I am on the "Course 1" course page logged in as teacher1
126
    And I navigate to "Badges > Manage badges" in current page administration
127
    And I follow "Course Badge"
128
    And I press "Award badge"
129
    When I set the field "role" to "Teacher"
130
    # Confirm that editing teacher sees a separate groups dropdown menu.
131
    Then "Separate groups" "select" should exist
132
    And I should see "All participants" in the "Separate groups" "select"
133
    # Confirm that all participants are displayed when All participants is selected.
134
    And I should see "Student 1" in the "potentialrecipients[]" "select"
135
    And I should see "Student 2" in the "potentialrecipients[]" "select"
136
    And I should see "Teacher 1" in the "potentialrecipients[]" "select"
137
    And I should see "Teacher 2" in the "potentialrecipients[]" "select"
138
    And I set the field "Separate groups" to "Class A"
139
    # Confirm that only members of selected group are displayed
140
    And I should not see "Student 1" in the "potentialrecipients[]" "select"
141
    And I should not see "Teacher 1" in the "potentialrecipients[]" "select"
142
    And I should see "Student 2" in the "potentialrecipients[]" "select"
143
    And I should see "Teacher 2" in the "potentialrecipients[]" "select"
144
    And I set the field "Separate groups" to "Class B"
145
    And I should not see "Student 2" in the "potentialrecipients[]" "select"
146
    And I should not see "Teacher 2" in the "potentialrecipients[]" "select"
147
    And I should see "Student 1" in the "potentialrecipients[]" "select"
148
    And I should see "Teacher 1" in the "potentialrecipients[]" "select"
149
 
150
  @javascript
151
  Scenario Outline: Teacher can award badge to members of visible groups
152
    Given I am on the "Course 1" "course editing" page logged in as teacher1
153
    And I expand all fieldsets
154
    # Set the group mode to visible groups.
155
    And I set the field "Group mode" to "Visible groups"
156
    And I press "Save and display"
157
    When I am on the "Course 1" course page logged in as <loggedinuser>
158
    And I navigate to "Badges > Manage badges" in current page administration
159
    And I follow "Course Badge"
160
    And I press "Award badge"
161
    And I set the field "role" to "<awarder>"
162
    # Confirm that teachers see a visible groups dropdown menu.
163
    Then "Visible groups" "select" should exist
164
    # Confirm that My groups option group exists.
165
    And "optgroup[label='My groups']" "css_element" should exist in the "select[name='group']" "css_element"
166
    # Confirm that Other groups option group exists.
167
    And "optgroup[label='Other groups']" "css_element" should exist in the "select[name='group']" "css_element"
168
    # Confirm that all participants are displayed when All participants is selected.
169
    And I set the field "Visible groups" to "All participants"
170
    And I should see "Student 1" in the "potentialrecipients[]" "select"
171
    And I should see "Student 2" in the "potentialrecipients[]" "select"
172
    And I should see "Teacher 1" in the "potentialrecipients[]" "select"
173
    And I should see "Teacher 2" in the "potentialrecipients[]" "select"
174
    # Confirm that only members of selected group are displayed.
175
    And I set the field "Visible groups" to "Class A"
176
    And I should not see "Student 1" in the "potentialrecipients[]" "select"
177
    And I should not see "Teacher 1" in the "potentialrecipients[]" "select"
178
    And I should see "Student 2" in the "potentialrecipients[]" "select"
179
    And I should see "Teacher 2" in the "potentialrecipients[]" "select"
180
    And I set the field "Visible groups" to "Class B"
181
    And I should not see "Student 2" in the "potentialrecipients[]" "select"
182
    And I should not see "Teacher 2" in the "potentialrecipients[]" "select"
183
    And I should see "Student 1" in the "potentialrecipients[]" "select"
184
    And I should see "Teacher 1" in the "potentialrecipients[]" "select"
185
 
186
    Examples:
187
      | loggedinuser | awarder             |
188
      | teacher1     | Teacher             |
189
      | teacher2     | Non-editing teacher |
190
 
191
  @javascript
192
  Scenario Outline: Teacher can award badge to members when group mode is set to no groups
193
    Given I am on the "Course 1" "course editing" page logged in as teacher1
194
    And I expand all fieldsets
195
    # Set the group mode to no groups.
196
    And I set the field "Group mode" to "No groups"
197
    And I press "Save and display"
198
    When I am on the "Course 1" course page logged in as <loggedinuser>
199
    And I navigate to "Badges > Manage badges" in current page administration
200
    And I follow "Course Badge"
201
    And I press "Award badge"
202
    And I set the field "role" to "<awarder>"
203
    # Confirm that no group dropdowns don't exist.
204
    Then "Separate groups" "select" should not exist
205
    And "Visible groups" "select" should not exist
206
    # Confirm all participants are displayed.
207
    And I should see "Student 1" in the "potentialrecipients[]" "select"
208
    And I should see "Student 2" in the "potentialrecipients[]" "select"
209
    And I should see "Teacher 1" in the "potentialrecipients[]" "select"
210
    And I should see "Teacher 2" in the "potentialrecipients[]" "select"
211
 
212
    Examples:
213
      | loggedinuser | awarder             |
214
      | teacher1     | Teacher             |
215
      | teacher2     | Non-editing teacher |