Issue Details (XML | Word | Printable)

Key: MDL-12886
Type: Bug Bug
Status: Open Open
Priority: Critical Critical
Assignee: Ludo ( Marc Alier)
Reporter: Martin Dougiamas
Votes: 8
Watchers: 23
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Implement basic web service function set

Created: 09/Jan/08 04:51 PM   Updated: 04/Mar/09 12:21 PM
Component/s: Lib, Networking
Affects Version/s: 1.9
Fix Version/s: 2.0

File Attachments: 1. File dfws_webservice.tgz (24 kB)
2. File dfws_webservice.tgz (21 kB)
3. XML File WSMoodleForGenDep.wsdl (63 kB)


Participants: Brian King, David Castro, Eloy Lafuente (stronk7), Frédéric Hoogstoel, Jerome Mouneyrac, Jordi Piguillem Poch, Ken DeVellis, Ludo ( Marc Alier), Martin Dougiamas, Matteo Bertazzo, Patrick Pollet, Petr Skoda, Ralf Hilgenstock and Thomas Bachert
Security Level: None
Affected Branches: MOODLE_19_STABLE
Fixed Branches: MOODLE_20_STABLE

Sub-Tasks  All   Open   
 Sub-Task Progress: 

 Description  « Hide
We need to implement the functions described here:

  http://docs.moodle.org/en/Development:Web_services

Most of the functions need to be implemented / integrated in core libraries, and the web services wrappers just call those.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Martin Dougiamas added a comment - 24/Jan/08 03:18 PM
All of these subtasks need specifications and discussion before development

Ludo ( Marc Alier) added a comment - 21/Feb/08 04:30 PM
We have I implemented some functions as first prototype.
Howevere we need write access to the CVS, we lost it since the migration from sourceforge.
Users : granludo pigui tusefomal davcastro
thanks!
L.

Martin Dougiamas added a comment - 21/Feb/08 09:38 PM
All developers need to go here to reapply now: http://moodle.org/cvs (make sure you log in)

Eloy Lafuente (stronk7) added a comment - 22/Feb/08 02:35 AM
I've "accepted" request from developer "pigui" granting CVS access to "/contrib/plugins/mod/wiki" as requested.

Note that, in the request, "pigui" asked about extra-access to know where to store their WS-related code.... Martin?

Ciao


Martin Dougiamas added a comment - 27/Mar/08 10:42 AM

Martin Dougiamas added a comment - 08/Apr/08 11:25 AM
Pigui, any progress on this? I can't see any and it's getting urgent.

Ludo ( Marc Alier) added a comment - 08/Apr/08 03:30 PM
Sorry for the delay... we are commiting the code today.

Frédéric Hoogstoel added a comment - 08/Apr/08 05:13 PM
Hi,

we have developped for two years web services for Moodle 1.8.2, under PHP5.
They are available on http://www.assembla.com/spaces/MoodleWSPourGenDep.
On this site, you'll find also a PHP client and a Java client to test these web services and see how to use them.

These web services have been developped during a project name Bricoles and the PhD Thesis in Computer Science and Learning Sciences of Pierre-André Caron. See http://noce.univ-lille1.fr/projets/bricoles/ for the project and http://tel.archives-ouvertes.fr/tel-00156376 for the thesis.
The goal of these web services is to help learning design using Model Driven Engineering.
We (NOCE research team) have developped a Model Driven Learning Engineering workshop, including two free tools :

  • ModX that allows to build learning design metamodels and model
  • GenDep that allows to deploy a learning setup model on a learning platform.
    GenDep uses web services to communicate with the learning platform.
    GenDep already exploits Moodle, Ganesha, Claroline and Wiki MST webservices to deploy learning setups.

ModX and GenDep are available at : http://noce.univ-lille1.fr/projets/ModX/index.php

We have presented our project at french-speaking Moodlemoot 2007 and we will present the evolution of our work at french-speaking Moodlemoot 2008.

We are currently studying how to articulate our web services with those described in this issue.


