Unenroll a student from multiple courses

Re: Unenroll a student from multiple courses

от Nicholas Stefanski -
Number of replies: 0

Hi,

Sorry to resurrect an old thread, but I was trying to do something similar and figured  out a kind of shortcut.

If you have the "Configurable Reports" block, this query can create the unenrolment link for each course the user is enroled in.  You still have to follow each link and click the button, because the final unenrolment requires a sesskey, but it really speeds up the workflow from opening each course, going to 'Enroled Users', and finding the user in a list.

SELECT ue.id, e.courseid, CONCAT('<a href="/enrol/unenroluser.php?id=',c.id,'&ue=',ue.id,'" target="_blank">Unenrol ',u.firstname,' ',u.lastname,' from ',c.shortname,'</a>') AS link
FROM prefix_user_enrolments ue 
	JOIN prefix_enrol e ON ue.enrolid = e. id 
	JOIN prefix_course c ON e.courseid = c.id 
	JOIN prefix_user u ON ue.userid = u.id 
WHERE ue.userid = ### 

Just replace the "###" at the end with the user id in question. This works in 2.7, can't guarantee the link is the same for other versions.