MDL-65069 mod_forum: Stripped out inpage form and advanced redirect
[moodle.git] / mod / forum / tests / behat / separate_group_discussions.feature
CommitLineData
f2946a54
AN
1@mod @mod_forum
2Feature: Posting to all groups in a separate group discussion is restricted to users with access to all groups
3 In order to post to all groups in a forum with separate groups
4 As a teacher
bff7570e 5 I need to have the accessallgroups capability
f2946a54
AN
6
7 Background:
8 Given the following "users" exist:
9 | username | firstname | lastname | email |
0fe86bbd
RT
10 | teacher1 | Teacher | 1 | teacher1@example.com |
11 | noneditor1 | Non-editing teacher | 1 | noneditor1@example.com |
12 | noneditor2 | Non-editing teacher | 2 | noneditor2@example.com |
13 | student1 | Student | 1 | student1@example.com |
bff7570e 14 | student2 | Student | 2 | student2@example.com |
f2946a54
AN
15 And the following "courses" exist:
16 | fullname | shortname | category |
17 | Course 1 | C1 | 0 |
18 And the following "course enrolments" exist:
19 | user | course | role |
20 | teacher1 | C1 | editingteacher |
21 | noneditor1 | C1 | teacher |
22 | noneditor2 | C1 | teacher |
23 | student1 | C1 | student |
bff7570e 24 | student2 | C1 | student |
f2946a54
AN
25 And the following "groups" exist:
26 | name | course | idnumber |
27 | Group A | C1 | G1 |
28 | Group B | C1 | G2 |
29 | Group C | C1 | G3 |
30 And the following "group members" exist:
31 | user | group |
32 | teacher1 | G1 |
33 | teacher1 | G2 |
34 | noneditor1 | G1 |
35 | noneditor1 | G2 |
36 | noneditor1 | G3 |
37 | noneditor2 | G1 |
38 | noneditor2 | G2 |
39 | student1 | G1 |
bff7570e
AN
40 | student2 | G1 |
41 | student2 | G2 |
42 And the following "activities" exist:
43 | activity | name | intro | course | idnumber | groupmode |
44 | forum | Standard forum name | Standard forum description | C1 | sepgroups | 1 |
45
46 Scenario: Teacher with accessallgroups can view all groups
47 Given I log in as "teacher1"
fdeeaff9 48 And I am on "Course 1" course homepage
bff7570e
AN
49 When I follow "Standard forum name"
50 Then the "Separate groups" select box should contain "All participants"
51 Then the "Separate groups" select box should contain "Group A"
52 Then the "Separate groups" select box should contain "Group B"
53 Then the "Separate groups" select box should contain "Group C"
f2946a54 54
bff7570e 55 Scenario: Teacher with accessallgroups can select any group when posting
f2946a54 56 Given I log in as "teacher1"
fdeeaff9 57 And I am on "Course 1" course homepage
f2946a54 58 And I follow "Standard forum name"
858179b0 59 When I click on "Add a new discussion topic" "link"
97babbf7 60 And I click on "Advanced" "button"
f2946a54
AN
61 Then the "Group" select box should contain "All participants"
62 And the "Group" select box should contain "Group A"
63 And the "Group" select box should contain "Group B"
bff7570e 64 And the "Group" select box should contain "Group C"
f267b8b2 65 And I should see "Post a copy to all groups"
f2946a54 66
bff7570e
AN
67 Scenario: Teacher with accessallgroups can post in groups they are a member of
68 Given I log in as "teacher1"
fdeeaff9 69 And I am on "Course 1" course homepage
bff7570e
AN
70 And I follow "Standard forum name"
71 And I select "Group A" from the "Separate groups" singleselect
858179b0 72 When I click on "Add a new discussion topic" "link"
97babbf7 73 And I click on "Advanced" "button"
bff7570e
AN
74 Then I should see "Post a copy to all groups"
75 And I set the following fields to these values:
76 | Subject | Teacher 1 -> Group B |
77 | Message | Teacher 1 -> Group B |
78 # Change the group in the post form.
79 | Group | Group B |
80 And I press "Post to forum"
81 And I wait to be redirected
82 # We should be redirected to the group that we selected when posting.
83 And the field "Separate groups" matches value "Group B"
84 And I should see "Group B" in the "Teacher 1 -> Group B" "table_row"
85 And I should not see "Group A" in the "Teacher 1 -> Group B" "table_row"
86 And I should not see "Group C" in the "Teacher 1 -> Group B" "table_row"
87 # It should also be displayed under All participants
88 And I select "All participants" from the "Separate groups" singleselect
89 And I should see "Group B" in the "Teacher 1 -> Group B" "table_row"
90 And I should not see "Group A" in the "Teacher 1 -> Group B" "table_row"
91 And I should not see "Group C" in the "Teacher 1 -> Group B" "table_row"
92 # It should not be displayed in Groups A, or C.
93 And I select "Group A" from the "Separate groups" singleselect
94 And I should not see "Teacher 1 -> Group B"
95 And I select "Group C" from the "Separate groups" singleselect
96 And I should not see "Teacher 1 -> Group B"
97
98 Scenario: Teacher with accessallgroups can post in groups they are not a member of
99 Given I log in as "teacher1"
fdeeaff9 100 And I am on "Course 1" course homepage
bff7570e
AN
101 And I follow "Standard forum name"
102 And I select "Group A" from the "Separate groups" singleselect
858179b0 103 When I click on "Add a new discussion topic" "link"
97babbf7 104 And I click on "Advanced" "button"
bff7570e
AN
105 Then I should see "Post a copy to all groups"
106 And I set the following fields to these values:
107 | Subject | Teacher 1 -> Group C |
108 | Message | Teacher 1 -> Group C |
109 | Group | Group C |
110 And I press "Post to forum"
111 And I wait to be redirected
112 # We should be redirected to the group that we selected when posting.
113 And the field "Separate groups" matches value "Group C"
114 # We redirect to the group posted in automatically.
115 And I should see "Group C" in the "Teacher 1 -> Group C" "table_row"
116 And I should not see "Group A" in the "Teacher 1 -> Group C" "table_row"
117 And I should not see "Group B" in the "Teacher 1 -> Group C" "table_row"
118 # It should also be displayed under All participants
119 And I select "All participants" from the "Separate groups" singleselect
120 And I should see "Group C" in the "Teacher 1 -> Group C" "table_row"
121 And I should not see "Group A" in the "Teacher 1 -> Group C" "table_row"
122 And I should not see "Group B" in the "Teacher 1 -> Group C" "table_row"
123 # It should not be displayed in Groups A, or B.
124 And I select "Group A" from the "Separate groups" singleselect
125 And I should not see "Teacher 1 -> Group C"
126 And I select "Group B" from the "Separate groups" singleselect
127 And I should not see "Teacher 1 -> Group C"
128
129 Scenario: Teacher with accessallgroups can post to all groups
130 Given I log in as "teacher1"
fdeeaff9 131 And I am on "Course 1" course homepage
bff7570e 132 And I follow "Standard forum name"
858179b0 133 When I click on "Add a new discussion topic" "link"
97babbf7 134 And I click on "Advanced" "button"
bff7570e
AN
135 And I set the following fields to these values:
136 | Subject | Teacher 1 -> Post to all |
137 | Message | Teacher 1 -> Post to all |
138 | Post a copy to all groups | 1 |
139 And I press "Post to forum"
140 And I wait to be redirected
141 # Posting to all groups means that we should be redirected to the page we started from.
142 And the field "Separate groups" matches value "All participants"
143 And I select "Group A" from the "Separate groups" singleselect
144 Then I should see "Group A" in the "Teacher 1 -> Post to all" "table_row"
145 And I should not see "Group B" in the "Teacher 1 -> Post to all" "table_row"
146 And I should not see "Group C" in the "Teacher 1 -> Post to all" "table_row"
147 And I select "Group B" from the "Separate groups" singleselect
148 And I should see "Group B" in the "Teacher 1 -> Post to all" "table_row"
149 And I should not see "Group A" in the "Teacher 1 -> Post to all" "table_row"
150 And I should not see "Group C" in the "Teacher 1 -> Post to all" "table_row"
151 And I select "Group C" from the "Separate groups" singleselect
152 And I should see "Group C" in the "Teacher 1 -> Post to all" "table_row"
153 And I should not see "Group A" in the "Teacher 1 -> Post to all" "table_row"
154 And I should not see "Group B" in the "Teacher 1 -> Post to all" "table_row"
155 # No point testing the "All participants".
156
157 Scenario: Students in one group can only post in their group
158 Given I log in as "student1"
fdeeaff9 159 And I am on "Course 1" course homepage
bff7570e
AN
160 When I follow "Standard forum name"
161 Then I should see "Group A"
858179b0 162 And I click on "Add a new discussion topic" "link"
bff7570e
AN
163 And I should see "Group A"
164 And I should not see "Group B"
165 And I should not see "Group C"
166 And I should not see "Post a copy to all groups"
167 And I set the following fields to these values:
168 | Subject | Student -> B |
169 | Message | Student -> B |
170 And I press "Post to forum"
171 And I wait to be redirected
172 And I should see "Group A" in the "Student -> B" "table_row"
173 And I should not see "Group B" in the "Student -> B" "table_row"
174
175 Scenario: Students in multiple group can post in all of their group individually
176 Given I log in as "student2"
fdeeaff9 177 And I am on "Course 1" course homepage
bff7570e
AN
178 When I follow "Standard forum name"
179 And I select "Group A" from the "Separate groups" singleselect
858179b0 180 And I click on "Add a new discussion topic" "link"
97babbf7 181 And I click on "Advanced" "button"
bff7570e
AN
182 And the "Group" select box should not contain "All participants"
183 And the "Group" select box should contain "Group A"
184 And the "Group" select box should contain "Group B"
185 And the "Group" select box should not contain "Group C"
186 And I should not see "Post a copy to all groups"
187 And I set the following fields to these values:
188 | Subject | Student -> B |
189 | Message | Student -> B |
190 | Group | Group B |
191 And I press "Post to forum"
192 And I wait to be redirected
193 # We should be redirected to the group that we selected when posting.
194 And the field "Separate groups" matches value "Group B"
195 And I should see "Group B" in the "Student -> B" "table_row"
196 And I should not see "Group A" in the "Student -> B" "table_row"
197 And I select "Group A" from the "Separate groups" singleselect
198 And I should not see "Student -> B"
199 # Now try posting in Group A (starting at Group B)
200 And I select "Group B" from the "Separate groups" singleselect
858179b0 201 And I click on "Add a new discussion topic" "link"
97babbf7 202 And I click on "Advanced" "button"
bff7570e
AN
203 And the "Group" select box should not contain "All participants"
204 And the "Group" select box should contain "Group A"
205 And the "Group" select box should contain "Group B"
206 And the "Group" select box should not contain "Group C"
207 And I should not see "Post a copy to all groups"
208 And I set the following fields to these values:
209 | Subject | Student -> A |
210 | Message | Student -> A |
211 | Group | Group A |
212 And I press "Post to forum"
213 And I wait to be redirected
214 # We should be redirected to the group that we selected when posting.
215 And the field "Separate groups" matches value "Group A"
216 And I should see "Group A" in the "Student -> A" "table_row"
217 And I should not see "Group B" in the "Student -> A" "table_row"
218 And I select "Group B" from the "Separate groups" singleselect
219 And I should not see "Student -> A"
220
f2946a54
AN
221 Scenario: Teacher in all groups but without accessallgroups can only post in their groups
222 And I log in as "admin"
223 And I set the following system permissions of "Non-editing teacher" role:
224 | moodle/site:accessallgroups | Prohibit |
225 And I log out
226 Given I log in as "noneditor1"
fdeeaff9 227 And I am on "Course 1" course homepage
f2946a54 228 And I follow "Standard forum name"
858179b0 229 When I click on "Add a new discussion topic" "link"
97babbf7 230 And I click on "Advanced" "button"
f2946a54
AN
231 Then the "Group" select box should not contain "All participants"
232 And the "Group" select box should contain "Group A"
233 And the "Group" select box should contain "Group B"
f267b8b2 234 And I should see "Post a copy to all groups"
f2946a54 235
f2946a54
AN
236 Scenario: Teacher in some groups and without accessallgroups can only post in their groups
237 And I log in as "admin"
238 And I set the following system permissions of "Non-editing teacher" role:
239 | moodle/site:accessallgroups | Prohibit |
240 And I log out
241 Given I log in as "noneditor1"
fdeeaff9 242 And I am on "Course 1" course homepage
f2946a54 243 And I follow "Standard forum name"
858179b0 244 When I click on "Add a new discussion topic" "link"
97babbf7 245 And I click on "Advanced" "button"
f2946a54
AN
246 Then the "Group" select box should not contain "All participants"
247 And the "Group" select box should contain "Group A"
248 And the "Group" select box should contain "Group B"
f267b8b2 249 And I should see "Post a copy to all groups"
1f0f002e
EL
250
251 Scenario: Students can view all participants discussions in separate groups mode
252 Given I log in as "teacher1"
fdeeaff9 253 And I am on "Course 1" course homepage
1f0f002e
EL
254 When I add a new discussion to "Standard forum name" forum with:
255 | Subject | Forum post to all participants |
256 | Message | This is the body |
257 | Group | All participants |
258 And I log out
259 And I log in as "student1"
fdeeaff9 260 And I am on "Course 1" course homepage
1f0f002e
EL
261 And I follow "Standard forum name"
262 Then I should see "Forum post to all participants"