Frédéric Hoogstoel added a comment - 08/Apr/08 06:46 PM
WSDL description of web services for Moodle 1.8.2 developped by NOCE research team in Bircoles project.

Ludo ( Marc Alier) added a comment - 08/Apr/08 11:13 PM
Done... we have commited our work. We will try to work directy over the cvs when all of us can access it without problems.
There's a layer of php functions implementing the functionality, there's also a SOAP layer that implements calls to these php functions and finally there's a pyton client that connects to the soap ws.
Next week we will post more detailed documentation.
Ludo


Patrick Pollet added a comment - 12/Jun/08 05:56 PM
At the French MoodleMoot 2008, Frederic Hoogstoel, author of a SOAP WS with operations mostly aimed at creating "personnalized" courses from a learning profile determined outside Moodle (ie create/modify categories and courses, adding sections, forums, wikis...to courses and enroling/unenroling) , and me, current maintainer of the OK Web service implementation, that is more focused on "getting informations out of Moodle" (users, courses, activities, roles, grades...) have agreed to merge our two implementations that are really complementary.

Most of the operations he is currently supporting are not in mine and conversely.

We are really waiting for Ludo's implementation of " STANDARD list of CORE web service function" to start reducing our lower layer (server.class.php) that currently speaks (most of the time) to Moodle core API and in some rare cases do direct SQL calls ( such as when retrieving last activities in a course).

In the meantime we will focus on "merging" our high layer implementations that will finally propose about 80 operations, why names and parameters as per current OK WS 1.5.10 revision ( see wspp directory in CVS contrib/patches/ws )

More to come in future weeks.

If you can read french, our two communications at the Freench MM2K8 are here

http://moodlemoot2008.vet-nantes.fr/moodle/course/view.php?id=34

http://moodlemoot2008.vet-nantes.fr/moodle/course/view.php?id=56

Cheers.


Jerome Mouneyrac added a comment - 20/Jun/08 05:13 PM
Hi all,
I would need more information about your work on Web Services for Moodle 2.0.

I went to have a look to the contrib folder in patches/dfws.
Tell me when I'm wrong:

  • Functions defined in the Moodle 2.0 specification are in the "apis" repository
  • "inout" repository contains all way to access to these functions (SOAP, XML-RPC, REST)
  • The repository mod is for module web services (not in the Moodle 2.0 specification yet)
  • There is an api.php, connect.php and lib.php file in the project root repository.

It's apparently not the last version of your work, can I get an access to the last version?
Who works on what exactly?
Do we really need all this code for Moodle 2.0? (it could be a stupid question but I read somewhere that it was first based to work with Moodle 1.8)
Does the last code version follow the Moodle 2.0 specification?

For information, I'm still a recent Moodler, and not an expert in web services yet.
I'm a bit confuse, I'd really appreciate more information.

Have you a way to communicate easily? You can contact me on skype, my skype account is jerome.mouneyrac@skype.com

Last point, I can not access to the two French discussions. I created a "jerome" account on the French Moodlemoot website but I'm not allowed to access to these conversations.

Thanks a lot for your help.


Patrick Pollet added a comment - 24/Jun/08 09:01 PM
Hello,

I finally succeeded to get dwfs running against a test Moodle 1.9 ... First the webservice directory MUST be at the "root" of the Moodle installation, nowhere else ...

