Items API Methods
init()
Initialize and create a new instance of Items API to load and interact with the Learnosity assessment.
You must use this method in order to initialize Items API and access its methods and events.
The init
method is called from the LearnosityItems
factory, and should only be called once per instantiation of the Items API. From there, you can use the returned application instance, referred to as itemApp
throughout the documentation, to access all Items API methods.
In Assess mode, it injects the assessment player interface into the page at the given DOM selector which will be used as a container or wrapper. See the Quick Start for further information and examples.
In Inline mode, it injects individual Items into the empty containers of each DOM placeholder element where Items will be rendered on the page. See the Embedding the Items API Into Formative Content With "Inline" Rendering article for more information and examples.
Examples
<div id="my-assessment-player-container"></div>
<script>
// Initializing the Items API in Assess mode with the assessment player
var initializationObject = {
// See Initialization for a full list of options
// ...
};
var domSelector = '#my-assessment-player-container';
var callbacksObject = {
errorListener: function (event) {
console.log("Learnosity Items API error", event);
},
readyListener: function () {
console.log("Learnosity Items API is ready");
}
};
var itemsApp = window.LearnosityItems.init(
initializationObject,
domSelector,
callbacksObject
);
</script>
Arguments
-
initializationObject object
See Items API Initialization for a full list of options.
-
domSelector string
Specifies the DOM selector to inject the assessment player used by Items API.
Important An empty container element must be placed on the page with a unique ID where the assessment player will be rendered.
This argument only applies to assessments in Assess mode.
<!-- On the page, add a <div> container with a unique ID where the assessment player will be rendered --> <div id="my-assessment-player-container"></div> <script> // When init() is called, the assessment player will be injected // into the 'my-assessment-player-container' container on the page window.LearnosityItems.init( initializationObject, '#my-assessment-player-container', callbacks ); </script>
-
callbacksObject object
See Items API Initialization Callbacks for a full list of callbacks.
Return value
Type itemsApp