@pie-element/multiple-choice 11.0.1-next.0 → 11.0.1-next.11

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [11.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@10.0.0...@pie-element/multiple-choice@11.1.0) (2025-10-07)
7
+
8
+ **Note:** Version bump only for package @pie-element/multiple-choice
9
+
10
+
11
+
12
+
13
+
6
14
  # [11.0.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@9.20.2...@pie-element/multiple-choice@11.0.0) (2025-10-02)
7
15
 
8
16
 
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [8.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@8.0.0...@pie-element/multiple-choice-configure@8.1.0) (2025-10-07)
7
+
8
+ **Note:** Version bump only for package @pie-element/multiple-choice-configure
9
+
10
+
11
+
12
+
13
+
6
14
  ## [8.0.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@7.7.11...@pie-element/multiple-choice-configure@8.0.1) (2025-10-02)
7
15
 
8
16
  **Note:** Version bump only for package @pie-element/multiple-choice-configure
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice-configure",
3
- "version": "8.0.1",
3
+ "version": "8.1.0",
4
4
  "private": true,
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [6.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@6.0.0...@pie-element/multiple-choice-controller@6.1.0) (2025-10-07)
7
+
8
+ **Note:** Version bump only for package @pie-element/multiple-choice-controller
9
+
10
+
11
+
12
+
13
+
6
14
  ## [6.0.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@5.10.11...@pie-element/multiple-choice-controller@6.0.1) (2025-10-02)
7
15
 
8
16
  **Note:** Version bump only for package @pie-element/multiple-choice-controller
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice-controller",
3
3
  "private": true,
4
- "version": "6.0.1",
4
+ "version": "6.1.0",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
package/lib/choice.js CHANGED
@@ -173,11 +173,12 @@ var Choice = /*#__PURE__*/function (_React$Component) {
173
173
  currentBackgroundColor = hoverAnswerBackgroundColor;
174
174
  }
175
175
 
