Learn enrolments

Competencies FAQ



Can a competency be added to more than one course or activity?

Definitely – and your organisation might well need to do this, if certain competencies need to be met in a series of courses or several activities within one course.

I can’t see evidence uploaded by my students

  • Are you a course teacher? You will not be able to see evidence of prior learning unless your administrator has given you a role with the capability moodle/competency:userevidenceview set to Allow .

How does ‘Attach evidence’ work?

  • A teacher can set “Attach evidence” as an option when an activity or a course is completed. Once an activity or course has been completed, the activity or course in question will display as Evidence at the bottom of the competency in question in a student’s learning plan. A manager or other user with the capability moodle/competency:userevidenceview set to Allow will be able to see this evidence.
  • However, they will not be alerted that the evidence is available, so the student should request a review, as below.

How does “Request review” work?

  • A student can request a review of a competency, for example if they have submitted a piece of work as attached evidence and they wish to alert their course tutor to this. The student accesses the competencies from their learning plan and clicks'”Request review” from the Edit menu.
  • The student will then see ‘waiting for review’ next to that competency.
  • The course tutor/supervisor or anyone who is allowed to review competencies will see the request from the learning plans block on their dashboard:
  • They click the link to access the student’s requested competency and (1 in screenshot below) click to start the review.
  • When the review is in progress, the words the student sees change from ‘waiting for review’ to ‘in review’.
  • The course tutor can then review the evidence (2 in screenshot below) and then (3) click to finish the review. The message ‘in review’ no longer displays for the student.
  • The course tutor can then rate the competency if required (4):

How can a course teacher review competencies?

See the Competency reviewer role.

How can a course teacher view their students’ learning plans?

See the Learning plan viewer role.

How can a course teacher manage their students’ learning plans?

See the Learning plan supervisor role.

How do teachers rate competencies?

Competencies may be met automatically upon activity completion (with the ‘Default’ scale as above) or teachers may rate competencies manually with a customised ‘Proficient’ scale.

  • A teacher accesses the Competency breakdown report, selects a student and clicks on a particular competency which has not yet been rated:
  • The teacher then clicks the ‘Rate’ button:
  • The teacher then chooses from the desired rating from the available options:
  • Once saved, the Proficient scale will change if the competency was met:
  • The competency breakdown report will reflect this, using the wording of the scale:
  • In the example below, the first competency was manually rated “Highly competent”; the second competency was automatically met upon activity completion and the third competency was manually rated “Not competent”.

I can’t see the Learning plans block

  • Are you a course teacher? You will not be able to see the Learning plans block unless your administrator has set the capability block/lp:view to Allow for teachers. However, administrators additionally need to set other capabilities in the system context relating to viewing learning plans and evidence for the block to display any useful information.
  • It might be helpful to create a custom role, such as ‘Supervisor’, with the capabilities you wish to allow in the system context.
  • If students have no learning plans, or if teachers/supervisors have no competencies needing reviewing, then the Learning plans block is not visible when editing is not turned on.

I can’t see competencies when trying to add them to a learning template

Make sure you are in the right part of the site. If you added competencies to a category you will need to add the learning template to that category. If you added competencies to the system you will need to add your learning plan template to the system.

The learning plan shows all competencies met but the course competencies screen shows some are still incomplete.

  • Competencies exist outside a course,so it might be that the competency has been met in another course but not the one you are in
  • If a manager or other user who is allowed to review competencies chooses to rate a competency from the learning plan, then the competency will not show as complete inside the course, but it will display as complete in the learning plan.

The progress bar shows 100% complete but the learning plan is not marked complete.

  • A learning plan does not automatically display as “complete” once all competencies have been met.
  • It may be manually marked as complete by a user with the relevant capabilities – or –
  • a due date may be set for completion when a learning plan template is created.

What is the difference between ‘default’ and ‘proficient’ when setting up scales in a competency framework?

  • The default value is what is displayed in the breakdown report and for a student in their learning plan when a competency is automatically met upon activity completion. In the example below, ‘competent” will display when a student completes a task satisfactorily.
  • Items in the Proficient list can be displayed when a teacher rates a competency manually. There may be several different levels which can all be competent. In the example below, ‘Just competent’,’Competent’ or ‘Highly competent’ will result in the student achieving that competency:
Custom competency scale

Note that the above is a custom created scale.

How can students create their own learning plans?

How can I export or import competency frameworks?

See Competency frameworks.

Any further questions?

Please post in the Competencies forum on

Learn enrolments

Competency frameworks

Site administrators and users with the capability to manage competency frameworks at site or category level can create, import and export a competency framework and define associated competencies. See the video CBE for admins for more information on manually setting up competency frameworks and the video Competency frameworks for information on importing a framework.



