Probably the most common and problematic mistake that we see with xAPI implementations is getting the Activity ID wrong. There are three main ways people get the Activity ID wrong:
- The format of the ID
- Using multiple IDs where a single ID should be used
- Using a single ID where multiple IDs should be used.
We can group those last two together as getting the uniqueness of the ID wrong. This example-packed guide is intended to help you get the Activity ID right.
Related: What is an Activity ID?
Format
The format of the Activity ID should follow the following rules:
- The Activity ID should be a web address, starting with http:// or https://
- That web address should be within a website controlled by the organization creating or commissioning the content, whether that’s an organization or a content vendor.
- You don’t have to host anything at this address, it doesn't need to be the address where the content is hosted; the point is to make sure the ID is universally unique.
- The Activity ID should be something meaningful when you read it, making it easier for you to identify the activity from the ID.
So, this is an example of a good Activity ID:
https://watershedlrs.com/xapi/activities/get-the-activity-right-10142015
This Activity ID is at a domain we control and it’s clear for a developer to see exactly which activity it relates to. The date on the end allows us to distinguish between different versions of the activity.
Here’s some examples of technically valid, but practically bad Activity IDs:
https://watershed.com/xapi/activities/get-the-activity-right-10142015
This is bad because we don’t control watershed.com and there’s a risk that another learning record provider could use the same ID.
http://10142015_courseid/
This is bad because we don’t control the domain 10142015_courseid and there’s therefore a small risk that another learning record provider could use the same ID. Also the ID is not at all descriptive.
https://watershedlrs.com/xapi/activities/10142015
This is bad because I can’t tell from the ID what the activity is.
https://watershed.com/xapi/activities/Get-The-Activity-Right-10142015
This is ok, so long as you always use the same capitalization. If you use different capitalization then the Learning Record Store will treat it as a completely different ID. To avoid confusion and errors, we recommend always using lowercase.
https://watershedlrs.com/xapi/activities/that's the way to do it 10142015
This is bad because it includes spaces and an apostrophe. Don't include any spaces or special characters in your activity ids.
Uniqueness
The Activity ID should be unique from the ID used by other activities but should be the same every time that activity is referenced. This sounds simple, but it’s a really common issue with xAPI implementations. Let’s look at a number of different scenarios and the reasons why the Activity ID should be the same or different.
A learner launches an e-learning course. Later another learner launches the same course.
Same: the same course is being launched so the Activity ID should be the same.
A learner takes 2 attempts at a learning game.
Same: use the context.registration property to distinguish between attempts.
A learner adds a competency to their profile. Then they add a different competency.
Different: each competency should have a unique ID.
The same PDF file is launched from different sections on an intranet.
Same: it’s the same PDF being used each time.
A learner answers a quiz question where the quiz is the parent context activity. They pass the quiz.
Same: when the quiz is used as a context activity the same ID should be used.
Different: the quiz and the question have different Activity IDs.
A learner tweets a tweet. Then they tweet another tweet.
Different: each tweet should have a unique ID.