General plugins (Local): CSV Enrolls & Groups plugin

local_userenrols
Maintained by FredFred 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.
495 sites
216 downloads
27 fans
Current versions available: 4

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.

Screenshots

Screenshot #0

Contributors

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

Comments RSS

Show comments
  • Fred
    Tue, Aug 25, 2020, 10:36 PM
    @csaba... the safest way to do this without waiting for a version update, is to comment out three specific lines in the plugin's lib.php file, lines beginning at 217 which look like the code below. Commenting out the case statement for 'idnumber' and the next two lines will make the regular expression used for idnumbers the same as the one used for usernames (default), which allows for a field beginning with an alpha, or numeric, and followed by more alpha, numeric, underscores, and dashes.

    // Choose the regex pattern based on the $ident_field
    switch($ident_field)
    {
    case 'email':
    $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';
    break;
    //case 'idnumber':
    // $regex_pattern = '/^"?\s*(\d{1,32})\s*"?(?:\s*[;,\t]\s*"?\s*([a-z0-9][\w\' .,&-\[\]\{\}\(\)]*))?\s*"?$/Ui';
    // break;
    default:
    $regex_pattern = '/^"?\s*([a-z0-9][\w@.-]*)\s*"?(?:\s*[;,\t]\s*"?\s*([a-z0-9][\w\' .,&-\[\]\{\}\(\)]*))?\s*"?$/Ui';
    break;
    }

    I apologize for the difficulty. As I look at this, I should have made the idnumber field validation more flexible, rather than specific to our environment. I will make a change to the plugin at some point in the near future.

    Regards,
    FW
  • Picture of Csaba Vágvölgyi
    Wed, Aug 26, 2020, 2:33 PM
    It works smile
    @Fred, thank you very much!
  • Picture of Rinat Akhmetzyanov
    Wed, Sep 9, 2020, 10:16 PM
    Hello @Fred.
    Where am i can find header a template for upload users with group?
  • Fred
    Wed, Sep 9, 2020, 10:24 PM
    @Rinat, I do not fully understand the question, but assuming you want to enroll users, and put them into groups, then the file contents should look like the following:
    username1,GroupA
    username2,GroupA
    username3,GroupB
    Username4,GroupC
    ...
    ...
  • Picture of Rinat Akhmetzyanov
    Thu, Sep 10, 2020, 3:46 PM
    @Fred, Thanks a lot. I understood how the plugin works)
  • Picture of Juan Fortuna
    Thu, Oct 29, 2020, 7:04 PM
    Hi Fred, I want to ask you if you can help me with the columns of the .txt file. What columns do I hav to put in the file to enroll my students and teachers using groups? If the group doesn't exist, it would create it? Can you show me an example for the .txt or .csv file? I hope you understand my english, I'm not native speaker. Thank you very much.
  • Fred
    Thu, Oct 29, 2020, 10:10 PM
    @juanfortuna, coincidentally, there's a post just above, from @rinat, that asks essentially the same question. the file should look like:
    username1,GroupA
    username2,GroupA
    username3,GroupB
    username4,GroupC
    ...
    ...

    Set 'Assign to group' to 'Yes' (puts users in groups), 'Use group' to 'User file data' (use group specified in the import file) and 'Create group' to 'Yes' (create a group if it does not already exist)
  • Picture of Juan Fortuna
    Fri, Oct 30, 2020, 2:34 AM
    Thank you Fred!, yes I saw it , but can you tell me if I want to asign different roles to eachone in the file, can I do it? Thanks
  • Fred
    Fri, Oct 30, 2020, 4:04 AM
    @juanfortuna, no, you can only choose one role for all users in the import file. Suggest you put teachers in one file and students in another.
  • Picture of Juan Fortuna
    Fri, Oct 30, 2020, 7:22 PM
    Yes I was thinking about that suggestion!. Thank you very much, it's a very usefull plugin!.
  • Picture of Артем Жуков
    Tue, Jan 12, 2021, 7:10 PM
    Hello! How to make the plugin understand the Cyrillic alphabet in the imported file in the group name?
  • Picture of herve boris
    Tue, Jan 12, 2021, 10:33 PM
    Hallo Guy,
    please i have a question: We would like every teacher/manager to have the opportunity to upload a list of participants as a CSV file on your course.
    Best regards


  • Picture of Mojmir Sedlar
    Fri, Jan 22, 2021, 11:27 PM
    Hallo,
    Is it possible by using this plugin - prohibited new group creation during the CSV import? User with enrolment right can not create a new group but only can added users to that group where is enroled.

    Thanks
    Mojmir
  • Fred
    Fri, Jan 22, 2021, 11:34 PM
    @Артем, I apologize for the delay in responding. Best option is to adjust the regular expression used to validate input so it will accept the range of characters from the Cyrillic alphabet; or, if the source of the input file is trusted absolutely, adjust the regular expression to access any/all characters. The regular expression is still used to parse the fields, though it can be simplified to split the string on commas, tabs, etc.
  • Fred
    Fri, Jan 22, 2021, 11:36 PM
    @Mojmir, yes, you can prevent new groups from being created by leaving the 'Create groups' option set to 'No'
1 2 3 4
Please login to post comments