You are using an unsupported browser. Please update your browser to the latest version on or before July 31, 2020.
close
You are viewing the article in preview mode. It is not live at the moment.
Extensions
print icon

Extensions are a way to include additional information in a particular xAPI object that is not part of the standard properties of that object.

 

For Example:

  • If your module had a difficulty setting, you could track which setting a user had chosen in a context extension.
  • In a javelin throwing simulation, you might would want to track both distance thrown as well as an assigned point score. "Score" is already available in the result object, and you could track the distance thrown in a result extension.

Actor, ContextObject, and Result objects can all support extensions. Regardless of which object type you are adding them to, they are handled in the same way.

 

First, create a new Extension object:

FXAPIExtension SampleExtension; 

 

Then you can either use the add() or addSimple() functions to add as many key/value pairs to the Extension object as you want. These non-type specific functions require a TSharedPtr<FJsonValue>.

  • Add() — the Add() enforces the requirement that an extension key be an IRI and allows you to use an FString as your key

  • AddCustom() — the AddCustom() function requires the key to be an IRI, which conforms to the xAPI spec

There are also type specific functions for adding, both with a Add and AddCustom version. Any function with AddCustom in the name requires the key to be an IRI.

Example Code

FXAPIExtension SampleExtension;
SampleExtension.AddCustomString("https://www.pixovr.com/xapi/extensions/iri_extension","value");
SampleExtension.AddString("simple_key", "value");

Previous Article: SendSessionEvent() Function

Feedback
0 out of 0 found this helpful

scroll to top icon