Not long ago I was tasked to make a tool to manage Moodle courses by moving them through categories, creating and cleaning them up. Now I had to make some way to “refresh” the course participants and that means unenrolling teachers and managers, assign different roles, suspending students, adding students, all that stuff.
This was going pretty good and easy until I hit upon a web service function
core_enrol_edit_user_enrolment. It’s an
External function that updates a given user enrolment, it is needed to suspend students from a course.
From the official API docs, we can see that it takes in required arguments courseid (User enrolment ID), ueid (User enrolment ID) and status (Enrolment status).
The problem here is with a ueid (User enrolment ID) argument because there’s no function that returns such an ID. At least I wasn’t able to find one easily accessible and I had to make my own web service function to get that ID.