Extensions/Assessment/networkStatus

Checks for an active network connection. If none found, adds an icon to the UI to indicate the status to the end user.

Can also be used to check the current download speed.

Parameters:
NameTypeAttributesDescription
optionsobject<optional>

Object of configuration options.

Properties
NameTypeAttributesDescription
iconWrapperstring<optional>

Classname of element to inject the broken connection icon. You should never need this if using any of the Learnosity regions. Defaults to top-right-wrapper.

intervalnumber<optional>

Millisecond interval to check connection. Defaults to 30000 (30 seconds).

messagestring<optional>

Message for tooltip and screen reader users.

renderboolean<optional>

Whether to render the icon or not. Defaults to true.

uristring<optional>

URI to check for network connectivity. Defaults to a Learnosity API endpoint which is already whitelisted.

Example
const options = {
    iconWrapper: 'top-right-wrapper',
    interval: 30000,
    message: 'Internet connection is currently down.',
    render: true,
    uri: 'https://questions.learnosity.com?latest-lts',
}

LT.init(itemsApp, {
    extensions: [
        { id: 'networkStatus', args: options },
    ],
});

Methods

checkConnection() → {promise}

Checks for network connectivity using a HEAD request. The return promise resolves to true if the request is successful, false otherwise.

Since
2.12.0
Returns: 
promise

checkSpeed() → {string}

Checks the current download speed using the Network Information API. Returns the current download speed in Mbps or a message indicating that the API is not supported. Eg 10 Mbps.

Since
2.25.0
Returns: 
string