Skip to content
patrickpollet edited this page Jun 14, 2013 · 23 revisions

Welcome to the moodle_local_mass_enroll wiki!

Table of Contents

Description

One awkward thing about Moodle 1.x and the recent Moodle 2.x is that teachers are allowed to manually enroll known Moodle accounts to a course as teachers, non editing teachers, students... , but not using a 'flat file' produced by some CSV export. Also there is currently no option to massively unenrol users from a course using a CSV file.

They have to send a file to an admin user who will inject it into Moodle using the standard 'flatfile enrollment' method with the following limitations :

  • Teachers must provide account's and course idnumbers and admin user must reformat the file by adding the required extra columns 'add/delete' and 'target role', before copying the file to the appropriate location in moodledata directory.
  • The report information is sent to admin, not to the course's teacher; so admin has to forward it to the teacher after the cron job has completed.
  • There is no way in flatfile enrollment method to specify in which groups these accounts should be added, so teacher has to go manually again across the list to assign accounts to groups.
This little extension, that adds itself to course administration menu will hopefully help teachers to do it themselves.

After installing it (see below) a new item 'Bulk enrolments' will appear in the course administration menu for teachers (see screenshots).

It requires a CSV file, prepared by the teacher, with an unique Moodle id in the first column (idnumber, username or email) and optionally a group name in the second column.

Options are provided to force group (and grouping) autocreation if they do not yet exist in the target course.

Every line of the file may contain a different group name or even no group for some accounts

Enjoy.

Installation & Usage (MOODLE 1.9)

The following documentation if for the Moodle 2.x version. For previous version see mass enroll moodle 19.

Installation (MOODLE 2.x)

Using git (recommended)

Go to your moodle installation directory and clone the github repo by :

 cd /var/www/moodle
 git clone  https://github.com/patrickpollet/moodle_local_mass_enroll.git  local/mass_enroll
 echo 'local/mass_enroll' >> .git/info/exclude

Eventually select the branch corresponding to your Moodle version (moodle_22, moodle_23...)

 cd local/mass_enroll
 git checkout moodle_2x  

using zip

Collect the zip file of the appropriate moodle_2x branch on github

Unzip it into the local directory of your moodle installation

Rename the folder patrickpollet-moodle_local_mass_enroll-xxxxxx to mass_enroll

From Moodle's database of plugins

Checkout https://moodle.org/plugins/view.php?plugin=local_mass_enroll

Testings

Being logged in to Moodle as a teacher of some course, make a note of the course id (xxx) which is the last part on the URL when viewing the course

  http://yourmoodle/course/view.php?id=xxx 

In another navigator window or tab call

  http://yourmoodle/local/mass_enroll/mass_enroll.php?id=xxx

You should see the bulk enrolments page with two tabs, one for bulk enrolments, one for bulk unenrolments (if you have the required capabilities) and be able to experiment with it.

When (if) pleased, consider adding it to Moodle course admin menu by reading the following section.

Final installation

Enable the extra items in course setting menus for all courses by adding the line

 $CFG->allow_mass_enroll_feature=1;

at the end of section 6 of your config.php file.

To turn it off, juste remove that line or change it to

 $CFG->allow_mass_enroll_feature=0;

Thus two new menu items named 'Bulk enrolments' and 'Bulk unenrolments' should appear under the item 'Users' in course admin menu (see screenshots) if current user has at least one of the required capabilities.

Tips and Tricks

Tuning the capabilities

By default the capability to 'bulk enrol' to a course is given at system level to admins and editing teachers and to 'bulk unenrol' only to admins. You may override these capabilties at site level, category level or course level.

Creating the CSV import

Make sure your CSV file contains a first line with some column names ; its content is not parsed during the import, but if absent, you will miss the first user to enrol/unenrol.

This extention only read the two first columns of the CSV file, therefore there is no need to delete any extraneous column.

Before importing it, have a look to it content using a simple text editor (notepad, kate ,textEdit...) to check the caracter encoding used (UTF8, ISO, WINDOWS...) and the separator used (comma,tabulation...)

If the CSV file contains double quotes around strings (username, email...) they will be automatically removed during the import process.

Reusing the enroling CSV for unenrolements

In the unenrolment process, this extension only consider the first column of the CSV file. Therfore you may reuse the very same file that was used to enrol users at the beginning of the course.

Setting an expiration date for enrolments

This extension use the manual enrolment plugin of the course to enrol the new users. If there is none in your course, it will add one automatically. Therefore if you want to define an expiration date to the users you are about to import, edit first the parameters of the manual enrolment plugin and set the expiration date.

Use it to populate groups in your course

Populating groups in a Moodle course can be tedious if you have many users. You can use this extention to help you. Export a list of users from the course (the easiest way is to export the gradebook). Load it into you favorite spreadsheet and insert two columns at the left side. In the first copy either the content of the idnumber column (if you use them, likely because you Moodle is synched with some LDAp directory) or the email column (that one is mandatory in Moodle and unique) and in the second add the group names you want to assign users. Remove lines for users that you do not want to assign groups (or leave the second column blank).

Save the result as a CSV file and import it using this extension by specifying what identifier is in the first column (idnumber or email).

In the report you will get complaints that every user is already enroled, but the group assignment will be done.

You may repeat the operation if you want to assign users to several groups.

Credits

2010-2012 Patrick Pollet (pp@patrickpollet.net) https://twitter.com/patrickpollet

http://moodle.org/user/profile.php?id=69061

See also

This version has been ported to Moodle 2.x from the previous 1.9x version http://moodle.org/mod/data/view.php?d=13&rid=3595