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

Enrol Sync: Enrol operation command file

From MoodleDocs

Back to index

Description

This features completes the standard file based enrolment adding automation. Groupes are handled so are hidden role assignations. The control file for enrolments can use several verbs (i.e. commands) in order to alter role and group assignations within a course.

File Format

Field Data type or sample Comments
cmd 'add', 'del' or 'shift' Verb
rolename 'student', 'teacher'* Role shortname
cid String ID Course external IDnumber
uid String ID User external IDnumber
hidden 0 or 1 Hidden assignation switch
gcmd 'gadd', 'gaddcreate', 'greplace', 'greplacecreate' Group verb
g1 String Group name
...
g<n> String Group names

Detail

cmd: Assignation command

Tells what to do with this enrolment line:

  • add: Add assignation to the given role in course cid. Other assignations remain.
  • del: Deletes assignation for role rolename. If rolename is empty (or do not match any existing role name), then all assignations are removed. Assignations to upper contexts (categories, system context) are NEVER altered by a deletion.
  • shift: Assigns to the given role after having removed all other assignations. Equivalent to a pair of 'del' than 'add'.

This column is mandatory in the file, and cannot be empty.

rolename: Role shortname

Most common cases will use "student", "teacher" or "editingteacher". Any role can be used.

If the rolename is eroneous, the whole command line will be written back in the 'tryback' file (if 'tryback' file generation is enabled).

cid: Course identifier

Depending on the tool settings in main screen, this ID can be either the numeric ID of the course, the shortname or the IDNumber.

If the course is NOT found in Moodle and playback file generation is enabled, the whole command line will be written back in the playback file.

This column is mandatory in the file, and cannot be empty.

uid: User identifier

Depending on the tool settings in main screen, this ID can be either the numeric ID of the user, the username, the email or the user's IDNumber.

If the course is NOT found in Moodle and 'tryback' file generation is enabled, the whole command line will be written back in the 'tryback' file.

This column is mandatory in the file, and cannot be empty.

hidden: Hidden role assignment

If present and contains '1', the role assignation will be hidden.

This column is NOT mandatory in the file, or can be empty.

gcmd: Commande de groupe

This additional syntax allows to add group operations to the enrol command line. Possible values are:

  • gadd: add group assignation of the user in current course.
  • greplace: add group assignation after removing all previous group bindings for this user in this course.

This command will operate on any non empty group column that follows on the command line.

g1 ... gn: Group definition columns

Defines argument groups that will be processed with the gcmd command. Column must contain group names as they figure in the course. If a group does not exist in the course, it will be created sofar.

File Sample

  cmd;uid;cid;rolename;hidden;gcmd;g1;g2;g3
  add;john.doe;student;COURSE1;0;gadd;All Students;G1;;
  add;bill.smith;student;COURSE1;0;gadd;All Students;G2;;
  add;tom.bridges;student;COURSE1;0;gadd;All Students;G1;;
  add;tom.sludges;editingteacher;COURSE1;0;gadd;;G1;G2;
  shift;tim.sloane;teacher;COURSE1;0;;;;;