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 update courses using a CSV file
3
  In order to update 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
      | Some random name | C1  | 0 |
11
      | Another course   | CF1 | 0 |
12
    And I log in as "admin"
13
    And I navigate to "Courses > Upload courses" in site administration
14
 
15
  @javascript
16
  Scenario: Updating a course fullname
17
    Given I upload "admin/tool/uploadcourse/tests/fixtures/courses.csv" file to "File" filemanager
18
    And I set the field "Upload mode" to "Only update existing courses"
19
    And I set the field "Update mode" to "Update with CSV data only"
20
    And I click on "Preview" "button"
21
    When I click on "Upload courses" "button"
22
    Then I should see "Course updated"
23
    And I should see "The course does not exist and creating course is not allowed"
24
    And I should see "Courses total: 3"
25
    And I should see "Courses updated: 1"
26
    And I should see "Courses created: 0"
27
    And I should see "Courses errors: 2"
28
    And I am on site homepage
29
    And I should see "Course 1"
30
    And I should not see "Course 2"
31
    And I should not see "Course 3"
32
 
33
  @javascript
34
  Scenario: Updating a course with custom fields
35
    Given the following "custom field categories" exist:
36
      | name  | component   | area   | itemid |
37
      | Other | core_course | course | 0      |
38
    And the following "custom fields" exist:
39
      | name    | category | type     | shortname | configdata            |
40
      | Field 1 | Other    | checkbox | checkbox  |                       |
41
      | Field 2 | Other    | date     | date      |                       |
42
      | Field 3 | Other    | select   | select    | {"options":"a\nb\nc"} |
43
      | Field 4 | Other    | text     | text      |                       |
44
      | Field 5 | Other    | textarea | textarea  |                       |
45
    When I upload "admin/tool/uploadcourse/tests/fixtures/courses_custom_fields.csv" file to "File" filemanager
46
    And I set the following fields to these values:
47
      | Upload mode | Only update existing courses |
48
      | Update mode | Update with CSV data only    |
49
    And I click on "Preview" "button"
50
    And I click on "Upload courses" "button"
51
    Then I should see "Course updated"
52
    And I should see "Courses updated: 1"
53
    And I am on site homepage
54
    And I should see "Course fields 1"
55
    And I should see "Field 1: Yes"
56
    And I should see "Field 2: Tuesday, 1 October 2019, 2:00"
57
    And I should see "Field 3: b"
58
    And I should see "Field 4: Hello"
59
    And I should see "Field 5: Goodbye"
60
 
61
  @javascript
62
  Scenario: Unsupported enrol methods are not updated
63
    Given the following config values are set as admin:
64
      | enrol_plugins_enabled | manual,lti |
65
    And the following "courses" exist:
66
      | fullname         | shortname | category |
67
      | Course 2         | C2        | 0        |
68
    And I am on the "C2" "enrolment methods" page
69
    When I select "Publish as LTI tool" from the "Add method" singleselect
70
    And the following fields match these values:
71
      | LTI version | LTI Advantage |
72
    And I set the following fields to these values:
73
      | Custom instance name | Published course     |
74
      | Tool to be published | Course               |
75
    And I press "Add method"
76
    And I should see "Published course"
77
    And I navigate to "Courses > Upload courses" in site administration
78
    And I set the field "Upload mode" to "Create new courses, or update existing ones"
79
    And I set the field "Update mode" to "Update with CSV data only"
80
    And I upload "admin/tool/uploadcourse/tests/fixtures/unsupported_enrol_method.csv" file to "File" filemanager
81
    And I click on "Preview" "button"
82
    And I click on "Upload courses" "button"
83
    Then I should see "Enrolment method 'enrol_lti_plugin' is not supported in csv upload"
84
    And I should see "Courses errors: 1"
85
    And I am on the "C2" "enrolment methods" page
86
    And I should see "manualtest"
87
    And I should not see "Manual enrolments"
88
    And I should see "Published course"
89
    And I should not see "ltitest"
90
 
91
  @javascript
92
  Scenario: Manager can use upload course tool to update courses in course category
93
    Given the following "users" exist:
94
      | username | firstname | lastname | email             |
95
      | user1    | User      | 1        | user1@example.com |
96
    And the following "categories" exist:
97
      | name  | category | idnumber |
98
      | Cat 1 | 0        | CAT1     |
99
      | Cat 2 | 0        | CAT2     |
100
      | Cat 3 | CAT1     | CAT3     |
101
    And the following "courses" exist:
102
      | fullname | shortname | category |
103
      | Course 1 | C01       | CAT1     |
104
      | Course 2 | C02       | CAT2     |
105
      | Course 3 | C03       | CAT3     |
106
      | Course 4 | C04       | CAT3     |
107
    And the following "role assigns" exist:
108
      | user  | role    | contextlevel | reference |
109
      | user1 | manager | Category     | CAT1      |
110
    When I log in as "user1"
111
    And I am on course index
112
    And I follow "Cat 1"
113
    And I navigate to "Upload courses" in current page administration
114
    And I upload "admin/tool/uploadcourse/tests/fixtures/courses_manager2.csv" file to "File" filemanager
115
    And I set the field "Upload mode" to "Only update existing courses"
116
    And I set the field "Update mode" to "Update with CSV data only"
117
    And I click on "Preview" "button"
118
    # Course C01 is in "our" category but can not be moved to Cat 2 because current user can not manage it.
119
    Then I should see "No permission to upload courses in category: Cat 2" in the "C01" "table_row"
120
    # Course C02 can not be updated (no capability in "Cat 2" context).
121
    And I should see "A course with this short name exists but you don't have permission to use the upload courses functionality to update it." in the "C02" "table_row"
122
    # Course with short name "C05" does not exist.
123
    And I should see "The course does not exist and creating course is not allowed" in the "C05" "table_row"
124
    And I click on "Upload courses" "button"
125
    And I should see "Course updated"
126
    And I should see "Courses total: 5"
127
    And I should see "Courses updated: 2"
128
    And I should see "Courses errors: 3"
129
    And I am on course index
130
    And I follow "Cat 1"
131
    # Course C04 was moved from Cat 3 to Cat 1.
132
    And I should see "Course 4"
133
    And I should see "Course 1"
134
    And I follow "Cat 3"
135
    And I should see "Course 3"
136
    And I log out