Moodle flat file and IMS Enterprise enrolment

Moodle's flat file and IMS Enterprise enrolment methods load course memberships from files that a legacy system produces. This page covers how the feeds are processed, what to configure, and how to confirm that files are actually processed.

On this page

When a file feed is the right way to enrol Moodle users

A file feed is the right choice when a legacy system or student information system can export files on a schedule but cannot call Moodle directly and cannot expose a database view. The flat file enrolment plugin reads a specially formatted text file from a location you configure, creates or removes course enrolments, and works through Moodle's cron. The IMS Enterprise enrolment plugin reads XML files in the IMS Enterprise format, which many campus and SIS products already export. Both pull changes in from a file, so the source system needs no Moodle credentials, no open database port and no API client code.

Teams usually choose a file feed over a database or web service sync for three reasons. The export is often already built and approved by the source system owner, so the change is small. Files also leave an inspectable record of what was sent, which helps during audits and when a term's enrolments need checking. And a file can be reviewed, held or replayed without touching a live database. The trade-off is latency: changes appear only at the next processing run, so confirm with your registrar or HR owner how quickly enrolments must reflect a change, and whether a late file is acceptable. If the feed needs near-real-time updates or detailed error responses per record, a web service design is usually the better fit, and the sibling pages on database and web service provisioning cover that route.

Choosing between flat file, IMS Enterprise and other enrolment sync methods

The flat file method is Moodle's simplest file-based route. A legacy system exports a specially formatted text file to a location the Moodle server can read, and the enrolment plugin checks that location on each cron run and processes what it finds. The file is produced by whoever owns the source export, often an HR or student records team working from a scheduled report. It fits small, stable populations and sources that can only produce files, but it depends on the file arriving on time and being removed after processing.

  • Input: a delimited text file with one enrolment action per line, written to a configured folder on the server.
  • Producer: usually an export job in the source system, run by the team that owns the data.
  • Fits: a single source that can only export files, modest volumes and changes made in batches.
  • Does not fit: near-real-time changes, sources that need error feedback per record, or sites where the file share cannot be locked down.
  • Risk: if cron cannot delete a processed file, Moodle may process it again on later runs.

Confirm with your Moodle administrator how cron runs on your server and who owns the file location before you choose this route.

How a feed file moves from the source system into course enrolments

The flow starts when the legacy system exports a flat file or IMS Enterprise XML feed and places it in a location the Moodle server can read. Cron then runs the flat file enrolment task, which checks that location, applies enrol, suspend and unenrol actions to course memberships, and attempts to delete the processed file. The two points to check are file permissions, so the web server user can read the file, and deletion, because a file cron cannot delete may be processed again on every run.

Feed file flow from export to course enrolments, with failure points at permissions and deletion.

How the flat file format and cron processing work

The flat file enrolment plugin (enrol_flatfile) works from a single specially formatted text file that a source system writes to a location you configure on the Moodle server. The plugin does not read a database or call an API. It repeatedly checks that location for the file, and each time cron runs it reads the file, applies the enrolments and unenrolments it describes, and then tries to delete the file so the same instructions are not applied again. Because the file is the only input, the export from your legacy system must produce it on a schedule that matches how often you need course memberships to change, and the writer must know exactly when Moodle will pick it up relative to that export.

The most important failure to plan for is the warning Moodle raises when cron cannot delete the processed file. If the file cannot be removed, for example because the web server or cron user lacks write permission on the directory, the plugin can process the same file again on later cron runs, re-applying old instructions over changes made since. Treat the deletion step as a control to test, not a detail: confirm that the cron user owns or can write to the feed location, that the export process replaces the file rather than appending to it, and that the warning appears in your site's notifications or logs so someone sees it. Monitoring for stale or repeatedly processed files belongs in the operations plan.

Before building the export, confirm the exact field layout, delimiter, action codes, role identifiers and course and user identifier formats in the current enrol_flatfile documentation and language strings for the Moodle version you run, since these details are what the export must match. The enrol_flatfile language strings are the place to start, and a test file run on a non-production site will show how the plugin treats malformed rows. Record the layout as a specification the source system owners sign off on, because a change to the source extract later will otherwise fail silently.

