Immerse SDK
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Sending Statements

Once you have created a Report Hierarchy, sending statements is simple as activities are implemented as ScriptableObjects that can be referenced in an Action Reporter, Completion Reporter or your own custom scripts.

Sending statements to the Immerse platform requires Platform Services package v1.7.1 or newer.

Completion

Once an activity is completed, a completion statement should be sent. For a more component based approach, see the Completion Reporter page.

Method Description
void Complete(bool success) Sends a completion statement for the activity with the provided success value.
void Complete(Result result) Sends a completion statement for the activity with the provided result object.

Result

A result object can be attached to a completion statement, this is used to describe how well a user did during the activity.
Each of the fields listed below are optional values that can be attached to the result object, any configuration can be used, as per the xAPI specification.
The Result struct can also be serialized to show it as a configurable object on a component in the inspector.

Field Description
Completion If the event was completed
Success If the event was successful
Duration How long the event took
Score Score data for the event
Response Response/comment for the event

Score

A score can be attached to a Result. This object follows the xAPI standard which provides a lot of flexibility in the data you record. Again, all fields are optional.

Field Description
Scaled Scaled score (0 - 1)
Raw Raw value for the score
Min Minimum score (relates to raw value)
Max Maximum score (relates to raw value)

Actions

Actions can be attached to any activity in your session. These are intended to capture any additional, smaller actions that the user takes during the session that do not require completion tracking and therefore require less information.

Method Description
void ReportAction(IVerb verb, string subject) Reports an action against the activity with the provided verb
void ReportAction(IVerb verb, string subject, string response) Reports an action against the activity with the provided verb and includes a response string.

Below is a very basic MonoBehaviour example that will report an action against the attached Activity with the the Attached verb, using the game object’s name as the subject string.

using ImmerseSDK.Reporting.Structure;
using ImmerseSDK.Reporting.Structure.Verbs;
using UnityEngine;

public class ActionExample : MonoBehaviour
{
    public Activity Activity;
    public VerbObject Verb;
    
    private void Start()
    {
        Activity.ReportAction(Verb, gameObject.name);
    }
}

Here is another code example demonstrating how to create result and score objects and include them in a statement.

using ImmerseSDK.Reporting;
using ImmerseSDK.Reporting.Statements;
using ImmerseSDK.Reporting.Structure;
using ImmerseSDK.Reporting.Structure.Verbs;
using UnityEngine;

public class ActionExample : MonoBehaviour
{
    public Activity Activity;
    public VerbObject Verb;
    
    /// <summary>
    /// Report an action on Start for this gameObject
    /// </summary>
    private void Start()
    {
        Activity.ReportAction(Verb, gameObject.name);
    }

    /// <summary>
    /// Record a score without reporting completion or success
    /// </summary>
    /// <param name="scaledScore">The scaled score to report</param>
    /// <param name="question">A reference for the score</param>
    private void RecordScore(int scaledScore, string question)
    {
        var score = new Score
        {
            Scaled = scaledScore
        };
        
        var result = new Result
        {
            Score = score,
            Response = question
        };
        
        Activity.ReportActivity(result);
    }
    
    /// <summary>
    /// Complete the Activity with an overall score and response
    /// </summary>
    /// <param name="score">The overall score</param>
    private void CompleteWithSuccess(Score score)
    {
        var result = new Result
        {
            Completion = true,
            Success = true,
            Score = score,
        };

        Activity.ReportActivity(result);
    }
}