Skip to content

Commit

Permalink
Fix: Add ariaQuestion to slider (fixes: 170) (adaptlearning#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-replin authored Jan 30, 2023
1 parent 608546a commit e1c0d42
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ In addition to the attributes specifically listed below, [*question components*]
**instruction** (string): This optional text appears above the component. It is frequently used to
guide the learner’s interaction with the component.

**ariaQuestion** (string): This will be read out by screen readers instead of reading the title, body & instruction fields when focusing on the group or radiogroup.

**\_attempts** (integer): This specifies the number of times a learner is allowed to submit an answer. The default is `1`.

**\_shouldDisplayAttempts** (boolean): Determines whether or not the text set in **remainingAttemptText** and **remainingAttemptsText** will be displayed. These two attributes are part of the [core buttons](https://github.com/adaptlearning/adapt_framework/wiki/Core-Buttons) attribute group. The default is `false`.
Expand Down
1 change: 1 addition & 0 deletions example.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"displayTitle": "Slider type component",
"body": "Question text here",
"instruction": "Drag the slider to make your choice and select Submit.",
"ariaQuestion": "Question text specifically for screen readers.",
"_attempts": 1,
"_shouldDisplayAttempts": false,
"_questionWeight": 1,
Expand Down
9 changes: 9 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@
"help": "This is the instruction text",
"translatable": true
},
"ariaQuestion": {
"type": "string",
"required": false,
"default": "",
"inputType": "Text",
"validators": [],
"help": "This will be read out by screen readers instead of reading the 'Display title', 'Body' & 'Instruction' fields when focusing on the when focusing on the group or radiogroup. To be clear and concise, ensure the text encompasses only the question associated.",
"translatable": true
},
"_attempts": {
"type": "number",
"required": true,
Expand Down
9 changes: 9 additions & 0 deletions schema/component.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
"translatable": true
}
},
"ariaQuestion": {
"type": "string",
"title": "ARIA question",
"description": "This will be read out by screen readers instead of reading the 'Display title', 'Body' & 'Instruction' fields when focusing on the options. To be clear and concise, ensure the text encompasses only the question associated.",
"default": "",
"_adapt": {
"translatable": true
}
},
"_attempts": {
"type": "number",
"title": "Allowed attempts",
Expand Down
23 changes: 16 additions & 7 deletions templates/slider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ import { classes, templates } from 'core/js/reactHelpers';

export default function Slider (props) {
const {
_id,
_globals,
_shouldShowMarking,
_isInteractionComplete,
_isEnabled,
_isCorrect,
displayTitle,
body,
instruction,
ariaQuestion,
labelStart,
labelEnd,
_userAnswer,
Expand All @@ -21,13 +26,17 @@ export default function Slider (props) {

<templates.header {...props} />

<div className={classes([
'component__widget slider__widget',
!_isEnabled && 'is-disabled',
_isInteractionComplete && 'is-complete is-submitted show-user-answer',
_shouldShowMarking && _isCorrect && 'is-correct',
_shouldShowMarking && !_isCorrect && 'is-incorrect'
])}>
<div
className={classes([
'component__widget slider__widget',
!_isEnabled && 'is-disabled',
_isInteractionComplete && 'is-complete is-submitted show-user-answer',
_shouldShowMarking && _isCorrect && 'is-correct',
_shouldShowMarking && !_isCorrect && 'is-incorrect'
])}
aria-labelledby={ariaQuestion ? null : (displayTitle || body || instruction) && `${_id}-header`}
aria-label={ariaQuestion || null}
>

{(labelStart || labelEnd) &&
<div className="slider__label-container js-slider-label-container">
Expand Down

0 comments on commit e1c0d42

Please sign in to comment.