176
- var strokeStyle = hasSelectedStroke || hasHoverStroke ? {
176
+ var hasStroke = hasSelectedStroke || hasHoverStroke;
177
+ var strokeStyle = hasStroke ? {
177
178
  border: "".concat(normalizeStrokeWidth(currentStrokeWidth), " solid ").concat(currentStrokeColor),
178
179
  borderRadius: '8px'
179
180
  } : {};
180
- var names = (0, _classnames["default"])(classes.choice, (_classNames = {}, (0, _defineProperty2["default"])(_classNames, classes.noBorder, index === choicesLength - 1 || choicesLayout !== 'vertical' || strokeStyle), (0, _defineProperty2["default"])(_classNames, classes.horizontalLayout, choicesLayout === 'horizontal'), _classNames));
181
+ var names = (0, _classnames["default"])(classes.choice, (_classNames = {}, (0, _defineProperty2["default"])(_classNames, classes.noBorder, index === choicesLength - 1 || choicesLayout !== 'vertical' || hasStroke), (0, _defineProperty2["default"])(_classNames, classes.horizontalLayout, choicesLayout === 'horizontal'), _classNames));
181
182
  var choiceBackground = currentBackgroundColor !== 'initial' ? currentBackgroundColor : 'initial';
182
183
  return /*#__PURE__*/_react["default"].createElement("div", {
183
184
  className: choiceClass,
package/lib/choice.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/choice.jsx"],"names":["Choice","isHovered","props","disabled","checked","setState","choice","onChoiceChanged","index","choicesLength","showCorrect","isEvaluateMode","choiceMode","correctness","displayKey","classes","choicesLayout","gridColumns","isSelectionButtonBelow","selectedAnswerBackgroundColor","selectedAnswerStrokeColor","selectedAnswerStrokeWidth","hoverAnswerBackgroundColor","hoverAnswerStrokeColor","hoverAnswerStrokeWidth","autoFocusRef","tagName","state","choiceClass","feedback","choiceProps","onChange","normalizeStrokeWidth","width","trimmed","String","trim","test","hasSelectedStroke","hasHoverStroke","currentStrokeColor","currentStrokeWidth","currentBackgroundColor","strokeStyle","border","borderRadius","names","noBorder","horizontalLayout","choiceBackground","backgroundColor","handleMouseEnter","handleMouseLeave","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;;;;;;;;;;;;;;;8FAGH;AACNC,MAAAA,SAAS,EAAE;AADL,K;yGAIW,YAAM;AACvB,wBAA8B,MAAKC,KAAnC;AAAA,UAAQC,QAAR,eAAQA,QAAR;AAAA,UAAkBC,OAAlB,eAAkBA,OAAlB;;AAEA,UAAI,CAACD,QAAD,IAAa,CAACC,OAAlB,EAA2B;AACzB,cAAKC,QAAL,CAAc;AAAEJ,UAAAA,SAAS,EAAE;AAAb,SAAd;AACD;AACF,K;yGAEkB,YAAM;AACvB,YAAKI,QAAL,CAAc;AAAEJ,QAAAA,SAAS,EAAE;AAAb,OAAd;AACD,K;iGAEU,UAACK,MAAD,EAAY;AACrB,yBAAsC,MAAKJ,KAA3C;AAAA,UAAQC,QAAR,gBAAQA,QAAR;AAAA,UAAkBI,eAAlB,gBAAkBA,eAAlB;;AAEA,UAAI,CAACJ,QAAL,EAAe;AACbI,QAAAA,eA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,sBAAUG,IAtBjB;AAuBjBlC,EAAAA,YAAY,EAAE+B,sBAAUE;AAvBP,CAAnB;;eA0Be,wBAAW,UAACM,KAAD;AAAA,SAAY;AACpC1D,IAAAA,MAAM,EAAE;AACN2D,MAAAA,UAAU,EAAED,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,GAD3B;AAENC,MAAAA,aAAa,EAAEJ,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAF9B;AAGNE,MAAAA,WAAW,EAAEL,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAH5B;AAING,MAAAA,YAAY,EAAEN,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAJ7B;AAKNI,MAAAA,YAAY,sBAAeP,KAAK,CAACQ,OAAN,CAAcC,IAAd,CAAmB,GAAnB,CAAf;AALN,KAD4B;AAQpC1B,IAAAA,QAAQ,EAAE;AACRwB,MAAAA,YAAY,EAAE;AADN,KAR0B;AAWpCvB,IAAAA,gBAAgB,EAAE;AAChBsB,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,EAoBXnE,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 state = {\n isHovered: false,\n };\n\n handleMouseEnter = () => {\n const { disabled, checked } = this.props;\n\n if (!disabled && !checked) {\n this.setState({ isHovered: true });\n }\n };\n\n handleMouseLeave = () => {\n this.setState({ isHovered: false });\n };\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 selectedAnswerStrokeColor,\n selectedAnswerStrokeWidth,\n hoverAnswerBackgroundColor,\n hoverAnswerStrokeColor,\n hoverAnswerStrokeWidth,\n autoFocusRef,\n tagName\n } = this.props;\n \n const { isHovered } = this.state;\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 selectedAnswerStrokeColor,\n selectedAnswerStrokeWidth,\n tagName,\n };\n\n const normalizeStrokeWidth = (width) => {\n if (!width) return '2px'; // default\n const trimmed = String(width).trim();\n \n // add 'px' if the value is a number\n if (/^\\d+(\\.\\d+)?$/.test(trimmed)) {\n return `${trimmed}px`;\n }\n\n return trimmed;\n };\n\n const hasSelectedStroke = selectedAnswerStrokeColor && selectedAnswerStrokeColor !== 'initial';\n const hasHoverStroke = hoverAnswerStrokeColor && hoverAnswerStrokeColor !== 'initial';\n \n let currentStrokeColor = 'transparent';\n let currentStrokeWidth = '2px';\n let currentBackgroundColor = 'initial';\n \n if ((hasSelectedStroke || hasHoverStroke)) {\n if (checked && hasSelectedStroke) {\n // selected state takes priority when selected stroke is configured\n currentStrokeColor = selectedAnswerStrokeColor;\n currentStrokeWidth = selectedAnswerStrokeWidth;\n } else if (isHovered && !disabled && hasHoverStroke) {\n // hover state when not selected and not disabled, and hover stroke is configured\n currentStrokeColor = hoverAnswerStrokeColor;\n currentStrokeWidth = hoverAnswerStrokeWidth;\n }\n }\n \n if (checked && selectedAnswerBackgroundColor && selectedAnswerBackgroundColor !== 'initial') {\n currentBackgroundColor = selectedAnswerBackgroundColor;\n } else if (isHovered && !disabled && hoverAnswerBackgroundColor && hoverAnswerBackgroundColor !== 'initial') {\n currentBackgroundColor = hoverAnswerBackgroundColor;\n }\n\n const strokeStyle = (hasSelectedStroke || hasHoverStroke) ? {\n border: `${normalizeStrokeWidth(currentStrokeWidth)} solid ${currentStrokeColor}`,\n borderRadius: '8px',\n } : {};\n\n const names = classNames(classes.choice, {\n [classes.noBorder]: index === choicesLength - 1 || choicesLayout !== 'vertical' || strokeStyle,\n [classes.horizontalLayout]: choicesLayout === 'horizontal',\n });\n\n const choiceBackground = currentBackgroundColor !== 'initial' ? currentBackgroundColor : 'initial';\n\n return (\n <div \n className={choiceClass} \n key={index} \n style={{ backgroundColor: choiceBackground, ...strokeStyle }}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n >\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 selectedAnswerStrokeColor: PropTypes.string,\n selectedAnswerStrokeWidth: PropTypes.string,\n hoverAnswerBackgroundColor: PropTypes.string,\n hoverAnswerStrokeColor: PropTypes.string,\n hoverAnswerStrokeWidth: 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"}
1
+ {"version":3,"sources":["../src/choice.jsx"],"names":["Choice","isHovered","props","disabled","checked","setState","choice","onChoiceChanged","index","choicesLength","showCorrect","isEvaluateMode","choiceMode","correctness","displayKey","classes","choicesLayout","gridColumns","isSelectionButtonBelow","selectedAnswerBackgroundColor","selectedAnswerStrokeColor","selectedAnswerStrokeWidth","hoverAnswerBackgroundColor","hoverAnswerStrokeColor","hoverAnswerStrokeWidth","autoFocusRef","tagName","state","choiceClass","feedback","choiceProps","onChange","normalizeStrokeWidth","width","trimmed","String","trim","test","hasSelectedStroke","hasHoverStroke","currentStrokeColor","currentStrokeWidth","currentBackgroundColor","hasStroke","strokeStyle","border","borderRadius","names","noBorder","horizontalLayout","choiceBackground","backgroundColor","handleMouseEnter","handleMouseLeave","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;;;;;;;;;;;;;;;8FAGH;AACNC,MAAAA,SAAS,EAAE;AADL,K;yGAIW,YAAM;AACvB,wBAA8B,MAAKC,KAAnC;AAAA,UAAQC,QAAR,eAAQA,QAAR;AAAA,UAAkBC,OAAlB,eAAkBA,OAAlB;;AAEA,UAAI,CAACD,QAAD,IAAa,CAACC,OAAlB,EAA2B;AACzB,cAAKC,QAAL,CAAc;AAAEJ,UAAAA,SAAS,EAAE;AAAb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AAEqC,sBAAUO,MAhBpB;AAiBjB3C,EAAAA,yBAAyB,EAAEoC,sBAAUO,MAjBpB;AAkBjB1C,EAAAA,0BAA0B,EAAEmC,sBAAUO,MAlBrB;AAmBjBzC,EAAAA,sBAAsB,EAAEkC,sBAAUO,MAnBjB;AAoBjBxC,EAAAA,sBAAsB,EAAEiC,sBAAUO,MApBjB;AAqBjBtC,EAAAA,OAAO,EAAE+B,sBAAUO,MArBF;AAsBjB9C,EAAAA,sBAAsB,EAAEuC,sBAAUG,IAtBjB;AAuBjBnC,EAAAA,YAAY,EAAEgC,sBAAUE;AAvBP,CAAnB;;eA0Be,wBAAW,UAACM,KAAD;AAAA,SAAY;AACpC3D,IAAAA,MAAM,EAAE;AACN4D,MAAAA,UAAU,EAAED,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,GAD3B;AAENC,MAAAA,aAAa,EAAEJ,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAF9B;AAGNE,MAAAA,WAAW,EAAEL,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAH5B;AAING,MAAAA,YAAY,EAAEN,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAJ7B;AAKNI,MAAAA,YAAY,sBAAeP,KAAK,CAACQ,OAAN,CAAcC,IAAd,CAAmB,GAAnB,CAAf;AALN,KAD4B;AAQpC1B,IAAAA,QAAQ,EAAE;AACRwB,MAAAA,YAAY,EAAE;AADN,KAR0B;AAWpCvB,IAAAA,gBAAgB,EAAE;AAChBsB,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,EAoBXpE,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 state = {\n isHovered: false,\n };\n\n handleMouseEnter = () => {\n const { disabled, checked } = this.props;\n\n if (!disabled && !checked) {\n this.setState({ isHovered: true });\n }\n };\n\n handleMouseLeave = () => {\n this.setState({ isHovered: false });\n };\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 selectedAnswerStrokeColor,\n selectedAnswerStrokeWidth,\n hoverAnswerBackgroundColor,\n hoverAnswerStrokeColor,\n hoverAnswerStrokeWidth,\n autoFocusRef,\n tagName\n } = this.props;\n \n const { isHovered } = this.state;\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 selectedAnswerStrokeColor,\n selectedAnswerStrokeWidth,\n tagName,\n };\n\n const normalizeStrokeWidth = (width) => {\n if (!width) return '2px'; // default\n const trimmed = String(width).trim();\n \n // add 'px' if the value is a number\n if (/^\\d+(\\.\\d+)?$/.test(trimmed)) {\n return `${trimmed}px`;\n }\n\n return trimmed;\n };\n\n const hasSelectedStroke = selectedAnswerStrokeColor && selectedAnswerStrokeColor !== 'initial';\n const hasHoverStroke = hoverAnswerStrokeColor && hoverAnswerStrokeColor !== 'initial';\n \n let currentStrokeColor = 'transparent';\n let currentStrokeWidth = '2px';\n let currentBackgroundColor = 'initial';\n \n if ((hasSelectedStroke || hasHoverStroke)) {\n if (checked && hasSelectedStroke) {\n // selected state takes priority when selected stroke is configured\n currentStrokeColor = selectedAnswerStrokeColor;\n currentStrokeWidth = selectedAnswerStrokeWidth;\n } else if (isHovered && !disabled && hasHoverStroke) {\n // hover state when not selected and not disabled, and hover stroke is configured\n currentStrokeColor = hoverAnswerStrokeColor;\n currentStrokeWidth = hoverAnswerStrokeWidth;\n }\n }\n \n if (checked && selectedAnswerBackgroundColor && selectedAnswerBackgroundColor !== 'initial') {\n currentBackgroundColor = selectedAnswerBackgroundColor;\n } else if (isHovered && !disabled && hoverAnswerBackgroundColor && hoverAnswerBackgroundColor !== 'initial') {\n currentBackgroundColor = hoverAnswerBackgroundColor;\n }\n\n const hasStroke = hasSelectedStroke || hasHoverStroke;\n const strokeStyle = hasStroke ? {\n border: `${normalizeStrokeWidth(currentStrokeWidth)} solid ${currentStrokeColor}`,\n borderRadius: '8px',\n } : {};\n\n const names = classNames(classes.choice, {\n [classes.noBorder]: index === choicesLength - 1 || choicesLayout !== 'vertical' || hasStroke,\n [classes.horizontalLayout]: choicesLayout === 'horizontal',\n });\n\n const choiceBackground = currentBackgroundColor !== 'initial' ? currentBackgroundColor : 'initial';\n\n return (\n <div \n className={choiceClass} \n key={index} \n style={{ backgroundColor: choiceBackground, ...strokeStyle }}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n >\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 selectedAnswerStrokeColor: PropTypes.string,\n selectedAnswerStrokeWidth: PropTypes.string,\n hoverAnswerBackgroundColor: PropTypes.string,\n hoverAnswerStrokeColor: PropTypes.string,\n hoverAnswerStrokeWidth: 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"}
@@ -251,14 +251,20 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
251
251
  }, {
252
252
  key: "getChecked",
253
253
  value: function getChecked(choice) {
254
- // to determine if we are in evaluate mode or print mode
255
- // since both modes have showCorrect but it interferes with "browse mode" in IBX if the print props are set
254
+ // check for print context: options prop is passed from print.js and alwaysShowCorrect is true
255
+ var isPrintMode = this.props.options && this.props.alwaysShowCorrect;
256
+
257
+ if (isPrintMode) {
258
+ return choice.correct || false;
259
+ } // evaluate mode with show correct toggled
260
+
261
+
256
262
  var isEvaluateMode = this.state.showCorrect && this.props.mode === 'evaluate';
257
- var isPrintMode = this.props.alwaysShowCorrect && (!this.props.session || !this.props.session.value || this.props.session.value.length === 0);
258
263
 
259
- if (isEvaluateMode || isPrintMode) {
264
+ if (isEvaluateMode) {
260
265
  return choice.correct || false;
261
- }
266
+ } // default behavior: show what the user has selected
267
+
262
268
 
263
269
  return this.isSelected(choice.value);
264
270
  } // renderHeading function was added for accessibility.
@@ -455,7 +461,8 @@ exports.MultipleChoice = MultipleChoice;
455
461
  customAudioButton: {
456
462
  playImage: _propTypes["default"].string,
457
463
  pauseImage: _propTypes["default"].string
458
- }
464
+ },
465
+ options: _propTypes["default"].object
459
466
  });
