Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
@enrol @ewallah @enrol_coursecompleted @javascript
2
Feature: Enrolment on course completion
3
 
4
  Background:
5
    Given the following "courses" exist:
6
      | fullname | shortname | startdate     | enddate                    | enablecompletion |
7
      | Course 1 | C1        | ##yesterday## | ##tomorrow##               | 1                |
8
      | Course 2 | C2        | ##tomorrow##  | ##last day of next month## | 1                |
9
    And the following "activities" exist:
10
      | activity   | name   | intro            | course | idnumber |
11
      | page       | Page A | page description | C1     | page1    |
12
      | page       | Page B | page description | C2     | page2    |
13
    And the following "users" exist:
14
      | username | firstname | lastname | timezone            |
15
      | user1    | Username  | 1        | Asia/Tokyo          |
16
      | user2    | Username  | 2        | Europe/Brussels     |
17
      | teacher1 | Teacher   | 1        | America/Mexico_city |
18
    And the following "course enrolments" exist:
19
      | user     | course | role           |
20
      | user1    | C1     | student        |
21
      | user2    | C1     | student        |
22
      | teacher1 | C1     | editingteacher |
23
      | teacher1 | C2     | editingteacher |
24
    And the following config values are set as admin:
25
      | expiredaction | Unenrol user from course | enrol_coursecompleted |
26
    And the following config values are set as admin:
27
      | enableasyncbackup | 0 |
28
    And I log in as "admin"
29
    And I navigate to "Plugins > Enrolments > Manage enrol plugins" in site administration
30
    And I click on "Disable" "link" in the "Guest access" "table_row"
31
    And I click on "Disable" "link" in the "Self enrolment" "table_row"
32
    And I click on "Disable" "link" in the "Cohort sync" "table_row"
33
    And I click on "Enable" "link" in the "Course completed enrolment" "table_row"
34
    And I navigate to "Location > Location settings" in site administration
35
    And I set the field "Default timezone" to "Europe/Brussels"
36
    And I am on "Course 1" course homepage
37
    And I navigate to "Course completion" in current page administration
38
    And I expand all fieldsets
39
    And I set the field "Teacher" to "1"
40
    And I press "Save changes"
41
    And I am on the "Course 2" "enrolment methods" page
42
    And I select "Course completed enrolment" from the "Add method" singleselect
43
 
44
  Scenario: When a course is completed, a user is automatically enrolled into another course
45
    Given I set the following fields to these values:
46
       | Course | Course 1 |
47
    And I press "Add method"
48
    And I am on "Course 2" course homepage
49
    And I log out
50
    And I am on the "C1" "Course" page logged in as "teacher1"
51
    And I navigate to "Reports" in current page administration
52
    And I click on "Course completion" "link" in the "region-main" "region"
53
    And I follow "Click to mark user complete"
54
    And I log out
55
    And I log in as "admin"
56
    And I run the scheduled task "core\task\completion_regular_task"
57
    And I run all adhoc tasks
58
    And I log out
59
    When I am on the "C1" "Course" page logged in as "user1"
60
    Then I should not see "You will be enrolled in this course when"
61
    And I should see "Page A"
62
    And I am on "Course 2" course homepage
63
    But I should not see "You will be enrolled in this course when"
64
    And I should see "Page B"
65
 
66
  Scenario: Course completed enrolment fields
67
    Given I set the following fields to these values:
68
       | Course                    | Course 1 |
69
       | id_enrolperiod_enabled    | 1        |
70
       | id_enrolperiod_number     | 3 days   |
71
       | id_enrolstartdate_enabled | 1        |
72
       | id_enrolstartdate_year    | 2030     |
73
       | id_enrolenddate_enabled   | 1        |
74
       | id_enrolenddate_year      | 2031     |
75
    And I press "Add method"
76
    And I am on "Course 2" course homepage
77
    And I log out
78
    When I am on the "C1" "Course" page logged in as "teacher1"
79
    And I navigate to "Reports" in current page administration
80
    And I click on "Course completion" "link" in the "region-main" "region"
81
    And I follow "Click to mark user complete"
82
    And I wait "1" seconds
83
    And I run the scheduled task "core\task\completion_regular_task"
84
    And I run all adhoc tasks
85
    And I am on "Course 2" course homepage
86
    Then I navigate to course participants
87
    # The user enrolment only starts in 2030
88
    But I should not see "user1"
89
 
90
  Scenario: Course completed enrolment with a later start date
91
    Given I set the following fields to these values:
92
       | Course                    | Course 1 |
93
       | id_enrolstartdate_enabled | 1        |
94
       | id_enrolstartdate_year    | 2030     |
95
    And I press "Add method"
96
    And I am on "Course 2" course homepage
97
    And I log out
98
    And I am on the "C1" "Course" page logged in as "teacher1"
99
    And I navigate to "Reports" in current page administration
100
    And I click on "Course completion" "link" in the "region-main" "region"
101
    And I follow "Click to mark user complete"
102
    And I wait "1" seconds
103
    And I run the scheduled task "core\task\completion_regular_task"
104
    And I run all adhoc tasks
105
    And I am on "Course 2" course homepage
106
    When I navigate to course participants
