Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
@tool @tool_uploadcourse @_file_upload
2
Feature: An admin can create courses using a CSV file
3
  In order to create courses using a CSV file
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 "courses" exist:
9
      | fullname | shortname | category |
10
      | First course | C1 | 0 |
11
    And I log in as "admin"
12
    And I navigate to "Courses > Upload courses" in site administration
13
 
14
  @javascript
15
  Scenario: Creation of unexisting courses
16
    Given I upload "admin/tool/uploadcourse/tests/fixtures/courses.csv" file to "File" filemanager
17
    And I click on "Preview" "button"
18
    When I click on "Upload courses" "button"
19
    Then I should see "The course exists and update is not allowed"
20
    And I should see "Course created"
21
    And I should see "Courses total: 3"
22
    And I should see "Courses created: 2"
23
    And I should see "Courses errors: 1"
24
    And I am on site homepage
25
    And I should see "Course 2"
26
    And I should see "Course 3"
27
 
28
  @javascript
29
  Scenario: Creation of existing courses
30
    Given I upload "admin/tool/uploadcourse/tests/fixtures/courses.csv" file to "File" filemanager
31
    And I set the field "Upload mode" to "Create all, increment shortname if needed"
32
    And I click on "Preview" "button"
33
    When I click on "Upload courses" "button"
34
    Then I should see "Course created"
35
    And I should see "Course shortname incremented C1 -> C2"
36
    And I should see "Course shortname incremented C2 -> C3"
37
    And I should see "Course shortname incremented C3 -> C4"
38
    And I should see "Courses total: 3"
39
    And I should see "Courses created: 3"
40
    And I should see "Courses errors: 0"
41
    And I am on site homepage
42
    And I should see "Course 1"
43
    And I should see "Course 2"
44
    And I should see "Course 3"
45
 
46
  @javascript
47
  Scenario: Creation of new courses with custom fields
48
    Given the following "custom field categories" exist:
49
      | name  | component   | area   | itemid |
50
      | Other | core_course | course | 0      |
51
    And the following "custom fields" exist:
52
      | name    | category | type     | shortname | configdata            |
53
      | Field 1 | Other    | checkbox | checkbox  |                       |
54
      | Field 2 | Other    | date     | date      |                       |
55
      | Field 3 | Other    | select   | select    | {"options":"a\nb\nc"} |
56
      | Field 4 | Other    | text     | text      |                       |
57
      | Field 5 | Other    | textarea | textarea  |                       |
58
    When I upload "admin/tool/uploadcourse/tests/fixtures/courses_custom_fields.csv" file to "File" filemanager
59
    And I set the field "Upload mode" to "Create new courses only, skip existing ones"
60
    And I click on "Preview" "button"
61
    And I click on "Upload courses" "button"
62
    Then I should see "Course created"
63
    And I should see "Courses created: 1"
64
    And I am on site homepage
65
    And I should see "Course fields 1"
66
    And I should see "Field 1: Yes"
67
    And I should see "Field 2: Tuesday, 1 October 2019, 2:00"
68
    And I should see "Field 3: b"
69
    And I should see "Field 4: Hello"
70
    And I should see "Field 5: Goodbye"
71
 
72
  @javascript
73
  Scenario: Creation of new courses with custom fields using defaults
74
    Given the following "custom field categories" exist:
75
      | name  | component   | area   | itemid |
76
      | Other | core_course | course | 0      |
77
    And the following "custom fields" exist:
78
      | name    | category | type     | shortname | configdata                                          |
79
      | Field 1 | Other    | checkbox | checkbox  | {"checkbydefault":1}                                |
80
      | Field 2 | Other    | date     | date      | {"includetime":0}                                   |
81
      | Field 3 | Other    | select   | select    | {"options":"a\nb\nc","defaultvalue":"b"}            |
82
      | Field 4 | Other    | text     | text      | {"defaultvalue":"Hello"}                            |
83
      | Field 5 | Other    | textarea | textarea  | {"defaultvalue":"Some text","defaultvalueformat":1} |
84
    When I upload "admin/tool/uploadcourse/tests/fixtures/courses.csv" file to "File" filemanager
85
    And I set the field "Upload mode" to "Create all, increment shortname if needed"
86
    And I click on "Preview" "button"
87
    And I expand all fieldsets
88
    And the field "Field 1" matches value "1"
89
    And the field "Field 3" matches value "b"
90
    And the field "Field 4" matches value "Hello"
