Skip to content

Core model attributes

kirsty-hames edited this page Nov 4, 2024 · 43 revisions

The following extend the Backbone model:

  • configModel (configModel.js)
  • lockingModel (lockingModel.js)
  • notifyModel (notifyModel.js)
  • routerModel (routerModel.js)
  • adaptModel (adaptModel.js)

All core models extend adaptModel (adaptModel.js), and so contain its attributes:

In addition, questionModel.js extends componentModel (componentModel.js).

An asterisk denotes that an attribute is required.

Adapt Model Attributes

Attribute Description Default value
_canShowFeedback Allows the user to view feedback on their answer true
_classes Allows you to specify custom CSS classes ""
_canReset Controls the model's ability to reset. When set to false, calling model.reset() will return false and the model will not be reset. true
_isComplete Whether the item has been completed false
_isInteractionComplete false
_requireCompletionOf The number of children within the item that the learner must complete in order for the item to be set as completed. A value of -1 requires all of them to be completed -1
_isEnabled Controls the availability of the item. If _isEnabled is false, the item is disabled. true
_isResetOnRevisit Determines if the item should be reset to its default values upon returning false
_isAvailable Controls whether the item is available in the course true
_isHidden Controls the display of the item. When set to 'true', this is the equivalent of applying the CSS 'display:none'. When set to 'true' on a content object, the item will be hidden on a course's menu, provided that the menu supports this feature. false
_isOptional If set to true, the user will not be required to complete the component in order to complete the course. The completion of the component will still be tracked, but it will be ignored during any completion calculations. false
_isVisible When set to 'false', this is the equivalent of applying the CSS 'visibility:hidden' true
_isLocked Menus and other plug-ins can set its value using _lockType. Reference Locking objects with '_isLocked' and '_lockType' false
_questionWeight The weight of a particular question, which is used when calculating the score. 1
_buttons An object to store the label values for template buttons. Buttons can then be referenced in templates using {{{_buttons.submit}}} See fig.1.

Figure 1

"_buttons": { 
   "submit": "Submit", 
   "reset": "Reset", 
   "showCorrectAnswer": "ModelAnswer", 
   "hideCorrectAnswer": "My Answer" 
}

Course Model Attributes

Attribute Description Default value
_id* A unique identifier. In the authoring tool, this is randomly generated.
_type* The type of the particular item. Examples include block and component.
title* Used in document title.
_children "contentObjects"
_start The start settings allow you to control which page is rendered when a course loads, potentially bypassing the menu.
_isReady This is used to determine if the current item is ready (i.e. has been initialised). This needs to be set manually for custom components. For instance, this may be set to true post-render. false
_isA11yCompletionDescriptionEnabled Disables the hidden title label that describes the state of the course to screenreader users. true

ContentObjects Model Attributes

Attribute Description Default value
_parent "course"
_siblings "contentObjects"
_children "contentObjects"
_isA11yCompletionDescriptionEnabled Disables the hidden title label that describes the state of the menu/page to screenreader users. _isOptional contentObjects default to false true
_onScreen Attribute for attaching predefined animation to the contentObject when the element comes into view See documentation below

Article Model Attributes

Attribute Description Default value
_parent "contentObjects"
_siblings "articles"
_children "blocks"
_isA11yCompletionDescriptionEnabled Disables the hidden title label that describes the state of the article to screenreader users. _isOptional articles default to false true
_onScreen Attribute for attaching predefined animation to the article when the element comes into view See documentation below

Block Model Attributes

Attribute Description Default value
_parent "articles"
_siblings "blocks"
_children "components"
_isA11yCompletionDescriptionEnabled Disables the hidden title label that describes the state of the block to screenreader users. _isOptional blocks default to false true
_onScreen Attribute for attaching predefined animation to the block when the element comes into view See documentation below

Component Model Attributes

Attribute Description Default value
_parent "blocks"
_siblings "components"
_isA11yComponentDescriptionEnabled Disables the hidden label that provides the component description to screenreader users. They appear under the component heading and are designed to help users understand how to interact with the user interface by providing a simple name and description of its behaviour. Labels are specified in the _globals._component[componentName].ariaRegion true
_isA11yCompletionDescriptionEnabled Disables the hidden title label that describes the state of the component to screenreader users. Useful if the component is of no interest to a screenreader user - such as an optional decorative graphic component. _isOptional components default to false true
_onScreen Attribute for attaching predefined animation to the component when the element comes into view See documentation below

Question Model Attributes

Attribute Description Default value
_isQuestionType Indicates if the component type is a question. true
_shouldDisplayAttempts When set to true, the number of remaining attempts will be shown. false
_canShowModelAnswer Allow the user to view the correct answer if they answer the question incorrectly. true
_canShowCorrectness Instead of _canShowModelAnswer, this replaces the associated toggle button and displays correctness directly on the component. false
_canShowFeedback Show feedback to the user after each submission. true
_canShowMarking Setting this to false prevents ticks and crosses from being displayed on question completion. true
_questionWeight When _hasItemScoring is false, this is the question score for a correct response. This number is used in calculations of the final score reported to the LMS.

_onScreen documentation

_onScreen (object): The _onScreen object that contains values for _isEnabled, _classes, and _percentInviewVertical. The _onScreen feature is best used with blocks and components though it can also be used with contentObjects and articles.

_isEnabled (boolean): Turns _onScreen functionality on and off. Acceptable values are true and false.

_classes (string): CSS class name to be applied to the location that _onScreen is attached to. The class name is responsible for attaching the animation, and any associated styling required, to the element and must be predefined in one of the Less files. The standard values found in Vanilla's _animations.less are fade-in, fade-in-top, fade-in-bottom, fade-in-left, and fade-in-right. The direction in each of the class names defines the animation start point, e.g. fade-in-right states that the animation fades in from right to left until the element sits within its natural position.

_percentInviewVertical (number): This value determines the percentage on screen the element must be before the animation is triggered. The default value is 33.

"_onScreen": { 
   "_isEnabled": true, 
   "_classes": "fade-in-right", 
   "_percentInviewVertical": 33
}
Clone this wiki locally