The excellent point about this implementation is that the WSDL required by SOAP client in generated "on the fly" by collecting all datatypes and functions declarations from the files present in directories apis/* and mod/* , but they use the outdated nusoap library. A possible issue will be performance since the WSDL will be recomputed at each call.

Currently I got some answers from :

  • http://mymoodle/webservice/inout/direct/client.php after editing line 4 of this script to give an admin login/password or an user with manual access. The call mdl_course_get_courses_by_user gives no anwser for user id 4, where it should give 2 courses...
  • the python SOAP client navega.py do work, but again I got no answers at get_my_courses.

It is still unclear to me why there is two entry points (connect.php and inout.php ) and how the security is implemented , i.e how a single call to connect is required before jumping to inout.php and how inout.php reject unconnetd operations... but I am still searching

By quickly peeking in apis directory, I noticed that all functions that address creating or deleting Moodle entities (course, user...) do not check for roles... and call directly the delete_course() or delete_user() APi functions.

As far as the specifications are concerned it is true that the functions do not have yet the proposed names
but that could be easily solved. A more important problem is the parameters ; the calls only use Moodle internal IDS to identify the objects, where it is clear that for external information systems, these values are irrelevant. External system should not keep track of these numbers and talk to Moodle using "idnumbers" at least for users and courses. We have suggested in the specs that all calls should include a parameter stating what field of Moodle should be used to identify something, with a default to "idnumber".

I think Ludo's team should concentrated on writing the code in apis/ and mods/ directory, with the help of Moodle core developers, that are the most competent people on that matter, using the inout/direct/* scripts to test them out and let others take care of the real clients. Currently, people that already have implemented WS for Moodle ( Frederic and me for SOAP and Linux Box Corporation for XML-RPC) and eager to replace their "low level layer" that talks directly to Moodle API or do SQL calls by a set of well established functions located in Ludo's apis/ and mod/ directories

My 2 cents...

Cheers


Patrick Pollet added a comment - 24/Jun/08 09:11 PM
I forgot to say that there are some interesting docs at http://blogs.dfwikilabs.org/moodle_ws/.
Some entries are in spanish, but Google translator has been my friend as always

Patrick Pollet added a comment - 25/Jun/08 01:52 AM
One more step to do :

Python client navega.py do work as expected if you add the table mdl_api_session to Moodle database.
Copy & paste webservice/webservice/inout/soap/base_de_dades.txt file content into phpmyadmin

CREATE TABLE mdl_api_session (
id bigint(10) unsigned NOT NULL auto_increment,
userid bigint(10) unsigned NOT NULL default '0',
username varchar(100) NOT NULL default '',
ip varchar(25) NOT NULL default '',
content text NOT NULL default '',
session_id varchar(40) NOT NULL default '',
expires bigint(10) unsigned NOT NULL default '0',
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Store session data from usemdl_api_sessionrs migrating to other sites' AUTO_INCREMENT=1

So I start to understand how security is implemented. Operation mdl_config_login located in connect.php add a record to mdl_api_session table and that record is fetched back by inout.php and deleted by a call to mdl_config_logout operation.

In a prod version, database updates should be done by standard Moodle manipulations .

A+


Jerome Mouneyrac added a comment - 25/Jun/08 02:34 PM
Thanks a lot for all these information Patrick

Patrick Pollet added a comment - 26/Jun/08 05:58 PM
Hello,

I played harder on current dfws implementation and start to have some good results with it ...

Attached a modified version of cvs:/moodle.org/contrib/patches/dfws/webservice.
Unpack it at the root of you Mooalde and read the README_IMPORTANT.TXT for security.
--------------------------------------------------------------------

  • My goal was ONLY to try to understand how it works and check that adding operations
    was easier than in other implementations. That is TRUE !
  • a basic api for categories has been added in apis/ to test adding operations.
    Currently there is only one entry : mdl_category_get_categories(parent,recurse). DONE
  • UTF-8 encoding of the WSDL is enforced if Moodle's database is unicode. DONE
  • the current "security mechanism" by requiring first a call to mdl_config_login(user,pwd)
    and then passing back the sessionid to all calls to inout.php has been removed since it does not work.
    Anymore can call an inout operation that do not return a "complex type" such as mdl_user_add_instance
    without authentfication. DONE

I would suggest that the sessionid be added as the first parameter to all calls
but mdl_config_login and tested against the database... like it is currently done in OK Tech WS implementation. TODO

-since there is currently TWO entry points (connect.php and inout.php) the service names MUST be different
to allow automatic classes generation by wsdl2xxx utilities without overwriting ...DONE

  • for testing SOAP clients, see the directory inout/soap/testing and the file README_IMPORTANT.TXT.

Patrick Pollet added a comment - 26/Jun/08 05:59 PM
Some modificatiions to CVS current release (date APril 18th).

Patrick Pollet added a comment - 26/Jun/08 10:57 PM
correct some typos in first version attached.

Can an user with admin privileges remove the previous version. Thkx


Ludo ( Marc Alier) added a comment - 28/Jun/08 11:13 PM
In this subtask http://tracker.moodle.org/browse/MDL-13127 I and David are talking about the parameters for the delete_user function BUT the issue here migth affect all the API because
we should have a consistent way of passing parameters. Shall we debate it there?

Jerome Mouneyrac added a comment - 30/Jun/08 10:42 AM
I don't get it. Can you post an example when passing parameters is not consistent?
The technical specification (http://docs.moodle.org/en/Development:Web_services) should mention the parameters for every functions. Let us know where the specs are incomplete.

Ludo ( Marc Alier) added a comment - 30/Jun/08 02:10 PM
Sorry,
I did not explain myself - language issues - What I mean is that the way parameters are passed should be alike in all functions.

Martin Dougiamas added a comment - 30/Jun/08 02:34 PM - edited
Absolutely they should be consistent.

I like the idea of passing an array of "field" -> value like:

array (
'idnumber' => '434343',
'email' => 'martin@fred.com',
'id' => '3'
)

Where they are processed in order. Does that make sense to all?

delete user with idnumber 434343
delete user with email martin@fred.com
delete user with id 3

Obviously this could delete a lot of users at once:

array (
'firstname' => 'Martin'
}

Perhaps we should allow wildcards too:

array (
'lastname' => 'Doug%'
}


Ludo ( Marc Alier) added a comment - 30/Jun/08 02:44 PM
Hmm... acording to this who do we delete 3 users with id 4,5,6 ... the position of the associative array "id" s is taken...
So how do we doi it? separating id's by commas?

Ludo ( Marc Alier) added a comment - 30/Jun/08 02:49 PM
My idea is that we should implement ONE function to do all the heavylift ( delet the user and the role asocciations and so on ) ... this function shuld be invoqued by 4 functions like delete_users_by_id delete_users_by_username ...
So it may be easy for the user developer and from the maintenance point because just one function

Patrick Pollet added a comment - 30/Jun/08 02:59 PM
>In any order, and any number or items, where they are logically joined with AND in the function. Does that make sense to all?

So if you mean delete user whose idnumber is 434343 AND email=fred@xxx AND id=3 ??? :In that case is it too much demanding on the external SIS that will likely not know anything about Moodle internal ids and does not want to know about them.

And if you mean user whose idnumber is 434343 OR email=fred@xxx OR id=3 , it does not make sense to me either since, when writing processes to sync Moodle with my SIS it is very unlikely that I shall scan my database twice, once for idnumber and one for email. If in my place idNumber are the "primary key", I shall use it anywhere, if it is the email, I shall uses is instead, but never both...

I think Ludo's question is more :

-Shall we have ONE public operation delete_users (array of some info, corresponding field name in Moodle ) that could be called as :
res = delete_users (array(1,2,3), 'id')
or res = delete_users (array('CS27001','CS27002',...), 'idnumber')
or res = delete_users (array(jack@here,fred@ther,...), ,'email')
or res = delete_users (array(jack,fred,...), 'username')

  • Or shall we have four public operations :

res = delete_users_byid (array(1,2,3')
or res = delete_users_byidnumber('CS27001','CS27002',...)
or res = delete_users_byemail (array(jack@here,fred@ther,...)
or res = delete_users_byusername (array(jack,fred,...)

and make delete_users private to avoid devastating calls such as delete_users (array(1),'confirmed') or delete_users(array('patrick'),'firstname')... unless you feel that it should be allowed

Also the question of wildcards should be addressed (permitted or not) such as delete_users (array('CS%','idnumber) ....

To me it should not be permitted to delete_users for safety reasons ; it that case we should request a true identifying id (unique in database) ;
in contrast it should be allowed in get_users . I shall be happy with a get_users(array(1),'deleted')

Cheers.


Martin Dougiamas added a comment - 30/Jun/08 03:19 PM
Yep, fair enough Patrick, though I prefer the field name to be first (same as get_records etc)

delete_users ('id', array(1,2,3) )

I'm not keen on one function per field ... that would get unmanageable rather quickly!


Jerome Mouneyrac added a comment - 30/Jun/08 03:43 PM
As everybody agreed, I updated the specs for delete_users() : http://docs.moodle.org/en/Development:Web_services#delete_users
I added some Patrick's comment into a TBD paragraph.
For any change to do in the specs let me know.
Thanks everybody.

Matteo Bertazzo added a comment - 10/Jul/08 05:27 AM
hi all,
why not consider a solution based on SCA (http://www.osoa.org/display/PHP/SCA+with+PHP) ? Not only in this particular task (that could be the first dev) but also in whole next moodle dev?

1 y ago, when i started implementing a prototipal impl of a gateway between moodle and a student information system i thought it was the way; now i think it can be the way for moodle too.

what do you think about it?

mbertazz


Ludo ( Marc Alier) added a comment - 10/Jul/08 01:58 PM
Hi Matteo,
the proposed architecture consists of 3 layers. The first one consists in "putting the house in order". Meaning that we need a stable and consisten API to access to the Moodle core, that can be used for non moodle-core iniciates and that can resists changes (because we can change its implementation as the core evolves). Then we have proposed an architecture that allows to build diferent ws connectors. Because we don't one one aproach we want it all
So in this framework we can the implement thinks like the current oktech ws, something based on osa, or what my team did in the campus project (http://campus.org) with the OKI OSID's http://oki-project.org
Take a look at http://blogs.dfwikilabs.org/moodle_ws/2008/04/14/a-proposal-of-interoperability-architecture-for-moodle/ for more details and send us feedback.
L.

Patrick Pollet added a comment - 10/Jul/08 02:25 PM
Hi Mateo,

I quickly peeked at SCA site and indeed found some nice features such as automatic generation of a WSDL from a set of well commented php classes and functions, something Ludo is currently doing using the "old" nusoap library for his sample SOAP server, and me by hand (

So SCA could indeed be used to write the high level ws connectors Ludo is talking about. They claims to support a fair amount of protocols such as :

binding.ebaysoap Binding Documentation
binding.jsonrpc Binding Documentation
binding.message Binding Documentation
binding.restresource Binding Documentation
binding.restrpc Binding Documentation
[binding.simpledb Binding Documentation]
[binding.soap Binding Documentation]
binding.xmlrpc Binding Documentation

However I also noticed on their download page : "SCA is in its early stages while SDO has achieved a stable state. " , and that nothing has been released since august 2007...

Cheers.


Ludo ( Marc Alier) added a comment - 10/Jul/08 03:25 PM
Hi patrick, we used nusoap for a proof of concept development cause the guy who was coding it knew the APi.
I'm more into REST rigth now, IMO SOAP is not the way. But as I said I don't want any ws protocol... "I want them all".

Jordi Piguillem Poch added a comment - 10/Jul/08 04:03 PM
I added some comments to user and course functions.

I would like to discuss about get_user and get_course. It's important to define what are User and Course objects.


David Castro added a comment - 10/Jul/08 04:42 PM
I'm completely agree with Jordi.
First of all we have to define what are the user & course objects or instead of this define an array structure to start.

Ludo ( Marc Alier) added a comment - 10/Jul/08 04:49 PM
From a philosophical point of view, idl like this API to be COMPLETELLY INDEPENDENT FROM WHAT'S INSIDE THE MOODLE CORE. It needs to be independent from the implementation, if we return the user object or the course object and some darn day this changes in moodle 2.1 then... to the hell with the stability of the api. That's why we need to work with something like asociative arrays like MD suggested, and lock it. we can adapt implementations of the functions to each evolution of the core. but what the users whant is something fixed that does not change.
Please, pigui, put here a link to the working phpdoc that we where working yesterday and lets talk about it.
L.

Jordi Piguillem Poch added a comment - 10/Jul/08 07:59 PM
I uploaded the phpdoc here.

http://potato.lsi.upc.edu/api/


Ken DeVellis added a comment - 29/Jul/08 09:41 PM
Hello All,

Would it make sense to add a "reset_courses" function to the list of standard core functions?

One of the requirements in our moodle implementation is to reset all courses by category at the end of a term. Since we have over 500 courses, resetting these manually would have been an administrative challenge.

We use the Ok Tech WS to control enrolments and retrieve grades into our SIS and have modified some of their functions to work with collections of courses under a category. We added a simple reset_courses() web method and since it it was a good solution for our requirements, I thought it might be a candidate to add to the list of standard webservices core functions...


Patrick Pollet added a comment - 30/Jul/08 08:20 PM
Hello Ken,

Could you disclose yours modifications to OK Tech Implementation ? They could benefit to others while waiting for the official Moodle 2.0 API layer. Especially the grade part that has not been tested in production to my knowledge.

Thks.


Ken DeVellis added a comment - 01/Aug/08 12:05 PM
Hi Patrick,

I posted the modifications to the Web Services forum here:

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

Hope this will be of some benefit...


Brian King added a comment - 06/Oct/08 10:04 PM
Hi, we here at the Moodle Partner company in Switzerland ( liip.ch ) would like to implement some web services for the quiz module. See

http://docs.moodle.org/en/Development:Quiz_web_services

What is the status of web services for Moodle 2.0 currently? I've seen http://cvs.moodle.org/contrib/patches/ws/ ,which looks nice, but it's only an implementation for SOAP, unless I'm missing something.

We'd like to contribute what we do, but we're not sure how best to proceed now though. Assuming we develop these services using XML-RPC, where would these fit in in the CVS repository?

A little background:
For versions 1.4 and 1.5 of Moodle we developed a flash client for a customer; the flash client then talked to the Moodle via a custom script; the output was in IMS-QTI 2.0 format. This allows for the creation of very nice professional-looking "quizzes"; the user management, quiz and question details are handled in Moodle. This has proven to work very well. A couple of examples (in German / French only, sorry) can be seen here:

http://creaviva.lernfrage.ch/froodle/creaviva/100001-anonym-de-new-go
http://cleverunterwegs.lernfrage.ch/froodle/home/10011-anonym-fr-false-go

Back then, we had to modify the quiz handling and the question fields a bit (e.g. adding overall feedback). We'd like to update to using Moodle 1.9 / 2.0 and later, and get away from having to make core hacks to Moodle. The customer has agreed to opensource the updated IMS-QTI2-rendering flash client (which we will also contribute to the Moodle community, assuming that there's some way to get the necessary information from Moodle without having to make core hacks). We'd like to be able to get the necessary quiz information using a standard interface, that will not greatly change for each new version of Moodle. So, we're proposing to develop these: http://docs.moodle.org/en/Development:Quiz_web_services .

We would appreciate some feedback. We have a project scheduled to start soon, and would very much like to be able to develop something that the greater Moodle community can profit from.

Best regards,
Brian


Ludo ( Marc Alier) added a comment - 07/Oct/08 05:15 PM
@Brian Pleaase contact me at granludo@gmail.com so we can talk about this possible collaboration.

Jerome Mouneyrac added a comment - 06/Nov/08 12:23 PM
Hi,
I started writing some documentation on Moodle docs:
About the web service module: http://docs.moodle.org/en/Development:Web_services
About the Moodle API: http://docs.moodle.org/en/Development:Moodle_API
It's still work in progress and you're welcome to participate.
Thanks

Ludo ( Marc Alier) added a comment - 06/Nov/08 07:21 PM
Cool Jerome. We like this kind of structure. I'm creating a subtask to reimplement all of the functions above defined using this structure. I'm reopening all functions again .

Jerome Mouneyrac added a comment - 13/Jan/09 04:24 PM
Hi,
I committed on HEAD an alpha version of web service with Rest implementation. I used Ludo Team's work as a base.
You'll find:
  • A rest server is in /webservice/rest
  • A rest client is in /webservice/rest/client
  • Some User core functions are in /user/api.php
  • The web service description for these functions are in /user/wsapi.php

The /webservice/rest folder also contains a lib.php file that check the web service description in order to call the core function.

Some explanation about the process can be find here: http://docs.moodle.org/en/Development:Do_we_need_named_parameters#Web_Services_.2F_Moodle_API

If you like to run it, go to: http://your_moodle/webservice/rest/testclient/

All feedback are welcome.


Ludo ( Marc Alier) added a comment - 14/Jan/09 06:06 PM
We are adding functionalities suggestions in the API discussion page.
http://docs.moodle.org/en/Development_talk:Moodle_API_Function_List#Course

Petr Skoda added a comment - 15/Jan/09 01:24 AM
Hi, I am going to add a kill switch for this feature - I do not think this should be enabled by default especially until we get some security implemented.
Please add if (empty($CFG->enablewebservices)) { die;die;die;} into each new script, thanks

Ludo ( Marc Alier) added a comment - 15/Jan/09 04:00 PM
@petr OK, I agree. Will do.

Jerome Mouneyrac added a comment - 16/Jan/09 05:32 PM
Hi, here is a update about last days web service implementation:

Many stuff still need to be implemented before to reach a "stable" API:

  • access control (with token, session)
  • SOAP: call the generator automatically and only when necessary, manage token with SOAP
  • ful test of client/server for the user basics functions (optional parameters need to be tested, core functions reviews)
  • implement an entire module core api and ws functions, as the forum.
  • need to implement a third web service protocol
    ...

At this moment Petr will be working on access control and some core functions, Ludo team's soon on module forum web services, and I on SOAP, the full test and others stuff. I'll organize a talk between all of us.


Patrick Pollet added a comment - 16/Jan/09 06:52 PM
Hello Jerome,

I noticed that since few days, updates to /webservice directory and /lib/moodlewsapi.php and all
*/api.php and µ:wsapi.php are not anymore mirrored to the european mirrors (with anonymous login) I use to use for automatic nightly checkouts of latest updates.

