Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Statement Metadata API HTTP Interface

The routes table below describes the methods that the Statement Metadata HTTP interface provides. Both routes require that you specify an _id from the statement record, in order to determine to which statement the metadata should be added. This can be found be found by performing a GET request on the statement model.

Code Block
POST http://www.example.org/api/v2/statementmetadata/:id

...

The JSON body of these methods is a key-value pair such as the following. Some examples of where we currently add metadata can be found on question statements coming from Adapt.

Code Block
{
  "https://learninglocker.net/true-false-response": "Yes"
}

...

Name | Description --- | --- | --- _id | The unique id of the Statement metadata | An object containing key-value pairs, where the key is an IRI representing the metadata field with requirements defined by the xAPI specification and the value can be of any type.

Routes

Method

Description

PATCH /:id

Patches a model.

POST /:id

Creates or overwrites a model.

...

Please note: It is preferable to use PATCH where possible to prevent overwriting metadata set by Learning Locker that is required for certain parts of the UI to work.

...

To get the statement _id for the route above, we can perform a GET request on statements via the REST API.

If you haven't already inserted your statements, they can be added via the xAPI Statements HTTP Interface, for example:

Code Block
POST http://www.example.org/data/xAPI/statements
Authorization: YOUR_BASIC_AUTH
X-Experience-API-Version: 1.0.3
Content-Type: application/json; charset=utf-8

{
  "actor": { "mbox": "mailto:test1@example.org" },
  "verb": { "id": "http://www.example.org/verb" },
  "object": { "id": "http://www.example.org/activity" }
}

...

Then, we can use this statement identifier from the response to query the statement model (detailed documentation can be found on the HTTP REST page), in order to retrieve the _id which is used in the statement metadata routes. We can use URL query parameters to get the statement with the specified statement identifier, then return the statement identifier with the _id, which is returned by default.

...

This _id is then used to add statement metadata via the PATCH and POST routes.