Adding competency frameworks manually

  • Go to ‘Competency frameworks’ in Site administration to create competencies in the system, or access the same link from Category administration to add them from a category.
  • Any existing frameworks are displayed here; you can click a button to create a new one or look in the Competency frameworks repository .

Click the button to add a new framework or choose from repository

  • The ID number should be very specific, especially if it is likely that you will have multiple versions of a competency framework on the site at the same time (e.g. when revising the framework each year).
  • The Scale is the default scale used when rating a competency. An individual competency in a framework can have a different scale to the framework.
  • Clicking Configure scales displays extra information about the scale for ratings. There should be a default value, which is assigned when the competency is completed by an automated rule – and the list of values that are deemed “proficient” need to be listed so that the student can see at a glance, which competencies have been achieved and which have not. For more information see Competencies FAQ.
  • From the Taxonomies drop downs, you can define the words used to describe competencies in the framework, depending on their depth in the tree.

Once you have created a competency framework, it will appear in the list of frameworks and you can add competencies to it.

Importing competency frameworks

  • Existing frameworks in CSV format may be imported from ‘Import competency framework’ in Site administration. See the video Competency frameworks for a demo.
  • has a Competency frameworks repository for sharing files. It can be accessed directly from ‘Competency frameworks’ in Site administration.
  • If you are unsure how to set up your CSV file, download an existing framework to use as a model. Here is a basic explanation:
  1. “Parent ID number” – competencies are arranged in a tree. This field indicates which competency is the parent of the current row.
  2. “ID number” – a string that uniquely identifies this competency in this framework
  3. “Short name” – a short name for the competency
  4. “Description” – a longer description for the competency
  5. “Description format” – a number representing the format of the text in the description. Valid options are: 0 = Moodle format, 1 = HTML, 2 = Plain text, 3 = Wiki format, 4 = Markdown
  6. “Scale values” – only required on the framework row. Defines a comma separated list of options used to grade the competencies
  7. “Scale configuration” – a json encoded object used to define the scale configuration. is a valid default
  8. “Related ID numbers” – a comma separated list of id numbers belonging to competencies related to the current row
  9. “Is framework” – must be 1 for a single row in the framework which defines the name and description of the entire framework
  10. “Taxonomy” – defined for the framework row, defines the lang string keys used to describe competencies at each level of the framework

Plugins are available for importing in other formats. Search the Moodle plugins directory for competency framework to find out what else is available.

Adding competencies to a framework

To add competencies to a framework, click on the framework name to go to the page where you can manage the competencies for this framework.Managing competencies for the Mathematics framework

This page lets you build the tree of competencies that defines your competency framework. To start adding competencies, first click on a node in the tree (the topmost node in the tree will be the framework itself), then click on the “Add competency” button. (If you have changed the name in Taxonomies, the button will be named differently, such as “Add skill”.)

  • The ID number – this is required and must be unique within this competency framework. It is used to map competencies in backup and restore, as well as when migrating to a newer version of a competency framework.
  • The Scale and items in “Configure scales” will default to the scale configured for the competency framework, but can be changed for an individual competency if required.
  • Clicking Edit next to a competency once it has been created and selected displays other options, for example marking it as “related” to other competencies or creating an automatic completion rule. An automatic completion rule allows one competency to be completed automatically when all sub-competencies are complete.

More options with selected competencies

Setting a competency rule

Competency rules can be added to any competency in a framework, as long as it has children. A competency rule can be used to automatically mark as complete a parent competency when all children of it are complete. Linking the child competencies to course activities combined with the competency rule ‘Mark as complete when all children are complete’ will award the parent competency to a student when he has successfully completed the course activities.

  • A competency may be marked complete when other competencies are complete or have a certain number of points.
  • To do this, click Edit next to the competency and choose Competency rule
  • Click in the box next to Outcome (1 below) and choose “Mark as complete” (2 below.)
Click the arrow‘Mark as complete’ reveals a ‘When’ field
  • From the new ‘When’ field, you can choose ‘All children are complete’ or ‘Points required are met’. For ‘Points required’ you can then set the points and whether or not a competency is required:

Exporting competency frameworks

Competency frameworks may be exported in CSV format from ‘Export competency framework’ in Site administration.

Learn enrolments

LDAP enrolment

This page requires updating. Please do so and remove this template when finished.

Location: LDAP edit settings link in Site administration > Plugins > Enrolments > Manage enrol plugins



How to set up LDAP enrollment

This describes how to set up Lightweight Directory Access Protocol (LDAP) enrollment in Moodle (first written by Lars Jensen). LDAP enrolment works best in Moodle when used in conjunction with LDAP authentication, and we’re going to assume that you have already set Moodle up for LDAP authentication.


  1. You are running a recent version of Moodle.
  2. You are using LDAP authentication as your primary authentication method.
  3. Each user in has a uid attribute in the users LDAP record, that matches the “ID number” in the same users Moodle profile (this can easily be arranged with a mapping on the Moodle LDAP Authentication setup page – for Active Directory, use ‘distinguishedName’, without the quotes)

