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

New: Added basic support for _canShowCorrectness #182

Merged
merged 4 commits into from
Oct 8, 2024
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 @@ -61,6 +61,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 @@
"_isRandom": false,
"_selectable": 1,
"_canShowModelAnswer": true,
"_canShowCorrectness": false,
"_canShowFeedback": true,
"_canShowMarking": true,
"_recordInteraction": true,
Expand Down
17 changes: 17 additions & 0 deletions less/gmcq.less
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@
&__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;
}

&:not(.can-show-marking) &-item__state-correctness {
display: none;
}
}

.gmcq-item {
Expand Down
9 changes: 9 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,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 @@ -151,6 +151,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
23 changes: 15 additions & 8 deletions templates/gmcq.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export default function Gmcq(props) {
_isCorrect,
_isCorrectAnswerShown,
_shouldShowMarking,
_canShowModelAnswer,
_canShowCorrectness,
_isRadio,
_columns,
_isRound,
Expand All @@ -39,7 +41,10 @@ export default function Gmcq(props) {
'component__widget',
'gmcq__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',
_columns && hasColumnLayout && 'has-column-layout'
])}
Expand Down Expand Up @@ -112,7 +117,16 @@ export default function Gmcq(props) {
<span className='icon'></span>

</span>
</span>

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

<span className='gmcq-item__state gmcq-item__state-correctness'>
<span className='gmcq-item__icon gmcq-item__correct-icon'>
<span className='icon'></span>
</span>
Expand All @@ -122,13 +136,6 @@ export default function Gmcq(props) {
</span>
</span>

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

</span>

</label>
Expand Down