Upload courses

In addition to creating new courses, the upload courses functionality may also be used to update or delete courses, or import content from another course. For information on using this functionality to create course templates, see Adding a new course.

To upload one or more courses

Go to Administration > Site administration > Courses > Upload courses

Either drag and drop the CSV file or click the 'Choose a file' button and select the file in the file picker

Note: It is also possible to use the command-line tool admin/tool/uploadcourse/cli/uploadcourse.php.

When using the web interface, use the Preview option to see if any errors were detected in the previewed rows. If you proceed with the upload and there were something wrong detected with a course, it will be ignored.

Short file example

uploadcourse.csv:

Note: shortname, fullname, and category are required.

The category field takes the id of the category, with the default category Miscellaneous having id 1. Categories must already exist. If you put a category id that does not exist, you will receive a "Could not resolve category by ID" error during upload preview, and courses in that category will not be created.

Role renaming

It is worth noting that the short name for the teacher role is editingteacher and the short name for the non-editing teacher is teacher.

Course action fields

Those settings take precedence over the Course process parameters.

delete

1 to delete the course

rename

The shortname to rename the course to

backupfile

An absolute path to a backup file (.mbz) to import in the course.

(This means the full path to your course, for example /home/yourmoodle/public_html/moodle27/transfert/backup.mbz . If you are unsure of this, look at include_path in Site administration>Server>PHP info.)

templatecourse

The short name of a course to import the content from

reset

1 to reset the course

Mandatory fields

shortname

This field is mandatory for every operation, with the only exception of creating new courses. See details on the course process parameter Shortname template for more information.

fullname

Required when creating a new course.

category, category_idnumber, category_path

One of these is required when creating a course.

Import options

To prevent unexpected behaviour, you have to specify what you want the tool to be able to do.

Upload mode

This allows you to specify if courses can be created and/or updated.

Update mode

If you allow courses to be updated, you also have to tell the tool what to update the courses with.

Allow deletes

Whether the delete field is accepted or not

Allow renames

Whether the rename field is accepted or not

Allow resets

Whether the reset field is accepted or not

Course process

This allows you to specify actions to be taken for every course uploaded.

Shortname template

If you are creating courses without a shortname, you can use this field to automatically generate a shortname. This field accepts two placeholders: %i for the ID number, %f for the summary.

Restore file

A backup file (.mbz) to import in the course after create/update.

Restore from course

The shortname of a course to import content from after create/update.

Reset after upload

Whether to reset the course after creating/updating it.

Default course values

Those are values that can be set in the web interface for all the fields that are not specified in the CSV file. Note that they are always used when creating a course, but only when specified during update (see Update mode).

Increasing speed

When importing the content of a backup file, or another course, you are advised to enable the setting keeptempdirectoriesonbackup. This will considerably speed up the process of the upload if you are importing multiple times from the same source.