I have to use my cvs account on cvs.moodle.org to retrieve your work on web services and thus I have to do it manually every morning to keep the pace ... Surprisingly these updates are nevertheless available by anonymous http access on http://cvs.moodle.org .

Is this intentional ?

I am glad to learn that a wsdl generator is in progress, since in my SOAP implementation I have a wsdl2php.php script that generates php client classes "a la" java or python.

Cheers.


Jerome Mouneyrac added a comment - 19/Jan/09 12:09 PM
Patrick, all mirrors should be a complete copy of the main repository. I've been told there were some problems on some european servers last week. There could also be some delay for the copy (in hours).
It should work but if it happens again, I'll alert our new sys admin.

Brian King: I'm sending an email to you, sorry for this late answer.


Thomas Bachert added a comment - 29/Jan/09 11:52 PM
Will any of these fix the pull/push of quiz grades into the gradebook for 1.9.2? Please refer to http://tracker.moodle.org/browse/MDL-18032

Petr Skoda added a comment - 30/Jan/09 12:36 AM
Thomas please do not post unrelated questions in other bugs. Tim already told you that your problem is not a moodle bug.

Jordi Piguillem Poch added a comment - 05/Feb/09 11:33 PM
Groups are nearly finished, we are going to start with course functions.

Jerome Mouneyrac added a comment - 16/Feb/09 01:48 PM
Hi all,
I wrote a document about the current web service implementation: http://docs.moodle.org/en/Development_talk:Web_services#Design_state_at_the_16_Feb_2009
I explain some interrogation I've got about the design, the use of zend component... I invite you to read it and express your opinion