The Course Setup

Our setup involves the following course and user definitions:

  • Two courses, Math101 and Eng201.
  • Two teachers, TeacherA and TeacherB.
  • Three students, StudentDStudentE, and StudentF.
  • StudentD and StudentE are enrolled as students in Math101, and TeacherA is enrolled as teacher of Math101. StudentE and StudentF are enrolled as students in Eng201, and TeacherA and TeacherB are both enrolled as teachers of Eng201.

The LDAP Container Setup

  1. Define two LDAP containers ou=StudentEnrollment and ou=TeacherEnrollment
  2. For each course we define an LDAP group entry (e.g a posixGroup entry) in the StudentEnrollment and TeacherEnrollment containers. Thus, we define a Math101 posixGroup under StudentEnrollment, and we define a Math101 posixGroup under TeacherEnrollment. We define the two Eng201 groups in a similar way. Be careful, the name of the posixGroup has to match the Course ID number of the Moodle course. Do not use the course short name, it will not work. (Changing the group name slightly in the Windows pre 2000 group name window will allow you to have two security groups with the same name in MS-AD)
  3. Enroll students and teachers as members of in the LDAP-groups we just defined. This is done by entering the users uid attribute (idnumber) in the memberUid attribute of the relevant group:
    • TeacherA is a member of the Math101 group under TeacherEnrollment.
    • StudentD and StudentE are a members of the Math101 group under StudentEnrollment.
    • TeacherA and TeacherB are members of the Eng201 group under TeacherEnrollment
    • StudentE and StudentF are a members of the Eng201 group under StudentEnrollment.

The LDAP Enrollment Configuration in Moodle

The LDAP enrollment settings in Moodle corresponding to the above setup are as follows:

LDAP Enrollment Variable:Value:
enrol_ldap_student_memberattribute:memberUid (use ‘member’ -without the quotes- for Active Directory)
enrol_ldap_teacher_memberattribute:memberUid (use ‘member’ -without the quotes- for Active Directory)
enrol_ldap_objectclass:posixGroup (use ‘group’ -without the quotes- for Active Directory)

Additionally, since you are using LDAP authentication, you should also map the Moodle “ID number” of users to the “uid” in the ldap entry of the user. This is done on the Moodle LDAP Authentication page (not the LDAP Enrollment page).

Automatic course creation

Courses can be created automatically if there are LDAP enrolments to a course that doesn’t yet exist in Moodle. To enable this, set enrol_ldap_autocreate to Yes.

enrol_ldap_category field sets the category for the automatically created courses.

enrol_ldap_template field can contain the shortname of a course that is used as a template in the automatic course creation.

Note that only the basic settings are copied from the template course such as start date, format etc. no content or block configuration will be copied over.


  1. You do not need to create the courses manually in Moodle. If they don’t exist, they will be created when the first enrolled user login.
  2. We are using the same string cn and uid in a users LDAP record. This is not necessary, I believe. However, if you use different values, you will need to define the ldap_user_attribute to uid in the LDAP authentication setup.
  3. The value of the group id number (gidNumber) defined for the groups in step 2 of the LDAP Container Setup above is not critical. It is not used in this setup.
  4. The attached .ldif file assumes that users are in the ou=People container in LDAP. You will need to configure your LDAP Authentication setup to reflect this (ldap_contexts variable).
  5. User passwords for this setup are defined in the attached .ldif file.
  6. If you use the attached .ldif file, you’ll need to edit the ldap server information (the “dn=” lines).

Other LDAP Layout

I do suggest to create a new LDAP object, say moodleCourse, which contains all information,& members of the course, including teachers, students a.s.o. For instance (OpenLDAP):

