Playr:ApiDocs
From QTITools Wiki
[edit] Introduction
ASDEL playr has a simple, easy-to-use web-based api that you can use to integrate it with your application. The api is somewhat REST-like. The following text describes the methods made available by the playr api interface. See Playr:ApiExamples for practical implementation examples.
[edit] Description of usage
To start, you need to open a session with the webapp. Beware, that this session will expire after 30 minutes of inactivity by default. To get the session, perform a GET request for http://playr_server:playr_port/path_to_playr/api/newSession. The session key is in the response body. You need to save this somewhere (i.e. in your applications session).
The session can then be initialised by sending a multipart POST request (must be proper multipart atm) to http://playr_server:playr_port/path_to_playr/api/init;jsessionid=the_session_id with the fields "view" and "renderer" set to correct values, and a file attachment containing the test content package. The init response will contain the first page of the test renderered using the respective renderer as its body. (Note: if your HTTP client supports cookies, the jsessionid bit of the urls shouldn't be required).
Subsequent interactions with the server should be handled by POSTing (regular, not multipart) the responses from the rendered page back to the server at the url: http://playr_server:playr_port/path_to_playr/api/play;jsessionid=the_session_id. The response to these requests will be the next rendered page.
The current qti report can be accessed at anytime during a valid, initialised, session by GETting http://playr_server:playr_port/path_to_playr/api/report;jsessionid=the_session_id
The web-service api also supports more advanced introspection capabilities for interrogating the controller and JQTI objects for the current session. The introspection api can be accessed from http://playr_server:playr_port/path_to_playr/api/introspect/path/to/object;jsessionid=the_session_id. Where /path/to/object is the path from the PlayrCoordinator object to the object you want to inspect. By default, the body of these requests will return the printed value of the object (how it is printed depends on the particular object's toString() method). As an example, the following will get the finished status of the test represented by the_session_id: http://playr_server:playr_port/path_to_playr/api/introspect/isCompleted;jsessionid=the_session_id
It is possible to browse the object tree by appending a ?list query to the end of the introspection url. This will give you a list of possible fields and methods you can inspect from the current object. The introspection api does attempt to limit the methods you can use to those which should not affect the internal state of JQTI (in particular only 'getter' methods are allowed; those which return something and have no arguments).

