I'm trying to figure out how to enroll users into a course. I'm trying to figure out exactly how I get the context id for a course that the function moodle_role_assign requires . It doesn't appear there is any way to do this. I see work is being done on a new function (http://tracker.moodle.org/browse/MDL-26250), but it too appears to require a context id. Am I overlooking a function to get a context id for a course?
Hi John, we are using courseid in MDL-26250, no worries.
Excellent, thank you very much!
That's great for enrolling users. What about unenrolling them? The only external service function currently available for that is the simple role_unassign one under /enrol/externallib.php, and it, too, requires a contextid to function.
Will there be a simple unenroll service as there is for enrolling?
Will there be a simple unenroll service as there is for enrolling?
Use the OK tech webservices, there you get all the stuff you need:
unenrol_students
and so far. The smoothest way to enrol users to courses is to use
moodle_enrol_manual_enrol_users
Good luck!