Authentication: Autoenrol cohort

auth_mcae
Maintained by Picture of Dan Marsden Dan Marsden
This Authentication plugin automatically assigns users into cohorts based on information in their user profile fields.
525 sites
159 downloads
25 fans
Moodle 2.1, 2.2

Build status moodle-auth_mcae.svg?branch=v3.1

Release notes

Auto cohort authentication plugin for moodle 2.x

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

Upgrade

  • Replace the your_moodle/auth/mcae folder with new one
  • Visit Site administration - Notifications page and follow the instructions
  • !!! If you update to version 2.9 you must rewrite templates! See configuration section.

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 Checkbox
  • datetimetest - type Date/Time
  • droptest - type Dropdown menu
  • textinputtext - 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"

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2

Contributors

Picture of Dan Marsden
Dan Marsden (Lead maintainer)
Picture of Andrew Kama
Andrew Kama: Previous maintainer
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Dave Feasey
    Fri, 29 May 2015, 2:22 AM
    I would like (as with Kevin Treussier) to be able to use an enumerated list in a single field to separate users into multiple cohorts. For example user with a user field "isATP;isPartner" should go into two cohorts isATP and isPartner. I can't figure out how to define the separator and make this work.

    Using version 1.2 of the plugin (2014121815 1.2) with Moodle 2.8.3+ (Build: 20150219) Version 2014111003.03

    Thanks.
  • Floyd Saner - Tail of the Dragon, U.S. 129, NC
    Thu, 13 Aug 2015, 5:05 AM
    I installed the latest GitHub pull on Moodle 2.8. The plugin works OK for standard accounts. I tried to use the plugin with email-based registration, but as documented in the readme file, extra code needs to be added. The problem is that the new Moodle Themes do not have a /layout/general.php or /layout/default.php file. Where should I insert the code? When will this plugin be updated for Moodle 2.8?
  • Picture of David Mudrák
    Tue, 1 Dec 2015, 8:10 PM

    This plugin is now seeking new maintainer - https://moodle.org/mod/forum/discuss.php?d=260354#p1301333

  • Picture of Troy Fennell
    Mon, 21 Dec 2015, 4:53 AM
    I'd like to use this mod to auto enrol a user into a specific cohort the moment the system recognizes they have been added to a specific group.

    I have my system set up to auto enroll a user into a specific group as soon as they enroll that group's parent course. It would be nice to be able to segregate them now into a specific cohort automatically.

    Can someone provide the steps for doing this? Please?
  • Picture of Leandro Campos
    Fri, 22 Jan 2016, 4:03 AM
    Hi. I am with difficults to configure this. I need this:
    All users with domain specific (example @hotmail.com) will add in cohort (HOTMAIL). How make this?
  • Picture of Blair F.
    Fri, 15 Apr 2016, 11:56 PM
    Leandro, did you ever figure it out? I have a similar situation, but I find it difficult to understand how to configure this plugin.
  • Picture of József Somogyi
    Wed, 15 Jun 2016, 10:37 PM
    Leandro, Blair "did you ever figure it out? I have a similar situation, but I find it difficult to understand how to configure this plugin."
  • Picture of Blair F.
    Sat, 25 Jun 2016, 4:40 AM
    No, József. I never got a response and am not spending any time on it until I do.
  • Picture of it.webdevsupport Master
    Tue, 13 Sep 2016, 6:33 PM
    Hello!! I am using plugin saml2 to authenticate in my web app. Actually, my app doesn't create automatic cohorts with this plugin. So I would like to know if it is possible and what I should do. Thanks.
  • Picture of Derek Lawrie
    Thu, 2 Feb 2017, 5:55 PM
    Is anyone still using this on any version 2 install?
    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.
  • Picture of Tim Tarbotton
    Sun, 30 Apr 2017, 8:03 AM
    Hello, I am looking for a plugin that will automatically add a Email-based self-registration to a specific 'cohort' based on the users 'local club' field. I want to add the 'local club' as a mandatory field during self-registration.

    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!
  • Picture of Dan Marsden
    Mon, 1 May 2017, 5:43 AM
    this plugin creates cohorts based on user profile information - for example if you have a local club field in the user profile it will create a site-wide cohort with the club name and assign everyone with the same club name into a site-wide cohort. You can then use other plugins/mangement to assign those cohorts to courses etc.
  • Picture of Tristan daCosta
    Thu, 11 May 2017, 5:01 PM
    Hi Dan. I wonder how big a task it would be to add the ability to create cohorts from user Badges? ie. {{badge_badgename}} into cohort "badgename".

    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
  • Picture of A Guy
    Fri, 12 May 2017, 4:47 AM
    I am using this plugin and it works great with the exception of one process. The user has to log in and then log out. Then log back in in order for the user to be enrolled in the cohort/course. How can I get this to allow the user to be enrolled in the course via the cohort upon first logging in? Thanks
  • Picture of Dan Marsden
    Fri, 12 May 2017, 7:15 AM
    @A Guy - try using the version in github to see if that is better - there are a few changes there that improve the process a bit.
    @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)
1 2 3 4 5
Please login to post comments