HypeXAPI (main) doxdox documentation

Connector for Hype with xAPI

# ADL.xhrRequestOnError(xhr, method, url, callback, callbackargs)

Redirects the error handler to getDefault('xhrRequestOnError')

Parameters

Name Types Description
xhr Object - The XMLHttpRequest object
method String - The HTTP method used
url String - The URL of the request
callback Function - The callback function
callbackargs Object - The arguments to be passed to the callback function

# changeConfig(config)

This function forwards an updated config to ADL.XAPIWrapper

Parameters

Name Types Description
config Object This is an object containing config parameter

# cloneObject(obj)

This function clones an object

Parameters

Name Types Description
obj object - The object to be cloned

# function(key, value, store)

Set a custom data variable. This function is used to set a custom data variable that can be used in the LRS notation.

Parameters

Name Types Description
key string - The key of the custom data variable.
value string - The value of the custom data variable.
store object - The object to store the custom data variable in.

# getDefault(key)

This function returns the value of a default by key or all default if no key is given

Parameters

Name Types Description
key String This the key of the default.

Returns

Returns the current value for a default with a certain key.

# getXapiConfigFromAttributes(element)

Get the xAPI configuration from the element attributes

Parameters

Name Types Description
element HTMLElement

# hypeDocument.functions(hypeDocument, element, event)

This function is called on HypeDocumentLoad. It fires the HypeXAPI function if it exists.

Parameters

Name Types Description
hypeDocument HypeDocument - The HypeDocument object.
element HTMLElement - The element that triggered the event (document).
event Event - The HypeDocumentLoad event object.

# hypeDocument.sendStatementByArguments(verb, object, context, result, actor)

Send a statement to the LRS. This function is used by a GUI component that only has string input fields, the LRS notation is then fetched from a lookup based on the provided string keys (HypeXAPI.hype-export.py).

Parameters

Name Types Description
verb string - The verb of the statement.
object string - The object of the statement.
context string - The context of the statement.
result string - The result of the statement.
actor string - The actor of the statement.

# hypeDocument.sendStatementByDataset(element)

This function sends a statement to the LRS using the data-xapi-* attributes of the element.

Parameters

Name Types Description
element HTMLElement - The element to send the statement for.

# hypeDocument.setCustomDataVariable(key, value)

Set a custom data variable (forwards it from the hypeDocument context) This function is used to set a custom data variable that can be used in the LRS notation.

Parameters

Name Types Description
key string - The key of the custom data variable.
value string - The value of the custom data variable.

# HypeXAPI()

# isHypePreview()

This function is determines if we in a Hype Preview.

Returns

Boolean

Return true if not on device

# resolveKeyToArray(key)

This function takes a key and returns an array of the key

Parameters

Name Types Description
key string

# resolveObjectNotation(str, variables)

This function is used to resolve the object notation.

Parameters

Name Types Description
str string - The string to be resolved.
variables object - The variables to be used.

# runExpression(expression, context)

Evaluate a javascript expression in the context of an object

Parameters

Name Types Description
expression string The expression to evaluate
context object The context to evaluate the expression inside

Returns

any

The result of the evaluation

# sendStatement(stmt, debug)

Send a statement to the LRS

Parameters

Name Types Description
stmt Object - The statement to send
debug string - The debug mode

# sendStatementByDataset(element)

This function send a statement based on dataset attributes

Parameters

Name Types Description
element HTMLDivElement This is the element the attributes should be taken from

# sendStatementByDictonary(config, config.element, config.agent, config.verb, config.object, config.result, config.context, config.parent-activity, config.grouping-activity, config.context-activity, config.verb-id, config.verb-name, config.object-id, config.object-name, config.object-desc)

This function send a statement based on a config object equivalent to the dataset keys (without data-xapi- prefix). It will resolve all the keys in the config object and send the statement.

Parameters

Name Types Description
config Object This is an config object containing all the keys for the statement (at least verb and object are necessary).
config.element Object This is the element that will be used to get the xapi config from the attributes.
config.agent Object This is the agent that will be used in the statement.
config.verb Object This is the verb that will be used in the statement.
config.object Object This is the object that will be used in the statement.
config.result Object This is the result that will be used in the statement.
config.context Object This is the context that will be used in the statement.
config.parent-activity Object This is the parent activity that will be used in the statement.
config.grouping-activity Object This is the grouping activity that will be used in the statement.
config.context-activity Object This is the context activity that will be used in the statement.
config.verb-id Object This is the verb id that will be used in the statement.
config.verb-name Object This is the verb name that will be used in the statement.
config.object-id Object This is the object id that will be used in the statement.
config.object-name Object This is the object name that will be used in the statement.
config.object-desc Object This is the object description that will be used in the statement.

# setDefault(key, value)

This function allows to override a global default by key or if a object is given as key to override all default at once

Parameters

Name Types Description
key String This is the key to override
value String Function

# setDefaultActor(config)

This function set the default actor using setDefault it has its own function to make it stand out a little

Parameters

Name Types Description
config Object This is an object containing config parameter