@pie-element/multiple-choice 9.16.5-next.0 → 9.16.5-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/choice-input.js +33 -2
- package/lib/choice-input.js.map +1 -1
- package/lib/choice.js +5 -2
- package/lib/choice.js.map +1 -1
- package/lib/multiple-choice.js +17 -0
- package/lib/multiple-choice.js.map +1 -1
- package/module/element.js +101 -34
- package/module/print.js +101 -34
- package/package.json +2 -2
package/lib/choice-input.js
CHANGED
|
@@ -175,7 +175,9 @@ var StyledCheckbox = (0, _styles.withStyles)(inputStyles)(function (props) {
|
|
|
175
175
|
onChange = props.onChange,
|
|
176
176
|
disabled = props.disabled,
|
|
177
177
|
value = props.value,
|
|
178
|
-
id = props.id
|
|
178
|
+
id = props.id,
|
|
179
|
+
onKeyDown = props.onKeyDown,
|
|
180
|
+
inputRef = props.inputRef;
|
|
179
181
|
|
|
180
182
|
var key = function key(k) {
|
|
181
183
|
return correctness ? "".concat(correctness, "-").concat(k) : k;
|
|
@@ -194,7 +196,9 @@ var StyledCheckbox = (0, _styles.withStyles)(inputStyles)(function (props) {
|
|
|
194
196
|
};
|
|
195
197
|
return /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], (0, _extends2["default"])({
|
|
196
198
|
id: id,
|
|
199
|
+
inputRef: inputRef,
|
|
197
200
|
"aria-checked": checked,
|
|
201
|
+
onKeyDown: onKeyDown,
|
|
198
202
|
focusVisibleClassName: checked ? classes.focusVisibleChecked : classes.focusVisibleUnchecked,
|
|
199
203
|
disableRipple: true
|
|
200
204
|
}, miniProps, {
|
|
@@ -259,6 +263,29 @@ var ChoiceInput = /*#__PURE__*/function (_React$Component) {
|
|
|
259
263
|
|
|
260
264
|
(0, _classCallCheck2["default"])(this, ChoiceInput);
|
|
261
265
|
_this = _super.call(this, props);
|
|
266
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleKeyDown", function (event) {
|
|
267
|
+
var choiceMode = _this.props.choiceMode;
|
|
268
|
+
if (choiceMode !== 'checkbox') return;
|
|
269
|
+
var isArrowDown = event.key === 'ArrowDown';
|
|
270
|
+
var isArrowUp = event.key === 'ArrowUp';
|
|
271
|
+
if (!isArrowDown && !isArrowUp) return;
|
|
272
|
+
event.preventDefault();
|
|
273
|
+
var currentEl = document.getElementById(_this.choiceId);
|
|
274
|
+
if (!currentEl) return;
|
|
275
|
+
var fieldset = currentEl.closest('fieldset');
|
|
276
|
+
if (!fieldset) return;
|
|
277
|
+
var groupCheckboxes = Array.from(fieldset.querySelectorAll('input[type="checkbox"]'));
|
|
278
|
+
var currentIndex = groupCheckboxes.findIndex(function (el) {
|
|
279
|
+
return el === currentEl;
|
|
280
|
+
});
|
|
281
|
+
if (currentIndex === -1) return;
|
|
282
|
+
var nextIndex = isArrowDown ? currentIndex + 1 : currentIndex - 1;
|
|
283
|
+
var nextEl = groupCheckboxes[nextIndex];
|
|
284
|
+
|
|
285
|
+
if (nextEl) {
|
|
286
|
+
nextEl.focus();
|
|
287
|
+
}
|
|
288
|
+
});
|
|
262
289
|
_this.onToggleChoice = _this.onToggleChoice.bind((0, _assertThisInitialized2["default"])(_this));
|
|
263
290
|
_this.choiceId = _this.generateChoiceId();
|
|
264
291
|
_this.descId = "".concat(_this.choiceId, "-desc");
|
|
@@ -326,6 +353,7 @@ var ChoiceInput = /*#__PURE__*/function (_React$Component) {
|
|
|
326
353
|
value: value,
|
|
327
354
|
id: this.choiceId,
|
|
328
355
|
onChange: this.onToggleChoice,
|
|
356
|
+
onKeyDown: this.handleKeyDown,
|
|
329
357
|
'aria-describedby': this.descId
|
|
330
358
|
};
|
|
331
359
|
var hasMathOrImage = typeof label === 'string' && (label.includes('<math') || label.includes('\\(') || label.includes('\\[') || label.includes('<img') || label.includes('data-latex') || label.includes('data-raw') || label.includes('<mjx-container'));
|
|
@@ -335,7 +363,9 @@ var ChoiceInput = /*#__PURE__*/function (_React$Component) {
|
|
|
335
363
|
style: {
|
|
336
364
|
padding: 0
|
|
337
365
|
}
|
|
338
|
-
})), displayKey ? "".concat(displayKey, ".") : '') : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, hasMathOrImage && screenReaderLabel, /*#__PURE__*/_react["default"].createElement(Tag, tagProps
|
|
366
|
+
})), displayKey ? "".concat(displayKey, ".") : '') : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, hasMathOrImage && screenReaderLabel, /*#__PURE__*/_react["default"].createElement(Tag, (0, _extends2["default"])({}, tagProps, {
|
|
367
|
+
inputRef: this.props.autoFocusRef
|
|
368
|
+
})));
|
|
339
369
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
340
370
|
className: (0, _classnames["default"])(className, 'corespring-' + classSuffix, 'choice-input')
|
|
341
371
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -377,6 +407,7 @@ exports.ChoiceInput = ChoiceInput;
|
|
|
377
407
|
value: _propTypes["default"].string.isRequired,
|
|
378
408
|
classes: _propTypes["default"].object,
|
|
379
409
|
className: _propTypes["default"].string,
|
|
410
|
+
tagName: _propTypes["default"].string,
|
|
380
411
|
hideTick: _propTypes["default"].bool,
|
|
381
412
|
isEvaluateMode: _propTypes["default"].bool,
|
|
382
413
|
choicesLayout: _propTypes["default"].oneOf(['vertical', 'grid', 'horizontal']),
|
package/lib/choice-input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/choice-input.jsx"],"names":["CLASS_NAME","styleSheet","theme","row","display","alignItems","backgroundColor","color","background","checkboxHolder","flex","text","fontSize","horizontalLayout","padding","spacing","unit","margin","belowLayout","belowLayoutCenter","justifyContent","belowSelectionComponent","marginLeft","srOnly","position","left","top","width","height","overflow","formStyleSheet","label","letterSpacing","disabled","cursor","StyledFormControlLabel","name","props","classes","colorStyle","varName","fallback","inputStyles","correct","incorrect","root","primaryLight","checked","primary","opacity","pointerEvents","focusVisibleUnchecked","outline","focusUncheckedBorder","focusUnchecked","focusVisibleChecked","focusCheckedBorder","focusChecked","StyledCheckbox","correctness","onChange","value","id","key","k","resolved","miniProps","StyledRadio","tagName","ChoiceInput","onToggleChoice","bind","choiceId","generateChoiceId","descId","event","Math","random","toFixed","choiceMode","displayKey","feedback","className","rationale","hideTick","isEvaluateMode","choicesLayout","isSelectionButtonBelow","Tag","classSuffix","holderClassNames","choicelabel","screenReaderLabel","tagProps","hasMathOrImage","includes","control","undefined","React","Component","PropTypes","oneOf","string","bool","isRequired","func","object"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;AAEA,IAAMA,UAAU,GAAG,2BAAnB;;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,KAAD;AAAA,SAAY;AAC7BC,IAAAA,GAAG,EAAE;AACHC,MAAAA,OAAO,EAAE,MADN;AAEHC,MAAAA,UAAU,EAAE,QAFT;AAGHC,MAAAA,eAAe,EAAEC,gBAAMC,UAAN;AAHd,KADwB;AAM7BC,IAAAA,cAAc,EAAE;AACdL,MAAAA,OAAO,EAAE,MADK;AAEdC,MAAAA,UAAU,EAAE,QAFE;AAGdC,MAAAA,eAAe,EAAEC,gBAAMC,UAAN,EAHH;AAIdE,MAAAA,IAAI,EAAE,CAJQ;AAKd,iBAAW;AACTH,QAAAA,KAAK,EAAEA,gBAAMI,IAAN,EADE;AAET,oBAAY;AACVC,UAAAA,QAAQ,EAAE;AADA;AAFH;AALG,KANa;AAkB7BC,IAAAA,gBAAgB,oDACPb,UADO,GACQ;AACpB;AACA;AACAc,MAAAA,OAAO,EAAEZ,KAAK,CAACa,OAAN,CAAcC,IAHH;AAIpBC,MAAAA,MAAM,YAAKf,KAAK,CAACa,OAAN,CAAcC,IAAd,GAAqB,CAA1B,kBAAmCd,KAAK,CAACa,OAAN,CAAcC,IAAd,GAAqB,CAAxD,gBAA+Dd,KAAK,CAACa,OAAN,CAAcC,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AAV,CAAeC,UALR;AAMjBvB,EAAAA,QAAQ,EAAEmB,sBAAUE,MANH;AAOjBvE,EAAAA,KAAK,EAAEqE,sBAAUE,MAAV,CAAiBE,UAPP;AAQjBrB,EAAAA,SAAS,EAAEiB,sBAAUE,MARJ;AASjB1C,EAAAA,QAAQ,EAAEwC,sBAAUK,IAAV,CAAeD,UATR;AAUjB3C,EAAAA,KAAK,EAAEuC,sBAAUE,MAAV,CAAiBE,UAVP;AAWjBlE,EAAAA,OAAO,EAAE8D,sBAAUM,MAXF;AAYjBxB,EAAAA,SAAS,EAAEkB,sBAAUE,MAZJ;AAajBlB,EAAAA,QAAQ,EAAEgB,sBAAUG,IAbH;AAcjBlB,EAAAA,cAAc,EAAEe,sBAAUG,IAdT;AAejBjB,EAAAA,aAAa,EAAEc,sBAAUC,KAAV,CAAgB,CAAC,UAAD,EAAa,MAAb,EAAqB,YAArB,CAAhB,CAfE;AAgBjBd,EAAAA,sBAAsB,EAAEa,sBAAUG;AAhBjB,C;iCADRlC,W,kBAoBW;AACpBc,EAAAA,SAAS,EAAE,IADS;AAEpBpC,EAAAA,OAAO,EAAE,KAFW;AAGpBsC,EAAAA,cAAc,EAAE;AAHI,C;;eA4HT,wBAAWpF,UAAX,EAAuBoE,WAAvB,C","sourcesContent":["import FormControlLabel from '@material-ui/core/FormControlLabel';\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport { Feedback, color, PreviewPrompt } from '@pie-lib/pie-toolbox/render-ui';\nimport Radio from '@material-ui/core/Radio';\nimport classNames from 'classnames';\n\nimport FeedbackTick from './feedback-tick';\n\nconst CLASS_NAME = 'multiple-choice-component';\n\nconst styleSheet = (theme) => ({\n row: {\n display: 'flex',\n alignItems: 'center',\n backgroundColor: color.background(),\n },\n checkboxHolder: {\n display: 'flex',\n alignItems: 'center',\n backgroundColor: color.background(),\n flex: 1,\n '& label': {\n color: color.text(),\n '& > span': {\n fontSize: 'inherit',\n },\n },\n },\n horizontalLayout: {\n [`& .${CLASS_NAME}`]: {\n // visually reduce right padding, but maintain accessibility padding for checkbox indicators to be circles\n // add margin to the top, left and bottom of the checkbox to keep the same spacing as before\n padding: theme.spacing.unit,\n margin: `${theme.spacing.unit / 2}px 0 ${theme.spacing.unit / 2}px ${theme.spacing.unit / 2}px`,\n },\n },\n belowLayout: {\n '& > label': {\n alignItems: 'flex-start',\n },\n },\n belowLayoutCenter: {\n justifyContent: 'center',\n '& > label': {\n alignItems: 'center',\n },\n },\n belowSelectionComponent: {\n display: 'flex',\n alignItems: 'center',\n '& > span': {\n // visually reduce right padding, but maintain accessibility padding for checkbox indicators to be circles\n marginLeft: `-${theme.spacing.unit}px`,\n },\n },\n srOnly: {\n position: 'absolute',\n left: '-10000px',\n top: 'auto',\n width: '1px',\n height: '1px',\n overflow: 'hidden',\n },\n});\n\nconst formStyleSheet = {\n label: {\n color: `${color.text()} !important`, //'var(--choice-input-color, black)'\n backgroundColor: color.background(),\n letterSpacing: 'normal',\n },\n disabled: {\n // apply to all children\n '& *': {\n cursor: 'not-allowed !important',\n },\n },\n};\n\nexport const StyledFormControlLabel = withStyles(formStyleSheet, {\n name: 'FormControlLabel',\n})((props) => (\n <FormControlLabel {...props} classes={{ label: props.classes.label, disabled: props.classes.disabled }} />\n));\n\nconst colorStyle = (varName, fallback) => ({\n [`&.${CLASS_NAME}`]: {\n color: `var(--choice-input-${varName}, ${fallback}) !important`,\n },\n});\n\nconst inputStyles = {\n 'correct-root': colorStyle('correct-color', color.text()),\n 'correct-checked': colorStyle('correct-selected-color', color.correct()), //green[500]),\n 'correct-disabled': colorStyle('correct-disabled-color', color.disabled()), //'grey'),\n 'incorrect-root': colorStyle('incorrect-color', color.incorrect()),\n 'incorrect-checked': colorStyle('incorrect-checked', color.incorrect()), //orange[500]),\n 'incorrect-disabled': colorStyle('incorrect-disabled-color', color.disabled()),\n root: {\n ...colorStyle('color', color.text()),\n '&:hover': { color: `${color.primaryLight()} !important` },\n },\n checked: colorStyle('selected-color', color.primary()),\n disabled: {\n ...colorStyle('disabled-color', color.text()),\n opacity: 0.6,\n cursor: 'not-allowed !important',\n pointerEvents: 'initial !important',\n },\n focusVisibleUnchecked: {\n outline: `2px solid ${color.focusUncheckedBorder()}`,\n backgroundColor: color.focusUnchecked(),\n },\n focusVisibleChecked: {\n outline: `2px solid ${color.focusCheckedBorder()}`,\n backgroundColor: color.focusChecked(),\n },\n};\n\nexport const StyledCheckbox = withStyles(inputStyles)((props) => {\n const { correctness, classes, checked, onChange, disabled, value, id } = props;\n const key = (k) => (correctness ? `${correctness}-${k}` : k);\n\n const resolved = {\n root: classes[key('root')],\n checked: classes[key('checked')],\n disabled: classes[key('disabled')],\n };\n\n const miniProps = { checked, onChange, disabled, value };\n\n return (\n <Checkbox\n id={id}\n aria-checked={checked}\n focusVisibleClassName={checked ? classes.focusVisibleChecked : classes.focusVisibleUnchecked}\n disableRipple\n {...miniProps}\n className={CLASS_NAME}\n classes={{\n root: resolved.root,\n checked: resolved.checked,\n disabled: `${correctness ? '' : resolved.disabled}`,\n }}\n />\n );\n});\n\nexport const StyledRadio = withStyles(inputStyles)((props) => {\n const { correctness, classes, checked, onChange, disabled, value, id, tagName } = props;\n const key = (k) => (correctness ? `${correctness}-${k}` : k);\n\n const resolved = {\n root: classes[key('root')],\n checked: classes[key('checked')],\n disabled: classes[key('disabled')],\n };\n\n const miniProps = { checked, onChange, disabled, value };\n\n return (\n <Radio\n id={id}\n aria-checked={checked}\n focusVisibleClassName={checked ? classes.focusVisibleChecked : classes.focusVisibleUnchecked}\n disableRipple\n {...miniProps}\n className={CLASS_NAME}\n name={tagName}\n classes={{\n root: resolved.root,\n checked: resolved.checked,\n disabled: `${correctness ? '' : resolved.disabled}`,\n }}\n />\n );\n});\n\nexport class ChoiceInput extends React.Component {\n static propTypes = {\n choiceMode: PropTypes.oneOf(['radio', 'checkbox']),\n displayKey: PropTypes.string,\n checked: PropTypes.bool.isRequired,\n correctness: PropTypes.string,\n disabled: PropTypes.bool.isRequired,\n feedback: PropTypes.string,\n label: PropTypes.string.isRequired,\n rationale: PropTypes.string,\n onChange: PropTypes.func.isRequired,\n value: PropTypes.string.isRequired,\n classes: PropTypes.object,\n className: PropTypes.string,\n hideTick: PropTypes.bool,\n isEvaluateMode: PropTypes.bool,\n choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),\n isSelectionButtonBelow: PropTypes.bool,\n };\n\n static defaultProps = {\n rationale: null,\n checked: false,\n isEvaluateMode: false,\n };\n\n constructor(props) {\n super(props);\n this.onToggleChoice = this.onToggleChoice.bind(this);\n this.choiceId = this.generateChoiceId();\n this.descId = `${this.choiceId}-desc`;\n }\n\n onToggleChoice(event) {\n this.props.onChange(event);\n }\n\n generateChoiceId() {\n return 'choice-' + (Math.random() * 10000).toFixed();\n }\n\n render() {\n const {\n choiceMode,\n disabled,\n displayKey,\n feedback,\n label,\n correctness,\n classes,\n className,\n rationale,\n hideTick,\n isEvaluateMode,\n choicesLayout,\n value,\n checked,\n tagName,\n isSelectionButtonBelow,\n } = this.props;\n\n const Tag = choiceMode === 'checkbox' ? StyledCheckbox : StyledRadio;\n const classSuffix = choiceMode === 'checkbox' ? 'checkbox' : 'radio-button';\n\n const holderClassNames = classNames(classes.checkboxHolder, {\n [classes.horizontalLayout]: choicesLayout === 'horizontal',\n [classes.belowLayout]: isSelectionButtonBelow && choicesLayout !== 'grid',\n [classes.belowLayoutCenter]: isSelectionButtonBelow && choicesLayout === 'grid',\n });\n\n const choicelabel = (\n <>\n {displayKey && !isSelectionButtonBelow ? (\n <span className={classes.row}>\n {displayKey}.{'\\u00A0'}\n <PreviewPrompt className=\"label\" prompt={label} tagName=\"span\" />\n </span>\n ) : (\n <PreviewPrompt className=\"label\" prompt={label} tagName=\"span\" />\n )}\n </>\n );\n\n const screenReaderLabel = (\n <span id={this.descId} className={classes.srOnly}>\n {choiceMode === 'checkbox' ? 'Checkbox to select the answer below' : 'Radio button to select the answer below'}\n </span>\n );\n\n const tagProps = {\n disabled,\n checked,\n correctness,\n tagName,\n value,\n id: this.choiceId,\n onChange: this.onToggleChoice,\n 'aria-describedby': this.descId,\n };\n\n const hasMathOrImage =\n typeof label === 'string' &&\n (label.includes('<math') ||\n label.includes('\\\\(') ||\n label.includes('\\\\[') ||\n label.includes('<img') ||\n label.includes('data-latex') ||\n label.includes('data-raw') ||\n label.includes('<mjx-container'));\n\n const control = isSelectionButtonBelow ? (\n <span className={classes.belowSelectionComponent}>\n {hasMathOrImage && screenReaderLabel}\n <Tag {...tagProps} style={{ padding: 0 }} />\n {displayKey ? `${displayKey}.` : ''}\n </span>\n ) : (\n <>\n {hasMathOrImage && screenReaderLabel}\n <Tag {...tagProps} />\n </>\n );\n\n return (\n <div className={classNames(className, 'corespring-' + classSuffix, 'choice-input')}>\n <div className={classes.row}>\n {!hideTick && isEvaluateMode && <FeedbackTick correctness={correctness} />}\n <div className={classNames(holderClassNames, 'checkbox-holder')}>\n <StyledFormControlLabel\n label={choicelabel}\n value={value}\n htmlFor={this.choiceId}\n labelPlacement={isSelectionButtonBelow ? 'top' : undefined}\n control={control}\n />\n </div>\n </div>\n {rationale && <PreviewPrompt className=\"rationale\" defaultClassName=\"rationale\" prompt={rationale} />}\n <Feedback feedback={feedback} correctness={correctness} />\n </div>\n );\n }\n}\n\nexport default withStyles(styleSheet)(ChoiceInput);\n"],"file":"choice-input.js"}
|
|
1
|
+
{"version":3,"sources":["../src/choice-input.jsx"],"names":["CLASS_NAME","styleSheet","theme","row","display","alignItems","backgroundColor","color","background","checkboxHolder","flex","text","fontSize","horizontalLayout","padding","spacing","unit","margin","belowLayout","belowLayoutCenter","justifyContent","belowSelectionComponent","marginLeft","srOnly","position","left","top","width","height","overflow","formStyleSheet","label","letterSpacing","disabled","cursor","StyledFormControlLabel","name","props","classes","colorStyle","varName","fallback","inputStyles","correct","incorrect","root","primaryLight","checked","primary","opacity","pointerEvents","focusVisibleUnchecked","outline","focusUncheckedBorder","focusUnchecked","focusVisibleChecked","focusCheckedBorder","focusChecked","StyledCheckbox","correctness","onChange","value","id","onKeyDown","inputRef","key","k","resolved","miniProps","StyledRadio","tagName","ChoiceInput","event","choiceMode","isArrowDown","isArrowUp","preventDefault","currentEl","document","getElementById","choiceId","fieldset","closest","groupCheckboxes","Array","from","querySelectorAll","currentIndex","findIndex","el","nextIndex","nextEl","focus","onToggleChoice","bind","generateChoiceId","descId","Math","random","toFixed","displayKey","feedback","className","rationale","hideTick","isEvaluateMode","choicesLayout","isSelectionButtonBelow","Tag","classSuffix","holderClassNames","choicelabel","screenReaderLabel","tagProps","handleKeyDown","hasMathOrImage","includes","control","autoFocusRef","undefined","React","Component","PropTypes","oneOf","string","bool","isRequired","func","object"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;AAEA,IAAMA,UAAU,GAAG,2BAAnB;;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,KAAD;AAAA,SAAY;AAC7BC,IAAAA,GAAG,EAAE;AACHC,MAAAA,OAAO,EAAE,MADN;AAEHC,MAAAA,UAAU,EAAE,QAFT;AAGHC,MAAAA,eAAe,EAAEC,gBAAMC,UAAN;AAHd,KADwB;AAM7BC,IAAAA,cAAc,EAAE;AACdL,MAAAA,OAAO,EAAE,MADK;AAEdC,MAAAA,UAAU,EAAE,QAFE;AAGdC,MAAAA,eAAe,EAAEC,gBAAMC,UAAN,EAHH;AAIdE,MAAAA,IAAI,EAAE,CAJQ;AAKd,iBAAW;AACTH,QAAAA,KAAK,EAAEA,gBAAMI,IAAN,EADE;AAET,oBAAY;AACVC,UAAAA,QAAQ,EAAE;AADA;AAFH;AALG,KANa;AAkB7BC,IAAAA,gBAAgB,oDACPb,UADO,GACQ;AACpB;AACA;AACAc,MAAAA,OAAO,EAAEZ,KAAK,CAACa,OAAN,CAAcC,IAHH;AAIpBC,MAAAA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,CAAgB,CAAC,OAAD,EAAU,UAAV,CAAhB,CADK;AAEjBvB,EAAAA,UAAU,EAAEsB,sBAAUE,MAFL;AAGjB7E,EAAAA,OAAO,EAAE2E,sBAAUG,IAAV,CAAeC,UAHP;AAIjBnE,EAAAA,WAAW,EAAE+D,sBAAUE,MAJN;AAKjB3F,EAAAA,QAAQ,EAAEyF,sBAAUG,IAAV,CAAeC,UALR;AAMjBzB,EAAAA,QAAQ,EAAEqB,sBAAUE,MANH;AAOjB7F,EAAAA,KAAK,EAAE2F,sBAAUE,MAAV,CAAiBE,UAPP;AAQjBvB,EAAAA,SAAS,EAAEmB,sBAAUE,MARJ;AASjBhE,EAAAA,QAAQ,EAAE8D,sBAAUK,IAAV,CAAeD,UATR;AAUjBjE,EAAAA,KAAK,EAAE6D,sBAAUE,MAAV,CAAiBE,UAVP;AAWjBxF,EAAAA,OAAO,EAAEoF,sBAAUM,MAXF;AAYjB1B,EAAAA,SAAS,EAAEoB,sBAAUE,MAZJ;AAajBtD,EAAAA,OAAO,EAAEoD,sBAAUE,MAbF;AAcjBpB,EAAAA,QAAQ,EAAEkB,sBAAUG,IAdH;AAejBpB,EAAAA,cAAc,EAAEiB,sBAAUG,IAfT;AAgBjBnB,EAAAA,aAAa,EAAEgB,sBAAUC,KAAV,CAAgB,CAAC,UAAD,EAAa,MAAb,EAAqB,YAArB,CAAhB,CAhBE;AAiBjBhB,EAAAA,sBAAsB,EAAEe,sBAAUG;AAjBjB,C;iCADRtD,W,kBAqBW;AACpBgC,EAAAA,SAAS,EAAE,IADS;AAEpBxD,EAAAA,OAAO,EAAE,KAFW;AAGpB0D,EAAAA,cAAc,EAAE;AAHI,C;;eA4JT,wBAAWxG,UAAX,EAAuBsE,WAAvB,C","sourcesContent":["import FormControlLabel from '@material-ui/core/FormControlLabel';\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport { Feedback, color, PreviewPrompt } from '@pie-lib/pie-toolbox/render-ui';\nimport Radio from '@material-ui/core/Radio';\nimport classNames from 'classnames';\n\nimport FeedbackTick from './feedback-tick';\n\nconst CLASS_NAME = 'multiple-choice-component';\n\nconst styleSheet = (theme) => ({\n row: {\n display: 'flex',\n alignItems: 'center',\n backgroundColor: color.background(),\n },\n checkboxHolder: {\n display: 'flex',\n alignItems: 'center',\n backgroundColor: color.background(),\n flex: 1,\n '& label': {\n color: color.text(),\n '& > span': {\n fontSize: 'inherit',\n },\n },\n },\n horizontalLayout: {\n [`& .${CLASS_NAME}`]: {\n // visually reduce right padding, but maintain accessibility padding for checkbox indicators to be circles\n // add margin to the top, left and bottom of the checkbox to keep the same spacing as before\n padding: theme.spacing.unit,\n margin: `${theme.spacing.unit / 2}px 0 ${theme.spacing.unit / 2}px ${theme.spacing.unit / 2}px`,\n },\n },\n belowLayout: {\n '& > label': {\n alignItems: 'flex-start',\n },\n },\n belowLayoutCenter: {\n justifyContent: 'center',\n '& > label': {\n alignItems: 'center',\n },\n },\n belowSelectionComponent: {\n display: 'flex',\n alignItems: 'center',\n '& > span': {\n // visually reduce right padding, but maintain accessibility padding for checkbox indicators to be circles\n marginLeft: `-${theme.spacing.unit}px`,\n },\n },\n srOnly: {\n position: 'absolute',\n left: '-10000px',\n top: 'auto',\n width: '1px',\n height: '1px',\n overflow: 'hidden',\n },\n});\n\nconst formStyleSheet = {\n label: {\n color: `${color.text()} !important`, //'var(--choice-input-color, black)'\n backgroundColor: color.background(),\n letterSpacing: 'normal',\n },\n disabled: {\n // apply to all children\n '& *': {\n cursor: 'not-allowed !important',\n },\n },\n};\n\nexport const StyledFormControlLabel = withStyles(formStyleSheet, {\n name: 'FormControlLabel',\n})((props) => (\n <FormControlLabel {...props} classes={{ label: props.classes.label, disabled: props.classes.disabled }} />\n));\n\nconst colorStyle = (varName, fallback) => ({\n [`&.${CLASS_NAME}`]: {\n color: `var(--choice-input-${varName}, ${fallback}) !important`,\n },\n});\n\nconst inputStyles = {\n 'correct-root': colorStyle('correct-color', color.text()),\n 'correct-checked': colorStyle('correct-selected-color', color.correct()), //green[500]),\n 'correct-disabled': colorStyle('correct-disabled-color', color.disabled()), //'grey'),\n 'incorrect-root': colorStyle('incorrect-color', color.incorrect()),\n 'incorrect-checked': colorStyle('incorrect-checked', color.incorrect()), //orange[500]),\n 'incorrect-disabled': colorStyle('incorrect-disabled-color', color.disabled()),\n root: {\n ...colorStyle('color', color.text()),\n '&:hover': { color: `${color.primaryLight()} !important` },\n },\n checked: colorStyle('selected-color', color.primary()),\n disabled: {\n ...colorStyle('disabled-color', color.text()),\n opacity: 0.6,\n cursor: 'not-allowed !important',\n pointerEvents: 'initial !important',\n },\n focusVisibleUnchecked: {\n outline: `2px solid ${color.focusUncheckedBorder()}`,\n backgroundColor: color.focusUnchecked(),\n },\n focusVisibleChecked: {\n outline: `2px solid ${color.focusCheckedBorder()}`,\n backgroundColor: color.focusChecked(),\n },\n};\n\nexport const StyledCheckbox = withStyles(inputStyles)((props) => {\n const { correctness, classes, checked, onChange, disabled, value, id, onKeyDown, inputRef } = props;\n const key = (k) => (correctness ? `${correctness}-${k}` : k);\n\n const resolved = {\n root: classes[key('root')],\n checked: classes[key('checked')],\n disabled: classes[key('disabled')],\n };\n\n const miniProps = { checked, onChange, disabled, value };\n\n return (\n <Checkbox\n id={id}\n inputRef={inputRef}\n aria-checked={checked}\n onKeyDown={onKeyDown}\n focusVisibleClassName={checked ? classes.focusVisibleChecked : classes.focusVisibleUnchecked}\n disableRipple\n {...miniProps}\n className={CLASS_NAME}\n classes={{\n root: resolved.root,\n checked: resolved.checked,\n disabled: `${correctness ? '' : resolved.disabled}`,\n }}\n />\n );\n});\n\nexport const StyledRadio = withStyles(inputStyles)((props) => {\n const { correctness, classes, checked, onChange, disabled, value, id, tagName } = props;\n const key = (k) => (correctness ? `${correctness}-${k}` : k);\n\n const resolved = {\n root: classes[key('root')],\n checked: classes[key('checked')],\n disabled: classes[key('disabled')],\n };\n\n const miniProps = { checked, onChange, disabled, value };\n\n return (\n <Radio\n id={id}\n aria-checked={checked}\n focusVisibleClassName={checked ? classes.focusVisibleChecked : classes.focusVisibleUnchecked}\n disableRipple\n {...miniProps}\n className={CLASS_NAME}\n name={tagName}\n classes={{\n root: resolved.root,\n checked: resolved.checked,\n disabled: `${correctness ? '' : resolved.disabled}`,\n }}\n />\n );\n});\n\nexport class ChoiceInput extends React.Component {\n static propTypes = {\n choiceMode: PropTypes.oneOf(['radio', 'checkbox']),\n displayKey: PropTypes.string,\n checked: PropTypes.bool.isRequired,\n correctness: PropTypes.string,\n disabled: PropTypes.bool.isRequired,\n feedback: PropTypes.string,\n label: PropTypes.string.isRequired,\n rationale: PropTypes.string,\n onChange: PropTypes.func.isRequired,\n value: PropTypes.string.isRequired,\n classes: PropTypes.object,\n className: PropTypes.string,\n tagName: PropTypes.string,\n hideTick: PropTypes.bool,\n isEvaluateMode: PropTypes.bool,\n choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),\n isSelectionButtonBelow: PropTypes.bool,\n };\n\n static defaultProps = {\n rationale: null,\n checked: false,\n isEvaluateMode: false,\n };\n\n constructor(props) {\n super(props);\n this.onToggleChoice = this.onToggleChoice.bind(this);\n this.choiceId = this.generateChoiceId();\n this.descId = `${this.choiceId}-desc`;\n }\n\n onToggleChoice(event) {\n this.props.onChange(event);\n }\n\n generateChoiceId() {\n return 'choice-' + (Math.random() * 10000).toFixed();\n }\n\n handleKeyDown = (event) => {\n const { choiceMode } = this.props;\n\n if (choiceMode !== 'checkbox') return;\n\n const isArrowDown = event.key === 'ArrowDown';\n const isArrowUp = event.key === 'ArrowUp';\n\n if (!isArrowDown && !isArrowUp) return;\n\n event.preventDefault();\n\n const currentEl = document.getElementById(this.choiceId);\n if (!currentEl) return;\n\n const fieldset = currentEl.closest('fieldset');\n if (!fieldset) return;\n\n const groupCheckboxes = Array.from(fieldset.querySelectorAll('input[type=\"checkbox\"]'));\n\n const currentIndex = groupCheckboxes.findIndex((el) => el === currentEl);\n if (currentIndex === -1) return;\n\n const nextIndex = isArrowDown ? currentIndex + 1 : currentIndex - 1;\n const nextEl = groupCheckboxes[nextIndex];\n\n if (nextEl) {\n nextEl.focus();\n }\n };\n\n render() {\n const {\n choiceMode,\n disabled,\n displayKey,\n feedback,\n label,\n correctness,\n classes,\n className,\n rationale,\n hideTick,\n isEvaluateMode,\n choicesLayout,\n value,\n checked,\n tagName,\n isSelectionButtonBelow,\n } = this.props;\n\n const Tag = choiceMode === 'checkbox' ? StyledCheckbox : StyledRadio;\n const classSuffix = choiceMode === 'checkbox' ? 'checkbox' : 'radio-button';\n\n const holderClassNames = classNames(classes.checkboxHolder, {\n [classes.horizontalLayout]: choicesLayout === 'horizontal',\n [classes.belowLayout]: isSelectionButtonBelow && choicesLayout !== 'grid',\n [classes.belowLayoutCenter]: isSelectionButtonBelow && choicesLayout === 'grid',\n });\n\n const choicelabel = (\n <>\n {displayKey && !isSelectionButtonBelow ? (\n <span className={classes.row}>\n {displayKey}.{'\\u00A0'}\n <PreviewPrompt className=\"label\" prompt={label} tagName=\"span\" />\n </span>\n ) : (\n <PreviewPrompt className=\"label\" prompt={label} tagName=\"span\" />\n )}\n </>\n );\n\n const screenReaderLabel = (\n <span id={this.descId} className={classes.srOnly}>\n {choiceMode === 'checkbox' ? 'Checkbox to select the answer below' : 'Radio button to select the answer below'}\n </span>\n );\n\n const tagProps = {\n disabled,\n checked,\n correctness,\n tagName,\n value,\n id: this.choiceId,\n onChange: this.onToggleChoice,\n onKeyDown: this.handleKeyDown,\n 'aria-describedby': this.descId,\n };\n\n const hasMathOrImage =\n typeof label === 'string' &&\n (label.includes('<math') ||\n label.includes('\\\\(') ||\n label.includes('\\\\[') ||\n label.includes('<img') ||\n label.includes('data-latex') ||\n label.includes('data-raw') ||\n label.includes('<mjx-container'));\n\n const control = isSelectionButtonBelow ? (\n <span className={classes.belowSelectionComponent}>\n {hasMathOrImage && screenReaderLabel}\n <Tag {...tagProps} style={{ padding: 0 }} />\n {displayKey ? `${displayKey}.` : ''}\n </span>\n ) : (\n <>\n {hasMathOrImage && screenReaderLabel}\n <Tag {...tagProps} inputRef={this.props.autoFocusRef} />\n </>\n );\n\n return (\n <div className={classNames(className, 'corespring-' + classSuffix, 'choice-input')}>\n <div className={classes.row}>\n {!hideTick && isEvaluateMode && <FeedbackTick correctness={correctness} />}\n <div className={classNames(holderClassNames, 'checkbox-holder')}>\n <StyledFormControlLabel\n label={choicelabel}\n value={value}\n htmlFor={this.choiceId}\n labelPlacement={isSelectionButtonBelow ? 'top' : undefined}\n control={control}\n />\n </div>\n </div>\n {rationale && <PreviewPrompt className=\"rationale\" defaultClassName=\"rationale\" prompt={rationale} />}\n <Feedback feedback={feedback} correctness={correctness} />\n </div>\n );\n }\n}\n\nexport default withStyles(styleSheet)(ChoiceInput);\n"],"file":"choice-input.js"}
|
package/lib/choice.js
CHANGED
|
@@ -89,6 +89,7 @@ var Choice = /*#__PURE__*/function (_React$Component) {
|
|
|
89
89
|
gridColumns = _this$props2.gridColumns,
|
|
90
90
|
isSelectionButtonBelow = _this$props2.isSelectionButtonBelow,
|
|
91
91
|
selectedAnswerBackgroundColor = _this$props2.selectedAnswerBackgroundColor,
|
|
92
|
+
autoFocusRef = _this$props2.autoFocusRef,
|
|
92
93
|
tagName = _this$props2.tagName;
|
|
93
94
|
var choiceClass = 'choice' + (index === choicesLength - 1 ? ' last' : '');
|
|
94
95
|
var feedback = !isEvaluateMode || showCorrect ? '' : choice.feedback;
|
|
@@ -118,7 +119,8 @@ var Choice = /*#__PURE__*/function (_React$Component) {
|
|
|
118
119
|
backgroundColor: choiceBackground
|
|
119
120
|
}
|
|
120
121
|
}, /*#__PURE__*/_react["default"].createElement(_choiceInput["default"], (0, _extends2["default"])({}, choiceProps, {
|
|
121
|
-
className: names
|
|
122
|
+
className: names,
|
|
123
|
+
autoFocusRef: autoFocusRef
|
|
122
124
|
})));
|
|
123
125
|
}
|
|
124
126
|
}]);
|
|
@@ -144,7 +146,8 @@ Choice.propTypes = {
|
|
|
144
146
|
gridColumns: _propTypes["default"].string,
|
|
145
147
|
selectedAnswerBackgroundColor: _propTypes["default"].string,
|
|
146
148
|
tagName: _propTypes["default"].string,
|
|
147
|
-
isSelectionButtonBelow: _propTypes["default"].bool
|
|
149
|
+
isSelectionButtonBelow: _propTypes["default"].bool,
|
|
150
|
+
autoFocusRef: _propTypes["default"].object
|
|
148
151
|
};
|
|
149
152
|
|
|
150
153
|
var _default = (0, _styles.withStyles)(function (theme) {
|
package/lib/choice.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/choice.jsx"],"names":["Choice","choice","props","disabled","onChoiceChanged","index","choicesLength","showCorrect","isEvaluateMode","choiceMode","checked","correctness","displayKey","classes","choicesLayout","gridColumns","isSelectionButtonBelow","selectedAnswerBackgroundColor","tagName","choiceClass","feedback","choiceProps","onChange","names","noBorder","horizontalLayout","choiceBackground","backgroundColor","React","Component","propTypes","PropTypes","oneOf","object","bool","isRequired","func","number","string","theme","paddingTop","spacing","unit","paddingBottom","paddingLeft","paddingRight","borderBottom","palette","grey","marginRight"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;IAEaA,M;;;;;;;;;;;;;;;iGAGA,UAACC,MAAD,EAAY;AACrB,wBAAsC,MAAKC,KAA3C;AAAA,UAAQC,QAAR,eAAQA,QAAR;AAAA,UAAkBC,eAAlB,eAAkBA,eAAlB;;AAEA,UAAI,CAACD,QAAL,EAAe;AACbC,QAAAA,eAAe,CAACH,MAAD,CAAf;AACD;AACF,K;;;;;;WAED,kBAAS;AAAA;;AACP,
|
|
1
|
+
{"version":3,"sources":["../src/choice.jsx"],"names":["Choice","choice","props","disabled","onChoiceChanged","index","choicesLength","showCorrect","isEvaluateMode","choiceMode","checked","correctness","displayKey","classes","choicesLayout","gridColumns","isSelectionButtonBelow","selectedAnswerBackgroundColor","autoFocusRef","tagName","choiceClass","feedback","choiceProps","onChange","names","noBorder","horizontalLayout","choiceBackground","backgroundColor","React","Component","propTypes","PropTypes","oneOf","object","bool","isRequired","func","number","string","theme","paddingTop","spacing","unit","paddingBottom","paddingLeft","paddingRight","borderBottom","palette","grey","marginRight"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;IAEaA,M;;;;;;;;;;;;;;;iGAGA,UAACC,MAAD,EAAY;AACrB,wBAAsC,MAAKC,KAA3C;AAAA,UAAQC,QAAR,eAAQA,QAAR;AAAA,UAAkBC,eAAlB,eAAkBA,eAAlB;;AAEA,UAAI,CAACD,QAAL,EAAe;AACbC,QAAAA,eAAe,CAACH,MAAD,CAAf;AACD;AACF,K;;;;;;WAED,kBAAS;AAAA;;AACP,yBAkBI,KAAKC,KAlBT;AAAA,UACED,MADF,gBACEA,MADF;AAAA,UAEEI,KAFF,gBAEEA,KAFF;AAAA,UAGEC,aAHF,gBAGEA,aAHF;AAAA,UAIEC,WAJF,gBAIEA,WAJF;AAAA,UAKEC,cALF,gBAKEA,cALF;AAAA,UAMEC,UANF,gBAMEA,UANF;AAAA,UAOEN,QAPF,gBAOEA,QAPF;AAAA,UAQEO,OARF,gBAQEA,OARF;AAAA,UASEC,WATF,gBASEA,WATF;AAAA,UAUEC,UAVF,gBAUEA,UAVF;AAAA,UAWEC,OAXF,gBAWEA,OAXF;AAAA,UAYEC,aAZF,gBAYEA,aAZF;AAAA,UAaEC,WAbF,gBAaEA,WAbF;AAAA,UAcEC,sBAdF,gBAcEA,sBAdF;AAAA,UAeEC,6BAfF,gBAeEA,6BAfF;AAAA,UAgBEC,YAhBF,gBAgBEA,YAhBF;AAAA,UAiBEC,OAjBF,gBAiBEA,OAjBF;AAmBA,UAAMC,WAAW,GAAG,YAAYf,KAAK,KAAKC,aAAa,GAAG,CAA1B,GAA8B,OAA9B,GAAwC,EAApD,CAApB;AAEA,UAAMe,QAAQ,GAAG,CAACb,cAA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,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAJ7B;AAKNI,MAAAA,YAAY,sBAAeP,KAAK,CAACQ,OAAN,CAAcC,IAAd,CAAmB,GAAnB,CAAf;AALN,KAD4B;AAQpCxB,IAAAA,QAAQ,EAAE;AACRsB,MAAAA,YAAY,EAAE;AADN,KAR0B;AAWpCrB,IAAAA,gBAAgB,EAAE;AAChBoB,MAAAA,YAAY,EAAEN,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,GADnB;AAEhB,iBAAW;AACTO,QAAAA,WAAW,EAAEV,KAAK,CAACE,OAAN,CAAcC,IADlB,CAET;AACA;AACA;;AAJS;AAFK;AAXkB,GAAZ;AAAA,CAAX,EAoBX3C,MApBW,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\n\nimport ChoiceInput from './choice-input';\n\nexport class Choice extends React.Component {\n static propTypes = {};\n\n onChange = (choice) => {\n const { disabled, onChoiceChanged } = this.props;\n\n if (!disabled) {\n onChoiceChanged(choice);\n }\n };\n\n render() {\n const {\n choice,\n index,\n choicesLength,\n showCorrect,\n isEvaluateMode,\n choiceMode,\n disabled,\n checked,\n correctness,\n displayKey,\n classes,\n choicesLayout,\n gridColumns,\n isSelectionButtonBelow,\n selectedAnswerBackgroundColor,\n autoFocusRef,\n tagName\n } = this.props;\n const choiceClass = 'choice' + (index === choicesLength - 1 ? ' last' : '');\n\n const feedback = !isEvaluateMode || showCorrect ? '' : choice.feedback;\n\n const choiceProps = {\n ...choice,\n checked,\n choiceMode,\n disabled,\n feedback,\n correctness,\n displayKey,\n index,\n choicesLayout,\n gridColumns,\n onChange: this.onChange,\n isEvaluateMode,\n isSelectionButtonBelow,\n tagName,\n };\n\n const names = classNames(classes.choice, {\n [classes.noBorder]: index === choicesLength - 1 || choicesLayout !== 'vertical',\n [classes.horizontalLayout]: choicesLayout === 'horizontal',\n });\n\n const choiceBackground = selectedAnswerBackgroundColor && checked ? selectedAnswerBackgroundColor : 'initial';\n\n return (\n <div className={choiceClass} key={index} style={{ backgroundColor: choiceBackground }}>\n <ChoiceInput {...choiceProps} className={names} autoFocusRef={autoFocusRef} />\n </div>\n );\n }\n}\n\nChoice.propTypes = {\n choiceMode: PropTypes.oneOf(['radio', 'checkbox']),\n choice: PropTypes.object,\n disabled: PropTypes.bool.isRequired,\n onChoiceChanged: PropTypes.func,\n classes: PropTypes.object.isRequired,\n index: PropTypes.number,\n choicesLength: PropTypes.number,\n showCorrect: PropTypes.bool,\n isEvaluateMode: PropTypes.bool,\n checked: PropTypes.bool,\n correctness: PropTypes.string,\n displayKey: PropTypes.string,\n choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),\n gridColumns: PropTypes.string,\n selectedAnswerBackgroundColor: PropTypes.string,\n tagName: PropTypes.string,\n isSelectionButtonBelow: PropTypes.bool,\n autoFocusRef: PropTypes.object,\n};\n\nexport default withStyles((theme) => ({\n choice: {\n paddingTop: theme.spacing.unit * 2.5,\n paddingBottom: theme.spacing.unit + 2,\n paddingLeft: theme.spacing.unit + 2,\n paddingRight: theme.spacing.unit + 2,\n borderBottom: `1px solid ${theme.palette.grey[300]}`,\n },\n noBorder: {\n borderBottom: 'none',\n },\n horizontalLayout: {\n paddingRight: theme.spacing.unit * 2.5,\n '& label': {\n marginRight: theme.spacing.unit,\n // '& span:first-child': {\n // paddingRight: 0\n // }\n },\n },\n}))(Choice);\n"],"file":"choice.js"}
|
package/lib/multiple-choice.js
CHANGED
|
@@ -174,11 +174,26 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleGroupFocus", function (e) {
|
|
178
|
+
var _this$firstInputRef;
|
|
179
|
+
|
|
180
|
+
var fieldset = e.currentTarget;
|
|
181
|
+
var activeEl = document.activeElement;
|
|
182
|
+
|
|
183
|
+
if (fieldset.contains(activeEl) && activeEl !== fieldset) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if ((_this$firstInputRef = _this.firstInputRef) !== null && _this$firstInputRef !== void 0 && _this$firstInputRef.current) {
|
|
188
|
+
_this.firstInputRef.current.focus();
|
|
189
|
+
}
|
|
190
|
+
});
|
|
177
191
|
_this.state = {
|
|
178
192
|
showCorrect: _this.props.alwaysShowCorrect || false,
|
|
179
193
|
maxSelectionsErrorState: false
|
|
180
194
|
};
|
|
181
195
|
_this.onToggle = _this.onToggle.bind((0, _assertThisInitialized2["default"])(_this));
|
|
196
|
+
_this.firstInputRef = /*#__PURE__*/_react["default"].createRef();
|
|
182
197
|
return _this;
|
|
183
198
|
}
|
|
184
199
|
|
|
@@ -337,6 +352,7 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
|
|
|
337
352
|
}, teacherInstructionsDiv) : teacherInstructionsDiv), /*#__PURE__*/_react["default"].createElement("fieldset", {
|
|
338
353
|
tabIndex: 0,
|
|
339
354
|
className: classes.fieldset,
|
|
355
|
+
onFocus: this.handleGroupFocus,
|
|
340
356
|
role: choiceMode === 'radio' ? 'radiogroup' : 'group'
|
|
341
357
|
}, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
342
358
|
className: "prompt",
|
|
@@ -355,6 +371,7 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
|
|
|
355
371
|
style: columnsStyle
|
|
356
372
|
}, choices.map(function (choice, index) {
|
|
357
373
|
return /*#__PURE__*/_react["default"].createElement(_choice["default"], {
|
|
374
|
+
autoFocusRef: index === 0 ? _this3.firstInputRef : null,
|
|
358
375
|
choicesLayout: _this3.props.choicesLayout,
|
|
359
376
|
selectedAnswerBackgroundColor: _this3.props.selectedAnswerBackgroundColor,
|
|
360
377
|
gridColumns: gridColumns,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/multiple-choice.jsx"],"names":["translator","Translator","styles","theme","main","color","text","backgroundColor","background","position","border","partLabel","display","fontSize","margin","fontWeight","paddingBottom","spacing","unit","teacherInstructions","marginBottom","horizontalLayout","flexDirection","flexWrap","gridLayout","fieldset","padding","minWidth","srOnly","left","top","width","height","overflow","errorText","typography","palette","error","paddingTop","MultipleChoice","props","event","target","value","checked","maxSelections","onChoiceChanged","session","length","setState","maxSelectionsErrorState","selected","selector","mode","showCorrect","state","onShowCorrectToggle","choice","isCorrect","correct","isChecked","isSelected","undefined","alwaysShowCorrect","onToggle","bind","sessionValue","indexOf","nextProps","correctResponse","index","keyMode","String","fromCharCode","toUpperCase","choiceMode","classes","disabled","className","choices","gridColumns","prompt","responseCorrect","animationsDisabled","language","isSelectionButtonBelow","minSelections","autoplayAudioEnabled","customAudioButton","isEvaluateMode","showCorrectAnswerToggle","columnsStyle","gridTemplateColumns","selections","teacherInstructionsDiv","getMultipleChoiceMinSelectionErrorMessage","t","lng","renderHeading","hidden","visible","choicesLayout","map","selectedAnswerBackgroundColor","handleChange","hideTick","getChecked","getCorrectness","indexToSymbol","React","Component","PropTypes","string","oneOf","array","object","bool","func","isRequired","number","playImage","pauseImage","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAEA;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;;AAEA,IAAME,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,IAAI,EAAE;AACJC,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADH;AAEJC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN,EAFb;AAGJ,aAAO;AACL,kCAA0B;AADrB,OAHH;AAMJC,MAAAA,QAAQ,EAAE,UANN;AAOJ;AACA,kBAAY;AACVC,QAAAA,MAAM,EAAE;AADE;AARR,KADmB;AAazBC,IAAAA,SAAS,EAAE;AACTC,MAAAA,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,EAAE;AACPJ,IAAAA,KAAK,EAAE;AADA;AADmB,CAA9B;;eAMe,wBAAWzC,MAAX,EAAmBqC,cAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { CorrectAnswerToggle } from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport classNames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color, Collapsible, PreviewPrompt } from '@pie-lib/pie-toolbox/render-ui';\nimport Translator from '@pie-lib/pie-toolbox/translator';\n\nimport StyledChoice from './choice';\n\n// MultipleChoice\n\nconst { translator } = Translator;\n\nconst styles = (theme) => ({\n main: {\n color: color.text(),\n backgroundColor: color.background(),\n '& *': {\n '-webkit-font-smoothing': 'antialiased',\n },\n position: 'relative',\n // remove border from legend tags inside main to override the OT default styles\n '& legend': {\n border: 'none !important',\n },\n },\n partLabel: {\n display: 'block',\n fontSize: 'inherit',\n margin: '0',\n fontWeight: 'normal',\n paddingBottom: theme.spacing.unit * 2,\n },\n teacherInstructions: {\n marginBottom: theme.spacing.unit * 2,\n },\n horizontalLayout: {\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n },\n gridLayout: {\n display: 'grid',\n },\n fieldset: {\n border: '0px',\n padding: '0.01em 0 0 0',\n margin: '0px',\n minWidth: '0px',\n },\n srOnly: {\n position: 'absolute',\n left: '-10000px',\n top: 'auto',\n width: '1px',\n height: '1px',\n overflow: 'hidden',\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing.unit,\n },\n});\n\nexport class MultipleChoice extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n mode: PropTypes.oneOf(['gather', 'view', 'evaluate']),\n choiceMode: PropTypes.oneOf(['radio', 'checkbox']),\n keyMode: PropTypes.oneOf(['numbers', 'letters', 'none']),\n choices: PropTypes.array,\n partLabel: PropTypes.string,\n prompt: PropTypes.string,\n teacherInstructions: PropTypes.string,\n session: PropTypes.object,\n disabled: PropTypes.bool,\n onChoiceChanged: PropTypes.func,\n responseCorrect: PropTypes.bool,\n classes: PropTypes.object.isRequired,\n correctResponse: PropTypes.array,\n choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),\n gridColumns: PropTypes.string,\n alwaysShowCorrect: PropTypes.bool,\n animationsDisabled: PropTypes.bool,\n language: PropTypes.string,\n selectedAnswerBackgroundColor: PropTypes.string,\n onShowCorrectToggle: PropTypes.func,\n isSelectionButtonBelow: PropTypes.bool,\n minSelections: PropTypes.number,\n maxSelections: PropTypes.number,\n autoplayAudioEnabled: PropTypes.bool,\n customAudioButton: {\n playImage: PropTypes.string,\n pauseImage: PropTypes.string,\n }\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n showCorrect: this.props.alwaysShowCorrect || false,\n maxSelectionsErrorState: false,\n };\n\n this.onToggle = this.onToggle.bind(this);\n }\n\n isSelected(value) {\n const sessionValue = this.props.session && this.props.session.value;\n\n return sessionValue && sessionValue.indexOf && sessionValue.indexOf(value) >= 0;\n }\n\n // handleChange was added for accessibility. Please see comments and videos from PD-2441.\n handleChange = (event) => {\n const { value, checked } = event.target;\n const { maxSelections, onChoiceChanged, session } = this.props;\n\n if (session.value && session.value.length >= maxSelections) {\n // show/hide max selections error when user select/deselect an answer\n this.setState({ maxSelectionsErrorState: checked });\n\n if (checked) {\n // prevent selecting more answers\n return;\n }\n }\n\n onChoiceChanged({ value, selected: checked, selector: 'Mouse' });\n };\n\n onToggle = () => {\n if (this.props.mode === 'evaluate') {\n this.setState({ showCorrect: !this.state.showCorrect }, () => {\n if (this.props.onShowCorrectToggle) {\n this.props.onShowCorrectToggle();\n }\n });\n }\n };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n if (!nextProps.correctResponse && this.state.showCorrect !== false) {\n this.setState({ showCorrect: false }, () => {\n if (this.props.onShowCorrectToggle) {\n this.props.onShowCorrectToggle();\n }\n });\n }\n\n if (nextProps.alwaysShowCorrect && this.state.showCorrect !== true) {\n this.setState({ showCorrect: true }, () => {\n if (this.props.onShowCorrectToggle) {\n this.props.onShowCorrectToggle();\n }\n });\n }\n }\n\n indexToSymbol(index) {\n if (this.props.keyMode === 'numbers') {\n return `${index + 1}`;\n }\n\n if (this.props.keyMode === 'letters') {\n return String.fromCharCode(97 + index).toUpperCase();\n }\n\n return '';\n }\n\n getCorrectness = (choice = {}) => {\n const isCorrect = choice.correct;\n const isChecked = this.isSelected(choice.value);\n\n if (this.state.showCorrect) {\n return isCorrect ? 'correct' : undefined;\n }\n\n if (isCorrect) {\n if (isChecked) {\n // A correct answer is selected: marked with a green checkmark\n return 'correct';\n } else {\n // A correct answer is NOT selected: marked with an orange X\n return 'incorrect';\n }\n } else {\n if (isChecked) {\n // An incorrect answer is selected: marked with an orange X\n return 'incorrect';\n } else {\n // An incorrect answer is NOT selected: not marked\n return undefined;\n }\n }\n };\n\n getChecked(choice) {\n if (this.state.showCorrect) {\n return choice.correct || false;\n }\n\n return this.isSelected(choice.value);\n }\n\n // renderHeading function was added for accessibility.\n renderHeading() {\n const { mode, choiceMode, classes } = this.props;\n\n if (mode !== 'gather') {\n return null;\n }\n\n return choiceMode === 'radio' ? (\n <h2 className={classes.srOnly}>Multiple Choice Question</h2>\n ) : (\n <h2 className={classes.srOnly}>Multiple Select Question</h2>\n );\n }\n\n render() {\n const {\n mode,\n disabled,\n className,\n choices = [],\n choiceMode,\n gridColumns,\n partLabel,\n prompt,\n responseCorrect,\n teacherInstructions,\n classes,\n alwaysShowCorrect,\n animationsDisabled,\n language,\n isSelectionButtonBelow,\n minSelections,\n maxSelections,\n autoplayAudioEnabled,\n session,\n customAudioButton\n } = this.props;\n const { showCorrect, maxSelectionsErrorState } = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;\n const columnsStyle = gridColumns > 1 ? { gridTemplateColumns: `repeat(${gridColumns}, 1fr)` } : undefined;\n const selections = (session.value && session.value.length) || 0;\n\n const teacherInstructionsDiv = (\n <PreviewPrompt\n tagName=\"div\"\n className=\"prompt\"\n defaultClassName=\"teacher-instructions\"\n prompt={teacherInstructions}\n />\n );\n\n const getMultipleChoiceMinSelectionErrorMessage = () => {\n if (minSelections && maxSelections) {\n return minSelections === maxSelections\n ? translator.t('translation:multipleChoice:minmaxSelections_equal', { lng: language, minSelections })\n : translator.t('translation:multipleChoice:minmaxSelections_range', { lng: language, minSelections, maxSelections });\n }\n\n if (minSelections) {\n return translator.t('translation:multipleChoice:minSelections', { lng: language, minSelections });\n }\n\n return '';\n };\n\n return (\n <div id={'main-container'} className={classNames(classes.main, className, 'multiple-choice')}>\n {partLabel && <h3 className={classes.partLabel}>{partLabel}</h3>}\n\n {this.renderHeading()}\n\n {teacherInstructions && (\n <div className={classes.teacherInstructions}>\n {!animationsDisabled ? (\n <Collapsible\n labels={{\n hidden: 'Show Teacher Instructions',\n visible: 'Hide Teacher Instructions',\n }}\n >\n {teacherInstructionsDiv}\n </Collapsible>\n ) : (\n teacherInstructionsDiv\n )}\n </div>\n )}\n\n <fieldset tabIndex={0} className={classes.fieldset} role={choiceMode === 'radio' ? 'radiogroup' : 'group'}>\n <PreviewPrompt\n className=\"prompt\"\n defaultClassName=\"prompt\"\n prompt={prompt}\n tagName={'legend'}\n autoplayAudioEnabled={autoplayAudioEnabled}\n customAudioButton={customAudioButton}\n />\n\n {!alwaysShowCorrect && (\n <CorrectAnswerToggle\n show={showCorrectAnswerToggle}\n toggled={showCorrect}\n onToggle={this.onToggle.bind(this)}\n language={language}\n />\n )}\n\n <div\n className={classNames({\n [classes.gridLayout]: this.props.choicesLayout === 'grid',\n [classes.horizontalLayout]: this.props.choicesLayout === 'horizontal',\n })}\n style={columnsStyle}\n >\n {choices.map((choice, index) => (\n <StyledChoice\n choicesLayout={this.props.choicesLayout}\n selectedAnswerBackgroundColor={this.props.selectedAnswerBackgroundColor}\n gridColumns={gridColumns}\n key={`choice-${index}`}\n choice={choice}\n index={index}\n choicesLength={choices.length}\n showCorrect={showCorrect}\n isEvaluateMode={isEvaluateMode}\n choiceMode={choiceMode}\n disabled={disabled}\n tagName={partLabel ? `group-${partLabel}`: 'group'}\n onChoiceChanged={this.handleChange}\n hideTick={choice.hideTick}\n checked={this.getChecked(choice)}\n correctness={isEvaluateMode ? this.getCorrectness(choice) : undefined}\n displayKey={this.indexToSymbol(index)}\n isSelectionButtonBelow={isSelectionButtonBelow}\n />\n ))}\n </div>\n </fieldset>\n\n {choiceMode === 'checkbox' && (selections < minSelections) && (\n <div className={classes.errorText}>\n {getMultipleChoiceMinSelectionErrorMessage()}\n </div>\n )}\n {choiceMode === 'checkbox' && maxSelectionsErrorState && (\n <div className={classes.errorText}>\n {translator.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {\n lng: language,\n maxSelections,\n })}\n </div>\n )}\n </div>\n );\n }\n}\n\nMultipleChoice.defaultProps = {\n session: {\n value: [],\n },\n};\n\nexport default withStyles(styles)(MultipleChoice);\n"],"file":"multiple-choice.js"}
|
|
1
|
+
{"version":3,"sources":["../src/multiple-choice.jsx"],"names":["translator","Translator","styles","theme","main","color","text","backgroundColor","background","position","border","partLabel","display","fontSize","margin","fontWeight","paddingBottom","spacing","unit","teacherInstructions","marginBottom","horizontalLayout","flexDirection","flexWrap","gridLayout","fieldset","padding","minWidth","srOnly","left","top","width","height","overflow","errorText","typography","palette","error","paddingTop","MultipleChoice","props","event","target","value","checked","maxSelections","onChoiceChanged","session","length","setState","maxSelectionsErrorState","selected","selector","mode","showCorrect","state","onShowCorrectToggle","choice","isCorrect","correct","isChecked","isSelected","undefined","e","currentTarget","activeEl","document","activeElement","contains","firstInputRef","current","focus","alwaysShowCorrect","onToggle","bind","React","createRef","sessionValue","indexOf","nextProps","correctResponse","index","keyMode","String","fromCharCode","toUpperCase","choiceMode","classes","disabled","className","choices","gridColumns","prompt","responseCorrect","animationsDisabled","language","isSelectionButtonBelow","minSelections","autoplayAudioEnabled","customAudioButton","isEvaluateMode","showCorrectAnswerToggle","columnsStyle","gridTemplateColumns","selections","teacherInstructionsDiv","getMultipleChoiceMinSelectionErrorMessage","t","lng","renderHeading","hidden","visible","handleGroupFocus","choicesLayout","map","selectedAnswerBackgroundColor","handleChange","hideTick","getChecked","getCorrectness","indexToSymbol","Component","PropTypes","string","oneOf","array","object","bool","func","isRequired","number","playImage","pauseImage","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAEA;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;;AAEA,IAAME,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,IAAI,EAAE;AACJC,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADH;AAEJC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN,EAFb;AAGJ,aAAO;AACL,kCAA0B;AADrB,OAHH;AAMJC,MAAAA,QAAQ,EAAE,UANN;AAOJ;AACA,kBAAY;AACVC,QAAAA,MAAM,EAAE;AADE;AARR,KADmB;AAazBC,IAAAA,SAAS,EAAE;AACTC,MAAAA,OAAO,EAAE,OADA;AAETC,MAAAA,QAAQ,EAAE,SAFD;AAGTC,MAAAA,MAAM,EAAE,GAHC;AAITC,MAAAA,UAAU,EAAE,QAJH;AAKTC,MAAAA,aAAa,EAAEb,KAAK,CAACc,OAAN,CAAcC,IAAd,GAAqB;AAL3B,KAbc;AAoBzBC,IAAAA,mBAAmB,EAAE;AACnBC,MAAAA,YAAY,EAAEjB,KAAK,CAACc,OAAN,CAAcC,IAAd,GAAqB;AADhB,KApBI;AAuBzBG,IAAAA,gBAAgB,EAAE;AAChBT,MAAAA,OAAO,EAAE,MADO;AAEhBU,MAAAA,aAAa,EAAE,KAFC;AAGhBC,MAAAA,QAAQ,EAAE;AAHM,KAvBO;AA4BzBC,IAAAA,UAAU,EAAE;AACVZ,MAAAA,OAAO,EAAE;AADC,KA5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BF,C;AAmUrBpF,cAAc,CAAC8F,YAAf,GAA8B;AAC5BtF,EAAAA,OAAO,EAAE;AACPJ,IAAAA,KAAK,EAAE;AADA;AADmB,CAA9B;;eAMe,wBAAWzC,MAAX,EAAmBqC,cAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { CorrectAnswerToggle } from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport classNames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color, Collapsible, PreviewPrompt } from '@pie-lib/pie-toolbox/render-ui';\nimport Translator from '@pie-lib/pie-toolbox/translator';\n\nimport StyledChoice from './choice';\n\n// MultipleChoice\n\nconst { translator } = Translator;\n\nconst styles = (theme) => ({\n main: {\n color: color.text(),\n backgroundColor: color.background(),\n '& *': {\n '-webkit-font-smoothing': 'antialiased',\n },\n position: 'relative',\n // remove border from legend tags inside main to override the OT default styles\n '& legend': {\n border: 'none !important',\n },\n },\n partLabel: {\n display: 'block',\n fontSize: 'inherit',\n margin: '0',\n fontWeight: 'normal',\n paddingBottom: theme.spacing.unit * 2,\n },\n teacherInstructions: {\n marginBottom: theme.spacing.unit * 2,\n },\n horizontalLayout: {\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n },\n gridLayout: {\n display: 'grid',\n },\n fieldset: {\n border: '0px',\n padding: '0.01em 0 0 0',\n margin: '0px',\n minWidth: '0px',\n },\n srOnly: {\n position: 'absolute',\n left: '-10000px',\n top: 'auto',\n width: '1px',\n height: '1px',\n overflow: 'hidden',\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing.unit,\n },\n});\n\nexport class MultipleChoice extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n mode: PropTypes.oneOf(['gather', 'view', 'evaluate']),\n choiceMode: PropTypes.oneOf(['radio', 'checkbox']),\n keyMode: PropTypes.oneOf(['numbers', 'letters', 'none']),\n choices: PropTypes.array,\n partLabel: PropTypes.string,\n prompt: PropTypes.string,\n teacherInstructions: PropTypes.string,\n session: PropTypes.object,\n disabled: PropTypes.bool,\n onChoiceChanged: PropTypes.func,\n responseCorrect: PropTypes.bool,\n classes: PropTypes.object.isRequired,\n correctResponse: PropTypes.array,\n choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),\n gridColumns: PropTypes.string,\n alwaysShowCorrect: PropTypes.bool,\n animationsDisabled: PropTypes.bool,\n language: PropTypes.string,\n selectedAnswerBackgroundColor: PropTypes.string,\n onShowCorrectToggle: PropTypes.func,\n isSelectionButtonBelow: PropTypes.bool,\n minSelections: PropTypes.number,\n maxSelections: PropTypes.number,\n autoplayAudioEnabled: PropTypes.bool,\n customAudioButton: {\n playImage: PropTypes.string,\n pauseImage: PropTypes.string,\n },\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n showCorrect: this.props.alwaysShowCorrect || false,\n maxSelectionsErrorState: false,\n };\n\n this.onToggle = this.onToggle.bind(this);\n this.firstInputRef = React.createRef();\n }\n\n isSelected(value) {\n const sessionValue = this.props.session && this.props.session.value;\n\n return sessionValue && sessionValue.indexOf && sessionValue.indexOf(value) >= 0;\n }\n\n // handleChange was added for accessibility. Please see comments and videos from PD-2441.\n handleChange = (event) => {\n const { value, checked } = event.target;\n const { maxSelections, onChoiceChanged, session } = this.props;\n\n if (session.value && session.value.length >= maxSelections) {\n // show/hide max selections error when user select/deselect an answer\n this.setState({ maxSelectionsErrorState: checked });\n\n if (checked) {\n // prevent selecting more answers\n return;\n }\n }\n\n onChoiceChanged({ value, selected: checked, selector: 'Mouse' });\n };\n\n onToggle = () => {\n if (this.props.mode === 'evaluate') {\n this.setState({ showCorrect: !this.state.showCorrect }, () => {\n if (this.props.onShowCorrectToggle) {\n this.props.onShowCorrectToggle();\n }\n });\n }\n };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n if (!nextProps.correctResponse && this.state.showCorrect !== false) {\n this.setState({ showCorrect: false }, () => {\n if (this.props.onShowCorrectToggle) {\n this.props.onShowCorrectToggle();\n }\n });\n }\n\n if (nextProps.alwaysShowCorrect && this.state.showCorrect !== true) {\n this.setState({ showCorrect: true }, () => {\n if (this.props.onShowCorrectToggle) {\n this.props.onShowCorrectToggle();\n }\n });\n }\n }\n\n indexToSymbol(index) {\n if (this.props.keyMode === 'numbers') {\n return `${index + 1}`;\n }\n\n if (this.props.keyMode === 'letters') {\n return String.fromCharCode(97 + index).toUpperCase();\n }\n\n return '';\n }\n\n getCorrectness = (choice = {}) => {\n const isCorrect = choice.correct;\n const isChecked = this.isSelected(choice.value);\n\n if (this.state.showCorrect) {\n return isCorrect ? 'correct' : undefined;\n }\n\n if (isCorrect) {\n if (isChecked) {\n // A correct answer is selected: marked with a green checkmark\n return 'correct';\n } else {\n // A correct answer is NOT selected: marked with an orange X\n return 'incorrect';\n }\n } else {\n if (isChecked) {\n // An incorrect answer is selected: marked with an orange X\n return 'incorrect';\n } else {\n // An incorrect answer is NOT selected: not marked\n return undefined;\n }\n }\n };\n\n getChecked(choice) {\n if (this.state.showCorrect) {\n return choice.correct || false;\n }\n\n return this.isSelected(choice.value);\n }\n\n // renderHeading function was added for accessibility.\n renderHeading() {\n const { mode, choiceMode, classes } = this.props;\n\n if (mode !== 'gather') {\n return null;\n }\n\n return choiceMode === 'radio' ? (\n <h2 className={classes.srOnly}>Multiple Choice Question</h2>\n ) : (\n <h2 className={classes.srOnly}>Multiple Select Question</h2>\n );\n }\n\n handleGroupFocus = (e) => {\n const fieldset = e.currentTarget;\n const activeEl = document.activeElement;\n\n if (fieldset.contains(activeEl) && activeEl !== fieldset) {\n return;\n }\n\n if (this.firstInputRef?.current) {\n this.firstInputRef.current.focus();\n }\n };\n\n render() {\n const {\n mode,\n disabled,\n className,\n choices = [],\n choiceMode,\n gridColumns,\n partLabel,\n prompt,\n responseCorrect,\n teacherInstructions,\n classes,\n alwaysShowCorrect,\n animationsDisabled,\n language,\n isSelectionButtonBelow,\n minSelections,\n maxSelections,\n autoplayAudioEnabled,\n session,\n customAudioButton,\n } = this.props;\n const { showCorrect, maxSelectionsErrorState } = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;\n const columnsStyle = gridColumns > 1 ? { gridTemplateColumns: `repeat(${gridColumns}, 1fr)` } : undefined;\n const selections = (session.value && session.value.length) || 0;\n\n const teacherInstructionsDiv = (\n <PreviewPrompt\n tagName=\"div\"\n className=\"prompt\"\n defaultClassName=\"teacher-instructions\"\n prompt={teacherInstructions}\n />\n );\n\n const getMultipleChoiceMinSelectionErrorMessage = () => {\n if (minSelections && maxSelections) {\n return minSelections === maxSelections\n ? translator.t('translation:multipleChoice:minmaxSelections_equal', { lng: language, minSelections })\n : translator.t('translation:multipleChoice:minmaxSelections_range', {\n lng: language,\n minSelections,\n maxSelections,\n });\n }\n\n if (minSelections) {\n return translator.t('translation:multipleChoice:minSelections', { lng: language, minSelections });\n }\n\n return '';\n };\n\n return (\n <div id={'main-container'} className={classNames(classes.main, className, 'multiple-choice')}>\n {partLabel && <h3 className={classes.partLabel}>{partLabel}</h3>}\n\n {this.renderHeading()}\n\n {teacherInstructions && (\n <div className={classes.teacherInstructions}>\n {!animationsDisabled ? (\n <Collapsible\n labels={{\n hidden: 'Show Teacher Instructions',\n visible: 'Hide Teacher Instructions',\n }}\n >\n {teacherInstructionsDiv}\n </Collapsible>\n ) : (\n teacherInstructionsDiv\n )}\n </div>\n )}\n\n <fieldset\n tabIndex={0}\n className={classes.fieldset}\n onFocus={this.handleGroupFocus}\n role={choiceMode === 'radio' ? 'radiogroup' : 'group'}\n >\n <PreviewPrompt\n className=\"prompt\"\n defaultClassName=\"prompt\"\n prompt={prompt}\n tagName={'legend'}\n autoplayAudioEnabled={autoplayAudioEnabled}\n customAudioButton={customAudioButton}\n />\n\n {!alwaysShowCorrect && (\n <CorrectAnswerToggle\n show={showCorrectAnswerToggle}\n toggled={showCorrect}\n onToggle={this.onToggle.bind(this)}\n language={language}\n />\n )}\n\n <div\n className={classNames({\n [classes.gridLayout]: this.props.choicesLayout === 'grid',\n [classes.horizontalLayout]: this.props.choicesLayout === 'horizontal',\n })}\n style={columnsStyle}\n >\n {choices.map((choice, index) => (\n <StyledChoice\n autoFocusRef={index === 0 ? this.firstInputRef : null}\n choicesLayout={this.props.choicesLayout}\n selectedAnswerBackgroundColor={this.props.selectedAnswerBackgroundColor}\n gridColumns={gridColumns}\n key={`choice-${index}`}\n choice={choice}\n index={index}\n choicesLength={choices.length}\n showCorrect={showCorrect}\n isEvaluateMode={isEvaluateMode}\n choiceMode={choiceMode}\n disabled={disabled}\n tagName={partLabel ? `group-${partLabel}` : 'group'}\n onChoiceChanged={this.handleChange}\n hideTick={choice.hideTick}\n checked={this.getChecked(choice)}\n correctness={isEvaluateMode ? this.getCorrectness(choice) : undefined}\n displayKey={this.indexToSymbol(index)}\n isSelectionButtonBelow={isSelectionButtonBelow}\n />\n ))}\n </div>\n </fieldset>\n\n {choiceMode === 'checkbox' && selections < minSelections && (\n <div className={classes.errorText}>{getMultipleChoiceMinSelectionErrorMessage()}</div>\n )}\n {choiceMode === 'checkbox' && maxSelectionsErrorState && (\n <div className={classes.errorText}>\n {translator.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {\n lng: language,\n maxSelections,\n })}\n </div>\n )}\n </div>\n );\n }\n}\n\nMultipleChoice.defaultProps = {\n session: {\n value: [],\n },\n};\n\nexport default withStyles(styles)(MultipleChoice);\n"],"file":"multiple-choice.js"}
|
package/module/element.js
CHANGED
|
@@ -12239,7 +12239,7 @@ const inputStyles = {
|
|
|
12239
12239
|
}
|
|
12240
12240
|
};
|
|
12241
12241
|
const StyledCheckbox = styles$b.withStyles(inputStyles)(props => {
|
|
12242
|
-
const {correctness, classes, checked, onChange, disabled, value, id} = props;
|
|
12242
|
+
const {correctness, classes, checked, onChange, disabled, value, id, onKeyDown, inputRef} = props;
|
|
12243
12243
|
const key = k => correctness ? `${correctness}-${k}` : k;
|
|
12244
12244
|
const resolved = {
|
|
12245
12245
|
root: classes[key('root')],
|
|
@@ -12254,7 +12254,9 @@ const StyledCheckbox = styles$b.withStyles(inputStyles)(props => {
|
|
|
12254
12254
|
};
|
|
12255
12255
|
return React$4.createElement(Checkbox, {
|
|
12256
12256
|
id: id,
|
|
12257
|
+
inputRef: inputRef,
|
|
12257
12258
|
'aria-checked': checked,
|
|
12259
|
+
onKeyDown: onKeyDown,
|
|
12258
12260
|
focusVisibleClassName: checked ? classes.focusVisibleChecked : classes.focusVisibleUnchecked,
|
|
12259
12261
|
disableRipple: true,
|
|
12260
12262
|
...miniProps,
|
|
@@ -12301,7 +12303,7 @@ const StyledRadio = styles$b.withStyles(inputStyles)(props => {
|
|
|
12301
12303
|
__self: undefined,
|
|
12302
12304
|
__source: {
|
|
12303
12305
|
fileName: _jsxFileName$3,
|
|
12304
|
-
lineNumber:
|
|
12306
|
+
lineNumber: 167
|
|
12305
12307
|
}
|
|
12306
12308
|
});
|
|
12307
12309
|
});
|
|
@@ -12320,6 +12322,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12320
12322
|
value: PropTypes$3.string.isRequired,
|
|
12321
12323
|
classes: PropTypes$3.object,
|
|
12322
12324
|
className: PropTypes$3.string,
|
|
12325
|
+
tagName: PropTypes$3.string,
|
|
12323
12326
|
hideTick: PropTypes$3.bool,
|
|
12324
12327
|
isEvaluateMode: PropTypes$3.bool,
|
|
12325
12328
|
choicesLayout: PropTypes$3.oneOf(['vertical', 'grid', 'horizontal']),
|
|
@@ -12335,6 +12338,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12335
12338
|
}
|
|
12336
12339
|
constructor(props) {
|
|
12337
12340
|
super(props);
|
|
12341
|
+
ChoiceInput.prototype.__init.call(this);
|
|
12338
12342
|
this.onToggleChoice = this.onToggleChoice.bind(this);
|
|
12339
12343
|
this.choiceId = this.generateChoiceId();
|
|
12340
12344
|
this.descId = `${this.choiceId}-desc`;
|
|
@@ -12345,6 +12349,28 @@ class ChoiceInput extends React$4.Component {
|
|
|
12345
12349
|
generateChoiceId() {
|
|
12346
12350
|
return 'choice-' + (Math.random() * 10000).toFixed();
|
|
12347
12351
|
}
|
|
12352
|
+
__init() {
|
|
12353
|
+
this.handleKeyDown = event => {
|
|
12354
|
+
const {choiceMode} = this.props;
|
|
12355
|
+
if (choiceMode !== 'checkbox') return;
|
|
12356
|
+
const isArrowDown = event.key === 'ArrowDown';
|
|
12357
|
+
const isArrowUp = event.key === 'ArrowUp';
|
|
12358
|
+
if (!isArrowDown && !isArrowUp) return;
|
|
12359
|
+
event.preventDefault();
|
|
12360
|
+
const currentEl = document.getElementById(this.choiceId);
|
|
12361
|
+
if (!currentEl) return;
|
|
12362
|
+
const fieldset = currentEl.closest('fieldset');
|
|
12363
|
+
if (!fieldset) return;
|
|
12364
|
+
const groupCheckboxes = Array.from(fieldset.querySelectorAll('input[type="checkbox"]'));
|
|
12365
|
+
const currentIndex = groupCheckboxes.findIndex(el => el === currentEl);
|
|
12366
|
+
if (currentIndex === -1) return;
|
|
12367
|
+
const nextIndex = isArrowDown ? currentIndex + 1 : currentIndex - 1;
|
|
12368
|
+
const nextEl = groupCheckboxes[nextIndex];
|
|
12369
|
+
if (nextEl) {
|
|
12370
|
+
nextEl.focus();
|
|
12371
|
+
}
|
|
12372
|
+
};
|
|
12373
|
+
}
|
|
12348
12374
|
render() {
|
|
12349
12375
|
const {choiceMode, disabled, displayKey, feedback, label, correctness, classes, className, rationale, hideTick, isEvaluateMode, choicesLayout, value, checked, tagName, isSelectionButtonBelow} = this.props;
|
|
12350
12376
|
const Tag = choiceMode === 'checkbox' ? StyledCheckbox : StyledRadio;
|
|
@@ -12359,7 +12385,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12359
12385
|
__self: this,
|
|
12360
12386
|
__source: {
|
|
12361
12387
|
fileName: _jsxFileName$3,
|
|
12362
|
-
lineNumber:
|
|
12388
|
+
lineNumber: 289
|
|
12363
12389
|
}
|
|
12364
12390
|
}, displayKey, ".", '\u00A0', React$4.createElement(PreviewPrompt$1, {
|
|
12365
12391
|
className: "label",
|
|
@@ -12368,7 +12394,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12368
12394
|
__self: this,
|
|
12369
12395
|
__source: {
|
|
12370
12396
|
fileName: _jsxFileName$3,
|
|
12371
|
-
lineNumber:
|
|
12397
|
+
lineNumber: 291
|
|
12372
12398
|
}
|
|
12373
12399
|
})) : React$4.createElement(PreviewPrompt$1, {
|
|
12374
12400
|
className: "label",
|
|
@@ -12377,7 +12403,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12377
12403
|
__self: this,
|
|
12378
12404
|
__source: {
|
|
12379
12405
|
fileName: _jsxFileName$3,
|
|
12380
|
-
lineNumber:
|
|
12406
|
+
lineNumber: 294
|
|
12381
12407
|
}
|
|
12382
12408
|
}));
|
|
12383
12409
|
const screenReaderLabel = React$4.createElement('span', {
|
|
@@ -12386,7 +12412,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12386
12412
|
__self: this,
|
|
12387
12413
|
__source: {
|
|
12388
12414
|
fileName: _jsxFileName$3,
|
|
12389
|
-
lineNumber:
|
|
12415
|
+
lineNumber: 300
|
|
12390
12416
|
}
|
|
12391
12417
|
}, choiceMode === 'checkbox' ? 'Checkbox to select the answer below' : 'Radio button to select the answer below');
|
|
12392
12418
|
const tagProps = {
|
|
@@ -12397,6 +12423,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12397
12423
|
value,
|
|
12398
12424
|
id: this.choiceId,
|
|
12399
12425
|
onChange: this.onToggleChoice,
|
|
12426
|
+
onKeyDown: this.handleKeyDown,
|
|
12400
12427
|
'aria-describedby': this.descId
|
|
12401
12428
|
};
|
|
12402
12429
|
const hasMathOrImage = typeof label === 'string' && (label.includes('<math') || label.includes('\\(') || label.includes('\\[') || label.includes('<img') || label.includes('data-latex') || label.includes('data-raw') || label.includes('<mjx-container'));
|
|
@@ -12405,7 +12432,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12405
12432
|
__self: this,
|
|
12406
12433
|
__source: {
|
|
12407
12434
|
fileName: _jsxFileName$3,
|
|
12408
|
-
lineNumber:
|
|
12435
|
+
lineNumber: 328
|
|
12409
12436
|
}
|
|
12410
12437
|
}, hasMathOrImage && screenReaderLabel, React$4.createElement(Tag, {
|
|
12411
12438
|
...tagProps,
|
|
@@ -12415,14 +12442,15 @@ class ChoiceInput extends React$4.Component {
|
|
|
12415
12442
|
__self: this,
|
|
12416
12443
|
__source: {
|
|
12417
12444
|
fileName: _jsxFileName$3,
|
|
12418
|
-
lineNumber:
|
|
12445
|
+
lineNumber: 330
|
|
12419
12446
|
}
|
|
12420
12447
|
}), displayKey ? `${displayKey}.` : '') : React$4.createElement(React$4.Fragment, null, hasMathOrImage && screenReaderLabel, React$4.createElement(Tag, {
|
|
12421
12448
|
...tagProps,
|
|
12449
|
+
inputRef: this.props.autoFocusRef,
|
|
12422
12450
|
__self: this,
|
|
12423
12451
|
__source: {
|
|
12424
12452
|
fileName: _jsxFileName$3,
|
|
12425
|
-
lineNumber:
|
|
12453
|
+
lineNumber: 336
|
|
12426
12454
|
}
|
|
12427
12455
|
}));
|
|
12428
12456
|
return React$4.createElement('div', {
|
|
@@ -12430,28 +12458,28 @@ class ChoiceInput extends React$4.Component {
|
|
|
12430
12458
|
__self: this,
|
|
12431
12459
|
__source: {
|
|
12432
12460
|
fileName: _jsxFileName$3,
|
|
12433
|
-
lineNumber:
|
|
12461
|
+
lineNumber: 341
|
|
12434
12462
|
}
|
|
12435
12463
|
}, React$4.createElement('div', {
|
|
12436
12464
|
className: classes.row,
|
|
12437
12465
|
__self: this,
|
|
12438
12466
|
__source: {
|
|
12439
12467
|
fileName: _jsxFileName$3,
|
|
12440
|
-
lineNumber:
|
|
12468
|
+
lineNumber: 342
|
|
12441
12469
|
}
|
|
12442
12470
|
}, !hideTick && isEvaluateMode && React$4.createElement(FeedbackTick$1, {
|
|
12443
12471
|
correctness: correctness,
|
|
12444
12472
|
__self: this,
|
|
12445
12473
|
__source: {
|
|
12446
12474
|
fileName: _jsxFileName$3,
|
|
12447
|
-
lineNumber:
|
|
12475
|
+
lineNumber: 343
|
|
12448
12476
|
}
|
|
12449
12477
|
}), React$4.createElement('div', {
|
|
12450
12478
|
className: classNames$2(holderClassNames, 'checkbox-holder'),
|
|
12451
12479
|
__self: this,
|
|
12452
12480
|
__source: {
|
|
12453
12481
|
fileName: _jsxFileName$3,
|
|
12454
|
-
lineNumber:
|
|
12482
|
+
lineNumber: 344
|
|
12455
12483
|
}
|
|
12456
12484
|
}, React$4.createElement(StyledFormControlLabel, {
|
|
12457
12485
|
label: choicelabel,
|
|
@@ -12462,7 +12490,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12462
12490
|
__self: this,
|
|
12463
12491
|
__source: {
|
|
12464
12492
|
fileName: _jsxFileName$3,
|
|
12465
|
-
lineNumber:
|
|
12493
|
+
lineNumber: 345
|
|
12466
12494
|
}
|
|
12467
12495
|
}))), rationale && React$4.createElement(PreviewPrompt$1, {
|
|
12468
12496
|
className: "rationale",
|
|
@@ -12471,7 +12499,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12471
12499
|
__self: this,
|
|
12472
12500
|
__source: {
|
|
12473
12501
|
fileName: _jsxFileName$3,
|
|
12474
|
-
lineNumber:
|
|
12502
|
+
lineNumber: 354
|
|
12475
12503
|
}
|
|
12476
12504
|
}), React$4.createElement(Feedback, {
|
|
12477
12505
|
feedback: feedback,
|
|
@@ -12479,7 +12507,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12479
12507
|
__self: this,
|
|
12480
12508
|
__source: {
|
|
12481
12509
|
fileName: _jsxFileName$3,
|
|
12482
|
-
lineNumber:
|
|
12510
|
+
lineNumber: 355
|
|
12483
12511
|
}
|
|
12484
12512
|
}));
|
|
12485
12513
|
}
|
|
@@ -12508,7 +12536,7 @@ class Choice extends React$3.Component {
|
|
|
12508
12536
|
};
|
|
12509
12537
|
}
|
|
12510
12538
|
render() {
|
|
12511
|
-
const {choice, index, choicesLength, showCorrect, isEvaluateMode, choiceMode, disabled, checked, correctness, displayKey, classes, choicesLayout, gridColumns, isSelectionButtonBelow, selectedAnswerBackgroundColor, tagName} = this.props;
|
|
12539
|
+
const {choice, index, choicesLength, showCorrect, isEvaluateMode, choiceMode, disabled, checked, correctness, displayKey, classes, choicesLayout, gridColumns, isSelectionButtonBelow, selectedAnswerBackgroundColor, autoFocusRef, tagName} = this.props;
|
|
12512
12540
|
const choiceClass = 'choice' + (index === choicesLength - 1 ? ' last' : '');
|
|
12513
12541
|
const feedback = !isEvaluateMode || showCorrect ? '' : choice.feedback;
|
|
12514
12542
|
const choiceProps = {
|
|
@@ -12541,15 +12569,16 @@ class Choice extends React$3.Component {
|
|
|
12541
12569
|
__self: this,
|
|
12542
12570
|
__source: {
|
|
12543
12571
|
fileName: _jsxFileName$2,
|
|
12544
|
-
lineNumber:
|
|
12572
|
+
lineNumber: 68
|
|
12545
12573
|
}
|
|
12546
12574
|
}, React$3.createElement(ChoiceInput$1, {
|
|
12547
12575
|
...choiceProps,
|
|
12548
12576
|
className: names,
|
|
12577
|
+
autoFocusRef: autoFocusRef,
|
|
12549
12578
|
__self: this,
|
|
12550
12579
|
__source: {
|
|
12551
12580
|
fileName: _jsxFileName$2,
|
|
12552
|
-
lineNumber:
|
|
12581
|
+
lineNumber: 69
|
|
12553
12582
|
}
|
|
12554
12583
|
}));
|
|
12555
12584
|
}
|
|
@@ -12572,7 +12601,8 @@ Choice.propTypes = {
|
|
|
12572
12601
|
gridColumns: PropTypes$2.string,
|
|
12573
12602
|
selectedAnswerBackgroundColor: PropTypes$2.string,
|
|
12574
12603
|
tagName: PropTypes$2.string,
|
|
12575
|
-
isSelectionButtonBelow: PropTypes$2.bool
|
|
12604
|
+
isSelectionButtonBelow: PropTypes$2.bool,
|
|
12605
|
+
autoFocusRef: PropTypes$2.object
|
|
12576
12606
|
};
|
|
12577
12607
|
var StyledChoice = styles$b.withStyles(theme => ({
|
|
12578
12608
|
choice: {
|
|
@@ -12600,6 +12630,27 @@ const {color: color} = _dll_pie_lib__pie_toolbox_render_ui;
|
|
|
12600
12630
|
const {Collapsible: Collapsible} = _dll_pie_lib__pie_toolbox_render_ui;
|
|
12601
12631
|
const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__pie_toolbox_render_ui;
|
|
12602
12632
|
const _jsxFileName$1 = "/home/circleci/repo/packages/multiple-choice/src/multiple-choice.jsx";
|
|
12633
|
+
function _optionalChain$1(ops) {
|
|
12634
|
+
let lastAccessLHS = undefined;
|
|
12635
|
+
let value = ops[0];
|
|
12636
|
+
let i = 1;
|
|
12637
|
+
while (i < ops.length) {
|
|
12638
|
+
const op = ops[i];
|
|
12639
|
+
const fn = ops[i + 1];
|
|
12640
|
+
i += 2;
|
|
12641
|
+
if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
|
|
12642
|
+
return undefined;
|
|
12643
|
+
}
|
|
12644
|
+
if (op === 'access' || op === 'optionalAccess') {
|
|
12645
|
+
lastAccessLHS = value;
|
|
12646
|
+
value = fn(value);
|
|
12647
|
+
} else if (op === 'call' || op === 'optionalCall') {
|
|
12648
|
+
value = fn((...args) => value.call(lastAccessLHS, ...args));
|
|
12649
|
+
lastAccessLHS = undefined;
|
|
12650
|
+
}
|
|
12651
|
+
}
|
|
12652
|
+
return value;
|
|
12653
|
+
}
|
|
12603
12654
|
const {translator} = Translator;
|
|
12604
12655
|
const styles$1 = theme => ({
|
|
12605
12656
|
main: {
|
|
@@ -12690,11 +12741,13 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12690
12741
|
MultipleChoice$1.prototype.__init.call(this);
|
|
12691
12742
|
MultipleChoice$1.prototype.__init2.call(this);
|
|
12692
12743
|
MultipleChoice$1.prototype.__init3.call(this);
|
|
12744
|
+
MultipleChoice$1.prototype.__init4.call(this);
|
|
12693
12745
|
this.state = {
|
|
12694
12746
|
showCorrect: this.props.alwaysShowCorrect || false,
|
|
12695
12747
|
maxSelectionsErrorState: false
|
|
12696
12748
|
};
|
|
12697
12749
|
this.onToggle = this.onToggle.bind(this);
|
|
12750
|
+
this.firstInputRef = React$2.createRef();
|
|
12698
12751
|
}
|
|
12699
12752
|
isSelected(value) {
|
|
12700
12753
|
const sessionValue = this.props.session && this.props.session.value;
|
|
@@ -12799,17 +12852,29 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12799
12852
|
__self: this,
|
|
12800
12853
|
__source: {
|
|
12801
12854
|
fileName: _jsxFileName$1,
|
|
12802
|
-
lineNumber:
|
|
12855
|
+
lineNumber: 220
|
|
12803
12856
|
}
|
|
12804
12857
|
}, "Multiple Choice Question") : React$2.createElement('h2', {
|
|
12805
12858
|
className: classes.srOnly,
|
|
12806
12859
|
__self: this,
|
|
12807
12860
|
__source: {
|
|
12808
12861
|
fileName: _jsxFileName$1,
|
|
12809
|
-
lineNumber:
|
|
12862
|
+
lineNumber: 222
|
|
12810
12863
|
}
|
|
12811
12864
|
}, "Multiple Select Question");
|
|
12812
12865
|
}
|
|
12866
|
+
__init4() {
|
|
12867
|
+
this.handleGroupFocus = e => {
|
|
12868
|
+
const fieldset = e.currentTarget;
|
|
12869
|
+
const activeEl = document.activeElement;
|
|
12870
|
+
if (fieldset.contains(activeEl) && activeEl !== fieldset) {
|
|
12871
|
+
return;
|
|
12872
|
+
}
|
|
12873
|
+
if (_optionalChain$1([this, 'access', _3 => _3.firstInputRef, 'optionalAccess', _4 => _4.current])) {
|
|
12874
|
+
this.firstInputRef.current.focus();
|
|
12875
|
+
}
|
|
12876
|
+
};
|
|
12877
|
+
}
|
|
12813
12878
|
render() {
|
|
12814
12879
|
const {mode, disabled, className, choices = [], choiceMode, gridColumns, partLabel, prompt, responseCorrect, teacherInstructions, classes, alwaysShowCorrect, animationsDisabled, language, isSelectionButtonBelow, minSelections, maxSelections, autoplayAudioEnabled, session, customAudioButton} = this.props;
|
|
12815
12880
|
const {showCorrect, maxSelectionsErrorState} = this.state;
|
|
@@ -12827,7 +12892,7 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12827
12892
|
__self: this,
|
|
12828
12893
|
__source: {
|
|
12829
12894
|
fileName: _jsxFileName$1,
|
|
12830
|
-
lineNumber:
|
|
12895
|
+
lineNumber: 269
|
|
12831
12896
|
}
|
|
12832
12897
|
});
|
|
12833
12898
|
const getMultipleChoiceMinSelectionErrorMessage = () => {
|
|
@@ -12855,21 +12920,21 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12855
12920
|
__self: this,
|
|
12856
12921
|
__source: {
|
|
12857
12922
|
fileName: _jsxFileName$1,
|
|
12858
|
-
lineNumber:
|
|
12923
|
+
lineNumber: 296
|
|
12859
12924
|
}
|
|
12860
12925
|
}, partLabel && React$2.createElement('h3', {
|
|
12861
12926
|
className: classes.partLabel,
|
|
12862
12927
|
__self: this,
|
|
12863
12928
|
__source: {
|
|
12864
12929
|
fileName: _jsxFileName$1,
|
|
12865
|
-
lineNumber:
|
|
12930
|
+
lineNumber: 297
|
|
12866
12931
|
}
|
|
12867
12932
|
}, partLabel), this.renderHeading(), teacherInstructions && React$2.createElement('div', {
|
|
12868
12933
|
className: classes.teacherInstructions,
|
|
12869
12934
|
__self: this,
|
|
12870
12935
|
__source: {
|
|
12871
12936
|
fileName: _jsxFileName$1,
|
|
12872
|
-
lineNumber:
|
|
12937
|
+
lineNumber: 302
|
|
12873
12938
|
}
|
|
12874
12939
|
}, !animationsDisabled ? React$2.createElement(Collapsible, {
|
|
12875
12940
|
labels: {
|
|
@@ -12879,16 +12944,17 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12879
12944
|
__self: this,
|
|
12880
12945
|
__source: {
|
|
12881
12946
|
fileName: _jsxFileName$1,
|
|
12882
|
-
lineNumber:
|
|
12947
|
+
lineNumber: 304
|
|
12883
12948
|
}
|
|
12884
12949
|
}, teacherInstructionsDiv) : teacherInstructionsDiv), React$2.createElement('fieldset', {
|
|
12885
12950
|
tabIndex: 0,
|
|
12886
12951
|
className: classes.fieldset,
|
|
12952
|
+
onFocus: this.handleGroupFocus,
|
|
12887
12953
|
role: choiceMode === 'radio' ? 'radiogroup' : 'group',
|
|
12888
12954
|
__self: this,
|
|
12889
12955
|
__source: {
|
|
12890
12956
|
fileName: _jsxFileName$1,
|
|
12891
|
-
lineNumber:
|
|
12957
|
+
lineNumber: 318
|
|
12892
12958
|
}
|
|
12893
12959
|
}, React$2.createElement(PreviewPrompt, {
|
|
12894
12960
|
className: "prompt",
|
|
@@ -12900,7 +12966,7 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12900
12966
|
__self: this,
|
|
12901
12967
|
__source: {
|
|
12902
12968
|
fileName: _jsxFileName$1,
|
|
12903
|
-
lineNumber:
|
|
12969
|
+
lineNumber: 324
|
|
12904
12970
|
}
|
|
12905
12971
|
}), !alwaysShowCorrect && React$2.createElement(CorrectAnswerToggle, {
|
|
12906
12972
|
show: showCorrectAnswerToggle,
|
|
@@ -12910,7 +12976,7 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12910
12976
|
__self: this,
|
|
12911
12977
|
__source: {
|
|
12912
12978
|
fileName: _jsxFileName$1,
|
|
12913
|
-
lineNumber:
|
|
12979
|
+
lineNumber: 334
|
|
12914
12980
|
}
|
|
12915
12981
|
}), React$2.createElement('div', {
|
|
12916
12982
|
className: classNames({
|
|
@@ -12921,9 +12987,10 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12921
12987
|
__self: this,
|
|
12922
12988
|
__source: {
|
|
12923
12989
|
fileName: _jsxFileName$1,
|
|
12924
|
-
lineNumber:
|
|
12990
|
+
lineNumber: 342
|
|
12925
12991
|
}
|
|
12926
12992
|
}, choices.map((choice, index) => React$2.createElement(StyledChoice, {
|
|
12993
|
+
autoFocusRef: index === 0 ? this.firstInputRef : null,
|
|
12927
12994
|
choicesLayout: this.props.choicesLayout,
|
|
12928
12995
|
selectedAnswerBackgroundColor: this.props.selectedAnswerBackgroundColor,
|
|
12929
12996
|
gridColumns: gridColumns,
|
|
@@ -12945,21 +13012,21 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12945
13012
|
__self: this,
|
|
12946
13013
|
__source: {
|
|
12947
13014
|
fileName: _jsxFileName$1,
|
|
12948
|
-
lineNumber:
|
|
13015
|
+
lineNumber: 350
|
|
12949
13016
|
}
|
|
12950
13017
|
})))), choiceMode === 'checkbox' && selections < minSelections && React$2.createElement('div', {
|
|
12951
13018
|
className: classes.errorText,
|
|
12952
13019
|
__self: this,
|
|
12953
13020
|
__source: {
|
|
12954
13021
|
fileName: _jsxFileName$1,
|
|
12955
|
-
lineNumber:
|
|
13022
|
+
lineNumber: 376
|
|
12956
13023
|
}
|
|
12957
13024
|
}, getMultipleChoiceMinSelectionErrorMessage()), choiceMode === 'checkbox' && maxSelectionsErrorState && React$2.createElement('div', {
|
|
12958
13025
|
className: classes.errorText,
|
|
12959
13026
|
__self: this,
|
|
12960
13027
|
__source: {
|
|
12961
13028
|
fileName: _jsxFileName$1,
|
|
12962
|
-
lineNumber:
|
|
13029
|
+
lineNumber: 379
|
|
12963
13030
|
}
|
|
12964
13031
|
}, translator.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {
|
|
12965
13032
|
lng: language,
|
package/module/print.js
CHANGED
|
@@ -12239,7 +12239,7 @@ const inputStyles = {
|
|
|
12239
12239
|
}
|
|
12240
12240
|
};
|
|
12241
12241
|
const StyledCheckbox = styles$b.withStyles(inputStyles)(props => {
|
|
12242
|
-
const {correctness, classes, checked, onChange, disabled, value, id} = props;
|
|
12242
|
+
const {correctness, classes, checked, onChange, disabled, value, id, onKeyDown, inputRef} = props;
|
|
12243
12243
|
const key = k => correctness ? `${correctness}-${k}` : k;
|
|
12244
12244
|
const resolved = {
|
|
12245
12245
|
root: classes[key('root')],
|
|
@@ -12254,7 +12254,9 @@ const StyledCheckbox = styles$b.withStyles(inputStyles)(props => {
|
|
|
12254
12254
|
};
|
|
12255
12255
|
return React$4.createElement(Checkbox, {
|
|
12256
12256
|
id: id,
|
|
12257
|
+
inputRef: inputRef,
|
|
12257
12258
|
'aria-checked': checked,
|
|
12259
|
+
onKeyDown: onKeyDown,
|
|
12258
12260
|
focusVisibleClassName: checked ? classes.focusVisibleChecked : classes.focusVisibleUnchecked,
|
|
12259
12261
|
disableRipple: true,
|
|
12260
12262
|
...miniProps,
|
|
@@ -12301,7 +12303,7 @@ const StyledRadio = styles$b.withStyles(inputStyles)(props => {
|
|
|
12301
12303
|
__self: undefined,
|
|
12302
12304
|
__source: {
|
|
12303
12305
|
fileName: _jsxFileName$3,
|
|
12304
|
-
lineNumber:
|
|
12306
|
+
lineNumber: 167
|
|
12305
12307
|
}
|
|
12306
12308
|
});
|
|
12307
12309
|
});
|
|
@@ -12320,6 +12322,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12320
12322
|
value: PropTypes$3.string.isRequired,
|
|
12321
12323
|
classes: PropTypes$3.object,
|
|
12322
12324
|
className: PropTypes$3.string,
|
|
12325
|
+
tagName: PropTypes$3.string,
|
|
12323
12326
|
hideTick: PropTypes$3.bool,
|
|
12324
12327
|
isEvaluateMode: PropTypes$3.bool,
|
|
12325
12328
|
choicesLayout: PropTypes$3.oneOf(['vertical', 'grid', 'horizontal']),
|
|
@@ -12335,6 +12338,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12335
12338
|
}
|
|
12336
12339
|
constructor(props) {
|
|
12337
12340
|
super(props);
|
|
12341
|
+
ChoiceInput.prototype.__init.call(this);
|
|
12338
12342
|
this.onToggleChoice = this.onToggleChoice.bind(this);
|
|
12339
12343
|
this.choiceId = this.generateChoiceId();
|
|
12340
12344
|
this.descId = `${this.choiceId}-desc`;
|
|
@@ -12345,6 +12349,28 @@ class ChoiceInput extends React$4.Component {
|
|
|
12345
12349
|
generateChoiceId() {
|
|
12346
12350
|
return 'choice-' + (Math.random() * 10000).toFixed();
|
|
12347
12351
|
}
|
|
12352
|
+
__init() {
|
|
12353
|
+
this.handleKeyDown = event => {
|
|
12354
|
+
const {choiceMode} = this.props;
|
|
12355
|
+
if (choiceMode !== 'checkbox') return;
|
|
12356
|
+
const isArrowDown = event.key === 'ArrowDown';
|
|
12357
|
+
const isArrowUp = event.key === 'ArrowUp';
|
|
12358
|
+
if (!isArrowDown && !isArrowUp) return;
|
|
12359
|
+
event.preventDefault();
|
|
12360
|
+
const currentEl = document.getElementById(this.choiceId);
|
|
12361
|
+
if (!currentEl) return;
|
|
12362
|
+
const fieldset = currentEl.closest('fieldset');
|
|
12363
|
+
if (!fieldset) return;
|
|
12364
|
+
const groupCheckboxes = Array.from(fieldset.querySelectorAll('input[type="checkbox"]'));
|
|
12365
|
+
const currentIndex = groupCheckboxes.findIndex(el => el === currentEl);
|
|
12366
|
+
if (currentIndex === -1) return;
|
|
12367
|
+
const nextIndex = isArrowDown ? currentIndex + 1 : currentIndex - 1;
|
|
12368
|
+
const nextEl = groupCheckboxes[nextIndex];
|
|
12369
|
+
if (nextEl) {
|
|
12370
|
+
nextEl.focus();
|
|
12371
|
+
}
|
|
12372
|
+
};
|
|
12373
|
+
}
|
|
12348
12374
|
render() {
|
|
12349
12375
|
const {choiceMode, disabled, displayKey, feedback, label, correctness, classes, className, rationale, hideTick, isEvaluateMode, choicesLayout, value, checked, tagName, isSelectionButtonBelow} = this.props;
|
|
12350
12376
|
const Tag = choiceMode === 'checkbox' ? StyledCheckbox : StyledRadio;
|
|
@@ -12359,7 +12385,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12359
12385
|
__self: this,
|
|
12360
12386
|
__source: {
|
|
12361
12387
|
fileName: _jsxFileName$3,
|
|
12362
|
-
lineNumber:
|
|
12388
|
+
lineNumber: 289
|
|
12363
12389
|
}
|
|
12364
12390
|
}, displayKey, ".", '\u00A0', React$4.createElement(PreviewPrompt$1, {
|
|
12365
12391
|
className: "label",
|
|
@@ -12368,7 +12394,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12368
12394
|
__self: this,
|
|
12369
12395
|
__source: {
|
|
12370
12396
|
fileName: _jsxFileName$3,
|
|
12371
|
-
lineNumber:
|
|
12397
|
+
lineNumber: 291
|
|
12372
12398
|
}
|
|
12373
12399
|
})) : React$4.createElement(PreviewPrompt$1, {
|
|
12374
12400
|
className: "label",
|
|
@@ -12377,7 +12403,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12377
12403
|
__self: this,
|
|
12378
12404
|
__source: {
|
|
12379
12405
|
fileName: _jsxFileName$3,
|
|
12380
|
-
lineNumber:
|
|
12406
|
+
lineNumber: 294
|
|
12381
12407
|
}
|
|
12382
12408
|
}));
|
|
12383
12409
|
const screenReaderLabel = React$4.createElement('span', {
|
|
@@ -12386,7 +12412,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12386
12412
|
__self: this,
|
|
12387
12413
|
__source: {
|
|
12388
12414
|
fileName: _jsxFileName$3,
|
|
12389
|
-
lineNumber:
|
|
12415
|
+
lineNumber: 300
|
|
12390
12416
|
}
|
|
12391
12417
|
}, choiceMode === 'checkbox' ? 'Checkbox to select the answer below' : 'Radio button to select the answer below');
|
|
12392
12418
|
const tagProps = {
|
|
@@ -12397,6 +12423,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12397
12423
|
value,
|
|
12398
12424
|
id: this.choiceId,
|
|
12399
12425
|
onChange: this.onToggleChoice,
|
|
12426
|
+
onKeyDown: this.handleKeyDown,
|
|
12400
12427
|
'aria-describedby': this.descId
|
|
12401
12428
|
};
|
|
12402
12429
|
const hasMathOrImage = typeof label === 'string' && (label.includes('<math') || label.includes('\\(') || label.includes('\\[') || label.includes('<img') || label.includes('data-latex') || label.includes('data-raw') || label.includes('<mjx-container'));
|
|
@@ -12405,7 +12432,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12405
12432
|
__self: this,
|
|
12406
12433
|
__source: {
|
|
12407
12434
|
fileName: _jsxFileName$3,
|
|
12408
|
-
lineNumber:
|
|
12435
|
+
lineNumber: 328
|
|
12409
12436
|
}
|
|
12410
12437
|
}, hasMathOrImage && screenReaderLabel, React$4.createElement(Tag, {
|
|
12411
12438
|
...tagProps,
|
|
@@ -12415,14 +12442,15 @@ class ChoiceInput extends React$4.Component {
|
|
|
12415
12442
|
__self: this,
|
|
12416
12443
|
__source: {
|
|
12417
12444
|
fileName: _jsxFileName$3,
|
|
12418
|
-
lineNumber:
|
|
12445
|
+
lineNumber: 330
|
|
12419
12446
|
}
|
|
12420
12447
|
}), displayKey ? `${displayKey}.` : '') : React$4.createElement(React$4.Fragment, null, hasMathOrImage && screenReaderLabel, React$4.createElement(Tag, {
|
|
12421
12448
|
...tagProps,
|
|
12449
|
+
inputRef: this.props.autoFocusRef,
|
|
12422
12450
|
__self: this,
|
|
12423
12451
|
__source: {
|
|
12424
12452
|
fileName: _jsxFileName$3,
|
|
12425
|
-
lineNumber:
|
|
12453
|
+
lineNumber: 336
|
|
12426
12454
|
}
|
|
12427
12455
|
}));
|
|
12428
12456
|
return React$4.createElement('div', {
|
|
@@ -12430,28 +12458,28 @@ class ChoiceInput extends React$4.Component {
|
|
|
12430
12458
|
__self: this,
|
|
12431
12459
|
__source: {
|
|
12432
12460
|
fileName: _jsxFileName$3,
|
|
12433
|
-
lineNumber:
|
|
12461
|
+
lineNumber: 341
|
|
12434
12462
|
}
|
|
12435
12463
|
}, React$4.createElement('div', {
|
|
12436
12464
|
className: classes.row,
|
|
12437
12465
|
__self: this,
|
|
12438
12466
|
__source: {
|
|
12439
12467
|
fileName: _jsxFileName$3,
|
|
12440
|
-
lineNumber:
|
|
12468
|
+
lineNumber: 342
|
|
12441
12469
|
}
|
|
12442
12470
|
}, !hideTick && isEvaluateMode && React$4.createElement(FeedbackTick$1, {
|
|
12443
12471
|
correctness: correctness,
|
|
12444
12472
|
__self: this,
|
|
12445
12473
|
__source: {
|
|
12446
12474
|
fileName: _jsxFileName$3,
|
|
12447
|
-
lineNumber:
|
|
12475
|
+
lineNumber: 343
|
|
12448
12476
|
}
|
|
12449
12477
|
}), React$4.createElement('div', {
|
|
12450
12478
|
className: classNames$2(holderClassNames, 'checkbox-holder'),
|
|
12451
12479
|
__self: this,
|
|
12452
12480
|
__source: {
|
|
12453
12481
|
fileName: _jsxFileName$3,
|
|
12454
|
-
lineNumber:
|
|
12482
|
+
lineNumber: 344
|
|
12455
12483
|
}
|
|
12456
12484
|
}, React$4.createElement(StyledFormControlLabel, {
|
|
12457
12485
|
label: choicelabel,
|
|
@@ -12462,7 +12490,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12462
12490
|
__self: this,
|
|
12463
12491
|
__source: {
|
|
12464
12492
|
fileName: _jsxFileName$3,
|
|
12465
|
-
lineNumber:
|
|
12493
|
+
lineNumber: 345
|
|
12466
12494
|
}
|
|
12467
12495
|
}))), rationale && React$4.createElement(PreviewPrompt$1, {
|
|
12468
12496
|
className: "rationale",
|
|
@@ -12471,7 +12499,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12471
12499
|
__self: this,
|
|
12472
12500
|
__source: {
|
|
12473
12501
|
fileName: _jsxFileName$3,
|
|
12474
|
-
lineNumber:
|
|
12502
|
+
lineNumber: 354
|
|
12475
12503
|
}
|
|
12476
12504
|
}), React$4.createElement(Feedback, {
|
|
12477
12505
|
feedback: feedback,
|
|
@@ -12479,7 +12507,7 @@ class ChoiceInput extends React$4.Component {
|
|
|
12479
12507
|
__self: this,
|
|
12480
12508
|
__source: {
|
|
12481
12509
|
fileName: _jsxFileName$3,
|
|
12482
|
-
lineNumber:
|
|
12510
|
+
lineNumber: 355
|
|
12483
12511
|
}
|
|
12484
12512
|
}));
|
|
12485
12513
|
}
|
|
@@ -12508,7 +12536,7 @@ class Choice extends React$3.Component {
|
|
|
12508
12536
|
};
|
|
12509
12537
|
}
|
|
12510
12538
|
render() {
|
|
12511
|
-
const {choice, index, choicesLength, showCorrect, isEvaluateMode, choiceMode, disabled, checked, correctness, displayKey, classes, choicesLayout, gridColumns, isSelectionButtonBelow, selectedAnswerBackgroundColor, tagName} = this.props;
|
|
12539
|
+
const {choice, index, choicesLength, showCorrect, isEvaluateMode, choiceMode, disabled, checked, correctness, displayKey, classes, choicesLayout, gridColumns, isSelectionButtonBelow, selectedAnswerBackgroundColor, autoFocusRef, tagName} = this.props;
|
|
12512
12540
|
const choiceClass = 'choice' + (index === choicesLength - 1 ? ' last' : '');
|
|
12513
12541
|
const feedback = !isEvaluateMode || showCorrect ? '' : choice.feedback;
|
|
12514
12542
|
const choiceProps = {
|
|
@@ -12541,15 +12569,16 @@ class Choice extends React$3.Component {
|
|
|
12541
12569
|
__self: this,
|
|
12542
12570
|
__source: {
|
|
12543
12571
|
fileName: _jsxFileName$2,
|
|
12544
|
-
lineNumber:
|
|
12572
|
+
lineNumber: 68
|
|
12545
12573
|
}
|
|
12546
12574
|
}, React$3.createElement(ChoiceInput$1, {
|
|
12547
12575
|
...choiceProps,
|
|
12548
12576
|
className: names,
|
|
12577
|
+
autoFocusRef: autoFocusRef,
|
|
12549
12578
|
__self: this,
|
|
12550
12579
|
__source: {
|
|
12551
12580
|
fileName: _jsxFileName$2,
|
|
12552
|
-
lineNumber:
|
|
12581
|
+
lineNumber: 69
|
|
12553
12582
|
}
|
|
12554
12583
|
}));
|
|
12555
12584
|
}
|
|
@@ -12572,7 +12601,8 @@ Choice.propTypes = {
|
|
|
12572
12601
|
gridColumns: PropTypes$2.string,
|
|
12573
12602
|
selectedAnswerBackgroundColor: PropTypes$2.string,
|
|
12574
12603
|
tagName: PropTypes$2.string,
|
|
12575
|
-
isSelectionButtonBelow: PropTypes$2.bool
|
|
12604
|
+
isSelectionButtonBelow: PropTypes$2.bool,
|
|
12605
|
+
autoFocusRef: PropTypes$2.object
|
|
12576
12606
|
};
|
|
12577
12607
|
var StyledChoice = styles$b.withStyles(theme => ({
|
|
12578
12608
|
choice: {
|
|
@@ -12600,6 +12630,27 @@ const {color: color} = _dll_pie_lib__pie_toolbox_render_ui;
|
|
|
12600
12630
|
const {Collapsible: Collapsible} = _dll_pie_lib__pie_toolbox_render_ui;
|
|
12601
12631
|
const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__pie_toolbox_render_ui;
|
|
12602
12632
|
const _jsxFileName$1 = "/home/circleci/repo/packages/multiple-choice/src/multiple-choice.jsx";
|
|
12633
|
+
function _optionalChain(ops) {
|
|
12634
|
+
let lastAccessLHS = undefined;
|
|
12635
|
+
let value = ops[0];
|
|
12636
|
+
let i = 1;
|
|
12637
|
+
while (i < ops.length) {
|
|
12638
|
+
const op = ops[i];
|
|
12639
|
+
const fn = ops[i + 1];
|
|
12640
|
+
i += 2;
|
|
12641
|
+
if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
|
|
12642
|
+
return undefined;
|
|
12643
|
+
}
|
|
12644
|
+
if (op === 'access' || op === 'optionalAccess') {
|
|
12645
|
+
lastAccessLHS = value;
|
|
12646
|
+
value = fn(value);
|
|
12647
|
+
} else if (op === 'call' || op === 'optionalCall') {
|
|
12648
|
+
value = fn((...args) => value.call(lastAccessLHS, ...args));
|
|
12649
|
+
lastAccessLHS = undefined;
|
|
12650
|
+
}
|
|
12651
|
+
}
|
|
12652
|
+
return value;
|
|
12653
|
+
}
|
|
12603
12654
|
const {translator} = Translator;
|
|
12604
12655
|
const styles$1 = theme => ({
|
|
12605
12656
|
main: {
|
|
@@ -12690,11 +12741,13 @@ class MultipleChoice extends React$2.Component {
|
|
|
12690
12741
|
MultipleChoice.prototype.__init.call(this);
|
|
12691
12742
|
MultipleChoice.prototype.__init2.call(this);
|
|
12692
12743
|
MultipleChoice.prototype.__init3.call(this);
|
|
12744
|
+
MultipleChoice.prototype.__init4.call(this);
|
|
12693
12745
|
this.state = {
|
|
12694
12746
|
showCorrect: this.props.alwaysShowCorrect || false,
|
|
12695
12747
|
maxSelectionsErrorState: false
|
|
12696
12748
|
};
|
|
12697
12749
|
this.onToggle = this.onToggle.bind(this);
|
|
12750
|
+
this.firstInputRef = React$2.createRef();
|
|
12698
12751
|
}
|
|
12699
12752
|
isSelected(value) {
|
|
12700
12753
|
const sessionValue = this.props.session && this.props.session.value;
|
|
@@ -12799,17 +12852,29 @@ class MultipleChoice extends React$2.Component {
|
|
|
12799
12852
|
__self: this,
|
|
12800
12853
|
__source: {
|
|
12801
12854
|
fileName: _jsxFileName$1,
|
|
12802
|
-
lineNumber:
|
|
12855
|
+
lineNumber: 220
|
|
12803
12856
|
}
|
|
12804
12857
|
}, "Multiple Choice Question") : React$2.createElement('h2', {
|
|
12805
12858
|
className: classes.srOnly,
|
|
12806
12859
|
__self: this,
|
|
12807
12860
|
__source: {
|
|
12808
12861
|
fileName: _jsxFileName$1,
|
|
12809
|
-
lineNumber:
|
|
12862
|
+
lineNumber: 222
|
|
12810
12863
|
}
|
|
12811
12864
|
}, "Multiple Select Question");
|
|
12812
12865
|
}
|
|
12866
|
+
__init4() {
|
|
12867
|
+
this.handleGroupFocus = e => {
|
|
12868
|
+
const fieldset = e.currentTarget;
|
|
12869
|
+
const activeEl = document.activeElement;
|
|
12870
|
+
if (fieldset.contains(activeEl) && activeEl !== fieldset) {
|
|
12871
|
+
return;
|
|
12872
|
+
}
|
|
12873
|
+
if (_optionalChain([this, 'access', _3 => _3.firstInputRef, 'optionalAccess', _4 => _4.current])) {
|
|
12874
|
+
this.firstInputRef.current.focus();
|
|
12875
|
+
}
|
|
12876
|
+
};
|
|
12877
|
+
}
|
|
12813
12878
|
render() {
|
|
12814
12879
|
const {mode, disabled, className, choices = [], choiceMode, gridColumns, partLabel, prompt, responseCorrect, teacherInstructions, classes, alwaysShowCorrect, animationsDisabled, language, isSelectionButtonBelow, minSelections, maxSelections, autoplayAudioEnabled, session, customAudioButton} = this.props;
|
|
12815
12880
|
const {showCorrect, maxSelectionsErrorState} = this.state;
|
|
@@ -12827,7 +12892,7 @@ class MultipleChoice extends React$2.Component {
|
|
|
12827
12892
|
__self: this,
|
|
12828
12893
|
__source: {
|
|
12829
12894
|
fileName: _jsxFileName$1,
|
|
12830
|
-
lineNumber:
|
|
12895
|
+
lineNumber: 269
|
|
12831
12896
|
}
|
|
12832
12897
|
});
|
|
12833
12898
|
const getMultipleChoiceMinSelectionErrorMessage = () => {
|
|
@@ -12855,21 +12920,21 @@ class MultipleChoice extends React$2.Component {
|
|
|
12855
12920
|
__self: this,
|
|
12856
12921
|
__source: {
|
|
12857
12922
|
fileName: _jsxFileName$1,
|
|
12858
|
-
lineNumber:
|
|
12923
|
+
lineNumber: 296
|
|
12859
12924
|
}
|
|
12860
12925
|
}, partLabel && React$2.createElement('h3', {
|
|
12861
12926
|
className: classes.partLabel,
|
|
12862
12927
|
__self: this,
|
|
12863
12928
|
__source: {
|
|
12864
12929
|
fileName: _jsxFileName$1,
|
|
12865
|
-
lineNumber:
|
|
12930
|
+
lineNumber: 297
|
|
12866
12931
|
}
|
|
12867
12932
|
}, partLabel), this.renderHeading(), teacherInstructions && React$2.createElement('div', {
|
|
12868
12933
|
className: classes.teacherInstructions,
|
|
12869
12934
|
__self: this,
|
|
12870
12935
|
__source: {
|
|
12871
12936
|
fileName: _jsxFileName$1,
|
|
12872
|
-
lineNumber:
|
|
12937
|
+
lineNumber: 302
|
|
12873
12938
|
}
|
|
12874
12939
|
}, !animationsDisabled ? React$2.createElement(Collapsible, {
|
|
12875
12940
|
labels: {
|
|
@@ -12879,16 +12944,17 @@ class MultipleChoice extends React$2.Component {
|
|
|
12879
12944
|
__self: this,
|
|
12880
12945
|
__source: {
|
|
12881
12946
|
fileName: _jsxFileName$1,
|
|
12882
|
-
lineNumber:
|
|
12947
|
+
lineNumber: 304
|
|
12883
12948
|
}
|
|
12884
12949
|
}, teacherInstructionsDiv) : teacherInstructionsDiv), React$2.createElement('fieldset', {
|
|
12885
12950
|
tabIndex: 0,
|
|
12886
12951
|
className: classes.fieldset,
|
|
12952
|
+
onFocus: this.handleGroupFocus,
|
|
12887
12953
|
role: choiceMode === 'radio' ? 'radiogroup' : 'group',
|
|
12888
12954
|
__self: this,
|
|
12889
12955
|
__source: {
|
|
12890
12956
|
fileName: _jsxFileName$1,
|
|
12891
|
-
lineNumber:
|
|
12957
|
+
lineNumber: 318
|
|
12892
12958
|
}
|
|
12893
12959
|
}, React$2.createElement(PreviewPrompt, {
|
|
12894
12960
|
className: "prompt",
|
|
@@ -12900,7 +12966,7 @@ class MultipleChoice extends React$2.Component {
|
|
|
12900
12966
|
__self: this,
|
|
12901
12967
|
__source: {
|
|
12902
12968
|
fileName: _jsxFileName$1,
|
|
12903
|
-
lineNumber:
|
|
12969
|
+
lineNumber: 324
|
|
12904
12970
|
}
|
|
12905
12971
|
}), !alwaysShowCorrect && React$2.createElement(CorrectAnswerToggle, {
|
|
12906
12972
|
show: showCorrectAnswerToggle,
|
|
@@ -12910,7 +12976,7 @@ class MultipleChoice extends React$2.Component {
|
|
|
12910
12976
|
__self: this,
|
|
12911
12977
|
__source: {
|
|
12912
12978
|
fileName: _jsxFileName$1,
|
|
12913
|
-
lineNumber:
|
|
12979
|
+
lineNumber: 334
|
|
12914
12980
|
}
|
|
12915
12981
|
}), React$2.createElement('div', {
|
|
12916
12982
|
className: classNames({
|
|
@@ -12921,9 +12987,10 @@ class MultipleChoice extends React$2.Component {
|
|
|
12921
12987
|
__self: this,
|
|
12922
12988
|
__source: {
|
|
12923
12989
|
fileName: _jsxFileName$1,
|
|
12924
|
-
lineNumber:
|
|
12990
|
+
lineNumber: 342
|
|
12925
12991
|
}
|
|
12926
12992
|
}, choices.map((choice, index) => React$2.createElement(StyledChoice, {
|
|
12993
|
+
autoFocusRef: index === 0 ? this.firstInputRef : null,
|
|
12927
12994
|
choicesLayout: this.props.choicesLayout,
|
|
12928
12995
|
selectedAnswerBackgroundColor: this.props.selectedAnswerBackgroundColor,
|
|
12929
12996
|
gridColumns: gridColumns,
|
|
@@ -12945,21 +13012,21 @@ class MultipleChoice extends React$2.Component {
|
|
|
12945
13012
|
__self: this,
|
|
12946
13013
|
__source: {
|
|
12947
13014
|
fileName: _jsxFileName$1,
|
|
12948
|
-
lineNumber:
|
|
13015
|
+
lineNumber: 350
|
|
12949
13016
|
}
|
|
12950
13017
|
})))), choiceMode === 'checkbox' && selections < minSelections && React$2.createElement('div', {
|
|
12951
13018
|
className: classes.errorText,
|
|
12952
13019
|
__self: this,
|
|
12953
13020
|
__source: {
|
|
12954
13021
|
fileName: _jsxFileName$1,
|
|
12955
|
-
lineNumber:
|
|
13022
|
+
lineNumber: 376
|
|
12956
13023
|
}
|
|
12957
13024
|
}, getMultipleChoiceMinSelectionErrorMessage()), choiceMode === 'checkbox' && maxSelectionsErrorState && React$2.createElement('div', {
|
|
12958
13025
|
className: classes.errorText,
|
|
12959
13026
|
__self: this,
|
|
12960
13027
|
__source: {
|
|
12961
13028
|
fileName: _jsxFileName$1,
|
|
12962
|
-
lineNumber:
|
|
13029
|
+
lineNumber: 379
|
|
12963
13030
|
}
|
|
12964
13031
|
}, translator.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {
|
|
12965
13032
|
lng: language,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/multiple-choice",
|
|
3
3
|
"repository": "pie-framework/pie-elements",
|
|
4
|
-
"version": "9.16.5-next.
|
|
4
|
+
"version": "9.16.5-next.3+fff627751",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"react-test-renderer": "^16.3.2",
|
|
20
20
|
"react-transition-group": "^2.3.1"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "fff62775142fc637ffef1f68660901ade504d597",
|
|
23
23
|
"scripts": {
|
|
24
24
|
"postpublish": "../../scripts/postpublish"
|
|
25
25
|
},
|