Skip to content

Commit

Permalink
New: Added support for _canShowCorrectness (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster authored Oct 8, 2024
1 parent 652de56 commit be2018c
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ guide the learner’s interaction with the component.

**\_canShowModelAnswer** (boolean): Setting this to `false` prevents the [**_showCorrectAnswer** button](https://github.com/adaptlearning/adapt_framework/wiki/Core-Buttons) from being displayed. The default is `true`.

**\_canShowCorrectness** (boolean): Setting this to `true` replaces the associated `_canShowModelAnswer` toggle button and displays correctness directly on the component items. The default is `false`.

**\_canShowFeedback** (boolean): Setting this to `false` disables feedback, so it is not shown to the user. The default is `true`.

**\_canShowMarking** (boolean): Setting this to `false` prevents ticks and crosses being displayed on question completion. The default is `true`.
Expand Down
1 change: 1 addition & 0 deletions example.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"_questionWeight": 1,
"_selectable": 1,
"_canShowModelAnswer": true,
"_canShowCorrectness": false,
"_canShowFeedback": true,
"_canShowMarking": true,
"_recordInteraction": true,
Expand Down
14 changes: 14 additions & 0 deletions less/mcq.less
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@
&__widget.show-correct-answer &-item:not(.is-correct):not(.is-incorrect) .is-selected &-item__answer-icon {
display: block;
}


// Always show selection
// --------------------------------------------------
&__widget.show-correctness &-item__answer-icon {
display: block;
}

// Class to show the item correctness
// --------------------------------------------------
&__widget.show-correctness .is-correct &-item__correct-icon,
&__widget.show-correctness .is-incorrect &-item__incorrect-icon {
display: block;
}
}

.mcq-item {
Expand Down
9 changes: 9 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@
"validators": [],
"help": "Allow the user to view the 'model answer' if they answer the question incorrectly?"
},
"_canShowCorrectness": {
"type": "boolean",
"required": false,
"default": false,
"title": "Display item correctness",
"inputType": "Checkbox",
"validators": [],
"help": "If enabled, this replaces the associated 'model answer' toggle button and displays correctness directly on the component items."
},
"_canShowFeedback": {
"type": "boolean",
"required": true,
Expand Down
6 changes: 6 additions & 0 deletions schema/component.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@
"description": "Allow the user to view the 'model answer' if they answer the question incorrectly",
"default": true
},
"_canShowCorrectness": {
"type": "boolean",
"title": "Enable items to display correctness",
"description": "If enabled, this replaces the associated 'model answer' toggle button and displays correctness directly on the component items.",
"default": false
},
"_canShowFeedback": {
"type": "boolean",
"title": "Enable feedback",
Expand Down
19 changes: 13 additions & 6 deletions templates/mcq.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export default function Mcq(props) {
_isCorrect,
_isCorrectAnswerShown,
_shouldShowMarking,
_canShowModelAnswer,
_canShowCorrectness,
_isRadio,
displayTitle,
body,
Expand All @@ -34,7 +36,10 @@ export default function Mcq(props) {
'component__widget',
'mcq__widget',
!_isEnabled && 'is-disabled',
_isInteractionComplete && 'is-complete is-submitted show-user-answer',
_isInteractionComplete && 'is-complete is-submitted',
_isInteractionComplete && !_canShowCorrectness && !_isCorrectAnswerShown && 'show-user-answer',
_isInteractionComplete && _canShowModelAnswer && _isCorrectAnswerShown && 'show-correct-answer',
_isInteractionComplete && _canShowCorrectness && 'show-correctness',
_isCorrect && 'is-correct'
])}
role={_isRadio ? 'radiogroup' : 'group'}
Expand Down Expand Up @@ -95,7 +100,14 @@ export default function Mcq(props) {
<span className='icon'></span>

</span>
</span>

<span className='mcq-item__text'>
<span className='mcq-item__text-inner' dangerouslySetInnerHTML={{ __html: compile(text) }}>
</span>
</span>

<span className='mcq-item__state mcq-item__state-correctness'>
<span className='mcq-item__icon mcq-item__correct-icon'>
<span className='icon'></span>
</span>
Expand All @@ -105,11 +117,6 @@ export default function Mcq(props) {
</span>
</span>

<span className='mcq-item__text'>
<span className='mcq-item__text-inner' dangerouslySetInnerHTML={{ __html: compile(text) }}>
</span>
</span>

</label>

</div>
Expand Down

0 comments on commit be2018c

Please sign in to comment.