xApiStatement Class Reference

Using the methods listed below, you can create complex xAPI statements. The class also provides a valuation method, as well as synchronous and asynchronous send methods.

Statement partStatement fieldMethod nameParametersDescription
Actoractor.namexapiActor.setName(String name)
actor.accountxapiActor.setAccount(String name, String homePage)Only one of these identifiers can be set in a statement. Each method will clear out any other actor identifiers when called to ensure this XAPI requirement is met.
actor.mboxxapiActor.setMbox(String mbox)
actor.mbox_sha1sumxapiActor.setMboxSha1Sum(String mbox_sha1sum)
actor.openidxapiActor.setOpenId(String openid)
Verbverb.idxapiVerb.setId(String id)
verb.displayxapiVerb.setDisplay(String text)
Objectobject.idxapiObject.setId(String id)
object.definition.namexapiObject.setName(String text)
object.definition.descriptionxapiObject.setDescription(String text)
object.definition.extensionsxapiObject.addExtension(String key, Object value)Add an key/value pair to object.definition.extensions.
object.definition.typexapiObject.setType(String type)
object.definition.moreInfoxapiObject.setMoreInfo(String moreInfo)This field must be a URI.
Contextcontext.contextActivitiesxapiContext.setActivityId(String id)Add a context activity object to the statement
xapiContext.setActivityName(String name)
xapiContext.setActivityDescription(String description)
xapiContext.setActivityType(String type)parent | category | grouping | other
xapiContext.addActivity(String classification)Add a context activity object to the statement
context.extensionsxapiContext.addExtension(String key, Object value)
context.language xapiContext.setLanguage(String language)
context.platformxapiContext.setPlatform(String platform)
context.revisionxapiContext.setRevision(String revision)
context.statementxapiContext.setStatement(String statementId)
context.instructorxapiContext.setInstructorName(String name)
xapiContext.setInstructorAccount(String name, String homePage)Only one of these identifiers can be set in a statement. Each method will clear out any other instructor identifiers when called to ensure this XAPI requirement is met.
xapiContext.setInstructorMbox(String mbox)
xapiContext.setInstructorMboxSha1Sum(String mbox_sha1sum)
xapiContext.setInstructorOpenId(String openid)
context.registrationxapiContext.setRegistration(String registration)
Resultresult.extensionsxapiResult.addExtension(String key, Object value)Add a key/value pair to result.extensions
result.completionxapiResult.setCompletion(Boolean completion)
result.durationxapiResult.setDuration(String duration)
result.responsexapiResult.setResponse(String response)
result.successxapiResult.setSuccess(Boolean success)
result.score.maxxapiResult.setScoreMax(Double max)
result.score.minxapiResult.setScoreMin(Double min)
result.score.rawxapiResult.setScoreRaw(Double raw)
result.score.scaledxapiResult.setScoreScaled(Double scaled)
n/aauthoritysetAuthorityName(String name)
setAuthorityAccount(String name, String homePage)Only one of these identifiers can be set in a statement. Each method will clear out any other authority identifiers when called to ensure this XAPI requirement is met.
setAuthorityMbox(String mbox)
setAuthorityMboxSha1Sum(String mbox_sha1sum)
setAuthorityOpenId(String openid)
n/aversionsetVersion(String version)
(all)validaten/aTo check the statement data as provided for validity (before sending)

Returns: Boolean
(all)sendSyncn/aTo send the statement (if valid, validity is checked before the send is attempted) to the LRS as configured in a synchronous manner – i.e. get a return value (Boolean) which determines whether the statement was sent successfully or not.

Note this method can only be called in a valid, synchronous context, such as a direct class execution. If the statement is instantiated in an invalid context (e.g. via @invocablemethod) then sendAsync must be used instead. If called in the wrong context then the method will not in fact be executed, and a statement will not be sent.

Returns: Boolean
(all)sendAsyncn/aTo send the statement (if valid, validity is checked before the send is attempted) to the LRS as configured in an asynchronous manner.

Note: this method executes as a @future, therefore asynchronously and in a separate thread to the callee. It will run but control will be immediately passed back to the calling code and its execution will continue whilst the method thread runs to completion. It should be called in circumstances where the processing environment allows, and where the completion status of the statement send is not required to determine any subsequent code. In such cases, the audit log object can be used to trigger this type of processing which can query the log record and associated status/data.

Returns: void

More Information

For more information and implementation details, browse the documentation below:

Setting up Globebyte xAPI Send xAPI from a flow Form action fields Send xAPI from Apex Logging and defaults xAPIStatement class reference