Grading API Methods
init()
Initialize and create a new instance of the Grading API to load and interact with the grading interface.
You must use this method in order to initialize Grading API and access its methods and events.
The init
method is called from the LearnosityGrading
factory, and should only be called once per instantiation of the Grading API. From there, you can use the returned application instance, referred to as gradingApp
throughout the documentation, to access all Grading API methods.
The Grading API attaches itself to a DOM placeholder element where the Item's responses will be rendered on the page.
Examples
<!-- On the page, add a <div> container with an unique ID where the assessment player will be rendered -->
<div id="grading-wrapper"></div>
<script>
const initializationObject = { ... };
const gradingWrapperElement = document.querySelector('#grading-wrapper-element');
// When init() is called, the grading inline will be injected
// using async and await function to initialize the grading inline
window.gradingApp = await LearnosityGrading.init(initializationObject, gradingWrapperElement);
// Or using a promise function to initialize the grading inline
LearnosityGrading.init(initializationObject, gradingWrapperElement)
.then(
(app) => {
// Reference of the grading app
window.gradingApp = app;
})
.catch((error) => {
// error handler
});
</script>
Arguments
-
initializationObject object
See Grading API Initialization for a full list of options.
-
domSelector string
Specifies the DOM selector to inject the grading inline used by Grading API.
Important An empty container element must be placed on the page with a unique ID where the grading inline be rendered.
Return value
Type object
Returns an instance of Grading API. See gradingApp methods for more information.