1 |
efrain |
1 |
@tool @tool_uploadcourse @_file_upload
|
|
|
2 |
Feature: An admin can create courses with cohort enrolments using a CSV file
|
|
|
3 |
In order to create courses using a CSV file with cohort enrolment
|
|
|
4 |
As an admin
|
|
|
5 |
I need to be able to upload a CSV file and navigate through the import process
|
|
|
6 |
|
|
|
7 |
Background:
|
|
|
8 |
Given the following "categories" exist:
|
|
|
9 |
| name | category | idnumber |
|
|
|
10 |
| Cat 0 | 0 | CAT0 |
|
|
|
11 |
| Cat 1 | CAT0 | CAT1 |
|
|
|
12 |
| Cat 1 | CAT0 | CAT2 |
|
|
|
13 |
And the following "cohorts" exist:
|
|
|
14 |
| name | idnumber | contextlevel | reference | visible |
|
|
|
15 |
| Cohort 1 | CV1 | Category | CAT1 | 1 |
|
|
|
16 |
| Cohort 2 | CV2 | Category | CAT2 | 1 |
|
|
|
17 |
| Cohort 3 | CV3 | Category | CAT2 | 1 |
|
|
|
18 |
| Cohort 4 | CV4 | Category | CAT1 | 1 |
|
|
|
19 |
| Cohort 5 | CV5 | Category | CAT1 | 1 |
|
|
|
20 |
And the following "courses" exist:
|
|
|
21 |
| fullname | shortname | category |
|
|
|
22 |
| Course 1 | C1 | CAT1 |
|
|
|
23 |
And I log in as "admin"
|
|
|
24 |
And I navigate to "Courses > Upload courses" in site administration
|
|
|
25 |
And I set the field "Upload mode" to "Create new courses, or update existing ones"
|
|
|
26 |
And I set the field "Update mode" to "Update with CSV data only"
|
|
|
27 |
|
|
|
28 |
@javascript
|
|
|
29 |
Scenario: Upload cohort enrolment if plugin is disabled
|
|
|
30 |
Given the following config values are set as admin:
|
|
|
31 |
| enrol_plugins_enabled | manual,guest,self |
|
|
|
32 |
And I upload "admin/tool/uploadcourse/tests/fixtures/enrolment_cohort.csv" file to "File" filemanager
|
|
|
33 |
When I click on "Preview" "button"
|
|
|
34 |
Then I should see "Cohort sync enrol plugin is disabled"
|
|
|
35 |
|
|
|
36 |
@javascript
|
|
|
37 |
Scenario: Validation of cohorts for uploaded courses
|
|
|
38 |
Given I upload "admin/tool/uploadcourse/tests/fixtures/enrolment_cohort.csv" file to "File" filemanager
|
|
|
39 |
And I click on "Preview" "button"
|
|
|
40 |
And I should see "Unknown cohort (Not exist)!"
|
|
|
41 |
And I should see "Cohort CV3 not allowed in this context."
|
|
|
42 |
When I click on "Upload courses" "button"
|
|
|
43 |
And I should see "Unknown cohort (Not exist)!"
|
|
|
44 |
And I should see "Cohort CV3 not allowed in this context."
|
|
|
45 |
And I should see "Cohort CV4 not allowed in this context."
|
|
|
46 |
And I should see "Invalid role names: student1"
|
|
|
47 |
And I should see "Courses created: 2"
|
|
|
48 |
And I should see "Courses updated: 0"
|
|
|
49 |
And I should see "Courses errors: 4"
|
|
|
50 |
And I am on the "Course 1" "enrolment methods" page
|
|
|
51 |
Then I should not see "Cohort sync (Cohort 3 - Student)"
|
|
|
52 |
And I am on the "Course 2" "enrolment methods" page
|
|
|
53 |
And I should not see "Cohort sync (Cohort 4 - Student)"
|
|
|
54 |
And I am on the "Course 3" "enrolment methods" page
|
|
|
55 |
And I should see "Cohort sync (Cohort 5 - Student)"
|
|
|
56 |
And I click on "Edit" "link" in the "Cohort 5" "table_row"
|
|
|
57 |
And the field "Add to group" matches value "None"
|
|
|
58 |
And I navigate to "Courses > Upload courses" in site administration
|
|
|
59 |
And I set the field "Upload mode" to "Create new courses, or update existing ones"
|
|
|
60 |
And I set the field "Update mode" to "Update with CSV data only"
|
|
|
61 |
And I upload "admin/tool/uploadcourse/tests/fixtures/enrolment_cohort_missing_fields.csv" file to "File" filemanager
|
|
|
62 |
And I click on "Preview" "button"
|
|
|
63 |
And I should see "Missing value for mandatory fields: cohortidnumber, role"
|
|
|
64 |
And "Upload courses" "button" should exist
|
|
|
65 |
|
|
|
66 |
@javascript
|
|
|
67 |
Scenario: Validation of groups for uploaded courses with cohort enrolments
|
|
|
68 |
Given the following "groups" exist:
|
|
|
69 |
| name | course | idnumber |
|
|
|
70 |
| group1 | C1 | G1 |
|
|
|
71 |
# Test that groupname can't be set when addtogroup is used.
|
|
|
72 |
And I upload "admin/tool/uploadcourse/tests/fixtures/enrolment_cohort_addtogroup_groupname.csv" file to "File" filemanager
|
|
|
73 |
And I click on "Preview" "button"
|
|
|
74 |
And I should see "You cannot specify groupname when addtogroup is set."
|
|
|
75 |
# Test creating a new group when uploading a course.
|
|
|
76 |
And I navigate to "Courses > Upload courses" in site administration
|
|
|
77 |
And I set the field "Upload mode" to "Create new courses, or update existing ones"
|
|
|
78 |
And I set the field "Update mode" to "Update with CSV data only"
|
|
|
79 |
And I upload "admin/tool/uploadcourse/tests/fixtures/enrolment_cohort_addtogroup.csv" file to "File" filemanager
|
|
|
80 |
And I click on "Preview" "button"
|
|
|
81 |
And I click on "Upload courses" "button"
|
|
|
82 |
And I should see "Courses created: 2"
|
|
|
83 |
And I should see "Courses errors: 0"
|
|
|
84 |
And I am on the "Course 2" "enrolment methods" page
|
|
|
85 |
And I should see "Cohort sync (Cohort 2 - Student)"
|
|
|
86 |
And I click on "Edit" "link" in the "Cohort 2" "table_row"
|
|
|
87 |
And the field "Add to group" matches value "Cohort 2 cohort"
|
|
|
88 |
And I am on the "Course 2" "groups" page
|
|
|
89 |
And I should see "Cohort 2 cohort"
|
|
|
90 |
And I am on the "Course 3" "enrolment methods" page
|
|
|
91 |
And I should see "Cohort sync (Cohort 1 - Student)"
|
|
|
92 |
And I click on "Edit" "link" in the "Cohort 1" "table_row"
|
|
|
93 |
And the field "Add to group" matches value "None"
|
|
|
94 |
And I am on the "Course 3" "groups" page
|
|
|
95 |
And I should not see "Cohort 1 cohort"
|
|
|
96 |
|
|
|
97 |
# Test assigning to an existing group when uploading a course.
|
|
|
98 |
And I navigate to "Courses > Upload courses" in site administration
|
|
|
99 |
And I set the field "Upload mode" to "Create new courses, or update existing ones"
|
|
|
100 |
And I set the field "Update mode" to "Update with CSV data only"
|
|
|
101 |
And I upload "admin/tool/uploadcourse/tests/fixtures/enrolment_cohort_groups.csv" file to "File" filemanager
|
|
|
102 |
And I click on "Preview" "button"
|
|
|
103 |
And I should see "Error, invalid group notexist"
|
|
|
104 |
When I click on "Upload courses" "button"
|
|
|
105 |
And I should see "Error, invalid group notexist"
|
|
|
106 |
And I should see "Courses updated: 1"
|
|
|
107 |
And I should see "Courses errors: 1"
|
|
|
108 |
And I am on the "Course 1" "enrolment methods" page
|
|
|
109 |
Then I should see "Cohort sync (Cohort 1 - Student)"
|
|
|
110 |
And I click on "Edit" "link" in the "Cohort 1" "table_row"
|
|
|
111 |
And the field "Add to group" matches value "group1"
|
|
|
112 |
And I am on the "Course 1" "groups" page
|
|
|
113 |
And I should see "group1"
|
|
|
114 |
|
|
|
115 |
@javascript
|
|
|
116 |
Scenario: Upload multiple enrolment methods of same type to the same course
|
|
|
117 |
Given I upload "admin/tool/uploadcourse/tests/fixtures/enrolment_cohort_multiple.csv" file to "File" filemanager
|
|
|
118 |
And I click on "Preview" "button"
|
|
|
119 |
When I click on "Upload courses" "button"
|
|
|
120 |
And I should see "Courses updated: 2"
|
|
|
121 |
And I am on the "Course 1" "enrolment methods" page
|
|
|
122 |
Then I should see "Cohort sync (Cohort 1 - Student)"
|
|
|
123 |
And I should see "Cohort sync (Cohort 4 - Non-editing teacher)"
|
|
|
124 |
And I click on "Edit" "link" in the "Cohort 1" "table_row"
|
|
|
125 |
And the field "Assign role" matches value "Student"
|
|
|
126 |
And I press "Cancel"
|
|
|
127 |
And I click on "Edit" "link" in the "Cohort 4" "table_row"
|
|
|
128 |
And the field "Assign role" matches value "Non-editing teacher"
|