xAPI Statement 101: Context Element

22 June 2016 by Ryan Smith

Having looked at the ActorVerbObject and Result elements of an xAPI statement, we now turn our attention to the Context – not of the Object, but context of the statement as a whole.

Understanding The Context Element of an xAPI Statement

The context consists of 9 elements that are all optional.

  • Registration– a enrollment ID
  • Instructor– the person who created the content
  • Team– the group that you are a part of
  • Context Activities
    • Parent – e.g. nested activities (a level is part of a course)
    • Grouping – e.g. a course is part of a qualification
    • Category – e.g. a tag, e.g. xAPI course, that helps you group things together
    • Other – anything else
  • Revision– the revision of the activity or if there has been a previous version of the activity
  • Platform– where it happened – e.g. Stream LXP (formerly Curatr), Moodle
  • Language– what language it happened in
  • Statement– reference to another statement that is contextually relevant (NOT the Object Statement)
  • Extensions– Not the Result or Object definition, this is more holistic to the whole activity

An Example Context Statement Summary

A complete Context statement that includes all elements may look something like this:

{

“actor”: {

“objectType”: “Agent”,

“name”: “John Smith”,

“account”: {

“name”: “123”,

“homePage”: “https://www.example.com/users/”

}

},

“verb”: {

“id”: “https://adlnet.gov/expapi/verbs/completed”,

“display”: {

“en-GB”: “completed”

}

},

“object”: {

“objectType”: “Activity”,

“id”: “https://www.example.com/activities/1”

},

“context”: {

“registration”: “957f56b7-1d34-4b01-9408-3ffeb2053b28”,

“instructor”: {

“objectType”: “Agent”,

“name”: “Joe Bloggs”

“account”: {

“name”: “321”,

“homePage”: “https://www.example.com/users/”

}

},

“team”: {

“objectType”: “Group”,

“name”: “HT2”,

“account”: {

“name”: “123”,

“homePage”: “https://www.example.com/groups/”

}

},

“contextActivities”: {

“parent”: [{

“objectType”: “Activity”,

“id”: “https://www.example.com/activities/parent”

}],

“grouping”: [{

“objectType”: “Activity”,

“id”: “https://www.example.com/activities/grouping”

}],

“category”: [{

“objectType”: “Activity”,

“id”: “https://www.example.com/activities/category”

}],

“other”: [{

“objectType”: “Activity”,

“id”: “https://www.example.com/activities/other”

}]

},

“revision”: “1.0.0”,

“platform”: “Example”,

“language”: “en-GB”,

“statement”: {

“objectType”: “StatementRef”,

“id”: “957f56b7-1d34-4b01-9408-3ffeb2053b28”

},

“extensions”: {

“https://www.example.com/ext”: true

}

}

}

As you can tell, if you include all of this data in your statement then it’s starting to get pretty long – but if you’re looking at really getting the most from your data, then there is one further element that we’ll look at in our final post on our 101 Series: xAPI Statements: Going Beyond the Basics.

For more practical tips and advice about the xAPI, download our Technology Managers Guide to xAPI

blank
Ryan Smith
Software Development Team Lead

Starting as a placement student in 2014, Ryan re-joined the Learning Locker team after graduating from Oxford Brookes University where he won the John Birch prize for the highest grade average in the University.

From his minimalist desk, Ryan leads the Learning Locker team and consults with people on all things xAPI to conscientiously craft products and services that sustain and evolve training and performance.

When he’s not swimming or injuring himself on the cricket field, Ryan enjoys playing funny (and usually inappropriate) games with his family.

View more from Ryan Smith
blank
Read more about Learning Pool
Visit our Learn and Connect section

Get a free demo

Get in touch to find out how we can help

Start your learning journey

Get started by telling us what you need and one of our team will be in touch very soon.