Moodle cohorts and cohort sync enrolment

Cohorts let Moodle enrol large groups of learners and staff at once, but only if the population source, sync rules and roles are designed first. This page covers how to plan Moodle cohort sync and what to confirm before building it.

On this page

When Moodle cohort sync is the right enrolment design

If many learners or staff need the same course access and enrolling them one by one has become a recurring chore, cohort sync is usually the design to evaluate first. Manual enrolment works for a handful of courses and a stable group of people, but every joiner, leaver and transfer then needs someone to act in the course. A cohort in Moodle is a named group of user accounts that lives at site level or inside a course category. Its membership is held separately from any course, so one list can be maintained once and reused. Cohort sync is the enrolment method that takes a cohort and enrols its members into a course with a chosen role, then keeps that course membership aligned as the cohort changes.

The practical difference from individual enrolment is where the decision sits. With manual or single-user enrolment, each course owner adds people course by course. With cohort sync, the membership decision is made once, in the cohort, and every course that syncs from it follows. Moodle core documents that cohorts can be populated by manual upload, by LDAP or by web services, so the source of truth can be a file, a directory group or an HR-driven integration. Confirm in your Moodle version which population methods are enabled on your site, since the cohort and enrolment settings and the upload and web service options are set by administrators and can be restricted or extended by plugins.

Before choosing this design, confirm three things in your own environment. First, check whether your users belong to one clear group that maps to one course set, because cohorts that overlap heavily become hard to reason about. Second, decide who may create, edit and remove cohort members, since a cohort change can immediately grant or remove course access. Third, test how removals propagate to course enrolments on a staging copy before go-live. If your groups come from directory structures or nested groups, read the sibling pages on LDAP enrolment by directory group and web service provisioning first, because they change where the authoritative list should live.

Cohort population options and when each fits

This table compares the four ways to fill a Moodle cohort: manual upload, LDAP, web services and cohort sync into courses. Read each row against the system that holds the membership decision, because the owner of that system determines who maintains the cohort and where it fails. The main takeaway is that cohort sync is only as reliable as the population method feeding it.

Population methodSource of truth it suitsWho maintains itMain risk
Manual upload (CSV)Small, stable lists held by a course or program owner outside any directorySite or category administrator, by hand for each changeStale membership when the list is not re-run after joiners and leavers
LDAP directory syncDirectory groups or attributes that already control access, such as an Active Directory group per programDirectory team, who must keep the group membership accurateNested or renamed groups change cohort membership without any Moodle change being reviewed
Web servicesAn HR or identity system that is the authoritative record for people and rolesIntegration team that owns the service account, token scope and sync codeFailed or partial sync runs that leave cohorts inconsistent with the source system
Cohort sync enrolmentA cohort already populated by one of the methods above, used to drive course or group accessCourse designers set the link, and the cohort owner controls membershipRemoving a member from the cohort silently unenrols them from every linked course
Cohort-based rolesA cohort that represents a job function, such as tutors or faculty, rather than a student groupSite administrator, with sign-off from the business owner of the roleOver-broad role assignment when a large cohort is linked to a course with elevated permissions

How cohort sync moves members into courses and groups

Cohort sync is a chain of three links: a cohort holds members, a cohort sync enrolment method in a course reads that cohort, and the course enrolment then carries a role for each member. Membership changes flow down the chain, so the cohort is the place to control access. When a cohort sync method runs in a course, Moodle enrols every current cohort member with the role you chose in that method's settings, and it does so for the members who are in the cohort at that moment. Each course that uses the method holds its own enrolment record for the user, which means the course role is assigned by the sync rather than typed into the course by a teacher. Before go-live, confirm in the release you run how the cohort sync task is scheduled and how often it applies changes, because the timing of additions and removals is the detail most often misunderstood.

Removing someone from a cohort removes the enrolment that cohort sync created, provided the enrolment was created by that method and the method is still active in the course. The removed user loses course access through that enrolment, but any enrolment they hold by another method, such as manual enrolment or a second cohort, stays in place. This is the main control risk: a teacher who was added manually keeps access after the cohort change. Check the behaviour of the unenrol setting on the method and the test with an account in a non-production site before you rely on it for leavers.

Cohort-based roles add to existing course roles rather than replacing them. A user can hold a teacher role from a manual enrolment and a student role from a cohort sync, and Moodle combines the permissions. Groups are different: a group is a set of members inside one course, used for group activities and group-mode settings, and it does not grant enrolment. Cohort sync can also populate groups as a separate step, so decide whether the cohort is controlling enrolment, grouping, or both, and document it for the course owners.

How cohort membership flows from source systems into courses

The flow starts with a source system: an uploaded CSV file, an LDAP directory or a web services caller. Each source writes members into a site or category cohort, which is the first point where external data enters Moodle. A cohort sync enrolment method then adds those members to target courses with an assigned role, and groups can be populated from the same cohort. Check that administrators, not the source feed, control which role each cohort grants, and that removals in the source are handled as intended.