Configuration options and when each fits

This table compares the main configuration decisions for a flat file or IMS Enterprise feed: where the file lives, how often cron processes it, how missing users and courses are handled, and what happens to file and enrolments afterwards. Read each row against your source system's export behavior, and treat the wrong setting column as the failure to test for before go-live.

OptionWhen it fitsWhat breaks if set wrongly
File locationA directory the Moodle cron user can read, and the source system can write to, outside the web-served document rootCron cannot find or read the file, so no enrolments change and the feed looks healthy from the source side
Processing schedule through cronA cron interval that matches how often the source system drops a new file, with a check that cron runs at allFiles wait too long, or cron stops and nothing is processed; late runs can apply stale changes out of order
Action on missing users or coursesChoose a policy agreed with the data owner, and confirm in a test run whether unknown records are skipped or createdEnrolments fail silently for new starters, or courses and accounts are created from incomplete source data
Role assignmentMap each role code in the feed to a Moodle role you have reviewed, and keep the mapping in version controlLearners receive teacher or manager roles, or the role code is ignored and users get no effective access
Unenrolment behaviorConfirm whether removed rows or explicit unenrol actions are expected by the source, and test with a sample file firstUsers keep course access after leaving the source system, or large unenrolments happen after a truncated file
File deletion or archive handlingLet cron remove the file only when its permissions allow it, or move processed files to an archive path you monitorIf cron cannot delete the file, Moodle warns and the same file can be processed repeatedly, repeating enrolment changes
File permissionsRestrict write access to the feed account and read access to the Moodle process, with no public accessOther accounts can alter the feed, or Moodle cannot read it, so the feed is either tampered with or silently ignored
Monitoring of processingAlert on a file left unprocessed past the expected window and review the cron and enrolment logs after each runFailures stay invisible until a user reports missing access, which is often after the enrolment window has passed

Setting up a file feed enrolment in Moodle

This sequence takes a flat file enrolment feed from an agreed format to a scheduled production job, with a check at each stage so that course memberships change only when the source file says they should. It keeps the test on a non-production course until the cron logs and enrolments confirm the behavior.

  1. Confirm the enrolment plugin is enabled

    The Moodle administrator checks in site administration that the flat file enrolment method is installed and enabled for the target version, and that it is available in the course enrolment methods for the test course. Confirm the version against the Moodle release notes for the site, because plugin availability and settings can differ between releases. Done means the plugin appears as enabled in the enrolment plugins list and the administrator can open its settings page without an error.

  2. Agree the export format with the source owner

    Work with the owner of the legacy system or student information system to fix the exact layout of the flat file: field order, delimiter, action codes for add and remove, role names, course short names and the user identifier. Ask the owner for a sample file and a description of when it is generated and how it is named. Done means both parties sign off on a written specification and a sample file that matches it line by line, including how a removed enrolment is expressed.

  3. Create a dedicated directory with restricted ownership

    The Linux administrator creates a directory for incoming feeds outside the web root, so the file is never served over HTTP, and assigns ownership to the account that runs Moodle cron with write access for the source process and read access for Moodle only. Remove world-readable permissions from the directory and its files. Done means the Moodle cron user can read and delete files in the directory, the web server user cannot read them, and a test write by the source account succeeds.

  4. Configure the plugin in Moodle

    In the flat file enrolment settings, the administrator enters the full path to the feed file, sets the field separator, default role and the behavior for removed enrolments, and maps the source role names to Moodle roles. Record each setting in the change log for the site. Done means the settings page saves without validation errors and the configured path points to the dedicated directory, with the values matching the agreed specification.

  5. Run a test file against a non-production course

    The team creates a small test file that covers one add, one role change and one removal, and places it in the dedicated directory on a non-production site or against a course created only for testing. Trigger cron manually or wait for the next run. Done means the test course shows the expected enrolments and roles, the removed user is unenrolled as the specification requires, and no unrelated course or user has changed.

  6. Check cron logs and course enrolments

    The administrator reviews the output of the cron run and the site logs for messages from the flat file enrolment plugin, looking specifically for warnings that cron could not delete the processed file, because a file that is not removed can be processed again on later runs. Compare the course participant lists with the test file line by line. Done means the logs show a successful run, the processed file has been removed from the directory, and the enrolments match the test file exactly.

  7. Switch on the production schedule

    Once the test passes, the administrator points the plugin at the production feed path, confirms that the source process writes complete files and does not overwrite a file that is still being processed, and checks that cron runs on the intended schedule. Set up monitoring that alerts the team when a feed file is older than expected or still present after a run. Done means the first production run completes, the monitoring alert fires correctly in a deliberate test, and the team has a documented procedure for re-running or correcting a feed.

