Moodle plugins directory: Auto assign cohort (deprecated for local_cohortauto) | Moodle.org
Auto assign cohort (deprecated for local_cohortauto)
PLEASE NOTE - this plugin has been deprecated and replaced by:
https://github.com/catalyst/moodle-local_cohortauto
---------------------------
Auto cohort authentication plugin
This authentication plugin automatically assigns users into cohorts.
Cohort name depends on user profile field.
Cohorts are created in CONTEXT_SYSTEM.
Installation
- Download the archive and extract the files, or clone the repository from GitHub
- Copy the 'mcae' folder into your_moodle/auth
- Visit Site administration - Notifications page and follow the instructions
Configuration
Template for cohort name
1 template per line.
In the template you may use any characters (except '{' and '}') and profile field values. To insert a profile field value, use {{ field_name }}
tag.
An email field have 3 variants:
{{ email.full }}
- full email{{ email.username }}
- only username{{ email.domain }}
- only domain{{ email.rootdomain }}
- root domain
By default moodle provides this fields
{{ id }}, {{ auth }}, {{ confirmed }}, {{ policyagreed }}, {{ deleted }}, {{ suspended }}, {{ mnethostid }}, {{ username }}, {{ idnumber }}, {{ firstname }}, {{ lastname }}, {{ email.full }}, {{ email.username }}, {{ email.domain }}, {{ email.rootdomain }}, {{ emailstop }}, {{ icq }}, {{ skype }}, {{ yahoo }}, {{ aim }}, {{ msn }}, {{ phone1 }}, {{ phone2 }}, {{ institution }}, {{ department }}, {{ address }}, {{ city }}, {{ country }}, {{ lang }}, {{ calendartype }}, {{ theme }}, {{ timezone }}, {{ firstaccess }}, {{ lastaccess }}, {{ lastlogin }}, {{ currentlogin }}, {{ lastip }}, {{ secret }}, {{ picture }}, {{ url }}, {{ descriptionformat }}, {{ mailformat }}, {{ maildigest }}, {{ maildisplay }}, {{ autosubscribe }}, {{ trackforums }}, {{ timecreated }}, {{ timemodified }}, {{ trustbitmask }}, {{ imagealt }}, {{ lastnamephonetic }}, {{ firstnamephonetic }}, {{ middlename }}, {{ alternatename }}, {{ lastcourseaccess }}, {{ currentcourseaccess }}, {{ groupmember }}
Additional tags become available if you have some custom profile fields. For example if you create custom profile fields
checkboxtest
- type Checkboxdatetimetest
- type Date/Timedroptest
- type Dropdown menutextinputtext
- type Text input- and
textareatest
- type Text area
You be able to use this tags: {{ profile.checkboxtest }}, {{ profile.datetimetest }}, {{ profile.droptest }}, {{ profile.textinputtext }}, {{ profile_field_checkboxtest }}, {{ profile_field_datetimetest }}, {{ profile_field_droptest }}, {{ profile_field_textareatest.text }}, {{ profile_field_textareatest.format }}, {{ profile_field_textinputtext }}
> Note: Profile field templates is case sensitive. {{ username }}
and {{ UserName }}
are two different fields!
Split arguments: Synopsis: %split(fieldname|delimiter)
Returns multiple cohorts, each of which is formed by splitting field on boundaries formed by the delimiter.
Arguments:
- fieldname - Profile field name. The same as tag, but without '{{' and '}}'
- delimiter - The boundary string. 1 - 5 signs.
Example:
User John set custom profile field "Known languages" to "English, Spanish, Chinese"
Main template contains string "Language - %split(knownlanguage|, )"
John will be enrolled in 3 cohorts: Language - English, Language - Spanish and Language - Chinese
Replace empty field
If profile field is empty then it's replaced with this value.
Replacement array
You can change the cohort name after it's generation.
1 replacement per line, format - old value|new value
very long cohort name|shortname
Note: The name must not be longer than 100 characters or it will be stripped
Unassign
Unassign users from cohorts after profile change.
To use an unassign feature:
- Go to Plugins - Authentication - Autoenrol cohort and enable unenrol function
- Go to yourmoodle/auth/mcae/convert.php and convert cohorts you want to "auth_mcae".
Convert only cohorts that are created by the "auth_mcae" module!
At yourmoodle/auth/mcae/convert.php page you may view, delete or convert cohorts into "manual" or "auth_mcae" mode.
Ignore users
List of users to ignore. Comma separated usernames.
admin,test,manager,teacher1,teacher2
Usage example
You have a custom profile fields "status" (student, teacher or admin) and "course".
You wnat to enrol many users into cohorts like "course - status" than enrol cohorts into courses.
At configuration page set:
Main template to {{ profile_field_course }} - {{ profile_field_status }}
Empty field text to none
Result:
- When 1st course student logins, he enrol to cohort named "1 - student"
- When 1st course teacher logins, he enrol to cohort named "1 - teacher"
- When admin logins, he enrol to cohort named "none - admin" (Course not set, status - admin)
To rename "none - admin" cohort to "Administration" you must set a replacement array field at the configuration page In our case: none - admin|Administrator
Result:
When admin logins, he enrol to cohort named "Administrator"
I use it quite happily, but was wondering if there is a way to remove suspended user accounts from the cohorts?
As it's suspended the user will never login again so they won't be removed.
If there is a way to "force" run the plugin via cli that would do the trick.
Is this something this plugin can do? I am not a developer but I would like some clarification to make sure this is what this plugin will achieve. I am using Moodle 3.3.
Appreciate the help!
This could then allow site role assignment / other functionality to users based on badges earned (sometimes through the use of other plugins ie. Cohort Role Syncronization).
For myself, the end goal would be for users to gain additional permissions once they have completed online training.
Complete training -> Earn Badge -> Enrolled in Cohort -> Cohort assigned custom role (Cohort Role Syncronization) -> Additional permissions with custom role
Anyone have any thoughts on this?
Thanks
@Tristan - it's not something I'm planning to work on at the moment, but feel free to submit a pull request if you work it out - or if you're willing to fund the time for someone to look at this drop me a private message and I can provide information on our rates (I work for the Moodle Partner Catalyst IT)
But what if the user profile was edited and user fields were updated!!
Will the user Shift to other cohort..
As of now what I observed is, user been added to the updated cohort group, but was not removed in the old cohort..
is there any way to do that..(to remove from the old cohort when the user profiles fields are updated)
Thank you
Is the Github version compatible with Moodle 3.3.1?
At first that process seemed to work perfectly. Now we are noticing that mcae is creating new cohorts with the same name and assigning users in that cohort instead of the cohort we setup beforehand (and added to courses as a enroll method). Do you have any idea what could be the problem?
And thank you for taking the time to maintain this plugin, Dan!
Best, Bas Harkink