new EventDispatcher()
The base of the event system.
Inherit this class if you want your H5P to dispatch events.
Methods
-
createXAPIEventTemplate(verb, extra) → {H5P.XAPIEvent}
-
Helper function to create event templates added to the EventDispatcher. Will in the future be used to add representations of the questions to the statements.
Parameters:
Name Type Argument Description verbstring Verb id in short form extraObject <optional>
Extra values to be added to the statement Returns:
Instance- Type
- H5P.XAPIEvent
-
off(type, listener)
-
Remove event listener. If no listener is specified, all listeners will be removed.
Parameters:
Name Type Description typestring Event type listenerH5P.EventCallback Event listener Throws:
-
listener must be a function
- Type
- TypeError
-
-
on(type, listener, thisArg)
-
Add new event listener.
Parameters:
Name Type Argument Description typestring Event type listenerH5P.EventCallback Event listener thisArgObject <optional>
Optionally specify the this value when calling listener. Throws:
-
listener must be a function
- Type
- TypeError
-
-
once(type, listener, thisArg)
-
Add new event listener that will be fired only once.
Parameters:
Name Type Description typestring Event type listenerH5P.EventCallback Event listener thisArgObject Optionally specify the this value when calling listener. Throws:
-
listener must be a function
- Type
- TypeError
-
-
trigger(event, eventData, extras)
-
Dispatch event.
Parameters:
Name Type Argument Description eventstring | H5P.Event Event object or event type as string eventData* <optional>
Custom event data(used when event type as string is used as first argument). extrasObject <optional>
Properties
Name Type Argument Description bubblesboolean <optional>
externalboolean <optional>
-
triggerXAPI(verb, extra)
-
Helper function for triggering xAPI added to the EventDispatcher.
Parameters:
Name Type Argument Description verbstring The short id of the verb we want to trigger extraOject <optional>
Extra properties for the xAPI statement -
triggerXAPICompleted(score, maxScore, success)
-
Helper function to create xAPI completed events DEPRECATED - USE triggerXAPIScored instead
Parameters:
Name Type Description scorenumber Will be set as the 'raw' value of the score object maxScorenumber will be set as the "max" value of the score object successboolean will be set as the "success" value of the result object - Deprecated:
-
- since 1.5, use triggerXAPIScored instead.
-
triggerXAPIScored(score, maxScore, verb, completion, success)
-
Helper function to create scored xAPI events
Parameters:
Name Type Description scorenumber Will be set as the 'raw' value of the score object maxScorenumber Will be set as the "max" value of the score object verbstring Short form of adl verb completionboolean Is this a statement from a completed activity? successboolean Is this a statement from an activity that was done successfully?