File permissions and ownership that stop feeds silently failing

Moodle's flat file enrolment checks a location on every cron run, and if cron cannot delete a processed file, the same file can be applied again and again. The cards below cover the permission, location and write practices that keep each feed processed once, and fail loudly when they do not.

Cron user must read the file

The account that runs Moodle cron must be able to read the feed file in the configured location. If it cannot, the enrolment run cannot apply changes and the feed sits unprocessed without an obvious error in the Moodle interface. Check the file as the cron user (for example, with a test read run under that account) after every change to the path, the owner or the web server user. Confirm the path in the flat file settings matches the directory you tested.

Cron user must delete the file

Deletion is what stops repeat processing. The warning in Moodle's flat file language strings states that if cron cannot delete the file, it may be processed repeatedly. Give the cron user delete rights on the file itself, which on most Linux systems means write permission on the containing directory, not just on the file. Test the delete step explicitly, because a successful read tells you nothing about whether the file will be removed afterwards.

Flat file language strings

Directory must not be publicly writable

The drop directory should be owned by a dedicated account and group, with write access limited to the source system's transfer account and read and delete access limited to the Moodle cron user. A world-writable directory lets any local user plant or replace a feed, which means an unauthorized enrolment change can look like a legitimate file. Review the mode bits and the group membership of the directory, and check the parent directories as well, since a permissive parent can undo a tight child.

Feed directory must stay out of the web root

Feed files contain names, identifiers and course memberships, so they should not sit under the Moodle code, data or public directories that the web server serves. Place the drop directory outside the document root and confirm that a direct HTTP request for a known file name returns a not-found or forbidden response. This matters most on sites that moved to the /public document root in Moodle 5.1, where folder layout changed and older paths may now be reachable by mistake.

Source system gets write-only access

The system that produces the feed needs to create files in the drop directory and nothing else. Give its transfer account write and execute rights on the directory, but no read, delete or rename rights on existing files, so it cannot alter a file Moodle has not yet processed. Use a dedicated account rather than a shared administrator login, and record which account produced each feed so an unexpected file can be traced back to its source.

Write files atomically

Moodle should never read a feed while it is still being written, because a partial file can enrol some users and skip others with no clear error. The source system should write the complete file under a temporary name in the same directory, then rename it into the watched name in one step. Renames within one filesystem are atomic on common Linux setups, so confirm the temporary and final names share a filesystem and that the cron user is not configured to pick up the temporary name.

Questions teams ask before running file-based enrolment

How much effort does building the export and field mapping take?

Effort depends mostly on how clean the source data is and how many fields must map into the feed. The export query, the mapping of source codes to Moodle course shortnames, role identifiers and user idnumbers, and the handling of edge cases such as students who change sections, are the main work. Each additional source table, term rule or course type adds testing time. A small feed with one source and stable codes is far simpler than a feed that merges several student information systems. Ask any partner for a written breakdown of the export, mapping, test cycles and handover, and ask which of those items are one-time and which recur each term.

Can our own team run file-based enrolment without outside help?

