Resetting Moodle and Deleting all users

Resetting Moodle and Deleting all users

by Raymond Yim -
Number of replies: 8
Last year was our trial period with Moodle and we would like to start afresh with Moodle this year. I would like to either reset everything in Moodle or just simply delete all the users and courses. I have 2 questions: 1. How do I go about resetting moodle? 2. For deleting user, I can only do it one by one. Is there a way to delete a large number of users at one go? Thanks. Raymond Yim ACS International Singapore
Average of ratings: -
In reply to Raymond Yim

Re: Resetting Moodle and Deleting all users

by Andy Hawkins -

Hello

If you do not need/intend to keep anything from your test Moodle then install afresh.

Assuming you have access to the server, use phpmyadmin to remove the entire Moodle database, rename/delete the Moodle folder and the Moodle data folder and reinstall. You may need to look at how your emails have been sent from Moodle - the cron job may be stored outside Moodle (we use Windows so would uninstall the Windows cron simulator) - do not know about Linux (yet).

Bulk deletion of users is discussed elsewhere - because of links between students and their assignments, forum postings etc it is not as simple as deleting them user database. Deleting them within Moodle 'hides' them by flagging them as deleted. To my knowledge there is no way to do so in bulk - yet (other than using SQL in phpmyadmin or similar - others may know better)

Hopefully the 'experts' will pick me up on anything I may have forgotten  - quite likely.smile

Good luck with your future Moodling

Andy

In reply to Andy Hawkins

Re: Resetting Moodle and Deleting all users

by Raymond Yim -
Thanks, Andy, for the info. My tech guy wasn't too comfortable for us to go into his server to meddle around with the server, so in the end we deleted it one by one on the website. Took about half and hour but managed to clear everything. Hope that moodle will have a bulk deletion feature in the future. Raymond
In reply to Raymond Yim

Re: Resetting Moodle and Deleting all users

by Nikki Stevens -
i've looked around, but not found SQL to delete users.  All that I need to delete are consecutive - userIDs from 40 - 90, and I know I will have to go into the db for this.  any help would be appreciated.
In reply to Nikki Stevens

Απάντηση: Re: Resetting Moodle and Deleting all users

by aggelos panagiotakis -

What about executing the following query?


DELETE FROM  `mdl_user` WHERE `id`> 30  AND `id` <60 


In reply to aggelos panagiotakis

Re: ÁðÜíôçóç: Re: Resetting Moodle and Deleting all users

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

The query suggested by "aggelos" would certainly delete the user records from the user table, although I think the WHERE condition should be modified:
DELETE FROM  `mdl_user` WHERE `id`>= 40  AND `id` <=90

However, there may well be other records for these users in tables, such as roles tables ("teacher", "administrator") and the tables maintained by the modules ("quiz", "resource", etc). Therefore, it would be safer and cleaner to delete the users one by one from the "Edit Users" page. That way, you can be sure that the all tables in the Moodle database are left in a consistent state (i.e. no orphan records are left behind)

In reply to Gordon Bateson

Re: ÁðÜíôçóç: Re: Resetting Moodle and Deleting all users

by Heather P -
Hi there
I have found that I appear to have users in my mdl_user table that don't show up on the 'Edit Users Page'. What would you recommend for getting rid of them?
It looks like they may have been failed attempts at logging in - their usernames start with a . (dot) and then are identical to the digits in the time modified field.
I also have a couple that look like failed log ins because they are not people in our authentication system and the usernames created look like a persons name and email address plus the digits from time modified field all squashed into one box. Do you think I'll be OK to just delete them from the database? I can't imagine what other tables will have been populated by these entries as they don't really look like proper entries, more sort of tangled up entries.
Thanks.
In reply to Gordon Bateson

Re: Resetting Moodle and Deleting all users

by David Barlow -

Hi

I wish to un-enrol all students, and then re-enrol them again (in different courses).  I deleted all users from the mdl-user table, but this did not clear the courses.  When I re-enrolled the students extaneous data in the database enrolled them into courses I didn't want them in.

I have not been able to solve this problem.  I have tried using a script file with blanks in the courses; and also using a non-existent course (giving error messages).  All to no avail.

I am facing the prospect of individually deleting 750 users.  Not something I relish.  I would really appreciate a bulk deletion facility, perhaps from a text file like the one where you can enrol students in bulk.

Anyone able to suggest something ?

David

In reply to David Barlow

Re: Resetting Moodle and Deleting all users

by David Barszczak -

You can get a php script to delete users via a csv file but this does not unassign them from roles or groups so you need to be very careful. Moodle only hides the users not actually delete them.

It may be easier to backup and try a fresh install.