Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add ariaQuestion to slider (fixes: 170) #171

Merged
merged 8 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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