How to properly delete users from moodle?

How to properly delete users from moodle?

by Everton Leite -
Number of replies: 0

Hello.

I work in a moodle instance that is running for 10 years now, currently at 3.9.2+ (Build: 20201028). The methodology we use is a bit odd. We don't have semesters or anything that limits the presence of students in the platform, since a person can start a course today and only finish it 10 years from now, or 6 months, or one month.

We have a lot of other instances of moodle, but all of them have semesters, so they are cleaned two times a year, but this specific one was never cleaned for the reason I mentioned. And, as you can imagine, the database's growth is a problem that is getting serious in the last few years. To put it in perspective, we have over 375k users and 600kk questions (yes, 600 million). The out-of-control random questions are being dealt with using the cron task running 24/7, and in 5 to 10 weeks we will solve this issue. But users are still a problem.

We have parallel software that deals with the academic life of the students, such as grades and the end of their courses. This software syncs its users with moodle, students and teachers, and this process works fine. When a student finishes his course, his moodle user is automatically "removed", having his deleted flag set to 1. But since we never reset the environment, the user table continues to build up and some tasks like searching the user list are now taking some seconds.

I try to play with the data privacy policy options, but given the size of the database, every test involving run the cron task got stuck forever in the step that calculates the users to be deleted. Once I set an expiration limit to user data, I cannot unset it (or didn't find how to do it). This really bugs me. Because of that, I'm not able to test anything else on the data privacy options.

Wrapping it up, the perfect solution for me would be a way to completely delete an user from the database, or at least part of his trail. Ideally, the users to be deleted must be defined in a way our parallel software could set the user ids that need to be removed, and then some moodle task could process the deletion of this users. I read a lot about the privacy data plugin, but I couldn't understand how to choose which users to delete or how the task works other than by setting an expiration period and letting moodle do all the job.

At this point, any ideas are welcome.

Average of ratings: -