Jerome Mouneyrac added a comment - 18/Feb/09 02:47 PM
For people who didn't read the previous link, here is situation:

Web Service API design: I think it's good, we should keep the description array as it's easy to understand by developers. The only thing still needed to be defined is: how to we define an array/object parameter? It could be good to support it if we want to support multiple operations at the same time: delete_users(id1, id2, id3,...)).
I said it "could be" because at this moment no servers in HEAD need the description array for this kind of web service function. The current SOAP/XMLRPC servers support this kind of function but use phpdoc. And I'm not sure that a RESTful server would support this kind of function.

REST protocol: I don't know yet how RESTful protocol support multiple operations. Moreover for implementing a real RESTful server we would need to improve the description array (web service API need to know if the web service function is GET/POST/PUT/DELETE).

SOAP protocol: I like the zend_soap server (and zend WSDL generator) in HEAD. With an accurate documentation generator, it should be easy to create a client.
I think we should remove the PHP soap client/server that I created, as well as the WSDL generator.

XMLRPC protocol: same as SOAP

AMF: I need to have a better look, for later.

As usual any comments are welcome, I'm most that listening for advices on the REST protocol and also the support of array in the description (web service API design)

Thanks


Jerome Mouneyrac added a comment - 18/Feb/09 04:52 PM
I talked with Martin and we should be able to get rid of the description array and have all the same information into the phpdoc. I'll come back soon to you with a solution for all the mentioned points (web service description + RESTful server). Sorry for the noise

