Overview
Learnosity's Items API user interface (UI) regions configuration allows the creation of a customized, fluid, and extensible assessment UI. All UI elements (such as buttons, timers, or assessment content) are modularized to allow placement in different regions of the assessment player.
The regions
configuration can be added as an attribute of an Items API activity. It can be set up to use one of several predefined layouts or be completely customized to fit your solution.
For example, the following is the default setting using the "main"
layout:
const initializationObject = {
"config": {
"regions": "main"
}
};
Figure 1: the regions on the screen that can be customized.
Table 1 below, provides a description of all the regions shown in the Figure 1 graphic.
Table 1: regions and descriptions
Region name | Description |
---|---|
top | First visible region in the assessment player. Spans the full width of the player. |
top-left | Just below the top region on the left side of the assessment player. Usually used for the assessment title. |
top-right | Below the top region on the right side of the assessment player. Space permitting, it shares a row with the top-left region, otherwise it stacks below. Primarily used to display essential information and controls including test time, item count, and pause. Only a few elements should be included here due to limited available width. |
items | Always displayed and does not need to be specified in the initialization of the Items API. May be configured with a slider_element or vertical_element to customize the layout of the Activity's Items. See the available elements table below for more information on these options. |
right | A vertical toolbar or "dock". Ideal for secondary buttons such as fullscreen, calculator, accessibility, etc. Buttons' labels are hidden when the menu is collapsed and tooltips are shown when the user hovers over a button. The verticaltoc_element is placed to the left of the toolbar when added to this region. When space is limited these controls are moved to the main menu to provide more space for the Items region. |
right with verticaltoc_element
|
The verticaltoc_element is placed to the left of the toolbar when added to the right region. When space is limited, these controls are moved to the main menu to provide more space for the Items region. |
bottom-left | On the left side of the assessment player, below the items and right regions. |
bottom-right | On the right side of the assessment player, below the items and right regions. Space permitting, it shares a row with the bottom-left region, otherwise it stacks beneath it. Alternately, if this region contains fewer than 4 elements and a verticaltoc_element is configured in the right region, then it is displayed directly below the right region. |
bottom | Last visible region in the assessment player, spanning the full width of the player. |
Initialization options
The sections below describe different ways of configuring Items API's regions using simple layout presets and the more flexible regions configuration object.
Layout presets
When passed as a string, the regions
attribute is expected to be one of the following available presets:
- main
- horizontal
- horizontal-fixed
- items-only
These presets can also be overridden to have particular elements or regions shown or hidden using the "region_overrides"
functionality explained further below.
Note: The "regions"
attribute replaces "ui_style"
.
Main region
Set the regions attribute to "main"
.
Note: this preset region is not supported in the sections config object.
"regions": "main"
Region | Elements |
---|---|
top-left (left to right) |
|
top-right (left to right) |
|
items (top to bottom) |
|
right (top to bottom) |
|
bottom-right (left to right) |
|
(*) Requires Annotations API.
Horizontal region
Set the regions attribute to "horizontal"
.
Note: this preset region is not supported in the sections config object.
"regions": "horizontal"
Region | Elements |
---|---|
top-left (left to right) |
|
top-right (left to right) |
|
items (top to bottom) |
|
right (top to bottom) |
|
bottom (left to right) |
|
(*) Requires Annotations API.
Horizontal fixed region
This has the same elements configuration as "horizontal"
, but the assessment player stretches to the available viewport height and adds a scrollbar on the Items region when necessary.
Adding "scrollable_option": true
to the items
element (slider_element
or vertical_element
) in a manual regions configuration or the region overrides achieves the same result.
"horizontal-fixed"
.
Note: this preset region is not supported in the sections config object.
"regions": "horizontal-fixed"
Items only region
Only displays the items
region. Useful for building a custom assessment UI that uses events and public methods to drive the application.
"items-only"
.
"regions": "items-only"
Region | Elements |
---|---|
items (top to bottom) |
|
Regions configuration object
When passed as an object the regions configuration requires an attribute for each region being used (except the Items region, which is always rendered). The provided region attributes are expected to be an array of elements and buttons which will be rendered in the specified order.
const assessActivity = {
/* Activity with a top-right, right and bottom-right regions */
"regions": {
"top-right": [ /* Elements */ ],
"right": [ /* Elements */ ],
"bottom-right": [ /* Elements */ ]
},
...
};
Each region can have many elements; however care should be taken to ensure there is enough space to display them properly.
An element is an object with a required "type"
attribute and some additional, optional attributes. For example, a "position"
attribute can be set to override the left/right alignment of the element within its region, as shown below. The "type"
name and other optional attributes can be found in the Elements and Buttons tables.
JSON example:
const initializationObject = {
"config": {
"regions": {
"top-right": [
{
"type": "pause_button",
"position": "right"
},
{
"type": "timer_element"
},
{
"type": "reading_timer_element"
},
{
"type": "itemcount_element",
"position": "right"
}
],
"right": [
{
"type": "save_button"
},
{
"type": "fullscreen_button"
},
{
"type": "separator_element"
},
{
"type": "accessibility_button"
},
{
"type": "calculator_button"
},
{
"type": "verticaltoc_element"
},
{
"type": "masking_button"
}
],
"bottom-right": [
{
"type": "next_button"
},
{
"type": "previous_button"
}
]
},
...
}
};
Backwards compatibility
If an element or button is defined in the regions object or is part of a layout preset then the related navigation.show_*
(e.g. show_next
) will be overridden.
Region overrides
The region_overrides
attribute in the initialization object allows simple overrides (i.e. to add, remove, or edit) for regions, region elements, or region element options. For example:
const initializationObject = {
"config": {
"region_overrides": {
"top-left": false,
"bottom": [
{
"type": "horizontaltoc_element"
}
]
}
}
};
Note:
- The overrides are applied to the original configuration before any responsive transformations are performed.
- The
items
region is not supported inregion_overrides
or custom regions of sections. This means that even if you set theitems
region in your section's region orregion_overrides
configuration, it will be ignored by the app. Theitems
region is only supported at the top global regions configuration level.
Usage
In this example, this code will disable the top-left
region.
"region_overrides": {
"top-left": false
}
Add a region
If the override contains a region that is not defined in the origin object, it will add the region. This example will replace the entire bottom
region with the defined elements (horizontal TOC).
"region_overrides": {
"bottom": [
{
"type": "horizontaltoc_element"
}
]
}
Add elements to a preset region
Insert additional elements to the end of a region which will be displayed after the preset elements. In this example, we add two elements to the end of the right
region, the horizontal TOC and the accessibility button.
"region_overrides": {
"right.horizontaltoc_element": true,
"right.accessibility_button": true
}
Add an element to a preset region with options
Add an element with options to the end of a region. This example adds a calculator with the scientific option.
"region_overrides": {
"right.calculator_button": {
"scientific_option": true
}
}
Remove an element from a region
Remove an element from a region by setting the element override value to false
.
"region_overrides": {
"right.calculator_button": false
}
Here's an example of mixed usage of adding and removing elements from a region:
"region_overrides": {
"right.horizontaltoc_element": true,
"right.accessibility_button": false
}
Global regions configuration and regions configuration in sections
Since assessments can be divided into sections, each section can have its own individual regions configuration as well.
Note: the regions settings in combination with sections will function differently depending on the LTS version being used. These differences are explained below.
v2021.2.LTS & v2021.3.LTS
The global regions configuration will merge the region from the first section, if it has a region configuration then it will become the new global regions configuration. The elements in the region will be rendered accordingly based on the new global regions configuration.
The regions configuration for all following sections will have the same logic as the first section.
For example:
{
"sections": [
{
"items": [...],
"config": {
"regions": {
"top": [
{
"type": "save_button"
},
{
"type": "calculator_button"
}
]
}
}
},
{
"items": [...],
"config": {
"regions": {
"right": [
{
"type": "save_button"
},
{
"type": "flagitem_button"
}
]
}
}
},
{
"items": [...],
"config": {
"regions": {
"top-right": [
{
"type": "save_button"
},
{
"type": "next_button"
}
]
}
}
}
],
"config": {
"regions": {
"top-right": [
{
"type": "fullscreen_button"
},
{
"type": "timer_element"
}
],
"top-left": [
{
"type": "calculator_button"
},
{
"type": "previous_button"
},
{
"type": "next_button"
}
]
},
...
}
}
In this case, the global regions config will merge with the first section's regions config. This means we'll see the following elements in the first section:
regions | elements |
---|---|
top | save button and calculator button (from section1 regions config) |
top-left | calculator button, previous button and next button (from global regions config) |
top-right | fullscreen button and timer (from global regions config) |
When navigating to the second section, we will see the following elements in section 2:
regions | elements |
---|---|
top | save button and calculator button (from merged global regions config) |
top-left | calculator button, previous button and next button (from merged global regions config) |
top-right | fullscreen button and timer (from merged global regions config) |
right | side menu with save button and flagitem button (from section2 regions config) |
When navigating to the third section, we will see the following elements in section 3:
regions | elements |
---|---|
top | save button and calculator button (from merged global regions config) |
top-left | calculator button, previous button and next button (from merged global regions config) |
top-right | save button and next button (from section 2 regions config) |
right | side menu with save button and flagitem button (from merged global regions config) |
v2022.1.LTS and above
The global regions configuration will get replaced by the regions config in a section. If the following section has a regions config, then it will replace the global regions config.
Regions config in section will override the global sections config, if it is using the keyword region_overrides
.
Note: do not use regions
and region_overrides
simultaneously in sections config as they might conflict with each other.
For example:
{
"sections": [
{
"items": [...],
"config": {
"regions" : {
"top-left": [
{
"type": "previous_button"
},
{
"type": "next_button"
}
],
"top-right": [
{
"type": "save_button"
}
]
}
}
},
{
"items": [...],
"config": {
"region_overrides": {
"top-right": [
{
"type": "itemcount_element"
}
]
}
}
},
{
"items": [...],
"config": {
"region_overrides": {
"top-left.calculator_button": false,
"top-right.fullscreen_button": false
}
}
}
],
"config": {
"regions": {
"top-right": [
{
"type": "fullscreen_button"
},
{
"type": "timer_element"
}
],
"top-left": [
{
"type": "calculator_button"
},
{
"type": "previous_button"
},
{
"type": "next_button"
}
]
}
}
}
In this case, the first section is using regions
will replace the global regions config. See the elements below with the regions replaced from the global config:
regions | elements |
---|---|
top-left | previous button and next button (from section 1 regions config) |
top-right | save button (from section 1 regions config) |
Section 2, which has region_overrides
will override the global regions config. See the elements below with the regions overridden from the global config:
regions | elements |
---|---|
top-left | calculator button, previous button and next button (from global regions config) |
top-right | items count (from section 1 regions config) |
Section 3, which has region_overrides
will override the global regions config, see the elements below with the regions overridden from the global config:
regions | elements |
---|---|
top-left |
previous button and next button (from global regions config) no calculator button as it is overridden by regions config in section 3 |
top-right |
timer (from global regions config) no fullscreen button as it is overridden by regions config in section 3 |
Elements
Title / Function | Type name | Options & defaults |
---|---|---|
Dropdown A dropdown menu containing one or more buttons. |
dropdown_element |
Example:
Allowed regions:
|
Horizontal Table of Contents A horizontal arrangement of the table of contents, as used with pagination. |
horizontaltoc_element |
Allowed regions:
|
Item Count The current item number of the total. For example, the second item on an assessment with 10 items total would read "2 of 10". |
itemcount_element |
Allowed regions:
|
Item Slider The default one-Item-at-a-time view, only permitted in the |
slider_element |
Allowed regions:
|
Progress Bar A simple progress bar style indicator similar to the Item count, showing the current position in the assessment. Only available in the |
progress_element |
Allowed regions:
|
Reading Timer Displays the current reading time, during which questions can be viewed but not answered. Hides automatically when the reading time ends, or if there is none configured. |
reading_timer_element |
Allowed regions:
|
Separator A horizontal separator that can be added to the right region. |
separator_element |
Allowed regions:
|
Title The assessment title and subtitle. |
title_element |
Allowed regions:
|
Timer A timer for the assessment, counting up or down depending on if the timer countdown option is enabled. Hidden during reading time. |
timer_element |
Allowed regions:
|
Vertical Items The vertical style Items view that shows all Items at once, only permitted in the |
vertical_element |
Allowed regions:
|
Vertical Table of Contents The vertical table of contents for the right region. |
verticaltoc_element |
Allowed regions:
|
Responsive behavior
Regions are designed to automatically adjust based on the width of the assessment player, allowing it to be optimized on-the-fly for different device types including desktops, smartphones and tablets.
Note: the breakpoint sizes below do not include the additional 10px margins on both sides of the player. For example, to activate the smallest size for the Medium breakpoint, the container size must be 501px (481px + 10px + 10px).
Breakpoint | Behavior |
---|---|
Small In containers of 480px wide or smaller. |
|
Medium In containers ranging from 481px to 800px wide. |
|
Large In containers of 801px wide or larger. |
No changes are made, will behave as described by the regions configuration. |
Demo (animation)
How to disable responsive rendering in regions
If necessary, the responsive rendering of regions can be disabled by setting the responsive_regions
flag to false
in the configuration section of the initialization object.
const initializationObject = {
"config": {
"regions": "main",
"configuration": {
"responsive_regions": false, // disables the responsive rendering behavior
}
}
};