1000's of students enrolled in 100's of courses that they have never entered.
Using the tools available in moodle:
Using the enrolled users screen to sort by "manual enrollment" method and role of "student" then clicking "Last Access to course" twice will bring the users that accessed the course to the top. This is great but the bad part is that after i scroll or next to the page that starts showing the users that have "never" accessed the course I have to click on each one individually (the ability to select all would help here) and then I select from the drop down "delete selected user enrollments" and on the next page confirm I want to delete them. Then wait minutes for it to perform the task after its complete then I have to individually check each user with "never" and repeat the process over and over until I have removed all the users. With over 5000 users to unenroll from 100's of courses this becomes much too time consuming. And this is for only one particular course. I will have to do this on over 300 courses.
Can I use a SQL query to do the following? And if so I have no experience writing such a SQL query, does anyone have or can write a query like this?
What I would like to do:
Select all courses and unenroll all users that have never accessed the course.
Please let me know if I need to post more information
Moodle 3.1.6 (Build: 20170508)
mysqlnd 5.0.11-dev - 20120503