Ralf Hilgenstock added a comment - 20/Feb/09 04:03 AM
I've seen the documentation.php file. I'm wondering how this file is integrated in the Moodle language system.

Jerome Mouneyrac added a comment - 20/Feb/09 09:57 AM
Hi Ralf, I think we need a webservices.php file in the lang folder. I'll add lang support to the documentation.php.

Jerome Mouneyrac added a comment - 24/Feb/09 02:27 PM
Hi I committed the new web services API design. It now use only the phpdoc. We generate the description array from these phpdoc now.

Here it how we need to write the phpdoc:

  • @param array|struct $params - no change to this line
  • @subparam string $params:student->name - student name

':' colon character indicates that the left word is considered as a non associative array
'->' arrow indicates that the left word is an object/associative array

However when we generate the description array, the non associative arrays are translated by associative arrays with all key starting by 'multiple:'. For example the description array for the above phpdoc would be:
description['functionname'] = array('params' => array('multiple:student' => array('name' => string)))

I'll update the Moodledocs with more information.


Jerome Mouneyrac added a comment - 25/Feb/09 11:46 AM
Web service task list

------------------------------------------
To be done for 2.0 release
------------------------------------------

  • write all external API file (+ add clean_parameter())
  • implement the token generation/checking with Moodle 2.0 Session into webservice/lib.php

-------------------------------------------
Under decision
------------------------------------------

  • our REST sever is not RESTful and use POST parameters. After discussion with Martin, it could be good to use only GET params for the "REST" server. However if many of you wanna a RESTful server it could be implemented. We would need to add an annotation to all function phpdoc (example: @httpmethod GET, @httpmethod PUT, @httpmethod POST, @httpmethod DELETE)

------------------------------------------
Optional
------------------------------------------

  • implement AMF server => generate PHP value object class from the phpdoc (use @subparam and @subreturn annotations)

Jordi Piguillem Poch added a comment - 03/Mar/09 08:31 PM
Hi Jerome,

Soap is not working.... there are some problems with the token.
I'm always geting 2147483647 (the bigest integer) instead of the hardcoded 465465465468468464.

The token must be a lower int value or a string.

Pigui.


Jerome Mouneyrac added a comment - 04/Mar/09 12:21 PM
Thanks Jordi, I fixed the mock token. (I'm using Ubuntu 64 ;o)