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 #209) #210

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

>**text** (string): Text that comprises 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): Determines whether the *item* must be selected for the answer to be correct. Value can be `true` or `false`. The value of **\_selectable** can be smaller, match or exceed the total 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 @@ -23,6 +23,7 @@
"_items": [
{
"text": "This is option 1 (Correct)",
"altText": "",
"_shouldBeSelected": true,
"_isPartlyCorrect": false
},
Expand Down
9 changes: 9 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@
"help": "This text will display as the answer text",
"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 @@ -58,6 +58,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/mcq.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function Mcq(props) {
aria-label={ariaQuestion || null}
>

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

<div
className={classes([
Expand All @@ -61,8 +61,8 @@ export default function Mcq(props) {
disabled={!_isEnabled}
checked={_isActive}
aria-label={!_shouldShowMarking ?
a11y.normalize(text) :
`${_shouldBeSelected ? ariaLabels.correct : ariaLabels.incorrect}, ${_isActive ? ariaLabels.selectedAnswer : ariaLabels.unselectedAnswer}. ${a11y.normalize(text)}`}
a11y.normalize(altText || text) :
`${_shouldBeSelected ? ariaLabels.correct : ariaLabels.incorrect}, ${_isActive ? ariaLabels.selectedAnswer : ariaLabels.unselectedAnswer}. ${a11y.normalize(altText || text)}`}
data-adapt-index={_index}
onKeyPress={onKeyPress}
onChange={onItemSelect}
Expand Down