Helpers
A selection of useful helpers for converting data into the required formats.
toBasicAuth
Converts a username and password string combination into a Basic
Authorization token. toBasicAuth
is a static method of the XAPI
Class.
calculateISO8601Duration
Useful for calculating ISO8601 durations when submitting statements that require durations. calculateISO8601Duration
is a static method of the XAPI
Class.
getXAPILaunchData
Gets the launch data if the module was launched using xAPI Launch. getXAPILaunchData
is a static method of the XAPI
Class.
getTinCanLaunchData
Gets the launch data if the module was launched as a TinCan module. getTinCanLaunchData
is a static method of the XAPI
Class.
getSearchQueryParamsAsObject
Converts search query parameters from a string into an object. getSearchQueryParamsAsObject
is a static method of the XAPI
Object. Used in getTinCanLaunchData
and getXAPILaunchData
. If any JSON is detected an attempt is made to parse it, else properties are returned as decoded strings.
For backwards compatibility with some LMS/LRS (SCORM Cloud), if an actor
property is found containing string arrays for name
, mbox
and account
these are coerced into objects containing the first array entry only. Also if the property is account
the first array object is converted from:
[{ accountServiceHomePage: "...", accountName: "..." }]
into:
{ homePage: "...", name: "..." }
getAxios
Returns the internal Axios instance. Useful for configuring interceptors or providing other advanced configuration.
Last updated