107
    # The user enrolment only starts in 2030
108
    Then I should not see "user1"
109
    And I log out
110
    And I log in as "guest"
111
    And I am on course index
112
    And I follow "Course 2"
113
    But I should see "You will be enrolled in this course when you complete course"
114
 
115
  Scenario: Manage enrolled users
116
    Given I set the following fields to these values:
117
       | Course | Course 1 |
118
    And I press "Add method"
119
    And I am on "Course 2" course homepage
120
    And I log out
121
    And I am on the "C1" "Course" page logged in as "teacher1"
122
    And I navigate to "Reports" in current page administration
123
    And I click on "Course completion" "link" in the "region-main" "region"
124
    And I follow "Click to mark user complete"
125
    And I log out
126
    And I log in as "admin"
127
    And I run the scheduled task "core\task\completion_regular_task"
128
    And I run all adhoc tasks
129
    And I log out
130
    And I am on the "C2" "Course" page logged in as "teacher1"
131
    And I navigate to course participants
132
    And I should see "Username 1" in the "participants" "table"
133
    And I log out
134
    And I am on the "C2" "Course" page logged in as "admin"
135
    And I navigate to course participants
136
    And I click on "//a[@data-action='unenrol']" "xpath_element" in the "user1" "table_row"
137
    And I click on "Unenrol" "button" in the "Unenrol" "dialogue"
138
    And I click on "//a[@data-action='unenrol']" "xpath_element" in the "teacher1" "table_row"
139
    And I click on "Unenrol" "button" in the "Unenrol" "dialogue"
140
    And I am on the "Course 2" "enrolment methods" page
141
    And I wait until the page is ready
142
    When I click on "[aria-label='Enrol users']" "css_element" in the "tr.lastrow" "css_element"
143
    Then I should see "Username 1"
144
    And I press "Enrol users"
145
    And I should see "1 Users enrolled"
146
    And I am on "Course 2" course homepage
147
    And I navigate to course participants
148
    And I should see "Username 1" in the "participants" "table"
149
    And I should see "Course 2"
150
    And I click on "[title='Course completion']" "css_element"
151
    And I should see "Course 1"
152
    And I should see "Aggregation method"
153
 
154
  Scenario: Bulk unenrol users
155
    Given I set the following fields to these values:
156
       | Course | Course 1 |
157
    And I press "Add method"
158
    And I am on "Course 2" course homepage
159
    And I log out
160
    When I am on the "C1" "Course" page logged in as "teacher1"
161
    And I navigate to "Reports" in current page administration
162
    And I click on "Course completion" "link" in the "region-main" "region"
163
    And I follow "Click to mark user complete"
164
    And I log out
165
    And I log in as "admin"
166
    And I run the scheduled task "core\task\completion_regular_task"
167
    And I run all adhoc tasks
168
    And I am on "Course 2" course homepage
169
    And I navigate to course participants
170
    And I click on "Select all" "checkbox"
171
    And I set the field "With selected users..." to "Delete selected enrolments on course completion"
172
    Then I should see "Delete selected enrolments on course completion"
173
    And I press "Unenrol users"
174
    But I should not see "Username 1" in the "participants" "table"
175
 
176
  Scenario: Bulk edit users
177
    Given I set the following fields to these values:
178
       | Course | Course 1 |
179
    And I press "Add method"
180
    And I am on "Course 2" course homepage
181
    And I log out
182
    And I am on the "C1" "Course" page logged in as "teacher1"
183
    And I navigate to "Reports" in current page administration
184
    And I click on "Course completion" "link" in the "region-main" "region"
185
    And I follow "Click to mark user complete"
186
    And I log out
187
    And I log in as "admin"
188
    And I run the scheduled task "core\task\completion_regular_task"
189
    And I run all adhoc tasks
190
    And I am on "Course 2" course homepage
191
    And I navigate to course participants
192
    When I click on "Select 'Username 1'" "checkbox"
193
    And I set the field "With selected users..." to "Edit selected enrolments on course completion"
194
    Then I should see "Edit selected enrolments on course completion"
195
    And I set the field "Alter status" to "Suspended"
196
    And I press "Save changes"
197
    And I should see "Username 1" in the "participants" "table"
198
    And I should see "Suspended" in the "participants" "table"
199
 
200
  @javascript
201
  Scenario: Admin can backup and restore a course with enrol course completions
202
    Given I set the following fields to these values:
203
       | Course | Course 1 |
204
    And I press "Add method"
205
    And I am on "Course 2" course homepage
206
    And I log out
207
    And I log in as "admin"
208
    When I am on "Course 2" course homepage
209
    And I backup "Course 2" course using this options:
210
      | Confirmation | Filename | test_backup.mbz |
211
    And I restore "test_backup.mbz" backup into a new course using this options:
212
      | Schema | Course name       | Course 3 |
213
      | Schema | Course short name | C3       |
214
    And I am on "Course 3" course homepage
215
    And I navigate to course participants
216
    Then I should see "1 participants found"
217
    But I should not see "Username 1" in the "participants" "table"
218
    And I should not see "Username 2" in the "participants" "table"
219
    And I am on the "Course 3" "enrolment methods" page
220
    And I should see "After completing course: C1"