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

Update: alternative item option text added (fixes #172) #173

Merged
merged 6 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ guide the learner’s interaction with the component.

>**text** (string): Optional text that is displayed as part of the multiple choice option.

>**altText** (string): This will be read out by screen readers instead of reading `text`.
Optional for providing alternative text, for example, to specify how a word should be pronounced.

>**\_shouldBeSelected** (boolean): Value can be `true` or `false`. Use `true` for items that must be selected for a correct answer. The value of **\_selectable** can be smaller, match or exceed the number of **\_items** where **\_shouldBeSelected** is set to `true`.

>**\_isPartlyCorrect** (boolean): Determines whether the *item* when selected marks the question as partly correct. Value can be `true` or `false`. 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 @@ -24,6 +24,7 @@
"_items": [
{
"text": "This is option 1.",
"altText": "",
"_shouldBeSelected": true,
"_isPartlyCorrect": false,
"_graphic": {
Expand Down
9 changes: 9 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@
"help": "Text that will be displayed with the image",
"translatable": true
},
"altText": {
"type": "string",
"required": false,
"default": "",
"inputType": "Text",
"validators": [],
"help": "This will be read out by screen readers instead of reading 'text'. Optional for providing alternative text, for example, to specify how a word should be pronounced.",
"translatable": true
},
"_shouldBeSelected": {
"type": "boolean",
"required": true,
Expand Down
8 changes: 8 additions & 0 deletions schema/component.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@
"translatable": true
}
},
"altText": {
"type": "string",
"description": "This will be read out by screen readers instead of reading 'text'. Optional for providing alternative text, for example, to specify how a word should be pronounced.",
"default": "",
"_adapt": {
"translatable": true
}
},
"_shouldBeSelected": {
"type": "boolean",
"title": "Mark this option as correct",
Expand Down
6 changes: 3 additions & 3 deletions templates/gmcq.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function Gmcq(props) {
aria-label={ariaQuestion || null}
>

{props._items.map(({ text, _index, _isActive, _shouldBeSelected, _graphic }, index) =>
{props._items.map(({ text, altText, _index, _isActive, _shouldBeSelected, _graphic }, index) =>

<div
className={classes([
Expand All @@ -69,8 +69,8 @@ export default function Gmcq(props) {
disabled={!_isEnabled}
checked={_isActive}
aria-label={!_shouldShowMarking ?
`${a11y.normalize(text)} ${_graphic?.alt || ''}` :
`${_shouldBeSelected ? ariaLabels.correct : ariaLabels.incorrect}, ${_isActive ? ariaLabels.selectedAnswer : ariaLabels.unselectedAnswer}. ${a11y.normalize(text)} ${_graphic?.alt || ''}`}
`${altText || a11y.normalize(text)} ${_graphic?.alt || ''}` :
`${_shouldBeSelected ? ariaLabels.correct : ariaLabels.incorrect}, ${_isActive ? ariaLabels.selectedAnswer : ariaLabels.unselectedAnswer}. ${altText || a11y.normalize(text)} ${_graphic?.alt || ''}`}
kirsty-hames marked this conversation as resolved.
Show resolved Hide resolved
data-adapt-index={_index}
onKeyPress={onKeyPress}
onChange={onItemSelect}
Expand Down
Loading