The longer version

TinCan.Statement

The events generated by JoinSession and CompleteSession are defined by how the module interacts with Apex, and require minimal customization. The information in the events sent by SendSessionEvent, on the other hand, are defined by what is happening inside the module itself and the construction of the data report needs to be much more open.

There is a short primer on xAPI in this documentation, which should provide some context for the rest of this section. If you want to dig deeper, there are much more comprehensive explanations out there you can find, including the official xAPI specification.

TinCan.Statement is a data structure compatible with the current xAPI standard.

Constructor

TinCanStatement only has a default constructor:

TinCan.Statement eventStatement = new TinCan.Statement();

Relevant Members

Set manually

The following properties are available for you to set yourself. Verb and target(ie object) are required to create a valid xAPI statement, while result and context are available should you wish to use them.

Required

  • verb: The action the user took

  • target: The object of the action

Optional

  • result: Data relating to the result of the action taken

  • context: Data that helps describe the conditions surrounding the action, both in game and at a system level.

    • context.registration, context.platform, and context.revision are set automatically.

    • context.revision is set to equal the ApexSystem variable "ModuleVersion".

Set Automatically

You will see the following properties show up on the Apex report, but you should not set them yourself- they are always the same, and will be set for you by the SDK:

  • actor: Set to the logged in user.

  • timestamp: records the time the event happened. Uses the headset system clock, and is set to UTC.

  • version: The version of of the xAPI spec being used. Currently 1.03.

Example Code

If you look at the TinCan API documentation you will find that there is a lot of possible data that you could include in a TinCan Statement, To help simplify things a little, you will find below some example code that includes the data that we feel is most relevant to the Apex System and should cover most of your needs. You are of course welcome to include any additional properties you would like in your report, and if you have any questions about how to do so, or about best practices feel free to contact us.

inCan.Statement eventStatement = new TinCan.Statement();
// Verb
eventStatement.verb = new TinCan.Verb();
eventStatement.verb.id = new Uri("https://pixovr.com/xapi/verbs/reported");
eventStatement.verb.display = new TinCan.LanguageMap();
eventStatement.verb.display.Add("en","Reported");
eventStatement.verb.display.Add("es","Reportado");

//Object
//Note: Activity is one of four ObjectTypes, but the one that 99% of statements on
//Apex should use.
//Note the TinCan API calls Objects "Targets"
TinCan.Activity eventActivity = new TinCan.Activity();
eventActivity.id = "https://pixovr.com/xapi/currentmodule/exampleObject";
eventStatement.target = eventActivity;

//Result
eventStatement.result = new TinCan.Result();
eventStatement.result.completion = true; //did they complete the event
eventStatement.result.success = true; //did they get a passing score or otherwise succeed at the event
eventStatement.result.duration = TimeSpan.FromSeconds(15);//how long did they spend on the event
eventStatement.result.response = "answer"; //how they answered a question, or otherwise responded
eventStatement.result.score = new TinCan.Score();
eventStatement.result.score.max = 100;
eventStatement.result.score.min = 0;
eventStatement.result.score.raw = 80;
eventStatement.result.score.scaled = 0.8;

//Context
eventStatement.context = new TinCan.Context(); 
Extension contextExtension = new Extension();
contextExtension.Add("https://www.pixovr.com/xapi/extensions/iri_extension","value");
contextExtension.AddSimple("simple_key", "value");
eventStatement.context.extensions = new TinCan.Extensions(contextExtension.ToJObject());

ApexSystem.SendSessionEvent(eventStatement);

Example Data

This is the data that appears on Apex using the above code.

id: aac695bc-2d63-404e-bca1-c7e115f1bdb6
verb: {
    "id":"https://pixovr.com/xapi/verbs/reported",
    "display":{
        "en":"Reported",
        "es":"Reportado"
    }
}
actor: {
    "mbox":"test@pixodev.com",
    "objectType":"Agent"
}
object: {
    "id":"https://pixovr.com/xapi/currentmodule/exampleObject",
    "objectType":"Activity"
}
result: {
    "score":{
        "max":100,
        "min":0,
        "raw":80,
        "scaled":0.8
    },
    "success":true,
    "duration":"PT15S",
    "response":"answer",
    "completion":true
}
context: {
    "platform":"OSXEditor",
    "revision":"1.00.00",
    "extensions":{
        "https://pixovr.com/xapi/extension/simple_key":"value",
        "https://www.pixovr.com/xapi/extensions/iri_extension":"value"
    },
    "registration":"5f683729-c787-41ed-9e69-c07f03458ab7"
}
version: 1.0.3
timestamp: 2022-07-15T14:16:39.2839650Z

Last updated