460
467
  MultipleChoice.defaultProps = {
461
468
  session: {
@@ -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","outline","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","relatedTarget","compareDocumentPosition","Node","DOCUMENT_POSITION_PRECEDING","firstInputRef","current","focus","alwaysShowCorrect","onToggle","bind","React","createRef","sessionValue","indexOf","nextProps","correctResponse","index","keyMode","String","fromCharCode","toUpperCase","isEvaluateMode","isPrintMode","choiceMode","classes","disabled","className","choices","gridColumns","prompt","responseCorrect","animationsDisabled","language","isSelectionButtonBelow","minSelections","autoplayAudioEnabled","customAudioButton","showCorrectAnswerToggle","columnsStyle","gridTemplateColumns","selections","teacherInstructionsDiv","getMultipleChoiceMinSelectionErrorMessage","t","lng","renderHeading","hidden","visible","handleGroupFocus","choicesLayout","map","selectedAnswerBackgroundColor","selectedAnswerStrokeColor","selectedAnswerStrokeWidth","hoverAnswerBackgroundColor","hoverAnswerStrokeColor","hoverAnswerStrokeWidth","handleChange","hideTick","getChecked","getCorrectness","indexToSymbol","Component","PropTypes","string","oneOf","array","object","bool","func","isRequired","number","playImage","pauseImage","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;A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N;AAiBjBzD,EAAAA,iBAAiB,EAAEwD,sBAAUK,IAjBZ;AAkBjBrC,EAAAA,kBAAkB,EAAEgC,sBAAUK,IAlBb;AAmBjBpC,EAAAA,QAAQ,EAAE+B,sBAAUC,MAnBH;AAoBjBb,EAAAA,6BAA6B,EAAEY,sBAAUC,MApBxB;AAqBjBZ,EAAAA,yBAAyB,EAAEW,sBAAUC,MArBpB;AAsBjBX,EAAAA,yBAAyB,EAAEU,sBAAUC,MAtBpB;AAuBjBV,EAAAA,0BAA0B,EAAES,sBAAUC,MAvBrB;AAwBjBT,EAAAA,sBAAsB,EAAEQ,sBAAUC,MAxBjB;AAyBjBR,EAAAA,sBAAsB,EAAEO,sBAAUC,MAzBjB;AA0BjB7E,EAAAA,mBAAmB,EAAE4E,sBAAUM,IA1Bd;AA2BjBpC,EAAAA,sBAAsB,EAAE8B,sBAAUK,IA3BjB;AA4BjBlC,EAAAA,aAAa,EAAE6B,sBAAUQ,MA5BR;AA6BjB/F,EAAAA,aAAa,EAAEuF,sBAAUQ,MA7BR;AA8BjBpC,EAAAA,oBAAoB,EAAE4B,sBAAUK,IA9Bf;AA+BjBhC,EAAAA,iBAAiB,EAAE;AACjBoC,IAAAA,SAAS,EAAET,sBAAUC,MADJ;AAEjBS,IAAAA,UAAU,EAAEV,sBAAUC;AAFL;AA/BF,C;AAuVrB9F,cAAc,CAACwG,YAAf,GAA8B;AAC5BhG,EAAAA,OAAO,EAAE;AACPJ,IAAAA,KAAK,EAAE;AADA;AADmB,CAA9B;;eAMe,wBAAW1C,MAAX,EAAmBsC,cAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';\nimport classNames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color, Collapsible, PreviewPrompt } from '@pie-lib/render-ui';\nimport Translator from '@pie-lib/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 '&:focus': {\n outline: 'none',\n },\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 selectedAnswerStrokeColor: PropTypes.string,\n selectedAnswerStrokeWidth: PropTypes.string,\n hoverAnswerBackgroundColor: PropTypes.string,\n hoverAnswerStrokeColor: PropTypes.string,\n hoverAnswerStrokeWidth: 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 // to determine if we are in evaluate mode or print mode\n // since both modes have showCorrect but it interferes with \"browse mode\" in IBX if the print props are set\n const isEvaluateMode = this.state.showCorrect && this.props.mode === 'evaluate';\n const isPrintMode =\n this.props.alwaysShowCorrect &&\n (!this.props.session || !this.props.session.value || this.props.session.value.length === 0);\n\n if (isEvaluateMode || isPrintMode) {\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 <h3 className={classes.srOnly}>Multiple Choice Question</h3>\n ) : (\n <h3 className={classes.srOnly}>Multiple Select Question</h3>\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 // Only focus the first input if user is tabbing forward\n if (!e.relatedTarget || fieldset.compareDocumentPosition(e.relatedTarget) & Node.DOCUMENT_POSITION_PRECEDING) {\n if (this.firstInputRef?.current) {\n this.firstInputRef.current.focus();\n }\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 && <h2 className={classes.partLabel}>{partLabel}</h2>}\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 selectedAnswerStrokeColor={this.props.selectedAnswerStrokeColor}\n selectedAnswerStrokeWidth={this.props.selectedAnswerStrokeWidth}\n hoverAnswerBackgroundColor={this.props.hoverAnswerBackgroundColor}\n hoverAnswerStrokeColor={this.props.hoverAnswerStrokeColor}\n hoverAnswerStrokeWidth={this.props.hoverAnswerStrokeWidth}\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"}
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","outline","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","relatedTarget","compareDocumentPosition","Node","DOCUMENT_POSITION_PRECEDING","firstInputRef","current","focus","alwaysShowCorrect","onToggle","bind","React","createRef","sessionValue","indexOf","nextProps","correctResponse","index","keyMode","String","fromCharCode","toUpperCase","isPrintMode","options","isEvaluateMode","choiceMode","classes","disabled","className","choices","gridColumns","prompt","responseCorrect","animationsDisabled","language","isSelectionButtonBelow","minSelections","autoplayAudioEnabled","customAudioButton","showCorrectAnswerToggle","columnsStyle","gridTemplateColumns","selections","teacherInstructionsDiv","getMultipleChoiceMinSelectionErrorMessage","t","lng","renderHeading","hidden","visible","handleGroupFocus","choicesLayout","map","selectedAnswerBackgroundColor","selectedAnswerStrokeColor","selectedAnswerStrokeWidth","hoverAnswerBackgroundColor","hoverAnswerStrokeColor","hoverAnswerStrokeWidth","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,gBA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B;AAuBjBV,EAAAA,0BAA0B,EAAES,sBAAUC,MAvBrB;AAwBjBT,EAAAA,sBAAsB,EAAEQ,sBAAUC,MAxBjB;AAyBjBR,EAAAA,sBAAsB,EAAEO,sBAAUC,MAzBjB;AA0BjB9E,EAAAA,mBAAmB,EAAE6E,sBAAUM,IA1Bd;AA2BjBpC,EAAAA,sBAAsB,EAAE8B,sBAAUK,IA3BjB;AA4BjBlC,EAAAA,aAAa,EAAE6B,sBAAUQ,MA5BR;AA6BjBhG,EAAAA,aAAa,EAAEwF,sBAAUQ,MA7BR;AA8BjBpC,EAAAA,oBAAoB,EAAE4B,sBAAUK,IA9Bf;AA+BjBhC,EAAAA,iBAAiB,EAAE;AACjBoC,IAAAA,SAAS,EAAET,sBAAUC,MADJ;AAEjBS,IAAAA,UAAU,EAAEV,sBAAUC;AAFL,GA/BF;AAmCjB3C,EAAAA,OAAO,EAAE0C,sBAAUI;AAnCF,C;AA4VrBlG,cAAc,CAACyG,YAAf,GAA8B;AAC5BjG,EAAAA,OAAO,EAAE;AACPJ,IAAAA,KAAK,EAAE;AADA;AADmB,CAA9B;;eAMe,wBAAW1C,MAAX,EAAmBsC,cAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';\nimport classNames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color, Collapsible, PreviewPrompt } from '@pie-lib/render-ui';\nimport Translator from '@pie-lib/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 '&:focus': {\n outline: 'none',\n },\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 selectedAnswerStrokeColor: PropTypes.string,\n selectedAnswerStrokeWidth: PropTypes.string,\n hoverAnswerBackgroundColor: PropTypes.string,\n hoverAnswerStrokeColor: PropTypes.string,\n hoverAnswerStrokeWidth: 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 options: PropTypes.object,\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 // check for print context: options prop is passed from print.js and alwaysShowCorrect is true\n const isPrintMode = this.props.options && this.props.alwaysShowCorrect;\n \n if (isPrintMode) {\n return choice.correct || false;\n }\n\n // evaluate mode with show correct toggled\n const isEvaluateMode = this.state.showCorrect && this.props.mode === 'evaluate';\n \n if (isEvaluateMode) {\n return choice.correct || false;\n }\n\n // default behavior: show what the user has selected\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 <h3 className={classes.srOnly}>Multiple Choice Question</h3>\n ) : (\n <h3 className={classes.srOnly}>Multiple Select Question</h3>\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 // Only focus the first input if user is tabbing forward\n if (!e.relatedTarget || fieldset.compareDocumentPosition(e.relatedTarget) & Node.DOCUMENT_POSITION_PRECEDING) {\n if (this.firstInputRef?.current) {\n this.firstInputRef.current.focus();\n }\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 && <h2 className={classes.partLabel}>{partLabel}</h2>}\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 selectedAnswerStrokeColor={this.props.selectedAnswerStrokeColor}\n selectedAnswerStrokeWidth={this.props.selectedAnswerStrokeWidth}\n hoverAnswerBackgroundColor={this.props.hoverAnswerBackgroundColor}\n hoverAnswerStrokeColor={this.props.hoverAnswerStrokeColor}\n hoverAnswerStrokeWidth={this.props.hoverAnswerStrokeWidth}\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/lib/print.js CHANGED
@@ -89,7 +89,8 @@ var MultipleChoicePrint = /*#__PURE__*/function (_HTMLElement) {
89
89
 
90
90
  var element = _this._options && /*#__PURE__*/_react["default"].createElement(_main["default"], {
91
91
  model: printModel,
92
- session: {}
92
+ session: {},
93
+ options: _this._options
93
94
  });
94
95
 
95
96
  _reactDom["default"].render(element, (0, _assertThisInitialized2["default"])(_this), function () {
package/lib/print.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/print.js"],"names":["log","preparePrintModel","model","opts","instr","role","prompt","promptEnabled","undefined","teacherInstructions","teacherInstructionsEnabled","showTeacherInstructions","alwaysShowCorrect","mode","disabled","animationsDisabled","lockChoiceOrder","choicesLayout","choices","map","c","rationale","rationaleEnabled","hideTick","feedback","keyMode","choicePrefix","MultipleChoicePrint","_options","_model","_session","_rerender","printModel","element","React","createElement","Main","session","ReactDOM","render","leading","trailing","o","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,mCAAN,CAAZ;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,KAAD,EAAQC,IAAR,EAAiB;AACzC,MAAMC,KAAK,GAAGD,IAAI,CAACE,IAAL,KAAc,YAA5B;AAEAH,EAAAA,KAAK,CAACI,MAAN,GAAeJ,KAAK,CAACK,aAAN,KAAwB,KAAxB,GAAgCL,KAAK,CAACI,MAAtC,GAA+CE,SAA9D;AACAN,EAAAA,KAAK,CAACO,mBAAN,GACEL,KAAK,IAAIF,KAAK,CAACQ,0BAAN,KAAqC,KAA9C,GAAsDR,KAAK,CAACO,mBAA5D,GAAkFD,SADpF;AAEAN,EAAAA,KAAK,CAACS,uBAAN,GAAgCP,KAAhC;AACAF,EAAAA,KAAK,CAACU,iBAAN,GAA0BR,KAA1B;AACAF,EAAAA,KAAK,CAACW,IAAN,GAAaT,KAAK,GAAG,UAAH,GAAgBF,KAAK,CAACW,IAAxC;AAEAX,EAAAA,KAAK,CAACY,QAAN,GAAiB,IAAjB;AACAZ,EAAAA,KAAK,CAACa,kBAAN,GAA2B,IAA3B;AACAb,EAAAA,KAAK,CAACc,eAAN,GAAwB,IAAxB;AACAd,EAAAA,KAAK,CAACe,aAAN,GAAsBf,KAAK,CAACe,aAAN,IAAuB,UAA7C;AAEA,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C,MAAAA,QAAQ,EAAE;AAA5B,KArBe,CAAjB;AALY;AA4Bb;;;;SACD,aAAYC,CAAZ,EAAe;AACb,WAAKd,QAAL,GAAgBc,CAAhB;AACD;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKd,MAAL,GAAcc,CAAd;;AACA,WAAKZ,SAAL;AACD;;;WAED,6BAAoB,CAAE;;;kDAvCyBa,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport debounce from 'lodash/debounce';\nimport cloneDeep from 'lodash/cloneDeep';\nimport Main from './main';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport debug from 'debug';\n\nconst log = debug('pie-element:multiple-choice:print');\n\n/**\n * Live in same package as main element - so we can access some of the shared comps!\n *\n * - update pslb to build print if src/print.js is there\n * - update demo el\n * - get configure/controller building\n */\n\nconst preparePrintModel = (model, opts) => {\n const instr = opts.role === 'instructor';\n\n model.prompt = model.promptEnabled !== false ? model.prompt : undefined;\n model.teacherInstructions =\n instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;\n model.showTeacherInstructions = instr;\n model.alwaysShowCorrect = instr;\n model.mode = instr ? 'evaluate' : model.mode;\n\n model.disabled = true;\n model.animationsDisabled = true;\n model.lockChoiceOrder = true;\n model.choicesLayout = model.choicesLayout || 'vertical';\n\n const choices = cloneDeep(model.choices);\n\n model.choices = choices.map((c) => {\n c.rationale = instr && model.rationaleEnabled !== false ? c.rationale : undefined;\n c.hideTick = instr;\n c.feedback = undefined;\n return c;\n });\n\n model.keyMode = model.choicePrefix || 'letters';\n\n return model;\n};\n\nexport default class MultipleChoicePrint extends HTMLElement {\n constructor() {\n super();\n this._options = null;\n this._model = null;\n this._session = [];\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n const printModel = preparePrintModel(this._model, this._options);\n\n const element =\n this._options &&\n React.createElement(Main, {\n model: printModel,\n session: {},\n });\n\n ReactDOM.render(element, this, () => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n set options(o) {\n this._options = o;\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n connectedCallback() {}\n}\n"],"file":"print.js"}
1
+ {"version":3,"sources":["../src/print.js"],"names":["log","preparePrintModel","model","opts","instr","role","prompt","promptEnabled","undefined","teacherInstructions","teacherInstructionsEnabled","showTeacherInstructions","alwaysShowCorrect","mode","disabled","animationsDisabled","lockChoiceOrder","choicesLayout","choices","map","c","rationale","rationaleEnabled","hideTick","feedback","keyMode","choicePrefix","MultipleChoicePrint","_options","_model","_session","_rerender","printModel","element","React","createElement","Main","session","options","ReactDOM","render","leading","trailing","o","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,mCAAN,CAAZ;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,KAAD,EAAQC,IAAR,EAAiB;AACzC,MAAMC,KAAK,GAAGD,IAAI,CAACE,IAAL,KAAc,YAA5B;AAEAH,EAAAA,KAAK,CAACI,MAAN,GAAeJ,KAAK,CAACK,aAAN,KAAwB,KAAxB,GAAgCL,KAAK,CAACI,MAAtC,GAA+CE,SAA9D;AACAN,EAAAA,KAAK,CAACO,mBAAN,GACEL,KAAK,IAAIF,KAAK,CAACQ,0BAAN,KAAqC,KAA9C,GAAsDR,KAAK,CAACO,mBAA5D,GAAkFD,SADpF;AAEAN,EAAAA,KAAK,CAACS,uBAAN,GAAgCP,KAAhC;AACAF,EAAAA,KAAK,CAACU,iBAAN,GAA0BR,KAA1B;AACAF,EAAAA,KAAK,CAACW,IAAN,GAAaT,KAAK,GAAG,UAAH,GAAgBF,KAAK,CAACW,IAAxC;AAEAX,EAAAA,KAAK,CAACY,QAAN,GAAiB,IAAjB;AACAZ,EAAAA,KAAK,CAAC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;AACnCjC,UAAAA,GAAG,CAAC,+BAAD,CAAH;AACA;AACD,SAHD;AAID,OAfD,MAeO;AACLA,QAAAA,GAAG,CAAC,MAAD,CAAH;AACD;AACF,KApBc,EAqBf,EArBe,EAsBf;AAAEyC,MAAAA,OAAO,EAAE,KAAX;AAAkBC,MAAAA,QAAQ,EAAE;AAA5B,KAtBe,CAAjB;AALY;AA6Bb;;;;SACD,aAAYC,CAAZ,EAAe;AACb,WAAKf,QAAL,GAAgBe,CAAhB;AACD;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKf,MAAL,GAAce,CAAd;;AACA,WAAKb,SAAL;AACD;;;WAED,6BAAoB,CAAE;;;kDAxCyBc,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport debounce from 'lodash/debounce';\nimport cloneDeep from 'lodash/cloneDeep';\nimport Main from './main';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport debug from 'debug';\n\nconst log = debug('pie-element:multiple-choice:print');\n\n/**\n * Live in same package as main element - so we can access some of the shared comps!\n *\n * - update pslb to build print if src/print.js is there\n * - update demo el\n * - get configure/controller building\n */\n\nconst preparePrintModel = (model, opts) => {\n const instr = opts.role === 'instructor';\n\n model.prompt = model.promptEnabled !== false ? model.prompt : undefined;\n model.teacherInstructions =\n instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;\n model.showTeacherInstructions = instr;\n model.alwaysShowCorrect = instr;\n model.mode = instr ? 'evaluate' : model.mode;\n\n model.disabled = true;\n model.animationsDisabled = true;\n model.lockChoiceOrder = true;\n model.choicesLayout = model.choicesLayout || 'vertical';\n\n const choices = cloneDeep(model.choices);\n\n model.choices = choices.map((c) => {\n c.rationale = instr && model.rationaleEnabled !== false ? c.rationale : undefined;\n c.hideTick = instr;\n c.feedback = undefined;\n return c;\n });\n\n model.keyMode = model.choicePrefix || 'letters';\n\n return model;\n};\n\nexport default class MultipleChoicePrint extends HTMLElement {\n constructor() {\n super();\n this._options = null;\n this._model = null;\n this._session = [];\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n const printModel = preparePrintModel(this._model, this._options);\n\n const element =\n this._options &&\n React.createElement(Main, {\n model: printModel,\n session: {},\n options: this._options,\n });\n\n ReactDOM.render(element, this, () => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n set options(o) {\n this._options = o;\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n connectedCallback() {}\n}\n"],"file":"print.js"}