A capable Moodle administrator with access to the server can usually set up a flat file feed, provided someone on the source side can produce the file on a schedule. The harder part is ownership: the export depends on a system your team may not administer. Teams with a Linux administrator, a Moodle administrator and a named data owner in the source system can often run it internally. Teams without shell access to the web server, or without anyone who can read the source schema, usually benefit from a partner for the first build and the test cycle. Confirm the Moodle release in use before planning, since the enrolment plugin settings and cron behaviour are checked against your installed version.

What does the source system owner need to provide?

The source system owner must agree on the file format, the field list, the update frequency and who owns failures. In practice they provide a sample export, a data dictionary for course and user codes, a rule for how withdrawn or suspended students appear, and a named contact for schedule changes. Without these, the feed becomes a guess. Ask the owner to confirm whether the export is a full snapshot or a list of changes, because that choice determines how unenrolments are handled. Record the agreement in writing before the build starts so later changes to the source are treated as scope changes.

How do we handle unenrolments safely?

Unenrolment is the step that causes the most damage when it goes wrong, so it should be designed on purpose. Decide whether a missing row means the student left the course or the export failed. A full snapshot can remove enrolments when a partial file arrives, so validate row counts against the previous run before processing. Use an unenrolment action only for records the source explicitly marks as withdrawn, and keep a backup before each run. Test with a copy of the site using a file that removes known test users. Confirm how your release handles these actions in the enrolment plugin documentation.

How do file feeds compare with database or web service sync?

A file feed is the simplest option when the source can only export data on a schedule and you want no live connection to the database. It is easy to inspect, because each file can be kept and reviewed. Its weaknesses are latency, reliance on cron running, and the risk of silent failure if no one checks that files are processed. A database sync, covered in the external database enrolment topic, reads the source directly and gives finer control over timing. A web service design, covered in the provisioning topic, suits systems that push changes in near real time and need strong error handling. Choose based on how often enrolments change, who can grant database access, and whether your team can monitor the chosen route.

Which items should we confirm against the Moodle release in use?

Confirm the enrolment plugin's settings, the cron and task behaviour, and the supported PHP and database versions for the release you run. Moodle 5.1 requires 64-bit PHP 8.2 or later and sites must be on Moodle 4.2.3 or later to upgrade, while Moodle 5.3 requires 64-bit PHP 8.3 or later and sites must run Moodle 4.4 or later to upgrade. Check the file permissions on the feed location for the web server user, and confirm that cron can delete processed files, because the plugin warns that a file cron cannot delete may be processed repeatedly. Confirm IMS Enterprise XML handling in the release notes before you commit to that format.

How do we know the feed is actually being processed?

Monitoring should confirm that each expected file was read, processed and removed from the feed location, and that the enrolment counts match the source. Set an alert when no file arrives within the expected window, when a file remains after processing, and when the row count drops sharply. Review the Moodle logs and cron output after each run. A partner or internal team can build these checks, but they depend on cron running reliably, so include cron health in the same monitoring plan.

Limits to confirm in your environment before go-live

The flat file and IMS Enterprise enrolment behavior described here depends on the Moodle release, plugin status and volume of data in your environment. The cards below list the points we cannot settle from published facts, so each one should be tested on a staging copy of your own feeds before production cron runs.

Plugin availability in your release

Flat file enrolment ships as an enrolment plugin, but its availability, default state and settings must be checked against the exact Moodle release you will run, including any point release. Confirm whether the enrolment method is enabled at site level and in each course, and whether your hosting stack or security policy restricts it. Record the release and plugin version in your build notes so the check is repeatable at each upgrade.

Flat file language strings

Supported IMS Enterprise elements

IMS Enterprise XML is a family of structures, and not every element, attribute or role code in a source system will be read the same way by Moodle. Ask your student information or HR system for a sample export, then map each record type to what Moodle actually creates or changes. Test person, group and membership records separately, and confirm how unknown elements are handled before you rely on the feed.

Unenrolment behavior on large feeds

Removing a user from a course is the riskiest part of a feed, because a truncated or malformed file can look like a mass withdrawal. Confirm how the enrolment method treats missing records, whether it unenrols or only suspends, and how it behaves when a feed is far smaller than the last one. Agree a rule with the data owner for when a run should stop for review instead of applying changes.

