Pearson
Always Learning

Posted by Wes | about 2 years ago

We are demystifying the Experience API for ourselves and anyone else that wants to follow along. We have covered terminology and Activity Providers. This article will focus on retrieving xAPI Statements from a LRS.

Background

We have been on a journey to understand the Experience API. We previously explored the following:

Statement Viewer

The Golf Example from TinCanAPI.com uses a public LRS for demo purposes. There is also a Statement Viewer prototype for viewing the statements from the public LRS. This statement viewer allows us to see how API query statements are assembled. We can retrieve the raw data by pasting that URL into the browser.

The browser prompts us with a dialog for username and password. We can use the same credentials (TestUser/password) that were passed to the Activity Provider. The browser will send these credentials in basic authentication format to the LRS. The browser responds by displaying JSON from the server without any formatting. That’s the same result a computer program would receive.

The Statement Viewer prototype allows us to customize the query. Some customizations are included in the headers of the request:

Prototype Parameter Prototype Value Header Name Header Value
Version 1.0.0 X-Experience-API-Version 1.0.0

The other customizations are passed as query string parameters in the URL:

Prototype Parameter Prototype Value Query String Name Query String Value
Agent Value test@beta.projecttincan.com agent URL Encoded

{
  "objectType":"Agent",
  "mbox":"mailto:test@beta.projecttincan.com"
}
Verb ID experienced verb URL Encoded http://adlnet.gov/expapi/verbs/experienced
Activity URL http://id.tincanapi.com/activity/tincan-prototypes/golf-example/Playing/Playing activity URL Encoded http://id.tincanapi.com/activity/tincan-prototypes/golf-example/Playing/Playing

Query Parameters

An xAPI query can be executed as a GET request from a REST client (Try Postman) with the following:

Headers

Authorization:  Basic%20VGVzdFVzZXI6cGFzc3dvcmQ%3D
X-Experience-API-Version: 1.0.0

URL

http://cloud.scorm.com/ScormEngineInterface/TCAPI/public/statements?
agent=%7B%22objectType%22%3A%22Agent%22%2C%22mbox%22%3A%22mailto%3Atest%40beta.projecttincan.com%22%7D
&verb=http%3A%2F%2Fadlnet.gov%2Fexpapi%2Fverbs%2Fexperienced
&activity=http%3A%2F%2Fid.tincanapi.com%2Factivity%2Ftincan-prototypes%2Fgolf-example%2FPlaying%2FPlaying
&limit=25&related_activities=false&related_agents=false

This query will result in many records, because this user is the default for the prototypes. Launching the activities with a less common user would result in a simpler response:

{
    "statements": [
        {
            "id": "f0dbd454-470f-4d8d-8fc3-6b01e30b2bc0",
            "actor": {
                "name": "Test User Jr",
                "mbox": "mailto:testjr@beta.projecttincan.com",
                "objectType": "Agent"
            },
            "verb": {
                "id": "http://adlnet.gov/expapi/verbs/experienced",
                "display": {
                    "en-US": "experienced"
                }
            },
            "context": {
                "registration": "e168d6a3-46b2-4233-82e7-66b73a179727",
                "contextActivities": {
                    "grouping": [
                        {
                            "id": "http://id.tincanapi.com/activity/tincan-prototypes/golf-example",
                            "objectType": "Activity"
                        },
                        {
                            "id": "http://id.tincanapi.com/activity/tincan-prototypes",
                            "objectType": "Activity"
                        }
                    ],
                    "category": [
                        {
                            "id": "http://id.tincanapi.com/recipe/tincan-prototypes/golf/1",
                            "definition": {
                                "type": "http://id.tincanapi.com/activitytype/recipe"
                            },
                            "objectType": "Activity"
                        },
                        {
                            "id": "http://id.tincanapi.com/activity/tincan-prototypes/elearning",
                            "definition": {
                                "name": {
                                    "en-US": "E-learning course"
                                },
                                "description": {
                                    "en-US": "An e-learning course built using the golf prototype framework."
                                },
                                "type": "http://id.tincanapi.com/activitytype/source"
                            },
                            "objectType": "Activity"
                        }
                    ],
                    "parent": [
                        {
                            "id": "http://id.tincanapi.com/activity/tincan-prototypes/golf-example",
                            "objectType": "Activity"
                        }
                    ]
                }
            },
            "timestamp": "2015-06-19T16:44:40.286Z",
            "stored": "2015-06-19T16:44:41.124Z",
            "authority": {
                "account": {
                    "homePage": "http://cloud.scorm.com/",
                    "name": "anonymous"
                },
                "objectType": "Agent"
            },
            "version": "1.0.0",
            "object": {
                "id": "http://id.tincanapi.com/activity/tincan-prototypes/golf-example/Playing/Playing",
                "definition": {
                    "name": {
                        "en-US": "Playing Golf"
                    },
                    "description": {
                        "en-US": "An overview of the game of golf."
                    },
                    "type": "http://activitystrea.ms/schema/1.0/page"
                },
                "objectType": "Activity"
            }
        }
    ]
}

What's next?

Awesome! Now we understand how a LRS becomes known to an Activity Provider and how to retrieve learning activities from a LRS. This leaves us with understanding how the statements are recorded in the LRS. Keep following along as we explore this in the next article of this series.

Feel free to jump ahead to other articles in this series:

Also, definitely check out TinCanAPI.com and ADLNet.gov's xAPI standard for more in-depth details. We are just scratching the surface with this whirlwind tour, and those resources were our reference. We would like to give credit and a BIG THANKS to the maintainers of both!

Tags: 
xAPI
Rating: 

Average: 5 (1 vote)

12232 reads
Always Learning
Pearson