Dynamic Cohorts

Dynamic Cohorts

by Simon Coggins -
Number of replies: 2

We have some funding to extend the current cohorts functionality to include 'dynamic' cohorts (see below for a summary).

Are there were any plans to extend cohorts in this direction, and if so, would you be interested in this implementation for core? We'd be happy to contribute the code and are keen on collaborating to ensure it aligns well with any existing or future plans in this direction.
Any feedback is also welcome on the implementation below or any problems that this change might introduce.
---
Existing cohorts would be given a 'type' with a choice between static or dynamic. Existing functionality would remain the same with existing cohorts being labelled as 'static'.
Dynamic cohorts would be defined by a set of rules, for example:
  • Users with an email matching '@example.com'
  • Users who have logged on in the last 3 months
  • Users with a user custom profile field set to 'instructor'
  • etc.
There would be a wide range of 'rules' and rules would be class-based to allow more to be added easily.
Groups of rules could be combined into rulesets, and applied with AND/OR logic so you could build up complex rulesets:
  • Users who have logged on in the last 3 months AND have their city set to 'New York'
  • Users who's language is set to 'es' OR Users who's language is set to 'fr'
On the back end, the cohort would still be defined as a list of userids in the cohort_members table. Event handlers would be added to check for changes that could affect cohort membership. An additional cron task would be included to catch any cases missed by the event handlers (for example, if a third party module modified a table directly).
Any events triggered by changes to cohort membership would also need to be retriggered when a cohort membership changes.
Average of ratings: -
In reply to Simon Coggins

Re: Dynamic Cohorts

by Aaron Murray -

Did this project ever happen?  

In reply to Aaron Murray

Re: Dynamic Cohorts

by Marina Glancy -
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Aaron,

Simon works for totara and, I suppose, they have implemented it there.

I want to point out here that it is very possible in moodle.

What you need to do is to create a custom plugin (for example "admin tool"), listen to the necessary events and automatically create cohorts and modify their members when you need to.

Cohorts in moodle have "component" property that can be set by plugins. If set, only the plugin will be responsible for editing cohort and it's members. These cohorts will be properly shown in Site administration>Users>Cohorts but without editing options. Everywhere where you can use normal cohorts (such as enrolments) you will be able to use the dynamic cohorts too.

Average of ratings: Useful (2)