Proper Way to Bulk Enroll Registered Users

Proper Way to Bulk Enroll Registered Users

by Trolling in the Deep -
Number of replies: 12

Hola!

I have an idea in mind on how to implement batch enrollment but I'm not sure if it is the proper way to do it.

1. I learned that there is a Flat file (CSV) enrollment plugin so I enabled and configured it.

2. I manually uploaded a csv file to the data directory.

3. Ran the cron and the users  listed in the csv file were successfully enrolled.

 

---

I would like to automate the process of uploading the csv file to the data directory to make it more user-friendly for the admin.

 

Am i doing this whole thing correctly?

Average of ratings: -
In reply to Trolling in the Deep

Re: Proper Way to Bulk Enroll Registered Users

by Andrew Lyons -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi,

What is the data source behind the CSV file?

It should be possible (and reasonably easy) to write a script to take a file in the data directory, create users from it if exists, then delete it. However, how do you plan to put the CSV file there? The dataroot isn't normally accessible to users so I assume that you're planning to automate this in some fashion, or are you planning to make it accessible to users?

As an alternative, have you considered the database authentication system? You can configure the database authentication plugin to connect to an external database and create your users automatically. You can also use the database enrolment plugin to enrol users on specific courses automatically too.

Hope that this helps,

Andrew
In reply to Andrew Lyons

Re: Proper Way to Bulk Enroll Registered Users

by Andrew Lyons -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Sorry - please ignore the first part of what I said - the Flatfile CSV plugin should accomodate this.

The other part should still stand - how is the CSV created and could it be replaced with a database?

Andrew
In reply to Andrew Lyons

Re: Proper Way to Bulk Enroll Registered Users

by Rosario Carcò -

There is a Database enrolment/synchronization plugin built into Moodle. Have a look at it, it supports a lot of databases and other file formats, ready to go.

As I feared SYNCHRONISATION, I wrote my own workflow and php-scripts to autmate not only user enrolment but also creation of courses with automated enrolment into these newly created courses. I wrote for Moodle 1.9x and did not have time to convert things to Moodle 2.x But I will do it probably by end of this year.

If you are interested in my workflow or code you might customize to fit your needs, search for uploadusersandcourses.php including my first name in these forums.

Rosario

In reply to Andrew Lyons

Re: Proper Way to Bulk Enroll Registered Users

by Trolling in the Deep -

As far as I know, the Flatfile CSV takes a csv file from a specified directory and enrolls the users indicated there.

My problem is: i want to automate the putting of csv file to the data directory because I am assuming that I cant make the school admin access an FTP and transfer the certain file. 

So there, I dont know where to start. Should I make a custom form that does the uploading? Or is there any existing plugin that I can use?

In reply to Trolling in the Deep

Re: Proper Way to Bulk Enroll Registered Users

by Trolling in the Deep -

And I was told that the list of USERS will come from an excel file so database is not in my options.  -_-

In reply to Trolling in the Deep

Re: Proper Way to Bulk Enroll Registered Users

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Well, probably the way in which that was said has given a false impression, something that happens all the time I am afraid. I will try to clear this up if I can. If you have a small Moodle that uses online self enrollments, then you will not have to worry about it. If you have a Moodle that is accessible only by users of your own network, then at some point before the User accesses Moodle, then they have to become a member of your network. This is the most common option I have worked with, and this is what we do.

