CSV Upload Users to Delete Enrolement
Preface
Moodle is not designed to easily delete a user’s module enrollment unless it is done in bulk. However there are ways to use CSV upload sheets to suspend users from modules so they do not have access. You would then be able to go into a course user list, filter by enrollments and find inactive manually enrolled users.
Summary of steps
Below is a series of steps you can follow to bulk suspend users from a course or courses
- Create a spreadsheet file that contains as a minimum the following fields:
- username (In this field put the username of the person you want to suspend)
- course1 (In this field put the course short name for the course you want to suspend access too)
- enrolstatus1 (to toggle th status of the user put a 1 in this field)
- If you want to suspend from numerous courses at the same time add additional fields titled course2, enrolstatus2, course3, enrolstatus3, etc.
- Download a copy of your spreadsheet as a CSV file
- Upload your CSV file to Moodle in the section Site Administration > Users > Upload Users
- Add your CSV to the File Upload area
- Under the Settings panel change the following settings
- Upload type to include ‘Updating existing users’
- Existing user details to ‘Override with file’
- Allow suspending and activating of accounts to ‘Yes’
- Select for bulk user actions to ‘All users’
- Select Upload Users, your CSV has now been applied and the users should be suspended from their courses
Note: enrolstatus field with a setting of 1 toggles the enrolment status of the user, the process above will only work if the users are not already suspended. Doing this to suspended accounts with make them active again
Viewing Suspended Users
When you are in a course click the gear menu and select more to see the module administration settings. Select users and click the title called ‘Enrolled users’ to view a list of all participants of the Module.
On this page you will be able to view all the users and apply filters to limit the users you will view. Add a filter for Enrolment methods: Manual enrolments and a filter for Status: Inactive. Doing this will allow you to see all the users you have suspended from the course in this way, along with any other manually enrolled and suspended users.
Benefits of this approach
The key benefit to doing this approach is it prevents users from being accidentally deleted, as they are first suspended from a course. This allows their data to be recovered by making them active again.