Source feeds populate cohorts, and administrator-set roles govern course enrolment.

How to set up cohorts and sync them into courses

This sequence moves a group of learners from a population source into Moodle cohorts, attaches those cohorts to courses with a fixed role, and proves the memberships are correct before anyone relies on them. Each step ends with a check you can repeat after every future change.

  1. Agree cohort naming and category placement

    Before creating anything, the Moodle administrator and the owners of the source data agree on a naming pattern for cohorts (for example, a prefix that identifies the source system, a term or intake, and a program code) and decide whether each cohort sits at site level or inside a course category. Site-level cohorts suit institution-wide groups, while category cohorts keep departmental groups visible only to the teams that manage them. Write the decisions down, because renaming cohorts later changes the ididentifiers that enrolment rules depend on. Done means a one-page naming standard has been signed off by the people who own the data and the course design.

  2. Choose the population method

    Decide how members enter each cohort: manual upload with a CSV file, an LDAP or Active Directory group if the directory already holds the membership, or a web services feed from an HR or identity system. Confirm the method against your own environment, because each one depends on different identifiers, service accounts and scheduling. Upload suits small or one-off groups, while automated population suits groups that change often. Record which system is the source of truth for each cohort, since a cohort fed from two sources will fight over its members. Done means every cohort has one named source and one named owner.

  3. Create the cohorts and populate a test group

    In Moodle, create each cohort in Site administration or in the category settings, using the agreed names and an identifier that matches the source data. Populate a small test group first, either by uploading a CSV with the username or identifier column or by running the directory or web services sync against a pilot population. Check that the test account appears in the cohort list and that the member count matches the number of rows or records you sent. Done means the cohort count and a named test account both match the source, and any mismatch is traced before going further.

  4. Add cohort sync to the target courses

    Open each target course, go to the enrolment methods page, and add the Cohort sync method. Select the cohort, choose the role the members should receive (usually Student for learners, with Teacher or Non-editing teacher added through separate cohorts), and set the enrolment start and end options as required by your policy. Keep the role choice narrow: a cohort sync that assigns Teacher to a large group is a common source of access problems. Done means each course lists the cohort sync method with the cohort and role you intended.

  5. Verify membership counts and course enrolments

    Compare three numbers: the count in the source system, the member count shown on the cohort page, and the number of enrolled users in each course filtered by the synced role. Run the cohort sync or wait for the scheduled task, then recheck the counts after a change, such as adding one test user to the cohort and confirming that user appears in the course with the expected role. Also confirm that removing a test user from the cohort results in the expected unenrolment behaviour for your settings. Done means the three counts agree, and the test additions and removals behave as the enrolment method settings say they should.

  6. Confirm a sample learner's access

    Sign in as a sample learner account, or use Moodle's log in as feature under an authorised administrator role, and confirm the learner sees the expected courses, activities and groups. Check that the learner has no access to courses outside the cohort and that teacher-level permissions are absent. Review the enrolment record on the user profile to confirm the enrolment came from the cohort sync method rather than a manual enrolment. Done means the sample learner's access matches the course design, with the enrolment source recorded as cohort sync.

  7. Document the sync and set up ongoing checks

    Record the cohort names, source systems, population method, owners, linked courses, roles and the check results from the earlier steps in the runbook for the platform. Set a regular review of the counts, add an alert or report for failed population jobs if your method supports it, and agree who responds when counts diverge from the source. Confirm the review schedule with the team that will operate Moodle, because the checks only protect enrolments if someone performs them. Done means a named owner, a written runbook and a recurring check exist for every cohort.

Security and operational risks in cohort-based enrolment

Cohorts are a shortcut to large-scale enrolment, and that shortcut also moves access quickly. The cards below cover where membership can go wrong, from over-broad roles to stale members, and the decisions that keep cohort changes controlled and reviewable.

Over-broad cohort membership

A cohort linked to a course through cohort sync gives every member the role you assigned, so one wrong cohort can grant teacher or manager rights across many courses. Review which roles each cohort sync assigns, and keep teaching roles in separate cohorts from student cohorts. Check the course and category context of each sync before enabling it, and confirm that no cohort carries a role wider than its members need.

Unreviewed upload files

The cohort upload tool accepts a CSV file that can add or remove many accounts in one action. A file built from a spreadsheet can contain the wrong identifiers, duplicate rows or accounts that should not be in the cohort. Restrict who can upload, keep the source file under version control or an audit trail, and run a preview review before you apply changes to a live site.

Service account scope for web services

When an HR or identity system populates cohorts through web services, the service account and its token define what that integration can change. A token that can edit any cohort in any category can affect the whole site. Limit the service account to the specific capabilities and contexts it needs, record who holds the token, and plan rotation and revocation before go-live.

