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

issue/2799 Removed redundant behaviour #144

Merged
merged 3 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions js/adapt-contrib-gmcq.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Adapt from 'core/js/adapt';
import components from 'core/js/components';
import GmcqView from './GmcqView';
import GmcqModel from './GmcqModel';

export default Adapt.register('gmcq', {
export default components.register('gmcq', {
model: GmcqModel,
view: GmcqView
});
25 changes: 12 additions & 13 deletions templates/gmcq.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Adapt from 'core/js/adapt';
import a11y from 'core/js/a11y';
import device from 'core/js/device';
import React from 'react';
import { templates, classes, html, compile } from 'core/js/reactHelpers';
import { templates, classes, compile } from 'core/js/reactHelpers';

export default function Gmcq(props) {
const ariaLabels = Adapt.course.get('_globals')._accessibility._ariaLabels;
Expand All @@ -11,7 +13,7 @@ export default function Gmcq(props) {
_isInteractionComplete,
_isCorrect,
_isCorrectAnswerShown,
_canShowMarking,
_shouldShowMarking,
_isRadio,
_columns,
displayTitle,
Expand All @@ -20,12 +22,10 @@ export default function Gmcq(props) {
onKeyPress,
onItemSelect,
onItemFocus,
onItemBlur,
isInteractive
onItemBlur
} = props;

const screenSize = Adapt.device.screenSize;
const shouldShowMarking = !isInteractive() && _canShowMarking;
const screenSize = device.screenSize;

return (
<div className='component__inner gmcq__inner'>
Expand All @@ -50,8 +50,8 @@ export default function Gmcq(props) {
<div
className={classes([
`gmcq-item item-${index}`,
(shouldShowMarking && _shouldBeSelected) ? 'is-correct' : null,
(shouldShowMarking && !_shouldBeSelected) ? 'is-incorrect' : null
(_shouldShowMarking && _shouldBeSelected) ? 'is-correct' : null,
(_shouldShowMarking && !_shouldBeSelected) ? 'is-incorrect' : null
])}
style={(_columns && screenSize === 'large') ?
{ width: `${100 / _columns}%` } :
Expand All @@ -65,9 +65,9 @@ export default function Gmcq(props) {
name={_isRadio ? `${_id}-item` : null}
type={_isRadio ? 'radio' : 'checkbox'}
disabled={!_isEnabled}
aria-label={!shouldShowMarking ?
`${Adapt.a11y.normalize(text)} ${_graphic?.alt || ''}` :
`${_shouldBeSelected ? ariaLabels.correct : ariaLabels.incorrect}, ${_isActive ? ariaLabels.selectedAnswer : ariaLabels.unselectedAnswer}. ${Adapt.a11y.normalize(text)} ${_graphic?.alt || ''}`}
aria-label={!_shouldShowMarking ?
`${a11y.normalize(text)} ${_graphic?.alt || ''}` :
`${_shouldBeSelected ? ariaLabels.correct : ariaLabels.incorrect}, ${_isActive ? ariaLabels.selectedAnswer : ariaLabels.unselectedAnswer}. ${a11y.normalize(text)} ${_graphic?.alt || ''}`}
data-adapt-index={_index}
onKeyPress={onKeyPress}
onChange={onItemSelect}
Expand Down Expand Up @@ -118,8 +118,7 @@ export default function Gmcq(props) {

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