91
    And the field "Field 5" matches value "Some text"
92
    # We have to enable the date field manually.
93
    And I set the following fields to these values:
94
      | customfield_date[enabled] | 1    |
95
      | customfield_date[day]     | 1    |
96
      | customfield_date[month]   | June |
97
      | customfield_date[year]    | 2020 |
98
    And I click on "Upload courses" "button"
99
    Then I should see "Course created"
100
    And I should see "Courses created: 3"
101
    And I am on site homepage
102
    And I should see "Course 1"
103
    And I should see "Field 1: Yes"
104
    And I should see "Field 2: 1 June 2020"
105
    And I should see "Field 3: b"
106
    And I should see "Field 4: Hello"
107
    And I should see "Field 5: Some text"
108
 
109
  @javascript
110
  Scenario: Validation of role for uploaded courses
111
    Given I navigate to "Users > Permissions > Define roles" in site administration
112
    And I click on "Add a new role" "button"
113
    And I click on "Continue" "button"
114
    And I set the following fields to these values:
115
      | Short name | notallowed |
116
      | Custom full name | notallowed |
117
      | contextlevel80 | 1 |
118
    And I click on "Create this role" "button"
119
    And I navigate to "Courses > Upload courses" in site administration
120
    And I upload "admin/tool/uploadcourse/tests/fixtures/enrolment_role.csv" file to "File" filemanager
121
    And I click on "Preview" "button"
122
    And I should see "Invalid role names: notexist"
123
    And I should see "Role notallowed not allowed in this context."
124
    When I click on "Upload courses" "button"
125
    And I should see "Course created"
126
    And I should see "Courses total: 3"
127
    And I should see "Courses created: 1"
128
    And I should see "Courses errors: 2"
129
    And I should see "Invalid role names: notexist"
130
    And I should see "Role notallowed not allowed in this context."
131
    And I am on site homepage
132
    And I should see "coursez"
133
 
134
  @javascript
135
  Scenario: Unsupported enrol methods are not created
136
    Given the following config values are set as admin:
137
      | enrol_plugins_enabled | manual,guest,lti |
138
    And I set the field "Upload mode" to "Create new courses, or update existing ones"
139
    And I set the field "Update mode" to "Update with CSV data only"
140
    And I upload "admin/tool/uploadcourse/tests/fixtures/unsupported_enrol_method.csv" file to "File" filemanager
141
    And I click on "Preview" "button"
142
    When I click on "Upload courses" "button"
143
    Then I should see "Course created"
144
    And I should see "Enrolment method 'enrol_lti_plugin' is not supported in csv upload"
145
    And I am on the "C2" "enrolment methods" page
146
    And I should see "manualtest"
147
    And I should not see "ltitest"
148
 
149
  @javascript
150
  Scenario: Manager can use upload course tool in course category
151
    Given the following "users" exist:
152
      | username | firstname | lastname | email             |
153
      | user1    | User      | 1        | user1@example.com |
154
    And the following "categories" exist:
155
      | name  | category | idnumber |
156
      | Cat 1 | 0        | CAT1     |
157
      | Cat 2 | 0        | CAT2     |
158
      | Cat 3 | CAT1     | CAT3     |
159
    And the following "role assigns" exist:
160
      | user  | role    | contextlevel | reference |
161
      | user1 | manager | Category     | CAT1      |
162
    When I log in as "user1"
163
    And I am on course index
164
    And I follow "Cat 1"
165
    And I navigate to "Upload courses" in current page administration
166
    And I upload "admin/tool/uploadcourse/tests/fixtures/courses_manager1.csv" file to "File" filemanager
167
    And I click on "Preview" "button"
168
    Then I should see "The course exists and update is not allowed" in the "C1" "table_row"
169
    And I should see "No permission to upload courses in category: Cat 2" in the "C2" "table_row"
170
    And I set the field "Course category" to "Cat 1 / Cat 3"
171
    And I click on "Upload courses" "button"
172
    And I should see "Course created"
173
    And I should see "Courses total: 5"
174
    And I should see "Courses created: 3"
175
    And I should see "Courses errors: 2"
176
    And I am on course index
177
    And I follow "Cat 1"
178
    And I should see "Course 4"
179
    And I follow "Cat 3"
180
    And I should see "Course 5"
181
    # Course 3 did not have category specified in CSV file and it was uploaded to the current category.
182
    And I should see "Course 3"
183
    And I log out