File size, frequency and cron timing

Feed processing runs inside Moodle's scheduled tasks, so a large file can extend a cron run, compete with other tasks and delay later jobs. Measure run time with a realistic copy of your largest export and confirm the cron interval that suits your delivery schedule. Check whether your web server or PHP limits stop an upload or read before Moodle does, and plan for a retry when a run fails midway.

Duplicate and conflicting rows

When two rows describe the same user or the same course membership with different roles, dates or statuses, the result depends on processing order and the rules in the plugin. Confirm how duplicate user records are matched, which identifier is authoritative, and what happens when one file adds a role that another removes. Build a pre-processing check that rejects conflicting rows and reports them to the data owner.

Interaction with cohort and LDAP enrolment

A course can receive memberships from a flat file, a cohort sync, an LDAP group or an external database at the same time, and each method may remove users it did not add. Map every enrolment source for each course and confirm which method owns each role and status. Test a removal in one source to see whether another source keeps the user enrolled, and document the answer before the first production run.

SAML2 plugin listing

Running file feeds day to day after launch

Ongoing ownership of a file feed has to be assigned before launch, because the first problems usually appear when the source system changes and nobody on the Moodle side knows the file has changed. Name one owner for the export on the source side, one owner for the Moodle enrolment configuration, and one person who receives failure notices. The source owner should be contractually or procedurally obligated to tell the Moodle owner before any change to column order, delimiters, action codes, course shortnames, or the file name pattern. Keep a short written record of the agreed format, including sample rows for each action the feed uses, so that a reviewer can compare a new export against it without reverse-engineering the old one.

Changes to the source format should be tested against a copy of the production Moodle, not against live courses. Build a small set of test files that cover adds, updates, suspensions and removals, plus deliberately malformed rows such as a missing course shortname or an unknown role. Run each file through the flat file enrolment plugin on staging and check the resulting enrolments, role assignments and the processing messages in the Moodle logs. Because the plugin's behaviour around unenrolment and empty files depends on its settings, confirm those settings in the staging environment before any change reaches production. Keep the test files under version control next to the configuration notes so the same tests can be rerun after each Moodle upgrade.

Cron health is a routine operations check, not a one-off task at go-live. Include the flat file task in the regular review of scheduled tasks, and check that cron runs on the schedule you configured, since the plugin only acts when cron runs. Watch for the plugin's warning that cron cannot delete a processed file, because a file that stays in place can be processed again on the next run and create repeated enrolment changes. Check file permissions after server patching or changes to the web server user, and confirm that the directory is still readable by the process that runs cron and writable by the process that removes the file. If a file is stuck, first check whether the file is still present and who owns it, then review the logs for the last run before deleting or moving anything. If a feed was processed twice, compare the affected enrolments with the source export for that date and correct them through the source, not by hand in Moodle, so the next export does not reverse the fix.

How DeployOpen scopes and delivers file-based enrolment

DeployOpen plans, implements, hardens, documents and supports self-hosted Moodle inside your own infrastructure, including file-based enrolment feeds from legacy systems. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.

How we scope

  • Inventory every source system that produces enrolment files and who owns each feed
  • Agree the flat file or IMS Enterprise XML format, field mapping and role assignments in writing
  • Define file location, permissions, cron schedule and the monitoring that confirms each feed is processed

How we build

  • Configure the enrolment plugin, file path and processing schedule in a staging Moodle first
  • Set file permissions so the cron user can read and delete processed files
  • Test duplicate, malformed and missing-file cases before any feed touches production courses

How we hand over

  • Deliver written configuration, file format specifications and a runbook for each feed
  • Document the alerting and log checks that show a feed ran and a file was removed
  • Walk your administrators through failure handling, including what to do when a file cannot be deleted

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer
  • Retest enrolment feeds after each Moodle upgrade, plugin change or source system change
  • Confirm with your team which Moodle release and PHP version each retest targets before scheduling

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.