Metacourse Link Block

From MoodleDocs

This block allows Metacourse/Child course links to be created/kept up to date via CSV files. It is very similar in both appearance and programming to the Tutor Link Block.

It can be operated in two modes:

Manual Upload - any user with the block/metalink:use capability (by default, only admins) can upload a file to process on demand.

Automatic - a file location is configured, then the block automatically checks this location. If a file is found, it is processed and results emailed to the administrator.


The block has several configuration options, found in Site Administration/Plugins/Blocks/Upload Tutor Relationships.

  • Location of File for Automatic Processing is the location of the file on the server's local file system to be processed by the block's cron job, allowing periodic updates of role assignments. Leaving this blank will disable the cron job.
  • Keep processed files allows files processed by cron jobs to be kept for future reference.
  • Processed file location is the folder that processed files will be placed in, if Keep processed files is ticked.
  • Days to keep processed files for is self-explanatory. After this many days, processed files will be deleted.


Correct File Format

The files to be processed should be in CSV format (hopefully no surprises there).

They may consist of any number of rows, each with three fields: tutor idnumber,tutee idnumber, action; it is important to note that the idnumbers are expected to be populated from an external database, they are not the id field in the user table. Action can be add or del, with add creating relationships and del deleting relationships. None of the fields should be delimited.

As of Moodle 2.0, the order of the fields changed slightly to make them more consistent with the Flatfile Enrolements plugin. The format for each row is now: action, parent course idnumber, child course idnumber. For example, a file with this contents:

add, 1234, 4321
add, 1234, 4322
del, 2232, 3223

Will assign the courses with idnumbers 4321 and 4321 as children of the course with idnumber 1234, then remove the course with idnumber 3223 from the course with idnumber 2232. Note than unlike 1.9, each row must contain three columns.

Trying to add relationships that already exist in Moodle or remove those that don't will not cause problems, as this block will skip over those records.

Manual upload

After the CSV file is created, navigate to the page containing the block, and upload the file. It will be processed and a report will appear showing you the operations that were successful, along with any errors.

Automatic processing

A file placed at the path specified in Location of file for automatic processing will be processed automatically when the block's cron job runs. A report will then be emailed to the Moodle Administrator.