Moodle WebServices

Development Blog about the Moodle Webservices API and interoperability Issues

Apr 14 2008

A proposal of interoperability architecture for Moodle

Published by ludo at 5:21 pm under API, English, Interoperability

Designing a Webservices Architecture for Moodle: Moodle-DFWs.

The purpose of this entry is to analyze the interoperability needs of Moode, and to make a proposal of architecture (that is already partially implemented). We call this Moodle-DFWs, because it needs a name. All this work is being done in the Universitat Politecnica de Catalunya by the group known as DFWikiteam.

Antecedents.

Martin Dougiamas assigned to us the task of developing a API to access the services of the Moodle core (Let’s call it THE API from now on). This task is described in the Moodle tracker and in Moodle Docs. It consists on a set of PHP functions that encapsulate most of the services that an external ( and even internal ) application shall need from a Moodle server. For example a backoffice application to manage inscriptions and billing. This API consists in a number of functions already proposed by Martin and other guys at Moodle.org and this development will help to redesign some of the very Moodle core functions in the future.

This will be useful for all developers who want to develop applications for Moodle, because this development can lead to a documented and stable API to hack into Moodle that should overcome new versions of Moodle. With funding we could even backport the API… anyone interested }-)

OK, e are doing this. But we are not going to stop there. Our intentions are more mean. We intend to provide an interoperability architecture to be built over this API. Some of the functions of THE API are already in the CVS and we are gaining speed writing them. ;-)

Requirements

Moodle-DFWs needs to be accessible using any transport protocol present or future. So it cannot depend on a concrete Webservices protocol, name it XML-RCP, SOAP, REST or two empty yogurt vases tied by a wire.
Moodle-DFWs will need to be implemented in the present version of Moodle (Moodle 1.9) and in the future versions as well. We take for granted that in the future more services will come up, but - come on guys - we need the semantics of the first release to remain stable. We don’t want it to be like a regular Java with lots of deprecated features…. we remember: “Java is evil and eats kids”… said the master.
Moodle-DFWs needs to be extendable, so contrib amb custom applications can have a standard way to extend Moodle out of its bounds. To ensure security and simplify administration: Moodle-DFWs has to obey the Moodle Capabilities system.

A first glimpse at Moodle-DFWs

Lets look at fig.1. In this figure we have Moodle (in an orange box, off course), just below Moodle we have blue boxes that represent Moodle extensions such activity modules, courses or blocks. The purple lines plug all these software artifacts with a green box labeled API. This is THE API that MD wants us to develop. At least the part that talks with the orange Moodle box.

We want to propose a way to extend THE API so MOD, BLOCK, and COURSE extensions can provide their own service through THE API. These extensions would be dynamically included in the API if the Moodle Admin allows it. So here’s the first thing to debate. There are scalability and security issues at stake… so we want to hear from Martin Langhoff and Petr Skodak soon (we hope he will like these more than the wiki ;-) ).

Moodle Webservice architecture diagram

Fig. 1 A firs glimpse on the Moodle-DFWs architecture.

There’s also a CON green box, just over THE API. We took this box out of THE API because is something you will only need when using a connection from another application. If you access THE API directly from a inside Moodle PHP application, an activity module for example, you just don’t need it. The CON box contains the methods to authenticate authorize the remote application. These remote applications will talk with the blue boxes inside the big green box on the left (still on fig 1). We call these boxes Connectors, and those are who implement a way of connection, giving us independence of the webservices protocol.

We have already released to the tracker one connector for PHP and another for SOAP. To test the SOAP connector Ferran Wrote a Python client, also in the CVS.

This architecture allows that the services implemented in the connectors can be independent of the methods of THE API they use. Security enhancements and scalability considerations can be applied in the design of custom connectors. In fact a connector does not need to implement a full access to the Moodle Services, juts what the organization needs. In this case the Moodle partners could meet a new field of business making custom, secure and high performance connectors. (I just have the feeling that MNET could be re-implemented as a connector some day (comments from my friend Martin Lanhoff are required!))

The current design of the connectors requires them to implement two basic components.

  • Connect: initiates the first connection with Moodle. Login and logout will be handled here, and will negotiate the services from THE API that will be accessed. To manage remote connections “connect” will be the address for the http/s session.
  • InOut: is the one who offers the client application the services implemented in the connector according to the rights of the authenticated user.

A three layered architecture.

So, we get this tree layers (See Fig. 2):

  • Connect Layer: Contains the connectors that implement services to local(PHP) or remote (Webservices) applications. Each component manifests the services implemented using the “info” function, and implement the Connect and InOut components.
  • Integration layer: This layer consists on THE API (being implemented) that provides a one point access to the Moodle + contrib functionalities.
  • Services Layer: Is where real things happen. THE API knows ho to deal with the Moodle core, and in future posts we will deal on how the activity modules, course formats and plugins can offer their services to the clients.

layers

Fig 2: 3 Layers are cool

 


That’s It… comments and serrano ham are most wellcome!
DFWikiteam

3 Responses to “A proposal of interoperability architecture for Moodle”

  1. Rahimon 11 Jun 2008 at 6:39 pm

    I was curious about the following:

    “Integration layer: This layer consists on THE API (being implemented) that provides a one point access to the Moodle + contrib functionalities.”

    Does this mean that you are calling your own functions to modify the data in the Moodle database, such as adding new users, enrolling users etc..? or are you using the functions that Moodle itself implements via the core?

  2. ludoon 12 Jun 2008 at 7:15 am

    It means that we call the Moodle core APIs we DO NOT access directly to the database and other persistence objects. Everithing needs to be done (and is being done) using the Moodle core functions. This functions howevera are scattered all over Moodle and this layers provides with ONE handle to rule them all ;-)
    The idea is that when the API is implemented tested and stable, the Moodle core team with refactor some of the functions to boos efficiency and evens some parts of moodle migth use this very layer to access the information.
    THis layers migth be the first step towarts a more structured core of moodle both for external developers and for moodle module developers.
    Cheers
    Ludo

  3. […] doing great things, and in the campus project we did some good job too. But the  goo thing of the proposed architecture that David and Ferran came up with is that allows the posibility of writting connectors […]

Trackback URI | Comments RSS

Leave a Reply