Auto assign cohort (deprecated for local_cohortauto)

Authentication ::: auth_mcae
Maintained by Dan Marsden, Catalyst IT
This Authentication plugin automatically assigns users into cohorts based on information in their user profile fields.
Latest release:
272 sites
9 downloads
51 fans
Current versions available: 6

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 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

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

Comments RSS

Comments

  • Jared Annis
    Thu, 19 Sept 2013, 7:23 AM
    Great job on this plugin! It works great as long as I log into moodle directly. I'm using Drupal-Moodle SSO for most of my end users, however. Is there a way have Moodle authentiate through Drupal Service, and then still auto enrol the user into a cohort?
  • Julia Küfner
    Thu, 19 Sept 2013, 8:21 PM
    Does anyone use this plugin with mnet ? It works great for all other authentication methods but with mnet it doesn't seem to be called when the user logs in ?
  • Seyit Kaya
    Sat, 28 Sept 2013, 12:23 AM
    How can i use it please explain
  • Seyit Kaya
    Sat, 28 Sept 2013, 12:28 AM
    How can i use it please explain i cant do it
  • Carlos Rubalcava
    Thu, 17 Oct 2013, 6:02 AM
    At what point does this gets done? At login or at signup or at course access?
  • François Lizotte
    Fri, 7 Mar 2014, 3:57 AM
    Hi, I think this module could really be useful, but I can't figure out the syntax. All I want to do is to enrol students in a cohort according to a profile field. Let's say field Program = Science. Then, all users having science would be enroled in the Science cohort.
  • Jefferson Bien-Aime
    Sat, 7 June 2014, 12:57 AM
    Great Plugin! in the availables templates, I didn't find description, but description, but I want to create cohort based on description-Departement. is It possible?
  • Jefferson Bien-Aime
    Sat, 7 June 2014, 2:44 AM
    Can we have a "%description"? I didn't find description, but description, but I want to create cohort based on %description-%departement. is It possible?
  • Davi DePaula
    Thu, 12 June 2014, 10:32 PM
    Has anyone tried this plugin with Moodle 2.7? Thanks.
  • Floyd Saner - Tail of the Dragon, U.S. 129, NC
    Thu, 17 July 2014, 9:52 AM
    Also looking for a Moodle 2.7 version
  • Daniel Dubbeldam
    Mon, 4 Aug 2014, 5:09 PM
    okay. So I have this plugin working on Moodle 2.7.
    however, for now, i'm stuk with the following:

    I want to give people the option, to use checkboxes as customprofilefield.
    1 have to options: option1 and option2.

    my main template lines are
    %profile_field_option1
    %profile_field_option2

    even when just 1 checkbox is checked, student comes into 2 cohorts....
    what do I miss here? since checkboxes returns 0's and 1's... where should I add the "1" ?
  • Andrew
    Thu, 7 Aug 2014, 9:26 PM
    Hi Andrew, in the php log of Moodle 2.6, I get the following PHP Warning: Creating default object from empty value in www\auth\mcae\auth.php on line 314. Although the warning presents no problem that I can see, would the following being added before 314 work to remove the warning?
    if (!isset($SESSION))
    $SESSION= new stdClass();
    Thanks, Andrew
  • Andrew Kama
    Sun, 10 Aug 2014, 10:13 PM
    Hi, Andrew. To remove the warning update plugin from github.
  • Francis Vendrell
    Wed, 20 Aug 2014, 2:50 PM
    Is this plugin compatible with Moodle 2.6 ?
  • Nathan Bruley
    Tue, 9 Sept 2014, 3:33 AM
    @Francis Seems to work in 2.6

    Does anyone know if it's possible to manually add people to a cohort created with this plugin? I'd like to add previous users that joined before adding the plugin who may not sign in.
Please login to post comments