Skip to content

Commit

Permalink
New: Added basic support for _canShowCorrectness
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster committed Sep 12, 2024
1 parent 694b891 commit 433e08b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
13 changes: 13 additions & 0 deletions less/gmcq.less
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
&__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;
}
}

.gmcq-item {
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

0 comments on commit 433e08b

Please sign in to comment.