Every year we have new enrollments, they have to be registered Users on the network before they can use any of the ICT related resources we have. From there, I ask for a list of new users in the format as a csv file. (The csv file is nothing more than a text file with a set of data that is separated by commas, no spaces, and an extension of *.csv that's all.) 

username,idnumber,firstname,lastname,email,

That is all, nothing more. At this point they have not been enrolled in any Moodle Course. We can get as many as four hundred, or as few as 75, depending on the location. I assume the network admin team sets up an automated SQL query that takes data from their database in that specific order. The query runs and I get the data, usually within an hour of me asking for it. I open the file in Excel, but really, any spreadsheet program will do as long as it reads and saves in the csv format. I add the headings,

username,password,firstname,lastname,email

to each column, deleting any existing heading then save it as a csv file again, upload it to Moodle and allow Moodle to work its magic. 

That is how the Excel reference comes into it.  

In reply to Colin Fraser

Re: Proper Way to Bulk Enroll Registered Users

by Trolling in the Deep -

I appreciate your long explanation. It's really helpful. smile

However, there's another way of doing it. There's an Enrollment Plugin called Flatfile CSV which allows an admin to enroll the specified users there. According to the docs, the format is like this:

add, student, 2012-001, Course101

add, teacher, 2006-143, Course101

 

The admin just needs to upload it to the moodle data directory and the plugin will do the work via cron. Meaning, the enrollment will be processed once the cron is ran.

The disadvantage of this is it's too advanced for a "school" admin.

--

So I want to create a function that lets the "school" admin upload the file because they dont want to complicate things and let the school admin operate it via an FTP client.

In reply to Trolling in the Deep

Re: Proper Way to Bulk Enroll Registered Users

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

well you can get the admin to add fields to Colin's csv file which will enrol students into courses - just add course1 and course2 etc with the short names of the courses to the fieldnames Colin mentioned.

In reply to Trolling in the Deep

Re: Proper Way to Bulk Enroll Registered Users

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Well there is another thing too, I can add courses, or ask them to add additional fields anything I want really. The Flatfile CSV is not "too advanced" for school Admins, first, there is this kind of issue.. #MDL-30871, then there is the other point where a lot of Admins do not really want to move too far away from a bog standard Moodle. Every plugin utilised causes a lot of angst when updating - mainly because they are third party plugins, which means they may suit one particular environment, but not mine. Or they can be showstoppers when upgrading. I used to test stuff all the time on my private Moodle and you might be surprised how often it does not work. A lot of the time I found some plugins did not play nicely together. Can't be bothered wasting the time now - too busy.

Experimenting is fine, I would encourage anyone to try stuff, but not with a production server, only a test site. If, or when, you are completely happy a third party plugin works as it is supposed to, do you try it on your production site - and then expect problems. This is why we do not use them too many problems when something does go wrong.    

 

In reply to Colin Fraser

Re: Proper Way to Bulk Enroll Registered Users

by Trolling in the Deep -

I'm not sure if what I did was elegant but it's working now.

I created a form that asks an admin to upload a csv/text file and then hit the specific function in the cron.php that does the enrollment.

In reply to Trolling in the Deep

Re: Proper Way to Bulk Enroll Registered Users

by Rosario Carcò -

Did you read my workflow in uploadusersandcourses??

It's as simple as that:

- export your data (e.g. from a school administration system, where you manage courses and students, and who has to attend which course)

- export that data to any shared volume (e.g. a windows-share)

- transform this data to UTF8 and to a simple CSV-Fornat as it is required by Moodle CSV-upload (e.g. like you use it with the built in uploaduser.php and my derived uploadusersandcourses.php)

- if your Moodle server is a LINUX server like mine, mount this share in /etc/fstab automatically at boot time. If your Moodle server is a Windows server, simply connect to this share (e.g. on drive M)

- modify my uploadusersandcourses_silently.php script to use your share and leave the rest as it is OR

- modify the builtin uploaduser.php code to uploaduser_silently.php using all the needed code for unattended operations I copied from cron.php to my uploadusersandcourses_silently.php

Alternatively you might also set up a scheduled job that uploads to the desired Moodle directory by ftp or any other file transmission protocol. The simplest being to use a server-share, where you can drag and drop your files. Letting the Moodle-server mount and access the same share. Even an automated copy job could read and copy your files to /data/1/ every 5 minutes or twice a day. No need to ask anyone to upload files by clicking.

Rosario

In reply to Rosario Carcò

Re: Proper Way to Bulk Enroll Registered Users

by Trolling in the Deep -

Thanks! smile

@Rosario: Oddly enough, they want a tool wherein the admin will upload the csv file that contains the users that they want to enroll. They dont want it to be scheduled or something.

Anyway, I was able to do it already.

this is how it looks like:

Uploader form  -> upload csv file -> upload to moodle date directory temporarily -> hit the functions in cron.php that enrolls bulk users -> users are now enrolled -> delete temp file

 

Thanks for all your replies.