attributetype ( oidAttrBase:44 NAME ( 'teacherUid' ) SUP memberUid
        DESC 'which person is a teacher of this course'

objectclass ( oidObjRoot:14 NAME 'moodleCourse' SUP top STRUCTURAL
        DESC 'course available in Moodle'
        MUST ( cn  )
        MAY ( owner $ gn $ sn $ seeAlso $ description $ memberUid $ teacherUid )

Note: Openldap 2.x will need something like:

attributetype   ( NAME 'teacherUid'
                SUP memberUid
                DESC 'which person is a teacher of this course'
                EQUALITY caseExactIA5Match
                SUBSTR caseExactIA5SubstringsMatch
                SYNTAX )

objectclass     (
                NAME 'moodleCourse'
                SUP top STRUCTURAL
                DESC 'course available in Moodle'
                MUST ( cn  )
                MAY ( owner $ gn $ sn $ seeAlso $ description $ memberUid $ teacherUid )

The configuration is like this, in bold you see required changes, in italic you see useful changes.

LDAP Enrollment Variable:Value:

Note: The enrol_ldap_course_idnumber (cn in my setup) is used to identify the course by the LDAP enrolment script and the database uses an INTEGER numeric here, in Moodle v1.8 anyway. When youcall 

cd enrol/ldap/ && php -f enrol_ldap_sync.php

 any course with the same idnumber is updated, hence,

it is quite important for the LDAP synchronisation and needs to be unique.

Sample of an moodleCourse LDAP object:

dn: cn=851,ou=moodle,ou=groups,dc=ldapserver,dc=tmcc,dc=edu
objectClass: moodleCourse
cn: 851
givenName: LV851
sn: 2007S/Introduction to Moodle
description: Jahr: 2007 Sommer, <A TARGET=_blank HREF="https://other_server/display/851">Announcement</A>
teacherUid: userA
memberUid: user1

In the same fashion one can add all the other role mappings.

See also

Using Moodle forum discussions:

Learn enrolments

IMS Enterprise



About IMS Enterprise

IMS Enterprise is an international standard XML file format which may be used to create and update user accounts, enrol and unenrol users from courses, assign roles, create courses and course categories, and update course full and short names.

Using this enrolment method

To use IMS Enterprise enrolment, it must be enabled in ‘Manage enrol plugins’ in the Site administration.

IMS Enterprise enrolment will import an XML file from on your Moodle server. Set “File location” to the full path to your xml file (locally on the server, e.g. /home/user/imsenterprise/file.xml)

IMS Enterprise is not added to courses, but instead you run the import directly from the “Site administration > Plugins > Enrolments > IMS Enterprise file” page. To do this, click the “perform an IMS Enterprise import right now” link or run cron.

Format overview

Below is a simple guide to the basic structure of a typical IMS Enterprise data file. Much more information is available on the IMS Enterprise official website.

You may like to read the conformance summary which describes which IMS data elements this plugin can process.

Basic guide to IMS Enterprise file format

For any IMS-style enrolment you need a <group> tag which specifies the course, a <person> tag which specifies the user account, and a <membership> tag containing <member> tags which specify a person’s role within a given course.

Remember that the numeric keys used in the Moodle databases are not the interoperable data – a student data system is never going to know in advance that Joe is the 20th user added to the Moodle database – so those aren’t the keys exchanged in this type of data.

Typically a course would have a reference code as well as a name, so let’s assume its code is MOODLE101. If you require a new course to be placed in a category other than the default, you can specify that using the <orgunit> tag. To define your course you could use

     <short>Moodle 101</short>
     <long>Moodle 101: Course Name</long>

The enrolment script will look for a course with code MOODLE101, and (optionally) create it if it doesn’t exist, the plugin also allows you to map between group tags and the course shortname, fullname and summary fields. Similarly for the person – let’s assume it’s “jmoodle”:

     <fn>Joe Moodle</fn>

If Joe doesn’t already have an account, the script can (optionally) create an account for him.

Let’s now look at the membership, adding the person to the course:

     <role roletype="01">
       <extension><cohort>unit 2</cohort></extension>

The IMS Enterprise specification does offer a facility for specifying start/end dates for enrolments, so those can be included using the <timeframe> tag if needed.

If a person is already added to a group within the course, the script won’t actually modify that. If they are not grouped, however, then the specified grouping will be applied.

Automatic creation of new courses

If required, the IMS Enterprise enrolment plugin can create new courses for any it finds in the IMS data but not in Moodle’s database.

Courses are first queried by their “idnumber” – an alphanumeric field in Moodle’s course table, which can specify the code used to identify the course in the Student Information System (for example). If that is not found, the course table is searched for the “short description”, which in Moodle is the short course identifier as displayed in the breadcrumbs etc. (In some systems these two fields may well be identical.) Only when that search has failed can the plugin optionally create new courses.

Any newly-generated courses are HIDDEN when created. This is to prevent the possibility of students wandering into completely empty courses that the teacher may be unaware of.

Unenrolling students/teachers

If required, the Enterprise data can add as well as remove course enrolments – for students and for teachers. If this setting is turned on, then Moodle will carry out unenrolments when specified in the data. Note, as of Moodle 2, you must use IMSEnterprise to remove members that have been added by the plugin. You cannot manually delete a member.

There are three ways of unenrolling students within the IMS data:

  • A <member> element which specifies the given student and course, and with the “recstatus” attribute of the <role> element set to 3 (which means “delete”). THIS IS NOT YET IMPLEMENTED IN THE MOODLE PLUGIN.
  • A <member> element which specifies the given student and course, and with the <status> element set to 0 (which means “inactive”).

The third method is slightly different. It does not require this config setting to be activated, and can be specified well in advance of the unenrolment date:

  • A <member> element which specifies a <timeframe> for the enrolment can specify the begin and/or end dates for enrolment of this particular student. These dates are loaded into Moodle’s enrolment data table if present, and so after the end-date, a student will no longer be able to access that particular course.

See also

Learn enrolments

Flat file

The flat file enrolment plugin allows bulk enrolment management (enrol or unenrol) of existing users in existing course via a CSV file.

The file is processed by the Flat file enrolment sync scheduled task and then deleted.

The file should include action, role, user ID number, and course ID number; start time and end time are optional fields. Details of the file format are shown on the flat file settings page Site administration > Plugins > Enrolments > Flat file (CSV).

Enabling flat file enrolment

An administrator can enable flat file enrolment as follows:

  1. Go to Site administration > Plugins > Enrolments > Manage enrol plugins and click the eye icon opposite Flat file (CSV). When enabled, it will no longer be greyed out.
  2. Click the settings link, configure as required (see details of settings below), then click the ‘Save changes’ button.

File location

You should specify an absolute path for the upload file (eg /var/moodledata/enrolments.txt) where it can be read and modified by the web server process. The file is automatically deleted after processing.

File encoding

Make sure, you save the file (for example in a text editor) with the same encoding.


You can choose to have an email sent to notify the Administrator, Teachers and/or students when the file has been processed.

Unenrolment action

  • “Unenrol user from course” When the user disappears from the external source, the enrolment is completely removed and all the roles removed. This means some user data and settings are purged from course during course unenrolment (that usually include grades, activity attempts, etc.)
  • “Keep user enrolled” When the user disappears from the external source, the enrolment is kept as is, and the user is still able to enter the course and perform activities, access resources, etc. It’s a “do nothing” option.
  • “Disable course enrolment and remove roles” When the user disappears from the external source, the enrolment is suspended and roles assigned by enrol instance are removed. Please note that user may “disappear” from gradebook and other areas.

Any questions?

Please post in the Enrolment forum on

See also

Learn enrolments

External database enrolment



Using an external database to control enrolments

You may use a external database (of nearly any kind) to control your enrolments. It is assumed your external database contains a field containing a course ID, a field containing a user ID, and optionally a field containing a role. These are compared against fields that you choose in the local course, user tables, and role tables.

The following are the supported data sources, but note that you will need to have to compiled PHP with the appropriate options or through ODBC.

  • access
  • ado
  • mssql
  • borland_ibase
  • csv
  • db2
  • fbsql
  • firebird
  • ibase
  • informix72
  • informix
  • mysql (deprecated, please use mysqli instead)
  • mysqli
  • mysqlt
  • oci805
  • oci8
  • oci8po
  • odbc
  • odbc_mssql
  • odbc_oracle
  • oracle
  • postgres64
  • postgres7
  • postgres
  • proxy
  • sqlanywhere
  • sybase
  • vfp

Enrolment and unenrolment

External database enrolment happens at the moment when a user logs into Moodle. The plugin will attempt to automatically enrol the student in all their courses according to the data in the external database and, optionally, create empty courses where they do not already exist. To check if it is working, you can log in as a student and then check that their list of courses is as you would expect.

The process also unenrols users from courses if they are no longer in the database. User records are marked according to their original enrolment method. Therefore the external database plugin can only unenrol users who were enroled by the plugin in the first place.

Hidden courses

Courses that are set to “Course is not available to students” can be ignored for enrolment purposes by setting the “enrol_db_ignorehiddencourse” to yes.

Enrolment and roles

The “enrol_database | defaultrole” setting in the plugin settings page specifies the role that the user will take when they are added to the course. The default setting will set them to the course default setting (initially “student”). However, you can specify a field in the external table (specified in the “enrol_database | remoterolefield” setting) that contains the short name or id for the user’s role. This could, for example, be used to enrol both students and teachers into courses using a suitably configured database.


The External unenrol action (“enrol_database | unenrolaction”) setting in the plugin settings page defines what action should be taken when a user enrolment disappears from external enrolment source. Each setting does the following:

  1. “Unenrol user from course” When the user disappears from the external source, the enrolment is completely removed and all the roles removed. This means some user data and settings are purged from course during course unenrolment (that usually include grades, activity attempts, etc.)
  2. “Keep user enrolled” When the user disappears from the external source, the enrolment is kept as is, and the user is still able to enter the course and perform activities, access resources, etc. It’s a “do nothing” option.
  3. “Disable course enrolment” When the user disappears from the external source, user enrolment is suspended (the user can’t access the course, but user data and settings are kept), and roles are kept as is. You might use this because in some cases the user needs a role with some capability to be visible in UI – such has in gradebook, assignments, etc.
  4. “Disable course enrolment and remove roles” When the user disappears from the external source, the enrolment is suspended and roles assigned by enrol instance are removed. Please note that user may “disappear” from gradebook and other areas.

Creating courses

Optionally courses that do not exist in the Moodle site can be created.

You can additionally specify the Category into which the new course will be placed, in the New course category id field. The data in this field must be the id of a currently existing category; it will not create a new category. The id number is number assigned by Moodle in the database when the category is created (e.g.

  • Do not confuse this category id with the new custom category id number field that you can manually assign to a category. (See Trackers and
  • Leaving the category id data empty means that a course will be assigned to the default category.
  • If you assign data to categories that do not exist already in Moodle, the courses will not be created.

Default new course category is the category to which courses will be assigned and created in, unless you set up and so indicate in the data field of the “New course category id field.”

You may also specify a New course template: a “template” course from which the new course will be copied. The data for this field should be the shortname of the template course.

Synchronising external database enrolments (scheduled task and deprecated script)

A scheduled task called “Synchronise external database enrolments task” synchronises all user enrolments at once – both adding and removing user enrolments (and creating courses if specified) (MDL-59986).

Note that you need to make sure all the users present in the external enrolments are already created in Moodle, because users not existing in Moodle can’t be enrolled in a course. If you are using external authentication plugins (db, ldap, etc.) you can use the scripts provided by those plugins to synchronise your users before running this script.

A deprecated script is also provided that can do this task if the scheduled task is disabled (if the scheduled task is enabled the script won’t do anything). The script is called sync.php and is found in the enrol/database/cli folder.

This script is meant to be called from a system cronjob to sync moodle enrolments with enrolments in the external database.

Example cron entry

   # 5 minutes past 4am
   5 4 * * * /usr/bin/php -c /path/to/php.ini /path/to/moodle/enrol/database/cli/sync.php


  • If you have a large number of enrolments, you may want to raise the memory limits by passing -d memory_limit=256M
  • For debugging and better logging, you are encouraged to use in the command line: -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
  • This only works for users that already exist in your Moodle site (see comment above)

Setting up enrolment sync (How to)

You will need to perform (as a minimum) the following steps to enable external database enrolment – only a single table is required in the database which contains a record for every user/course combination. If the table is large it is a good idea to make sure appropriate indexes have been created:

  • Use an existing database or create a new one. Use an existing table or create a new one with the following minimum fields.
    1. A unique course identifier to match one of the following fields.
      • the “idnumber” field in Moodle’s course table (varchar 100), which is manually specified as the “Course ID number” when editing a course’s settings
      • the “shortname” field in Moodle’s course table (varchar 255), which is manually specified as the “Course short name” when editing a course’s settings
      • the “id” field in Moodle’s course table (int 10), which is based on course creation order
    2. A unique user identifier to match one of the following fields.
      • the “idnumber” field in Moodle’s user table (varchar 255), which is manually specified as the “ID number” when editing a user’s profile
      • the “username” field in Moodle’s user table (varchar 100), which is manually specified as the “Username” when editing a user’s profile
      • the “email” field in Moodle’s user table (varchar 100), which is manually specified as the “Email address” when editing a user’s profile
      • the “id” field in Moodle’s user table (int 10), which is based on user creation order
    3. (optional) A unique role identifier to match one of the following fields.
      • the “shortname” field in Moodle’s role table (varchar 100), for example editingteacher, coursecreator, student, …
      • the “name” field in Moodle’s role table (varchar 255), for example Teacher, Course creator, Student, …
      • the “id” field in Moodle’s role table (int 10), which is based on initial installation and new role creation order
  • Populate the database table. Each user/course combination to have a record in the table.
  • In Moodle, go to Site administration > Plugins > Enrolments > Manage enrol plugins, find External Database in the list, enable it (click the closed-eye icon) and click Settings.
  • In the top panel, select the database type (make sure you have the necessary configuration in PHP for that type) and then supply the information to connect to the database.
  • The middle panel creates the mapping between Moodle and the external database. The first three settings are for the local (Moodle) field names and the last three for the remote (external database) settings. They are in the same order.
    • enrol_localcoursefield / enrol_remotecoursefield – in Moodle the name of the field in the course settings the uniquely identifies the course (e.g., idnumber). In the external database the name of the matching field.
    • enrol_localuserfield / enrol_remoteuserfield – in Moodle the name of the field in the user profile that uniquely identified the user (e.g., idnumber). In the external database the name of the matching field.
    • enrol_db_localrolefield / enrol_db_remoterolefield – (optional) in Moodle the name of the field in the role edit page the uniquely identifies the role (e.g., shortname). In the external database the name of the matching field.
  • The Roles panel specifies the role that the user will get in the course if their role is not specified in the external database.
  • A new optional field enrol_database | remoteotheruserfield allows those with the role “Other users” to be added but not to be included as course participants.
  • The final panel enables auto creation of courses.
  • Save changes, and then tick the box to enable external database enrolment.

Field Mapping Example:

Choose your fields from the Moodle database:

  • enrol_localcoursefield: A course identifier from mdl_course, e.g. “idnumber”
  • enrol_localuserfield: A user identifier from mdl_user, e.g. “idnumber”
  • enrol_localrolefield: (optional) A role identifier from mdl_role, e.g. “shortname”

Create a view in your external database which matches the chosen field values from Moodle:

  • enrol_remotecoursefield: A matching course identifier from your external database table, e.g. “course_number”
  • enrol_remoteuserfield: A matching user identifier from your external database table, e.g. “userid”
  • enrol_remoterolefield: (optional) A matching role identifier from your external database table, e.g. “role_name”

Potential gotchas

  • It almost goes without saying that the integrity of the external database is important. If data is missing from the database then there is a potential for users being unenrolled from some or all of their courses. The unenrollment process will remove them from any group assignments and also poll each module type to give the module the option of removing that user’s data if appropriate (for example, however, forum posts are never deleted). It is therefore prudent that you take the utmost care to ensure that the data in the external database is correct at all times.
  • Minor Security Issue Consider that if the ID number field you use to identify your students is editable by the students (in their profile), then there is a potential for them changing this to the id of another valid student and gaining access to resources that they should not. (However, they will still appear as themselves, they cannot impersonate the other user or otherwise gain access to their resources.) To prevent this and similar issues, you can lock the ID number as well as other fields so the user can not change them. Do this in the Data mapping section of Site administration > Plugins > Authentication > External database.

Errors and diagnostics

The plugin produces a number of diagnostic messages and/or errors which are recorded to the PHP error log (as defined in the php.ini file). In addition messages about courses that are in the database for the user but that do not exist in the Moodle site will only be produced if debugging is set to ALL or DEVELOPER.

You can get detailed progress information by executing the sync script with -v parameter:

 php /path/to/moodle/enrol/database/cli/sync.php -v

See also

Learn enrolments

Guest access

The Guest access facility allows users with the Guest role to view the contents of a course. This might be used, for example, if a Moodle site serves as a website where certain courses contain publicly available information, or else with a commercial Moodle site where courses with guest access can offers a “taster” of the kind of courses which may be purchased. (Note that the guest cannot participate in any activities; they can only view content.)



Course settings for guest access

How to allow guests into courses

  1. With the Boost theme, from the navigation drawer on the left, click ‘Participants’, and then from the gear menu on the right, click ‘Enrolment method> Guest access’. With other themes, click Administration > Course administration > Users > Enrolment methods and then Guest access.
  2. Enable guest access by clicking on the “eye” icon or by choosing it in the ‘Add method’ dropdown menu.
  3. If you wish to set a password, then click the configure icon and type in your password here.

Admin settings for guest access

How to allow guests onto your Moodle site

  • In Administration > Site administration > Plugins > Enrolments > Manage enrol plugins,ensure Guest access is enabled (has its eye open.) This enables Guest access.
  • In Administration > Site administration > Plugins > Authentication > Manage authentication set the Guest login button to Show if you want the button on the Front page.
  • Also Guest accounts can be logged – check the Administration> Site administration > Plugins > Logging > Log guest access setting
  • A site policy for guests may be set in Site administration > Security > Site policies. Guests then have to agree to the site policy before accessing a course with guest access.

Default settings for guest access

  • Clicking on Administration > Site administration > Plugins > Enrolments > Guest access brings up the screen where admin can set defaults for guest access in courses.
    • Clicking the ‘Advanced’ button next to ‘Allow guest access’ will hide this setting in a course and will instead display a ‘Show more’ link to click on to access the setting.
    • Guest access can be turned on by default in all new courses and you can also:
    • require each course with guest access to have a password for guests. (Note: this can confuse teachers who are not aware of the requirement.)
    • use or ignore your Moodle’s standard password policy for guest access passwords
    • offer if needed the first letter of the password as a hint.

Auto-login guests

  • In Administration > Site administration > Users > Permissions > User policies, you can tick the box so that visitors are automatically logged in as guests when accessing a course with guest access (i.e. they don’t have to click the “login as guest button”.
  • In Administration > Site administration > Plugins > Authentication > Manage Authentication, you must have “Guest login button” set to “Show”.
  • In Administration > Site administration > Security > Site policies you can check “Open to Google” setting so that the Google search robot will be allowed to enter your site as a Guest. In addition, people coming in to your site via a Google search will automatically be logged in as a Guest.

See also

Learn enrolments

Course meta link



About the Course meta link

The Course meta link makes it possible for all users enrolled in one course to be automatically enrolled in one or more other courses. The Course meta link plugin needs to be enabled both on the site level by the site admin and has to be enabled within the course.

Course settings for Course meta link

  • In a course, go to Administration > Course administration > Users > Enrolment methods.
  • Click the dropdown menu under the enrolment methods and select ‘Course meta link’.
  • In the screen that comes up next, either type in a search term to find your course, or select from the dropdown box the course or courses you wish to bring enrolments from, and then click ‘Add method’:

Several courses may be selected at once

  • For each linked course, the users may be added to an existing group in the new course, or a new group may be created for them. (Groups from the linked courses are not synced to groups in the new courses. All users will be added to one group when the link is made.)

Note: A teacher in a course will only be able to choose from courses they are teachers in elsewhere.

  • The users from the source (child) course will now be enrolled in the current course – see the numbers in the screenshot below:
  • When new users are enrolled to the source (child) course, they will be automatically brought into the current target (meta)course.

Site settings for Course meta link

The Course meta link plugin may be enabled or disabled throughout the site in Administration > Site administration > Plugins > Enrolments > Manage enrol plugins.

The page Administration > Site administration > Plugins > Enrolments > Course meta link contains options for defaults that admin can set. (It can be also be accessed by clicking the Settings link on on the course meta link section of Administration > Site administration > Plugins > Enrolments > Manage enrol plugins)

By default all role assignments from child courses are synchronised to meta courses. However, the “Roles that are not synchronised to metacourses” setting enables administrators to exclude particular roles.

Course meta link capabilities

Enabling teachers to add meta links

An administrator can enable teachers to add course meta links as follows:

  • Go to Site Administration > Users > Permissions > Define Roles
  • Select the Teacher Role and click on the Edit button
  • Scroll down to Course Meta Link as shown in the images below:
The default setting is “Not Set”
When the Edit button is clicked, the panel changes to “Allow” and a checkbox
Change to “Allow” by a click on the checkbox.
  • Scroll to the bottom of the page to save your changes.

Examples of meta-linked courses

Created – a child course and a meta course.Associating one child course and one meta course.

Examples: one “child” course (a course linked to a meta course) can be associated with many meta courses. Or one meta course can have many child courses associated with it. Both the child courses (non-meta courses) and the meta courses are independent and can be recycled many times, that is, each can be associated with many of the other.

2 child courses and a meta course.1 child course and 2 meta courses.3 child courses and 2 meta courses.

There is one limitation: you cannot ‘nest’ metacourses. In other words, if you have child course A linked to meta course B, and you then link B as a child course to meta course C, a student enrolled in A will be added to B, but not to C. In this situation, you would need to add a meta link directly between A and C instead of trying to nest them. (Another option might be to use Cohorts.)

See also

Some known issues:

  • MDL-34938 – Important Open Issue: Enrolment expiration date settings in child course do not properly unenrol students from the Meta-course – (old: FIXED as of Moodle 2.9)
  • MDL-27628 – A workaround in the tracker for adding more than one course at a time (old: FIXED as of Moodle 3.1)

How to use:

Learn enrolments

Cohort sync



About cohort sync

Cohort sync is for automatically enrolling members of a cohort in a course. If a user is added or removed from the cohort, they are automatically enrolled or unenrolled respectively. In other words, cohort sync synchronises cohort membership with course enrolment.

Enabling cohort sync

To use cohort sync, it must be enabled by an administrator in Site administration > Plugins > Enrolments > Manage enrol plugins.

Cohort themes

If cohort themes have been enabled in the Theme settings page of Site administration, then a specific cohort theme may be selected when creating or editing the cohort:

Learn enrolments

Enrolment plugins

Moodle provides a number of ways of managing course enrolment, called enrolment plugins.

Setting the enrolment method(s)
To set an enrolment method:
Click on Administration > Site administration > Plugins > Enrolments > Manage enrol plugins.
Click on the enable checkboxes opposite your chosen enrolment plugin(s). If you wish, you may choose more than one enrolment method. For example if you have some courses which students must pay for and some free courses, you can use PayPal and self enrolment.
Click the “Save changes” button.
Click the settings link opposite the enrolment plugin(s) you have chosen.
Configure the required settings and click the “Save changes” button.
Repeat until you have edited all the plugins you have enabled.
The order in which enrolment plugins are applied can be set. This may be important for some plugins. It also affects the order of enrolment options on the course enrol page.
Enrolment capabilities
Category enrolments:
Role assignments synchronised to course enrolment
Cohort sync:
Configure cohort instances
Guest access:
Configure guest access instances
LDAP enrolments:
Manage LDAP enrol instances
Manual enrolments:
Configure manual enrol instances
Enrol users
Manage user enrolments
Unenrol users from the course
Unenrol self from the course
Course meta link:
Configure meta enrol instances
Select course as meta linked
Configure PayPal enrol instances
Manage enrolled users
Unenrol users from course
Unenrol self from the course
Self enrolment:
Configure self enrol instances
Manage enrolled users
Unenrol users from course
Unenrol self from the course
Configure enrol instances in courses
Review course enrolments
See also
Enrolment FAQ
Using Moodle Enrolment Plugins forum