Note: You are currently viewing documentation for Moodle 2.3. Up-to-date documentation for the latest stable version is available here: Enrol Sync: User operation command file.

Enrol Sync: User operation command file

From MoodleDocs

Back to index

This file allows asking the "user creation tool" to create massively users in Moodle, and roughly enroll them in some courses.

A report file is generated after execution of the test in the special sync file cabinet at the following location:

sync/reports

This file can be retrieved using the embedded file manager.

File format

User bulk creation allows creating several users in a single operation. This tool is highly inspired from the bulk user import standard feature with some powerful enhancements. Conversely, some lonely used features have been removed.

Note that many authentication methods allow creating users without manual intervention. this is possible using external LDAP or database synchronisation. In some cases, there is a need to pre-feed Moodle with users:

  • Your user central database contains more identities than strictly required in Moodle : you may disable auto-account creation on auth and pre-feed moodle user table with only expected users.
  • You have complex pre-enrolment positionning of your users in several courses and several contexts, and you do not use an external enrolment synchronisation method (web services or LDAP groups).
  • You rely on user lists that are provided in CSV format, or CSV convertible formats.

In this case, you may use user operation file to import user definitions.

  • The first line MUST contain column names
  • One user per line
  • Field separator can be either coma ',' or semi-colon ';' (configuration required)
  • Encoding can be ISO-8859-1 or UTF-8 (configuration required)

Mandatory fields

If creating a user you will need

firstname, lastname

For updating existing users, the

username

column must exit. New users will provide an empty string as username.

Optional user attributes fields

institution, department, city, country, lang, auth, ajax, timezone, idnumber, icq, phone1, phone2, address, url, description, mailformat, maildisplay, htmleditor, autosubscribe, emailstop

Custom profile fields setup

Custom profile field feeding is optional, you may add any number of such columns by replacing xxxxxx with the short name of the field.

profile_field_xxxxx

Special fields for deletion or renaming

As for standard version of the user bulk import, deleted column and oldusername column will provide additionnal commands to the tool. Set value 1 in deleted column for deleting the user identified by the username column.

If oldusername is defined, username value will update the user identified by oldusername.

deleted, oldusername

Enrol while import

When importing new users, you may need to enrol them at the same time in courses. The user bulk command file can defined several sets of course enrolment dedicated columns.

Each set needs using subfields as defined below. All fields will be followed by an iteration number starting from 1. The number of defined sets will be equal to the max enrolment courses a user needs to enrol. Other users will let columns blank for surnumerous courses:

  • course: the course where enrol operation occur.
  • type: (abandonned)
  • role: shortname of the role to be assigned.
  • group: if a group attribute is defined, and a group with this groupname exists in the course, the user will be dropped in. (you must not use group ids here)
  • start: the start date, as a Unix timestamp
  • end: the end date, as a Unix timestamp

If role is omitted, the user will be enrolled internally as student.

course1, role1, group1, course2, role2, group2, course3, role3, etc.

Special feature : Remote enrolment in a VMoodle network

This feature is for users using the VMoodle Moodle Virtualization block for driving a MNET based platform set.

You may add a wwwroot<n> attribute to a course set to remotely tranfer and enrolment requirement to a remote Moodle in your network. The completion of the enrolment will need the operationg user to be allowed to use the VMoodle remote API. This is the case for a local administrator, and for the cron task that will also endorse the local admin role for this operation.

Note that when using a remote enrolment, the course<n> will hold the remote IDNumber of the course in the remote node.

course1, role1, group1, course2, role2, group2, course3, role3, wwwroot3, etc.

File Sample

  username, password, firstname, lastname, email, lang, idnumber, maildisplay, course1, group1, type1
  jonest, verysecret, Tom, Jones, jonest@someplace.edu, en, 3663737, 1, Intro101, Section 1, 1
  reznort, somesecret, Trent, Reznor, reznort@someplace.edu, en_us, 6736733, 0, Advanced202, Section 3, 3