Who can create and edit cohorts

Cohort creation and editing are capabilities that site and category administrators hold by default, and delegated roles can extend them. Decide which staff may create site cohorts, which may manage cohorts within a category, and which may only view membership. Document the decision in the role design, and check the assignments on each review cycle rather than assuming the defaults still fit your staffing.

Cleaning up cohorts after departures

Cohorts can outlive the people and programmes they were built for. When a leaver is removed from the source system, the Moodle account may stay active, and stale cohort members can keep course access through sync. Define how removals reach cohorts, who owns retirement of unused cohorts, and how long old membership records are kept. Confirm the process with your data retention policy.

Logging and reviewing membership changes

Membership changes should be traceable to a person, a file or a service account and a time. Review the Moodle logs for cohort events, and confirm with your hosting team how long those logs are retained and whether they are exported to a central log store. Schedule a periodic review that compares cohort membership with the source system and records each exception and its resolution.

Questions buyers ask about cohort sync

How much does cohort sync setup cost in Moodle?

No public price applies, because cost follows from the written scope. Moodle core and cohort sync are open source, so the spend is on people and infrastructure: the design work, the build of the cohort feeds, testing against real data, and the run cost afterwards. The main drivers are the number of source systems that populate cohorts, how many cohorts and categories the design needs, how many roles each cohort carries, and how clean the source data is. Ask any provider for a quote that separates one-time build work from recurring support, and that names every source system in scope.

How long does a cohort sync implementation take?

Duration depends on scope rather than on a fixed template, so no timeline is given here. A small site with one source file and a few cohorts is a much shorter job than a university populating site and category cohorts from an HR feed, a student system and LDAP groups at the same time. Plan time for the enrolment design, a test site with copied data, a review of duplicates and orphaned records, and a staged rollout by term or intake. Ask for the schedule as dated milestones in the written scope.

What does the work need from our team?

You need named owners for the source data, the Moodle site and the enrolment rules, and you need access to the systems that will feed cohorts. Expect to provide sample extracts, field definitions, a list of roles that cohorts should grant, and sign-off on which users are removed or suspended when a source record disappears. A Moodle administrator must be available to test on a non-production copy. Confirm these owners and access points before any build starts, because most delays come from waiting on data owners.

Can our own team run cohort sync after go-live?

Yes, if your team has Moodle administration skills, scheduled task knowledge and someone who understands the source data. Routine operation means checking that cohort uploads or sync tasks ran, reviewing error reports, and handling changes to source fields. Your team will need documented rules for cohort naming, membership removal and role assignment, otherwise later changes become risky. Many organizations keep a retainer for upgrades and periodic review, which is a question to raise in the quote.

Which data quality problems make cohort sync fail?

The most common failures come from duplicate or inconsistent identifiers, such as the same person with two student numbers, missing usernames, and records that change keys between systems. Cohort membership also breaks when a group is renamed in the source but not in Moodle, or when a feed removes a person silently. Check identifier uniqueness, agree how leavers are handled, and run a dry run that reports adds and removals before any change reaches learners. Poor source data usually adds more effort than the Moodle configuration itself.

How do we avoid removing learners from courses by mistake?

Set removal rules deliberately before enabling sync. Cohort sync enrolments can be configured to unenrol or keep users when they leave a cohort, and the choice should match your academic records process. Run a preview on a copy, limit the first live run to one category, and keep a backup of enrolments before the change. Review the task logs after each run. Confirm the exact behaviour for your Moodle version in the official documentation, because option names and defaults can change between releases.

Should we use cohort sync or direct LDAP group enrolment?

Use cohort sync when you need one membership list that several courses, groups or roles can reuse, and when a central feed controls who belongs. Direct LDAP group enrolment can be simpler when the directory already models course membership cleanly and nested groups are not needed. Cohorts also let you assign cohort-based roles at site or category level, which is useful for staff roles. Decide with the source owners, then document the choice so later changes do not split membership across two methods.

Limits to confirm in your Moodle environment

Cohort sync looks simple on paper, but its behaviour depends on the Moodle release, the database and PHP stack, and how many members each cohort holds. The cards below list what to verify in your own environment before you choose a population method and commit to a design.

Moodle version and cohort behaviour

Cohort features, sync tasks and the cohort management pages can change between releases, so confirm the behaviour you rely on in the exact version you will run. Check the release notes for the target version and test cohort creation, membership updates and deletion on a staging copy. Ask your implementation partner which behaviours were verified on your release, and which were only assumed from older documentation.

Release to verify
5.1
Moodle 5.1 notes

Supported PHP and database versions

