General plugins (Local): CSV Enrolls & Groups plugin

Maintained by Fred Fred Woolard
Use this local plugin to import user enrollments and group assignments from a delimited text file into the course. New user accounts will not be created, so each of the users listed in the input file must already have an account set up in the site. It also provides a way to make group assignments based on meta-course enrollments.
181 sites
8 fans
Moodle 2.3, 2.4, 2.5, 2.6, 2.7, 2.8

The CSV Enrolls & Groups plugin allows you to import user enrollments for a course from an uploaded delimited text file. It is contributed by Fred Woolard.

Enrollments are made with the manual enrol plugin and using a selectable role. The plugin can optionally create course groups and assign the new enrollees to those groups.

Each of the users listed in the input file must have an existing Moodle user account; new Moodle user accounts will not be created.

This plugin was originally (Moodle 1.9) a refactor of the mass_enroll course admin mod done by Patrick Pollet and Valery Fremaux, using the standard groups course import plugin as a template. The current Moodle 2.x revision is again a refactor, but as a local plugin (placed into the local/ directory off the Moodle root), and accessed from the course administration menu under the 'Users' node.

Besides being able to create groups, you can select from existing groups and override the data file's group designation. An additional feature allows instructors to make group assignments based on meta-course enrollments.


Screenshot #0


Fred Woolard (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Anthony Borrow
    Thu, 4 Apr 2013, 1:52 PM
    Fred - Many thanks for sharing this plugin with the Moodle community. I have installed and looked at the plugin and it looks good. I did not test it with an actual CSV file but I am presuming that part of things works fine. If not, folks can file issues in the tracker. When you get a chance, I would encourage you to add a page to Moodle Docs and then provide that URL under the Useful links section. Please do not hesitate to let me know if there is anything I can do to be supportive of your efforts. Peace - Anthony
  • Picture of Carina Martinez
    Thu, 6 Jun 2013, 11:29 PM
    Great job Fred! thanks!!

    We are needing something like this, but at other contexts (a block?), that allow import enrollments, like your plugin, for multiple pre-selected courses...
    I know about the upload users method, but it needs an administrator rol.

    Do you think it would be viable?
  • Fred
    Fri, 7 Jun 2013, 12:48 AM
    Carina, I understand your problem, and yes, building such a plugin would be viable. It could be a block, sited on the 'my' page, displayed only for users who have an instructor role. And that's something to consider for a future incarnation.
  • Picture of Frederic Jacquot
    Mon, 7 Jul 2014, 11:31 PM
    Thanks alot for this plugin!

    I realized there was a parsing error if i tried to create a group containing only one character (ie. "1" or "A").

    I modified the 3 regexp contained in lib.php but i'm not sure this may cause a side effect :

    line :
    $regex_pattern = '/^"? *([a-z0-9][\w.%-]*@[a-z0-9][a-z0-9.-]{0,61}[a-z0-9]\.[a-z]{2,6}) *"?(?: *[;,\t] *"? *([a-z0-9][\w\' .,&-]+))? *"?$/Ui';
    changed to :
    $regex_pattern = '/^"? *([a-z0-9][\w.%-]*@[a-z0-9][a-z0-9.-]{0,61}[a-z0-9]\.[a-z]{2,6}) *"?(?: *[;,\t] *"? *([\w\' .,&-]+))? *"?$/Ui';

    line :
    $regex_pattern = '/^"? *(\d{1,32}) *"?(?: *[;,\t] *"? *([a-z0-9][\w\' .,&-]+))? *"?$/Ui';
    change to :
    $regex_pattern = '/^"? *(\d{1,32}) *"?(?: *[;,\t] *"? *([\w\' .,&-]+))? *"?$/Ui';

    line :
    $regex_pattern = '/^"? *([a-z0-9][\w@.-]*) *"?(?: *[;,\t] *"? *([a-z0-9][\w\' .,&-]+))? *"?$/Ui';
    changed to :
    $regex_pattern = '/^"? *([a-z0-9][\w@.-]*) *"?(?: *[;,\t] *"? *([\w\' .,&-]+))? *"?$/Ui';
  • Fred
    Wed, 9 Jul 2014, 3:48 AM
    Frederic, thank you for the suggestion to change the regex validation; using single character group names should be perfectly valid. I do not believe your change will create any undesirable side effects. The change appears to only remove the restriction that group names begin with a letter or number, i.e it will allow underscores (_) as first letter.

    I will likely keep the restriction that group names begin with a letter or number, but will make changes to allow the single char group names.
  • Ajmal Sultany
    Thu, 11 Sep 2014, 5:23 PM
    Hi Fred,

    We are getting the following error message when uploading 800 students to groups via the plugin:

    Service Unavailable - This service is temporarily unavailable. Please try again later.

    The file size is only 10KB. Do you know what this may be?


    P.S. we are on Moodle 2.5
  • Fred
    Thu, 11 Sep 2014, 11:34 PM
    Ajmal, have responsed with direct messages.
  • Picture of Brenton Arnold
    Thu, 30 Apr 2015, 9:35 AM
    Hi Fred,
    How does it handle removing students from groups?

  • Fred
    Tue, 21 Jul 2015, 10:24 PM
    Brenton, I apologize for the delay in responding. The plugin does not remove users from any groups of which they may already be members.
  • Picture of Marc McLain
    Tue, 22 Sep 2015, 3:06 AM
    Hi Fred, would this plugin work for ONLY adding users to a group via CSV? We have users already enrolled in a course, but we need a way to group students and remove students from a group quickly and efficiently. Would this plugin be a viable option?
  • Fred
    Tue, 22 Sep 2015, 3:36 AM
    Marc, yes, the plugin will make group assignments for students who happen to already be enrolled in the course.
  • Mark
    Thu, 26 Nov 2015, 7:09 AM
    Hi Fred,
    I thought I saw somewhere that your plugin was scheduled for update/release for Moodle 2.8 and 2.9 in November.
    Has this happened?
  • Picture of Marc McLain
    Fri, 25 Mar 2016, 3:28 AM
    Hi Fred, I'm on Moodle 2.7 and am receiving the following error when I push the CSV file: "Unable to parse the line contents"

    The contents are by email. Would you happen to know why this issue is taking place?
  • Fred
    Fri, 25 Mar 2016, 3:45 AM
    Marc, there's likely a character I did not correctly account for in the email address. The regex pattern used for emails is:
    $regex_pattern = '/^"?\s*([a-z0-9][\w.%-]*@[a-z0-9][a-z0-9.-]{0,61}[a-z0-9]\.[a-z]{2,6})\s*"?(?:\s*[;,\t]\s*"?\s*([a-z0-9][\w\' .,&-]*))?\s*"?$/Ui';

    You test that pattern against your input file, or if you need help with that, you can message/email a sample email address entry from your file.
Please login to post comments