Merge branch 'MDL-45873' of https://github.com/bostelm/moodle
[moodle.git] / group / tests / behat / create_groups.feature
CommitLineData
550d842e 1@core @core_group
e613fd90
DM
2Feature: Organize students into groups
3 In order to organize course activities in groups
5d7b6307 4 As a teacher
e613fd90
DM
5 I need to group students
6
7 @javascript
8 Scenario: Assign students to groups
759b323e 9 Given the following "courses" exist:
e613fd90
DM
10 | fullname | shortname | category | groupmode |
11 | Course 1 | C1 | 0 | 1 |
759b323e 12 And the following "users" exist:
e613fd90 13 | username | firstname | lastname | email |
0fe86bbd
RT
14 | teacher1 | Teacher | 1 | teacher1@example.com |
15 | student0 | Student | 0 | student0@example.com |
16 | student1 | Student | 1 | student1@example.com |
17 | student2 | Student | 2 | student2@example.com |
18 | student3 | Student | 3 | student3@example.com |
759b323e 19 And the following "course enrolments" exist:
e613fd90
DM
20 | user | course | role |
21 | teacher1 | C1 | editingteacher |
22 | student0 | C1 | student |
23 | student1 | C1 | student |
24 | student2 | C1 | student |
25 | student3 | C1 | student |
26 And I log in as "teacher1"
27 And I follow "Course 1"
e5287f9b 28 And I go to "Users > Groups" in current page administration
e613fd90 29 And I press "Create group"
f083d614 30 And I set the following fields to these values:
e613fd90
DM
31 | Group name | Group 1 |
32 And I press "Save changes"
33 And I press "Create group"
f083d614 34 And I set the following fields to these values:
e613fd90
DM
35 | Group name | Group 2 |
36 And I press "Save changes"
0fe86bbd
RT
37 When I add "Student 0 (student0@example.com)" user to "Group 1" group members
38 And I add "Student 1 (student1@example.com)" user to "Group 1" group members
39 And I add "Student 2 (student2@example.com)" user to "Group 2" group members
40 And I add "Student 3 (student3@example.com)" user to "Group 2" group members
f083d614 41 Then I set the field "groups" to "Group 1 (2)"
e613fd90
DM
42 And the "members" select box should contain "Student 0"
43 And the "members" select box should contain "Student 1"
44 And the "members" select box should not contain "Student 2"
f083d614 45 And I set the field "groups" to "Group 2 (2)"
e613fd90
DM
46 And the "members" select box should contain "Student 2"
47 And the "members" select box should contain "Student 3"
48 And the "members" select box should not contain "Student 0"
e5287f9b 49 And I navigate to course participants
f083d614 50 And I set the field "Separate groups" to "Group 1"
e613fd90
DM
51 And I should see "Student 0"
52 And I should see "Student 1"
53 And I should not see "Student 2"
f083d614 54 And I set the field "Separate groups" to "Group 2"
e613fd90
DM
55 And I should see "Student 2"
56 And I should see "Student 3"
57 And I should not see "Student 0"
a2d3e3b6 58
a2d3e3b6 59 Scenario: Create groups and groupings without the 'moodle/course:changeidnumber' capability
759b323e 60 Given the following "courses" exist:
a2d3e3b6
MN
61 | fullname | shortname | category | groupmode |
62 | Course 1 | C1 | 0 | 1 |
759b323e 63 And the following "users" exist:
a2d3e3b6 64 | username | firstname | lastname | email |
0fe86bbd 65 | teacher1 | Teacher | 1 | teacher1@example.com |
759b323e 66 And the following "course enrolments" exist:
a2d3e3b6
MN
67 | user | course | role |
68 | teacher1 | C1 | editingteacher |
69 And I log in as "admin"
70 And I set the following system permissions of "Teacher" role:
71 | moodle/course:changeidnumber | Prevent |
72 And I log out
73 And I log in as "teacher1"
74 And I follow "Course 1"
e5287f9b 75 And I go to "Users > Groups" in current page administration
a2d3e3b6
MN
76 When I press "Create group"
77 Then the "idnumber" "field" should be readonly
f083d614 78 And I set the following fields to these values:
a2d3e3b6
MN
79 | Group name | The greatest group that never existed |
80 And I press "Save changes"
81 And I should see "The greatest group that never existed"
82 And I follow "Groupings"
83 And I press "Create grouping"
84 And the "idnumber" "field" should be readonly
f083d614 85 And I set the following fields to these values:
a2d3e3b6
MN
86 | Grouping name | Not the greatest grouping, but it's ok! |
87 And I press "Save changes"
88 And I should see "Not the greatest grouping, but it's ok!"
6685e048
FM
89
90 Scenario: Create groups with enrolment key
91 Given the following "courses" exist:
92 | fullname | shortname | category | groupmode |
93 | Course 1 | C1 | 0 | 1 |
94 | Course 2 | C2 | 0 | 1 |
95 And I log in as "admin"
feaa97af 96 And I am on site homepage
6685e048 97 And I follow "Course 1"
e5287f9b 98 And I go to "Users > Groups" in current page administration
6685e048 99 When I press "Create group"
9d4762c9
FM
100 And I set the following fields to these values:
101 | Group name | Group A |
102 | Enrolment key | badpasswd |
103 And I press "Save changes"
104 And I should see "Passwords must have at least 1 digit(s)"
6685e048
FM
105 And I set the following fields to these values:
106 | Group name | Group A |
107 | Enrolment key | Abcdef-1 |
108 And I press "Save changes"
109 And I press "Create group"
110 And I set the following fields to these values:
111 | Group name | Group B |
112 | Enrolment key | Abcdef-1 |
113 And I press "Save changes"
114 Then I should see "This enrolment key is already used for another group."
115 And I set the following fields to these values:
116 | Enrolment key | Abcdef-2 |
117 And I press "Save changes"
118 And the "groups" select box should contain "Group B (0)"
feaa97af 119 And I am on site homepage
6685e048 120 And I follow "Course 2"
e5287f9b 121 And I go to "Users > Groups" in current page administration
6685e048
FM
122 And I press "Create group"
123 And I set the following fields to these values:
124 | Group name | Group A |
125 | Enrolment key | Abcdef-1 |
126 And I should not see "This enrolment key is already used for another group."