1.x.x |
Documentation for the Unreal C++ Plugin
|
There are 3 functions used for manipulating session and data reporting:
All events used for when these functions are called are the same for when calling Authentication functionality. To see how to use the events, see Handling Authentication API Responses in the Authentication page.
All of the above functions are accessible in Blueprint, but due to the need to support optional values in the xAPI Spec, there is a limitation of what values can be set via Blueprints in the xAPI structures. If you cannot find a value in Blueprint that you need to fill out, know that you will need to accomplish this with C++.
A session is one complete play-through of single scenario. Different modules handle this in different ways, but the main idea is that a session should be the scenario itself, not the process of selecting an experience.
Some modules have a lobby that a user loads into after authentication and return to after running through a scenario. Time in the lobby should not count towards any session- the session begins when you choose an experience from the lobby, and the session ends when you finish the experience, either by completing it, or using a menu option to return to the lobby.
Other modules just have a front end menu, but the concept is the same- the session begins once you have selected the experience from the menu.
Every time a user enters a scenario, (whether directly from the login screen, from a lobby, from a front-end menu, or from any other system you have set up), you need to call UApexAPI::JoinSession(). Similarly, once they have finished a scenario you need to call UApexAPI::CompleteSession().
The UApexAPI::JoinSession() function should be called every time the user starts a new session.
FALSE
if there is no logged in user. Otherwise returns TRUE
.EApexRequestType::JoinSession
is called when the user was able to join the session successfully.EApexRequestType::JoinSession
is called when the user was not able to join the session or when the server is not able to be reached.The UApexAPI::JoinSession() has 2 optional parameters:
InScenarioId:FString
- Sets the UApexAPI::ScenarioId, which is then used as part of the id
property of the object
object. If this is not set, then whatever the UApexAPI::ScenarioId was previously set to will be used.InContextExtension:FXAPIExtension
- Allows you to include any custom extensions in the context object. This is used to include any additional information you want to report that is not in the standard JoinSession() report. See Extensions for more details.The UApexAPI::CompleteSession() function should be called every time the user completes a session.
It:
FALSE
if there is no logged in user or current session.EApexRequestType::CompleteSession
is called when the session was completed successfully.EApexRequestType::CompleteSession
is called when the session was not started, unable to be completed otherwise or when the server is not able to be reached.The UApexAPI::CompleteSession() function has 1 required parameter:
InSessionData:FSessionData
- Use this parameter to pass the basic data that Apex uses to complete the reporting dashboard for finished sessions. Failure to include any of this data will result in the dashboard displaying the session report as being "incomplete". More information can be found in the SessionData section of this page.FSessionData is a custom strcutre that stores end of session data, as well as content and result extension data.
The FSessionData is used for two purposes, both of which are automatic but are explained here for completeness. First, many of the required properties of the Result
object in the generated xAPI statement get populated with data from the FSessionData. Secondly, it is used to populate both the Result.Extension
and Context.Extension
within the FXAPIStatement
.
The Example Data below demonstrates how this additional top level data is included.
The following members are defined for FSessionData:
Complete:bool
TRUE
indicates the user made it all the way through to an expected completion point. FALSE
indicates they quit early, usually through a menu option to quit or return to lobby.Success:bool
TRUE
indicates they achieved a high enough score or otherwise performed the necessary tasks to pass the module. FALSE
indicates they did not.Score:float
The final score the user achieved on the module.ScoreScaled:float
Usually the "score" value divided by the "max" value. The value can range from -1 to 1.ScoreMin:float
The lowest possible score in the module (often 0, but it depends on the nature of your module).ScoreMax:float
The highest possible score a user could achieve in your moduleDuration:int
How long, in seconds, the session lasted.AdditionalContextData:FXAPIExtension
An extension to the Context
part of the xAPI Statement.AdditionalResultData:FXAPIExtension
An extension to the Result
part of the xAPI Statement.
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data") bool Complete; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data") bool Success; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data") float Score; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data") float ScoreScaled; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data") float ScoreMin; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data") float ScoreMax; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data") int Duration;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data") FXAPIExtension AdditionalContextData; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data") FXAPIExtension AdditionalResultData;
The UApexAPI::SendSessionEvent() function is how you send any data to Apex during a session.
It:
FALSE
if there is no logged in user, if UApexAPI::JoinSession() has not been called to start a session, if the InStatement.Actor
has had any data filled or if any of the following members in InStatement
have not been set.InStatement.Verb
InStatement.Verb.ID
InStatement.Target
EApexRequestType::SessionEvent
is called when the user was able to join the session successfully.EApexRequestType::SessionEvent
is called when the user was not able to join the session or when the server is not able to be reached.The UApexAPI::SendSessionEvent() function has 1 required parameter:
InStatement:FXAPIStatement
The object that provides all the necessary data to generate the xAPI statement.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.
Verb
: The action the user tookTarget
: The object of the actionResult
: Data relating to the result of the action takenContext
: 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 UApexAPI::ModuleVersion.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.There are a lot of possible ways to build an xAPI statement, with a LOT of potential information you could include. This flexibility is valuable if you have complex data you need to track. But sometimes, maybe even most of the time, all you need is something simple.
All an xAPI statement truly requires is an Actor, a Verb and an Object (which the Apex SDK refers to as a "Target"). The SendSessionEvent function will add the Actor information (i.e. the logged in user) to the passed InStatement
, so all you need to provide is a verb and an object, and their associated IDs.
The following code demonstrates how to do this:
There are a few things to note:
object
keyword. Any data you add to the EventStatement.Target
property will show up as an Object
property in the PixoVR Platform.Objects
(Targets) can be one of several types, but Activity
is by far the most common type. Refer to the official xAPI spec for more information about the other types.Verb.ID
and EventActivity.ID
need to be an IRI formatted FString.Now, if the simple version is not enough for your use case, below we've provided a more detailed example 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.
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:
Score
is already available in the result object, and you could track the distance thrown in a result extension.Actor
, Context
, Object
, 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, you declare a new FXAPIExtension:
Then you can either use the Add() or AddCustom() functions to add as many key/value pairs to the Extension object as you want. These non-type specific functions require a TSharedPtr<FJsonValue>
.
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.
FString
.int
.bool
.