Events API Methods
on()
Set up an event listener for the Events API instance.
You would want to use this method so that you can process the user events and take custom actions in your application when certain defined events occur.
Examples
var events = [
{
kind: '...',
user_id: '...',
activity_id: '...'
},
{
kind: '...',
user_id: '...'
}
];
function eventCallback(events) {
console.log(events);
/* Example:
[
{
"id": "ac478bc1-2e0e-44c1-a19c-6cb065f06bad",
"timestamp": "2014-10-08T00:51:28.808Z",
"actor": {
"account": {
"homePage": "yis0TYCu7U9V4o7M",
"name": "learner001"
},
"objectType": "Agent"
},
"verb": {
"id": "http://adlnet.gov/expapi/verbs/progressed",
"display": {
"en-US": "progressed"
}
},
"object": {
"id": "https://xapi.learnosity.com/activities/org/1/pool/null/activity/demoactivity",
"definition": {
"extensions": {
"data": 1
}
},
"objectType": "Activity"
}
}
]
*/
};
eventsApp.on(events, eventCallback);
Arguments
-
events array[object]
An array of objects describing the events to subscribe to.
-
kind string
The type of event to subscribe to.
Possible values
"assess_logging"
"assess_control"
-
user_id string
The specific user ID to include.
-
activity_id string
Only include events that contain this specific Activity ID.
-
-
eventCallback function
Callback function that will be triggered whenever the respective events are fired.
Return value
None (undefined
).