The Good
Moodle, as of the version 2 release, includes a built-in Web Services (WS) API that supports a variety of WS protocols including SOAP, REST, and XML-RPC. Since the API is built-in it's generally available whether the site is self-hosted or commercially hosted. The API is easily extensible to add greater functionality. The API provides a single standard method for WS for Moodle simplifying what was a more complex patchwork of third-party solutions.
The Bad
In my experience with LMS development, WS libraries are typically used to provide realtime integrations between specialized third-party software such as a student management system or a content repository. The core Moodle WS library is poorly suited to this use case because it doesn't provide functions to find specific objects in the Moodle database using an arbitrary matching field. This is an unfortunate oversight given Moodle's otherwise excellent support for this methodology with its consistent use of the ID Number field throughout its system. Without being able to do these targeted matches against a value known by the third-party software, one has to rely on function calls to get the entire list of objects (example full user list). This is simply impractical from a performance perspective for any realtime system of scale.
We ran across this problem during a recent project creating an integration between a membership portal and a Moodle 2.7 site.
We did some research and found that:
- There is a related improvement request in the Moodle development backlog see tracker https://tracker.moodle.org/browse/MDL-26886.
- Community member, Craig Baker, submitted a conceptual solution and prototype code in the comments to address the issue. Craigs tracker profile https://tracker.moodle.org/secure/ViewProfile.jspa?name=cbaker118.
The Fix
Using the extensible nature of the WS API, we created a local plugin to allow clean and easy installation of our additions. We based the new calls on the conceptual solution posted by Craig. Many thanks to Craig for his contribution.
You can download a copy of the eLC WS library from git at
Be aware this was an emergency solution that to date has only been used on one Moodle site. As always with contributed code you should test for your particular use case. Please share your experiences with the code if you decide to try it and whether there are any improvements you would like to see.
This solution only really deals with allowing enrollment of a user into a course without knowing the users internal database ID number. Additional functions are needed to fully address the issue across all aspects of the API. As we do more WS related projects we plan to add additional functions.