Bulk deletion of users in Moodle

  • Posted on: 27 July 2015
  • By: ocarcamob

By: Orlando Cárcamo Berrío

In my college courses I use a delivery mode known as blended learning. It is a combination of two instructional methods: face-to-face teaching and online teaching. The online dimension of this approach is carried out with the help of a Moodle installation. Each semester I upload users to the different courses by means of a CSV list. Once the courses end, users accounts have to be deleted. The deletion of users can be done all at once if we reset or reinitiate the course they belong to. However, sometimes we have a course with different groups and we want to delete just the students of one group while keeping the others.

Bulk deletion of users is not possible from within Moodle. The first time I had to delete a complete group of students, I googled the Internet and just found complicated explanations of how to do it via the ssh Linux command line or by editing the Moodle users data base table, something very dangerous for the health of the Moodle database. Any error could completely damage it.

Consequently, I had to delete user by user with the help of the bulk user actions menu which is a very handy tool except for bulk deletion of users. Deleting users one by one was a very lengthy process that took too much time our of me.

Finally, in late august 2014, I found how to completely delete all the users included in a separated group of a course group in less than one minute. This was really amazing for me and I want to share it with you.

The problem. Moodle does not offer the possibility of bulk deletion of users from the course administration neither from the platform administration. You cannot delete a complete group of users of a course. Instead you have to delete one user by one and this of course takes too much time.

The solution. After having googled a lot and having found certain experts forums with complicated intructions for deleting users directly in the users data base table, I managed to
follow a straightforward process similar to “upload users” in the Site Administration/users/upload users menu. I would say that bulk deletion of users is even an easier process than uploading users. The following are easy steps for bulk deletion of users.

STEPS FOR DELETING LIST OF USERS FROM A COURSE

1. Locate the original CVS users file. This was the file you used for uploading the lists of users of your course. This file contains important data such as the user names of the students, passwords, names, last names, etc. It looks like this:

2. Edit the original CVS user file. You should edit the original CVS file erasing the unnecessary data and leaving just the username (this is the most important data for deleting users), firstname, lastname. Then, add another column called “deleted”. Under the deleted column you should write 1. This numbers tells Moodle that such user can be deleted. If you write 0, the user will not be deleted. The edited CVS file finally looks like this:

3. Upload the edited CVS file. Go to the “site administration/users/accounts/upload users” menu and upload the edited file as you did when you first uploaded your course users. Once you have done this, in the first place you will see a page like this:

Then you should do the following adjustments to this page. In Upload type you should select the option Update existing users only. Then in Allow deletes select the option Yes.

Finally, for deleting all the users marked with 1 under the column deleted, just press the button upload users.

If everything went fine, you will see a page like this as a result:

At the bottom of this page, you will see a summary of the process of deleting Moodle users:

According to this summary, everything went fine. The group of students I wanted to delete had 31 students. The users deleted were 31.

CONCLUSION

After a long time looking for a way to massively delete users from a moodle installation, I finally found a very straightforward procedure.  I tried my best to write this tutorial so other new Moodle administrators can do the user deletion process a very easy one. I hope this experience can be useful to you.

REFERENCES

Moodle (2013). Upload users. Retrieved on August 27th 2014 from https://docs.moodle.org/22/en/Upload_users

Vaughn, Michael (2014).How to Remove a Student from a Moodle Course.  Retrieved on August 27th 2014 from https://wiki.elon.edu/display/TECH/How+to+Remove+a+Student+from+a+Moodle+Course