initialization - Assess API

Assess API Initialization

This article details the properties that are passed as parameters to the window.LearnosityAssess.init() method to initialize Assess API.

This method is the starting point to initializing and rendering Assess API, and as you can see in the example below, takes three key parameters:

Only the Initialization object is mandatory.


const initializationObject = {
    "items": [
            "content": "<span class='learnosity-response question-demoscience1234'></span>",
            "response_ids": [
            "workflow": "",
            "reference": "question-demoscience1"
           "content": "<span class='learnosity-response question-demoscience5678'></span>",
           "response_ids": [
           "workflow": "",
           "reference": "question-demoscience2"
    "questionsApiActivity": {
        "consumer_key": "INSERT_CONSUMER_KEY_HERE",
        "timestamp": "INSERT_CURRENT_TIMESTAMP_HERE",
        "user_id": "aeee19fb-4e7b-435c-92f9-d93a1099988b",
        "type": "submit_practice",
        "state": "initial",
        "id": "assessdemo",
        "name": "Assess API - Demo",
        "questions": [
                "response_id": "demoscience1234",
                "type": "sortlist",
                "description": "In this question, the student needs to sort the events, chronologically earliest to latest.",
                "list": ["Russian Revolution", "Discovery of the Americas", "Storming of the Bastille", "Battle of Plataea", "Founding of Rome", "First Crusade"],
                "instant_feedback": true,
                "feedback_attempts": 2,
                "validation": {
                    "valid_response": [4, 3, 5, 1, 2, 0],
                    "valid_score": 1,
                    "partial_scoring": true,
                    "penalty_score": -1
                "response_id": "demoscience5678",
                "type": "highlight",
                "description": "The student needs to mark one of the flower's anthers in the image.",
                "img_src": "",
                "line_color": "rgb(255, 20, 0)",
                "line_width": "4"

const callbacks = {
    errorListener: function(e) {
        // Adds a listener to all error codes.
        console.log("Error Code ", e.code);
        console.log("Error Message ", e.msg);
        console.log("Error Detail ", e.detail);

    readyListener: function() {
        console.log("Learnosity Questions API is ready");

const assessApp = window.LearnosityAssess.init(initializationObject, "learnosity_assess", callbacks);

Initialization Object

The Initialization object is a JSON object which is passed as the first parameter into the window.LearnosityAssess.init() method.

It includes all the information needed for Authentication, User Identification, Action Builder, and UI elements such as Table of Contents or various buttons. Only a few attributes are mandatory, the rest provide a high level of customization to enable you to tailor the Assessment experience to suit your needs.


= mandatory property

  • administration object

    Enables an administration panel with various control options.

  • configuration object

    Enables various customizations such as redirect URLs and reading time settings.

  • existing_session boolean

    By default, Assess API uses the value of the Activity state inside questionsApiActivity to determine whether current session is a new session, or is an existing session.

  • items array

    Array of Item objects.

  • metadata object

    Contains information related to the current session, such as the current time and the current Item, for example.

  • name string

    The name of the Activity that will be displayed in Learnosity's Reports API and Data API.

  • navigation object

    Customize navigational attributes are available to the user interacting with the player.

  • questionsApiActivity object

    Data from this object is passed to the Learnosity Questions API during initialization.

  • regions object

    Regions allows you to create a personalized, fluid and extensible assessment UI.

  • region_overrides RegionsObject

    Directly override the assessment player interface regions, region elements, or region element options.

  • responsive_regions boolean

    By default, the assessment player's regions are rendered to be responsive to different device screen resolutions.

  • subtitle string

    An optional test subtitle, which appears underneath the title in the player UI.

  • time object

    Used to define time parameters including countdown and expiry settings.

  • title string

    Optional test title which overrides the name property.

  • labelBundle object

    Specifies overrides for labels and text content shown in the assessment player.

HTML Element Selector

The second parameter passed to window.LearnosityAssess.init() is a string, containing either an id or a full CSS selector to an element on the HTML page. Each example below could be a valid value:

learnosity_assess  // just an id
#learnosity_assess // CSS selector based on id of an element
.learnosity_assess // CSS selector based on a class of an element

This value tells Assess API where to render itself on the page.

Note If the HTML element selector is not provided, Assess API will attempt to look for the element with id "learnosity_assess".


The Callbacks object contains optional callback functions that allow detection of the 'ready' status of an Assess API instance and any errors encountered.

An example of how to construct this object can be seen above.

The readyListener callback in particular is very important for the correct functioning of Assess API. most of the methods provided by the returned object from window.LearnosityAssess.init() will not be fully available until after the readyListener callback has triggered.


  • customUnload function

    This function is called when the user attempts to close the browser window.

  • errorListener function

    Function to be called on a Learnosity error event.

  • readyListener function

    Function to be called when the API has been successfully initialized.

Was this article helpful?

Did you arrive here by accident? If so, learn more about Learnosity.