Note: You are currently viewing documentation for Moodle 2.4. Up-to-date documentation for the latest stable version of Moodle may be available here: Web services API.

Development:Web services API

From MoodleDocs

Overview

Provide Moodle with a web service interface to allow exchange of data and information with other systems.

Specifically,

  1. Manage user data - send and retrieve the information,
  2. Manage course enrolments - add/remove teachers and students,
  3. Course management - create new courses based on templates,
  4. Gradebook info - extract grades information from Moodle.

The API will be built in two tiers:

  1. Generic Moodle web services - This will define the API available to be used by specific protocols.
  2. Protocol-specific web services - Using the generic services as the parent, define specific interfaces for SOAP, XML-RPC and others.

Class Structure:
Base class server.class.php:

This class provides most of the necessary functions to authenticate and communicate with Moodle. It also defines the methods that must be implemented by the protocol class. Any web service protocol class must:
  • call the base class constructor (parent::init()),
  • implement the main method (main([$httpdata])),
  • implement the request method (request($input)),
  • implement the reply method (response($request)).

Derived class (e.g. soapserver.class.php).

The driver for the whole operation is through service.php. It takes one argument, type, which contains a string identifying the protocol to use (e.g. 'soap').

So, to call a SOAP based web service:
http://your.server.org/moodle/ws/server.php?type=soap The data for the entire operation comes through the POST mechanism.

Manage User Data

These functions will allow the exchange of user data, and account management functions. Initial work will use the IMS Enterprise XML standard for data definition.

Manage Course Enrolments

These functions will allow for student, teacher and group management functions within a course. Initial work will use the IMS Enterprise XML standard for data definition.

Manage Courses

These functions will allow for definition and management of courses. Initial work will use the IMS Enterprise XML standard for data definition.

Manage Grades

These functions will allow for information about grades to be exchanged. Initial work will use the IMS Enterprise XML standard for data definition.


See discussion at

http://moodle.org/mod/forum/discuss.php?d=44079