Each Moodle release sets its own minimum PHP and database versions, and a site on an older stack may need a server or database upgrade before it can move. Confirm the PHP, PostgreSQL, MySQL, MariaDB or SQL Server version your target release accepts, and check that your cohort-heavy tables run on a supported engine. Plan the platform upgrade as a separate step with its own test window.

Minimum for 5.3
PHP 8.3
Moodle 5.3 notes

Web root pointing to /public

From Moodle 5.1, the web server document root must point to the new /public directory instead of the main Moodle folder. If it does not, the site can show directory listings or errors, and the cohort pages may never load for administrators. Update the Apache or Nginx configuration, confirm the change in each environment, and include it in your change record before you start populating cohorts.

Performance with very large cohorts

A cohort that holds tens of thousands of members can slow cohort sync, enrolment tasks and the cohort list page, especially when many cohorts sync into courses on the same cron run. Ask for a load test with a realistic member count, measure how long the sync task takes, and check whether sync runs overlap. Confirm the database, PHP limits and cron schedule can handle that volume before the production rollout.

Moodle source code

Availability of each population method

Uploading a CSV, syncing from LDAP and populating through web services are not all equally available or equally maintained across releases, and some depend on plugins or external services. Confirm that the method you plan to use is supported in the target release, that its plugin is compatible, and that the auth or web service settings are present in your environment. Record any gap as a decision point before design starts.

Core auth plugins

Identity source and directory access

Cohort membership that comes from a directory is only as accurate as the attributes and group memberships the directory exposes to Moodle. Confirm which directory, bind account and group attributes are available, whether nested groups are flattened, and who owns changes on the source side. Agree how removed users are handled so cohort membership and course access stay aligned after the source changes.

How DeployOpen plans and delivers cohort sync

DeployOpen starts cohort sync with a written scope that names every cohort source, every cohort it creates or maintains, and every course, group or role that a cohort feeds. Before any build, the work agrees which system is the owner of membership for each cohort, whether that is a directory, an HR feed, a student information system or a manual upload, and how Moodle should behave when a person leaves that source. The design also records the cohort naming convention, whether cohorts sit at site level or in categories, which cohort-based roles are granted and whether any cohort is meant to be edited by hand. These decisions are signed off in the agreement because they determine the sync configuration, the test cases and the support load after go-live.

The build follows the agreed design in a non-production Moodle instance that matches the production server stack. DeployOpen configures the cohort populating method (upload, LDAP or web services), the cohort sync enrolment method in each target course and the group and role mappings, then tests the paths that usually fail: a user moved between cohorts, a cohort with no members, a member whose account is suspended and a cohort removed from a course. Each test is recorded with inputs, expected results and actual results, and failures return to the design before the sync is moved to production. The testing also checks scheduled tasks and logs, so the client can see that membership changes are applied on the expected cycle. Exact durations and effort depend on the number of sources and courses, and the written scope should state them.

Handover covers the configuration as built, a runbook for operators, and a record of the design decisions and the test results, so that the client's team can explain how membership is decided. Clients should confirm, in the agreement, who receives administrator access, who approves changes to cohort rules and how cohort-based roles are reviewed. Ongoing support, upgrades and continuous checks are available as separate retainers, and DeployOpen does not publish a price list, so the quote follows from the written scope. Clients should ask for the deliverables list, the acceptance criteria and the change process for scope additions before they sign.

How DeployOpen works on Moodle cohort sync

DeployOpen plans, builds and documents cohort-based enrolment for Moodle in infrastructure you control. We start from how your people, roles and courses are organized, then design the cohort sources, sync rules and checks so memberships stay correct as your directories and feeds change.

How we scope

  • Map every source that defines cohort membership, such as uploads, LDAP groups or web service feeds, and name the owner of each.
  • Agree which cohorts are site-level and which sit in categories, and which roles each cohort sync assigns in courses and groups.
  • Write the scope in a fixed-scope agreement covering deliverables, test cases, and the environments included before work starts.

How we build

  • Configure cohort sources, sync rules and cohort-based role assignments in a staging Moodle that mirrors your production setup.
  • Test removals, renames and duplicate identifiers with a sample of real-format data, confirming suspended and unenrolled users behave as agreed.
  • Set the cron and task schedule for each sync and confirm the outcome with course, group and role reports before go-live.

How we hand over

  • Document each cohort source, its identifier, field mappings, sync frequency and the person responsible for it.
  • Provide a runbook covering failed sync checks, manual cohort corrections and how to roll back a bad upload or feed.
  • Walk your administrators through the configuration and the test results so your team can operate the setup after handover.

How we support

  • Offer ongoing support, Moodle upgrades and continuous testing as a retainer after handover, scoped in writing.
  • Review cohort sync behavior when Moodle releases change the affected code, and confirm compatibility against your planned version.
  • Ask any partner or internal team to confirm current Moodle version requirements for your target release before planning upgrades.

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.