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 part | Statement field | Method name | Parameters | Description |
---|---|---|---|---|
Actor | actor.name | xapiActor.setName | (String name) | |
actor.account | xapiActor.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.mbox | xapiActor.setMbox | (String mbox) | ||
actor.mbox_sha1sum | xapiActor.setMboxSha1Sum | (String mbox_sha1sum) | ||
actor.openid | xapiActor.setOpenId | (String openid) | ||
Verb | verb.id | xapiVerb.setId | (String id) | |
verb.display | xapiVerb.setDisplay | (String text) | ||
Object | object.id | xapiObject.setId | (String id) | |
object.definition.name | xapiObject.setName | (String text) | ||
object.definition.description | xapiObject.setDescription | (String text) | ||
object.definition.extensions | xapiObject.addExtension | (String key, Object value) | Add an key/value pair to object.definition.extensions. | |
object.definition.type | xapiObject.setType | (String type) | ||
object.definition.moreInfo | xapiObject.setMoreInfo | (String moreInfo) | This field must be a URI. | |
Context | context.contextActivities | xapiContext.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.extensions | xapiContext.addExtension | (String key, Object value) | ||
context.language | xapiContext.setLanguage | (String language) | ||
context.platform | xapiContext.setPlatform | (String platform) | ||
context.revision | xapiContext.setRevision | (String revision) | ||
context.statement | xapiContext.setStatement | (String statementId) | ||
context.instructor | xapiContext.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.registration | xapiContext.setRegistration | (String registration) | ||
Result | result.extensions | xapiResult.addExtension | (String key, Object value) | Add a key/value pair to result.extensions |
result.completion | xapiResult.setCompletion | (Boolean completion) | ||
result.duration | xapiResult.setDuration | (String duration) | ||
result.response | xapiResult.setResponse | (String response) | ||
result.success | xapiResult.setSuccess | (Boolean success) | ||
result.score.max | xapiResult.setScoreMax | (Double max) | ||
result.score.min | xapiResult.setScoreMin | (Double min) | ||
result.score.raw | xapiResult.setScoreRaw | (Double raw) | ||
result.score.scaled | xapiResult.setScoreScaled | (Double scaled) | ||
n/a | authority | setAuthorityName | (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/a | version | setVersion | (String version) | |
(all) | validate | n/a | To check the statement data as provided for validity (before sending) Returns: Boolean | |
(all) | sendSync | n/a | To 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) | sendAsync | n/a | To 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