@pie-element/multiple-choice 8.21.4-next.3 → 8.21.4-next.33

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.
@@ -8,7 +8,7 @@
8
8
  "@material-ui/core": "^3.9.2",
9
9
  "@material-ui/icons": "^3.0.1",
10
10
  "@pie-framework/pie-configure-events": "^1.3.0",
11
- "@pie-lib/pie-toolbox": "1.25.3",
11
+ "@pie-lib/pie-toolbox": "1.26.0",
12
12
  "debug": "^3.1.0",
13
13
  "lodash": "^4.17.15",
14
14
  "prop-types": "^15.6.2",
@@ -8,7 +8,7 @@
8
8
  "author": "",
9
9
  "license": "ISC",
10
10
  "dependencies": {
11
- "@pie-lib/pie-toolbox": "1.25.3",
11
+ "@pie-lib/pie-toolbox": "1.26.0",
12
12
  "debug": "^3.1.0",
13
13
  "lodash": "^4.17.15"
14
14
  }
package/lib/index.js CHANGED
@@ -66,7 +66,8 @@ var MultipleChoice = /*#__PURE__*/function (_HTMLElement) {
66
66
  var element = /*#__PURE__*/_react["default"].createElement(_main["default"], {
67
67
  model: _this._model,
68
68
  session: _this._session,
69
- onChoiceChanged: _this._onChange.bind((0, _assertThisInitialized2["default"])(_this))
69
+ onChoiceChanged: _this._onChange.bind((0, _assertThisInitialized2["default"])(_this)),
70
+ onShowCorrectToggle: _this.onShowCorrectToggle.bind((0, _assertThisInitialized2["default"])(_this))
70
71
  }); //TODO: aria-label is set in the _rerender because we need to change it when the model.choiceMode is updated. Consider revisiting the placement of the aria-label setting in the _rerender
71
72
 
72
73
 
@@ -117,6 +118,11 @@ var MultipleChoice = /*#__PURE__*/function (_HTMLElement) {
117
118
  }
118
119
 
119
120
  (0, _createClass2["default"])(MultipleChoice, [{
121
+ key: "onShowCorrectToggle",
122
+ value: function onShowCorrectToggle() {
123
+ (0, _mathRenderingAccessible.renderMath)(this);
124
+ }
125
+ }, {
120
126
  key: "setLangAttribute",
121
127
  value: function setLangAttribute() {
122
128
  var language = this._model && (0, _typeof2["default"])(this._model.language) ? this._model.language : '';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["log","isComplete","session","value","length","MultipleChoice","_model","_session","_rerender","element","React","createElement","Main","model","onChoiceChanged","_onChange","bind","setAttribute","choiceMode","setLangAttribute","ReactDOM","render","leading","trailing","_dispatchResponseChanged","event","CustomEvent","bubbles","composed","detail","complete","component","tagName","toLowerCase","dispatchEvent","_dispatchModelSet","hasModel","undefined","language","lang","slice","s","data","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,wBAAN,CAAZ;;AAEO,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,OAAD;AAAA,SAAa,CAAC,EAAEA,OAAO,IAAIA,OAAO,CAACC,KAAnB,IAA4BD,OAAO,CAACC,KAAR,CAAcC,MAA5C,CAAd;AAAA,CAAnB;;;;IAEcC,c;;;;;AACnB,4BAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,MAAL,GAAc,IAAd;AACA,UAAKC,QAAL,GAAgB,IAAhB;AAEA,UAAKC,SAAL,GAAiB,0BACf,YAAM;AACJ,UAAI,MAAKF,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAIE,OAAO,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACtCC,UAAAA,KAAK,EAAE,MAAKP,MAD0B;AAEtCJ,UAAAA,OAAO,EAAE,MAAKK,QAFwB;AAGtCO,UAAAA,eAAe,EAAE,MAAKC,SAAL,CAAeC,IAAf;AAHqB,SAA1B,CAAd,CADgC,CAOhC;;;AACA,cAAKC,YAAL,CACE,YADF,EAEE,MAAKX,MAAL,CAAYY,UAAZ,KAA2B,OAA3B,GAAqC,0BAArC,GAAkE,kCAFpE;;AAIA,cAAKD,YAAL,CAAkB,MAAlB,EAA0B,QAA1B;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;;;WAED,4BAAmB;AACjB,UAAMe,QAAQ,GAAG,KAAKhC,MAAL,6BAAsB,KAAKA,MAAL,CAAYgC,QAAlC,IAA6C,KAAKhC,MAAL,CAAYgC,QAAzD,GAAoE,EAArF;AACA,UAAMC,IAAI,GAAGD,QAAQ,GAAGA,QAAQ,CAACE,KAAT,CAAe,CAAf,EAAkB,CAAlB,CAAH,GAA0B,IAA/C;AACA,WAAKvB,YAAL,CAAkB,MAAlB,EAA0BsB,IAA1B;AACD;;;SAED,aAAUE,CAAV,EAAa;AACX,WAAKnC,MAAL,GAAcmC,CAAd;;AACA,WAAKjC,SAAL;;AACA,WAAK2B,iBAAL;AACD;;;SAED,eAAc;AACZ,aAAO,KAAK5B,QAAZ;AACD,K;SAED,aAAYkC,CAAZ,EAAe;AACb,WAAKlC,QAAL,GAAgBkC,CAAhB;;AACA,WAAKjC,SAAL,GAFa,CAGb;;;AACA,WAAKgB,wBAAL;AACD;;;WAED,mBAAUkB,IAAV,EAAgB;AACd,8CAAmB,KAAKnC,QAAxB,EAAkC,KAAKD,MAAL,CAAYY,UAA9C,EAA0DwB,IAA1D;;AACA,WAAKlB,wBAAL;;AACA,WAAKhB,SAAL;AACD;;;WAED,6BAAoB;AAClB,WAAKA,SAAL;AACD;;;kDAnGyCmC,W","sourcesContent":["import Main from './main';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport debounce from 'lodash/debounce';\nimport debug from 'debug';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering-accessible';\nimport { updateSessionValue } from './session-updater';\n\nconst log = debug('pie-ui:multiple-choice');\n\nexport const isComplete = (session) => !!(session && session.value && session.value.length);\n\nexport default class MultipleChoice extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n var element = React.createElement(Main, {\n model: this._model,\n session: this._session,\n onChoiceChanged: this._onChange.bind(this),\n });\n\n //TODO: aria-label is set in the _rerender because we need to change it when the model.choiceMode is updated. Consider revisiting the placement of the aria-label setting in the _rerender\n this.setAttribute(\n 'aria-label',\n this._model.choiceMode === 'radio' ? 'Multiple Choice Question' : 'Multiple Correct Answer Question',\n );\n this.setAttribute('role', 'region');\n\n this.setLangAttribute();\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 this._dispatchResponseChanged = debounce(() => {\n var event = new CustomEvent('session-changed', {\n bubbles: true,\n composed: true,\n detail: {\n complete: isComplete(this._session),\n component: this.tagName.toLowerCase(),\n },\n });\n\n this.dispatchEvent(event);\n });\n\n this._dispatchModelSet = debounce(\n () => {\n this.dispatchEvent(\n new CustomEvent('model-set', {\n bubbles: true,\n composed: true,\n detail: {\n complete: isComplete(this._session),\n component: this.tagName.toLowerCase(),\n hasModel: this._model !== undefined,\n },\n }),\n );\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n\n setLangAttribute() {\n const language = this._model && typeof this._model.language ? this._model.language : '';\n const lang = language ? language.slice(0, 2) : 'en';\n this.setAttribute('lang', lang);\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n this._dispatchModelSet();\n }\n\n get session() {\n return this._session;\n }\n\n set session(s) {\n this._session = s;\n this._rerender();\n //TODO: remove this session-changed should only be emit on user change\n this._dispatchResponseChanged();\n }\n\n _onChange(data) {\n updateSessionValue(this._session, this._model.choiceMode, data);\n this._dispatchResponseChanged();\n this._rerender();\n }\n\n connectedCallback() {\n this._rerender();\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["log","isComplete","session","value","length","MultipleChoice","_model","_session","_rerender","element","React","createElement","Main","model","onChoiceChanged","_onChange","bind","onShowCorrectToggle","setAttribute","choiceMode","setLangAttribute","ReactDOM","render","leading","trailing","_dispatchResponseChanged","event","CustomEvent","bubbles","composed","detail","complete","component","tagName","toLowerCase","dispatchEvent","_dispatchModelSet","hasModel","undefined","language","lang","slice","s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CAAf,EAAkB,CAAlB,CAAH,GAA0B,IAA/C;AACA,WAAKvB,YAAL,CAAkB,MAAlB,EAA0BsB,IAA1B;AACD;;;SAED,aAAUE,CAAV,EAAa;AACX,WAAKpC,MAAL,GAAcoC,CAAd;;AACA,WAAKlC,SAAL;;AACA,WAAK4B,iBAAL;AACD;;;SAED,eAAc;AACZ,aAAO,KAAK7B,QAAZ;AACD,K;SAED,aAAYmC,CAAZ,EAAe;AACb,WAAKnC,QAAL,GAAgBmC,CAAhB;;AACA,WAAKlC,SAAL,GAFa,CAGb;;;AACA,WAAKiB,wBAAL;AACD;;;WAED,mBAAUkB,IAAV,EAAgB;AACd,8CAAmB,KAAKpC,QAAxB,EAAkC,KAAKD,MAAL,CAAYa,UAA9C,EAA0DwB,IAA1D;;AACA,WAAKlB,wBAAL;;AACA,WAAKjB,SAAL;AACD;;;WAED,6BAAoB;AAClB,WAAKA,SAAL;AACD;;;kDAxGyCoC,W","sourcesContent":["import Main from './main';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport debounce from 'lodash/debounce';\nimport debug from 'debug';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering-accessible';\nimport { updateSessionValue } from './session-updater';\n\nconst log = debug('pie-ui:multiple-choice');\n\nexport const isComplete = (session) => !!(session && session.value && session.value.length);\n\nexport default class MultipleChoice extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n var element = React.createElement(Main, {\n model: this._model,\n session: this._session,\n onChoiceChanged: this._onChange.bind(this),\n onShowCorrectToggle: this.onShowCorrectToggle.bind(this),\n });\n\n //TODO: aria-label is set in the _rerender because we need to change it when the model.choiceMode is updated. Consider revisiting the placement of the aria-label setting in the _rerender\n this.setAttribute(\n 'aria-label',\n this._model.choiceMode === 'radio' ? 'Multiple Choice Question' : 'Multiple Correct Answer Question',\n );\n this.setAttribute('role', 'region');\n\n this.setLangAttribute();\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 this._dispatchResponseChanged = debounce(() => {\n var event = new CustomEvent('session-changed', {\n bubbles: true,\n composed: true,\n detail: {\n complete: isComplete(this._session),\n component: this.tagName.toLowerCase(),\n },\n });\n\n this.dispatchEvent(event);\n });\n\n this._dispatchModelSet = debounce(\n () => {\n this.dispatchEvent(\n new CustomEvent('model-set', {\n bubbles: true,\n composed: true,\n detail: {\n complete: isComplete(this._session),\n component: this.tagName.toLowerCase(),\n hasModel: this._model !== undefined,\n },\n }),\n );\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n\n onShowCorrectToggle() {\n renderMath(this);\n }\n\n setLangAttribute() {\n const language = this._model && typeof this._model.language ? this._model.language : '';\n const lang = language ? language.slice(0, 2) : 'en';\n this.setAttribute('lang', lang);\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n this._dispatchModelSet();\n }\n\n get session() {\n return this._session;\n }\n\n set session(s) {\n this._session = s;\n this._rerender();\n //TODO: remove this session-changed should only be emit on user change\n this._dispatchResponseChanged();\n }\n\n _onChange(data) {\n updateSessionValue(this._session, this._model.choiceMode, data);\n this._dispatchResponseChanged();\n this._rerender();\n }\n\n connectedCallback() {\n this._rerender();\n }\n}\n"],"file":"index.js"}
package/lib/main.js CHANGED
@@ -55,11 +55,13 @@ var Main = /*#__PURE__*/function (_React$Component) {
55
55
  var _this$props = this.props,
56
56
  model = _this$props.model,
57
57
  onChoiceChanged = _this$props.onChoiceChanged,
58
- session = _this$props.session; // model.partLabel is a property used for ebsr
58
+ session = _this$props.session,
59
+ onShowCorrectToggle = _this$props.onShowCorrectToggle; // model.partLabel is a property used for ebsr
59
60
 
60
61
  return /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewLayout, null, /*#__PURE__*/_react["default"].createElement(_multipleChoice["default"], (0, _extends2["default"])({}, model, {
61
62
  session: session,
62
- onChoiceChanged: onChoiceChanged
63
+ onChoiceChanged: onChoiceChanged,
64
+ onShowCorrectToggle: onShowCorrectToggle
63
65
  })));
64
66
  }
65
67
  }]);
@@ -70,7 +72,8 @@ var Main = /*#__PURE__*/function (_React$Component) {
70
72
  model: _propTypes["default"].object,
71
73
  session: _propTypes["default"].object,
72
74
  onChoiceChanged: _propTypes["default"].func,
73
- classes: _propTypes["default"].object.isRequired
75
+ classes: _propTypes["default"].object.isRequired,
76
+ onShowCorrectToggle: _propTypes["default"].func
74
77
  });
75
78
  (0, _defineProperty2["default"])(Main, "defaultProps", {
76
79
  model: {},
package/lib/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.jsx"],"names":["styles","Main","props","model","onChoiceChanged","session","React","Component","PropTypes","object","func","classes","isRequired","Styled","name","theme","typography","useNextVariants","Root"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS;AAAA,SAAO,EAAP;AAAA,CAAf;;IAEMC,I;;;;;AAYJ,gBAAYC,KAAZ,EAAmB;AAAA;AAAA,6BACXA,KADW;AAElB;;;;WAED,kBAAS;AACP,wBAA4C,KAAKA,KAAjD;AAAA,UAAQC,KAAR,eAAQA,KAAR;AAAA,UAAeC,eAAf,eAAeA,eAAf;AAAA,UAAgCC,OAAhC,eAAgCA,OAAhC,CADO,CAGP;;AACA,0BACE,gCAAC,uBAAD,qBACE,gCAAC,0BAAD,gCAAoBF,KAApB;AAA2B,QAAA,OAAO,EAAEE,OAApC;AAA6C,QAAA,eAAe,EAAED;AAA9D,SADF,CADF;AAKD;;;EAzBgBE,kBAAMC,S;;iCAAnBN,I,eACe;AACjBE,EAAAA,KAAK,EAAEK,sBAAUC,MADA;AAEjBJ,EAAAA,OAAO,EAAEG,sBAAUC,MAFF;AAGjBL,EAAAA,eAAe,EAAEI,sBAAUE,IAHV;AAIjBC,EAAAA,OAAO,EAAEH,sBAAUC,MAAV,CAAiBG;AAJT,C;iCADfX,I,kBAQkB;AACpBE,EAAAA,KAAK,EAAE,EADa;AAEpBE,EAAAA,OAAO,EAAE;AAFW,C;AAoBxB,IAAMQ,MAAM,GAAG,wBAAWb,MAAX,EAAmB;AAAEc,EAAAA,IAAI,EAAE;AAAR,CAAnB,EAAqCb,IAArC,CAAf;AAEA,IAAMc,KAAK,GAAG,4BAAe;AAC3BC,EAAAA,UAAU,EAAE;AACVC,IAAAA,eAAe,EAAE;AADP;AADe,CAAf,CAAd;;AAMA,IAAMC,IAAI,GAAG,SAAPA,IAAO,CAAChB,KAAD;AAAA,sBACX,gCAAC,wBAAD;AAAkB,IAAA,KAAK,EAAEa;AAAzB,kBACE,gCAAC,MAAD,EAAYb,KAAZ,CADF,CADW;AAAA,CAAb;;eAMegB,I","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';\nimport { PreviewLayout } from '@pie-lib/pie-toolbox/render-ui';\nimport MultipleChoice from './multiple-choice';\n\nconst styles = () => ({});\n\nclass Main extends React.Component {\n static propTypes = {\n model: PropTypes.object,\n session: PropTypes.object,\n onChoiceChanged: PropTypes.func,\n classes: PropTypes.object.isRequired,\n };\n\n static defaultProps = {\n model: {},\n session: {},\n };\n constructor(props) {\n super(props);\n }\n\n render() {\n const { model, onChoiceChanged, session } = this.props;\n\n // model.partLabel is a property used for ebsr\n return (\n <PreviewLayout>\n <MultipleChoice {...model} session={session} onChoiceChanged={onChoiceChanged} />\n </PreviewLayout>\n );\n }\n}\n\nconst Styled = withStyles(styles, { name: 'Main' })(Main);\n\nconst theme = createMuiTheme({\n typography: {\n useNextVariants: true,\n },\n});\n\nconst Root = (props) => (\n <MuiThemeProvider theme={theme}>\n <Styled {...props} />\n </MuiThemeProvider>\n);\n\nexport default Root;\n"],"file":"main.js"}
1
+ {"version":3,"sources":["../src/main.jsx"],"names":["styles","Main","props","model","onChoiceChanged","session","onShowCorrectToggle","React","Component","PropTypes","object","func","classes","isRequired","Styled","name","theme","typography","useNextVariants","Root"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS;AAAA,SAAO,EAAP;AAAA,CAAf;;IAEMC,I;;;;;AAaJ,gBAAYC,KAAZ,EAAmB;AAAA;AAAA,6BACXA,KADW;AAElB;;;;WAED,kBAAS;AACP,wBAAiE,KAAKA,KAAtE;AAAA,UAAQC,KAAR,eAAQA,KAAR;AAAA,UAAeC,eAAf,eAAeA,eAAf;AAAA,UAAgCC,OAAhC,eAAgCA,OAAhC;AAAA,UAAyCC,mBAAzC,eAAyCA,mBAAzC,CADO,CAGP;;AACA,0BACE,gCAAC,uBAAD,qBACE,gCAAC,0BAAD,gCACMH,KADN;AAEE,QAAA,OAAO,EAAEE,OAFX;AAGE,QAAA,eAAe,EAAED,eAHnB;AAIE,QAAA,mBAAmB,EAAEE;AAJvB,SADF,CADF;AAUD;;;EA/BgBC,kBAAMC,S;;iCAAnBP,I,eACe;AACjBE,EAAAA,KAAK,EAAEM,sBAAUC,MADA;AAEjBL,EAAAA,OAAO,EAAEI,sBAAUC,MAFF;AAGjBN,EAAAA,eAAe,EAAEK,sBAAUE,IAHV;AAIjBC,EAAAA,OAAO,EAAEH,sBAAUC,MAAV,CAAiBG,UAJT;AAKjBP,EAAAA,mBAAmB,EAAEG,sBAAUE;AALd,C;iCADfV,I,kBASkB;AACpBE,EAAAA,KAAK,EAAE,EADa;AAEpBE,EAAAA,OAAO,EAAE;AAFW,C;AAyBxB,IAAMS,MAAM,GAAG,wBAAWd,MAAX,EAAmB;AAAEe,EAAAA,IAAI,EAAE;AAAR,CAAnB,EAAqCd,IAArC,CAAf;AAEA,IAAMe,KAAK,GAAG,4BAAe;AAC3BC,EAAAA,UAAU,EAAE;AACVC,IAAAA,eAAe,EAAE;AADP;AADe,CAAf,CAAd;;AAMA,IAAMC,IAAI,GAAG,SAAPA,IAAO,CAACjB,KAAD;AAAA,sBACX,gCAAC,wBAAD;AAAkB,IAAA,KAAK,EAAEc;AAAzB,kBACE,gCAAC,MAAD,EAAYd,KAAZ,CADF,CADW;AAAA,CAAb;;eAMeiB,I","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';\nimport { PreviewLayout } from '@pie-lib/pie-toolbox/render-ui';\nimport MultipleChoice from './multiple-choice';\n\nconst styles = () => ({});\n\nclass Main extends React.Component {\n static propTypes = {\n model: PropTypes.object,\n session: PropTypes.object,\n onChoiceChanged: PropTypes.func,\n classes: PropTypes.object.isRequired,\n onShowCorrectToggle: PropTypes.func,\n };\n\n static defaultProps = {\n model: {},\n session: {},\n };\n constructor(props) {\n super(props);\n }\n\n render() {\n const { model, onChoiceChanged, session, onShowCorrectToggle } = this.props;\n\n // model.partLabel is a property used for ebsr\n return (\n <PreviewLayout>\n <MultipleChoice\n {...model}\n session={session}\n onChoiceChanged={onChoiceChanged}\n onShowCorrectToggle={onShowCorrectToggle}\n />\n </PreviewLayout>\n );\n }\n}\n\nconst Styled = withStyles(styles, { name: 'Main' })(Main);\n\nconst theme = createMuiTheme({\n typography: {\n useNextVariants: true,\n },\n});\n\nconst Root = (props) => (\n <MuiThemeProvider theme={theme}>\n <Styled {...props} />\n </MuiThemeProvider>\n);\n\nexport default Root;\n"],"file":"main.js"}
@@ -124,6 +124,15 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
124
124
  };
125
125
  });
126
126
  });
127
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onToggle", function () {
128
+ if (_this.props.mode === 'evaluate') {
129
+ _this.setState({
130
+ showCorrect: !_this.state.showCorrect
131
+ }, function () {
132
+ _this.props.onShowCorrectToggle();
133
+ });
134
+ }
135
+ });
127
136
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getCorrectness", function () {
128
137
  var choice = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
129
138
  var isCorrect = choice.correct;
@@ -168,27 +177,24 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
168
177
  return sessionValue && sessionValue.indexOf && sessionValue.indexOf(value) >= 0;
169
178
  } // handleChange and handleChangeCheckboxes functions were added for accessibility. Please see comments and videos from PD-2441. They should only be removed if a better solution is found.
170
179
 
171
- }, {
172
- key: "onToggle",
173
- value: function onToggle() {
174
- if (this.props.mode === 'evaluate') {
175
- this.setState({
176
- showCorrect: !this.state.showCorrect
177
- });
178
- }
179
- }
180
180
  }, {
181
181
  key: "UNSAFE_componentWillReceiveProps",
182
182
  value: function UNSAFE_componentWillReceiveProps(nextProps) {
183
- if (!nextProps.correctResponse) {
183
+ var _this2 = this;
184
+
185
+ if (!nextProps.correctResponse && this.state.showCorrect !== false) {
184
186
  this.setState({
185
187
  showCorrect: false
188
+ }, function () {
189
+ _this2.props.onShowCorrectToggle();
186
190
  });
187
191
  }
188
192
 
189
- if (nextProps.alwaysShowCorrect) {
193
+ if (nextProps.alwaysShowCorrect && this.state.showCorrect !== true) {
190
194
  this.setState({
191
195
  showCorrect: true
196
+ }, function () {
197
+ _this2.props.onShowCorrectToggle();
192
198
  });
193
199
  }
194
200
  }
@@ -241,7 +247,7 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
241
247
  key: "render",
242
248
  value: function render() {
243
249
  var _classNames,
244
- _this2 = this;
250
+ _this3 = this;
245
251
 
246
252
  var _this$props2 = this.props,
247
253
  mode = _this$props2.mode,
@@ -302,7 +308,7 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
302
308
  style: columnsStyle
303
309
  }, choices.map(function (choice, index) {
304
310
  return /*#__PURE__*/_react["default"].createElement(_choice["default"], {
305
- choicesLayout: _this2.props.choicesLayout,
311
+ choicesLayout: _this3.props.choicesLayout,
306
312
  gridColumns: gridColumns,
307
313
  key: "choice-".concat(index),
308
314
  choice: choice,
@@ -313,11 +319,11 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
313
319
  choiceMode: choiceMode,
314
320
  disabled: disabled,
315
321
  updateSession: onChoiceChanged,
316
- onChoiceChanged: _this2.props.choiceMode === 'radio' ? _this2.handleChange : _this2.handleChangeCheckboxes,
322
+ onChoiceChanged: _this3.props.choiceMode === 'radio' ? _this3.handleChange : _this3.handleChangeCheckboxes,
317
323
  hideTick: choice.hideTick,
318
- checked: _this2.getChecked(choice),
319
- correctness: isEvaluateMode ? _this2.getCorrectness(choice) : undefined,
320
- displayKey: _this2.indexToSymbol(index)
324
+ checked: _this3.getChecked(choice),
325
+ correctness: isEvaluateMode ? _this3.getCorrectness(choice) : undefined,
326
+ displayKey: _this3.indexToSymbol(index)
321
327
  });
322
328
  }))));
323
329
  }
@@ -345,7 +351,8 @@ exports.MultipleChoice = MultipleChoice;
345
351
  gridColumns: _propTypes["default"].string,
346
352
  alwaysShowCorrect: _propTypes["default"].bool,
347
353
  animationsDisabled: _propTypes["default"].bool,
348
- language: _propTypes["default"].string
354
+ language: _propTypes["default"].string,
355
+ onShowCorrectToggle: _propTypes["default"].func
349
356
  });
350
357
  MultipleChoice.defaultProps = {
351
358
  session: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/multiple-choice.jsx"],"names":["styles","theme","main","color","text","backgroundColor","background","partLabel","display","fontSize","margin","fontWeight","paddingBottom","spacing","unit","teacherInstructions","marginBottom","horizontalLayout","flexDirection","flexWrap","gridLayout","fieldset","border","padding","minWidth","srOnly","position","left","top","width","height","overflow","MultipleChoice","props","event","target","setState","selectedValue","value","checked","prevState","selectedValues","push","filter","currentValue","choice","isCorrect","correct","isChecked","isSelected","state","showCorrect","undefined","alwaysShowCorrect","onToggle","bind","sessionValue","session","indexOf","mode","nextProps","correctResponse","index","keyMode","String","fromCharCode","toUpperCase","choiceMode","includes","classes","disabled","className","choices","gridColumns","prompt","onChoiceChanged","responseCorrect","animationsDisabled","language","isEvaluateMode","showCorrectAnswerToggle","columnsStyle","gridTemplateColumns","teacherInstructionsDiv","renderHeading","hidden","visible","choicesLayout","map","length","handleChange","handleChangeCheckboxes","hideTick","getChecked","getCorrectness","indexToSymbol","React","Component","PropTypes","string","oneOf","array","object","bool","func","isRequired","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACvBC,IAAAA,IAAI,EAAE;AACFC,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADL;AAEFC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN,EAFf;AAGF,aAAO;AACH,kCAA0B;AADvB;AAHL,KADiB;AAQvBC,IAAAA,SAAS,EAAE;AACPC,MAAAA,OAAO,EAAE,OADF;AAEPC,MAAAA,QAAQ,EAAE,SAFH;AAGPC,MAAAA,MAAM,EAAE,GAHD;AAIPC,MAAAA,UAAU,EAAE,QAJL;AAKPC,MAAAA,aAAa,EAAEX,KAAK,CAACY,OAAN,CAAcC,IAAd,GAAqB;AAL7B,KARY;AAevBC,IAAAA,mBAAmB,EAAE;AACjBC,MAAAA,YAAY,EAAEf,KAAK,CAACY,OAAN,CAAcC,IAAd,GAAqB;AADlB,KAfE;AAkBvBG,IAAAA,gBAAgB,EAAE;AACdT,MAAAA,OAAO,EAAE,MADK;AAEdU,MAAAA,aAAa,EAAE,KAFD;AAGdC,MAAAA,QAAQ,EAAE;AAHI,KAlBK;AAuBvBC,IAAAA,UAAU,EAAE;AACRZ,MAAAA,OAAO,EAAE;AADD,KAvBW;AA0BvBa,IAAAA,QAAQ,EAAE;AACNC,MAAAA,MAAM,EAAE,KADF;AAENC,MAAAA,OAAO,EAAE,cAFH;AAGNb,MAAAA,MAAM,EAAE,KAHF;AAINc,MAAAA,QAAQ,EAAE;AAJJ,KA1Ba;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UM,IAXZ;AAYf5B,EAAAA,eAAe,EAAEsB,sBAAUK,IAZZ;AAaflC,EAAAA,OAAO,EAAE6B,sBAAUI,MAAV,CAAiBG,UAbX;AAcf5C,EAAAA,eAAe,EAAEqC,sBAAUG,KAdZ;AAefd,EAAAA,aAAa,EAAEW,sBAAUE,KAAV,CAAgB,CAAC,UAAD,EAAa,MAAb,EAAqB,YAArB,CAAhB,CAfA;AAgBf3B,EAAAA,WAAW,EAAEyB,sBAAUC,MAhBR;AAiBf9C,EAAAA,iBAAiB,EAAE6C,sBAAUK,IAjBd;AAkBf1B,EAAAA,kBAAkB,EAAEqB,sBAAUK,IAlBf;AAmBfzB,EAAAA,QAAQ,EAAEoB,sBAAUC;AAnBL,C;AAwPvBnE,cAAc,CAAC0E,YAAf,GAA8B;AAC1BjD,EAAAA,OAAO,EAAE;AACLnB,IAAAA,KAAK,EAAE;AADF;AADiB,CAA9B;;eAMe,wBAAWtC,MAAX,EAAmBgC,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 StyledChoice from './choice';\n\n// MultipleChoice\n\nconst styles = (theme) => ({\n main: {\n color: color.text(),\n backgroundColor: color.background(),\n '& *': {\n '-webkit-font-smoothing': 'antialiased',\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});\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 };\n\n constructor(props) {\n super(props);\n\n this.state = {\n selectedValue: null,\n selectedValues: [],\n showCorrect: this.props.alwaysShowCorrect || 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 and handleChangeCheckboxes functions were added for accessibility. Please see comments and videos from PD-2441. They should only be removed if a better solution is found.\n handleChange = (event) => {\n const target = event.target;\n\n this.setState({selectedValue: target.value});\n };\n\n handleChangeCheckboxes = (event) => {\n const {value, checked} = event.target;\n\n this.setState((prevState) => {\n let selectedValues = [...prevState.selectedValues];\n\n if (checked) {\n selectedValues.push(value);\n } else {\n selectedValues = selectedValues.filter((currentValue) => currentValue !== value);\n }\n\n return {selectedValues};\n });\n };\n\n onToggle() {\n if (this.props.mode === 'evaluate') {\n this.setState({showCorrect: !this.state.showCorrect});\n }\n }\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n if (!nextProps.correctResponse) {\n this.setState({showCorrect: false});\n }\n\n if (nextProps.alwaysShowCorrect) {\n this.setState({showCorrect: true});\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 if (this.isSelected(choice.value)) {\n return true;\n }\n\n return this.props.choiceMode === 'radio'\n ? this.state.selectedValue === choice.value\n : this.state.selectedValues.includes(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 onChoiceChanged,\n responseCorrect,\n teacherInstructions,\n classes,\n alwaysShowCorrect,\n animationsDisabled,\n language\n } = this.props;\n const {showCorrect} = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;\n const columnsStyle = gridColumns > 1 ? {gridTemplateColumns: `repeat(${gridColumns}, 1fr)`} : undefined;\n\n const teacherInstructionsDiv = (\n <PreviewPrompt\n tagName=\"div\"\n className=\"prompt\"\n defaultClassName=\"teacher-instructions\"\n prompt={teacherInstructions}\n />\n );\n\n return (\n <div 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 className={classes.fieldset}>\n <PreviewPrompt className=\"prompt\" defaultClassName=\"prompt\" prompt={prompt} tagName={'legend'}/>\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 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 updateSession={onChoiceChanged}\n onChoiceChanged={this.props.choiceMode === 'radio' ? this.handleChange : this.handleChangeCheckboxes}\n hideTick={choice.hideTick}\n checked={this.getChecked(choice)}\n correctness={isEvaluateMode ? this.getCorrectness(choice) : undefined}\n displayKey={this.indexToSymbol(index)}\n />\n ))}\n </div>\n </fieldset>\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":["styles","theme","main","color","text","backgroundColor","background","partLabel","display","fontSize","margin","fontWeight","paddingBottom","spacing","unit","teacherInstructions","marginBottom","horizontalLayout","flexDirection","flexWrap","gridLayout","fieldset","border","padding","minWidth","srOnly","position","left","top","width","height","overflow","MultipleChoice","props","event","target","setState","selectedValue","value","checked","prevState","selectedValues","push","filter","currentValue","mode","showCorrect","state","onShowCorrectToggle","choice","isCorrect","correct","isChecked","isSelected","undefined","alwaysShowCorrect","onToggle","bind","sessionValue","session","indexOf","nextProps","correctResponse","index","keyMode","String","fromCharCode","toUpperCase","choiceMode","includes","classes","disabled","className","choices","gridColumns","prompt","onChoiceChanged","responseCorrect","animationsDisabled","language","isEvaluateMode","showCorrectAnswerToggle","columnsStyle","gridTemplateColumns","teacherInstructionsDiv","renderHeading","hidden","visible","choicesLayout","map","length","handleChange","handleChangeCheckboxes","hideTick","getChecked","getCorrectness","indexToSymbol","React","Component","PropTypes","string","oneOf","array","object","bool","func","isRequired","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACvBC,IAAAA,IAAI,EAAE;AACFC,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADL;AAEFC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN,EAFf;AAGF,aAAO;AACH,kCAA0B;AADvB;AAHL,KADiB;AAQvBC,IAAAA,SAAS,EAAE;AACPC,MAAAA,OAAO,EAAE,OADF;AAEPC,MAAAA,QAAQ,EAAE,SAFH;AAGPC,MAAAA,MAAM,EAAE,GAHD;AAIPC,MAAAA,UAAU,EAAE,QAJL;AAKPC,MAAAA,aAAa,EAAEX,KAAK,CAACY,OAAN,CAAcC,IAAd,GAAqB;AAL7B,KARY;AAevBC,IAAAA,mBAAmB,EAAE;AACjBC,MAAAA,YAAY,EAAEf,KAAK,CAACY,OAAN,CAAcC,IAAd,GAAqB;AADlB,KAfE;AAkBvBG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,EAAE;AACLrB,IAAAA,KAAK,EAAE;AADF;AADiB,CAA9B;;eAMe,wBAAWtC,MAAX,EAAmBgC,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 StyledChoice from './choice';\n\n// MultipleChoice\n\nconst styles = (theme) => ({\n main: {\n color: color.text(),\n backgroundColor: color.background(),\n '& *': {\n '-webkit-font-smoothing': 'antialiased',\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});\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 onShowCorrectToggle: PropTypes.func,\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n selectedValue: null,\n selectedValues: [],\n showCorrect: this.props.alwaysShowCorrect || 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 and handleChangeCheckboxes functions were added for accessibility. Please see comments and videos from PD-2441. They should only be removed if a better solution is found.\n handleChange = (event) => {\n const target = event.target;\n\n this.setState({selectedValue: target.value});\n };\n\n handleChangeCheckboxes = (event) => {\n const {value, checked} = event.target;\n\n this.setState((prevState) => {\n let selectedValues = [...prevState.selectedValues];\n\n if (checked) {\n selectedValues.push(value);\n } else {\n selectedValues = selectedValues.filter((currentValue) => currentValue !== value);\n }\n\n return {selectedValues};\n });\n };\n\n onToggle = () => {\n if (this.props.mode === 'evaluate') {\n this.setState({ showCorrect: !this.state.showCorrect }, () => {\n this.props.onShowCorrectToggle();\n });\n }\n };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n if (!nextProps.correctResponse && this.state.showCorrect !== false) {\n this.setState({ showCorrect: false }, () => {\n this.props.onShowCorrectToggle();\n });\n }\n\n if (nextProps.alwaysShowCorrect && this.state.showCorrect !== true) {\n this.setState({ showCorrect: true }, () => {\n this.props.onShowCorrectToggle();\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 if (this.isSelected(choice.value)) {\n return true;\n }\n\n return this.props.choiceMode === 'radio'\n ? this.state.selectedValue === choice.value\n : this.state.selectedValues.includes(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 onChoiceChanged,\n responseCorrect,\n teacherInstructions,\n classes,\n alwaysShowCorrect,\n animationsDisabled,\n language\n } = this.props;\n const {showCorrect} = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;\n const columnsStyle = gridColumns > 1 ? {gridTemplateColumns: `repeat(${gridColumns}, 1fr)`} : undefined;\n\n const teacherInstructionsDiv = (\n <PreviewPrompt\n tagName=\"div\"\n className=\"prompt\"\n defaultClassName=\"teacher-instructions\"\n prompt={teacherInstructions}\n />\n );\n\n return (\n <div 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 className={classes.fieldset}>\n <PreviewPrompt className=\"prompt\" defaultClassName=\"prompt\" prompt={prompt} tagName={'legend'}/>\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 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 updateSession={onChoiceChanged}\n onChoiceChanged={this.props.choiceMode === 'radio' ? this.handleChange : this.handleChangeCheckboxes}\n hideTick={choice.hideTick}\n checked={this.getChecked(choice)}\n correctness={isEvaluateMode ? this.getCorrectness(choice) : undefined}\n displayKey={this.indexToSymbol(index)}\n />\n ))}\n </div>\n </fieldset>\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,4 +1,4 @@
1
- import {_dll_react, _dll_prop_types, _dll_react_dom, _dll_classnames, _dll_lodash, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.18.2/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_react_dom, _dll_classnames, _dll_lodash, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.18.3/module/index.js";
2
2
  import {_dll_pie_lib__pie_toolbox_editable_html, _dll_pie_lib__pie_toolbox_config_ui, _dll_pie_lib__pie_toolbox_render_ui} from "../../../@pie-lib/pie-toolbox-module@4.12.0/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
package/module/element.js CHANGED
@@ -1,4 +1,4 @@
1
- import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug, _dll_pie_lib__pie_toolbox_math_rendering_accessible} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.18.2/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug, _dll_pie_lib__pie_toolbox_math_rendering_accessible} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.18.3/module/index.js";
2
2
  import {_dll_pie_lib__pie_toolbox_render_ui, _dll_pie_lib__pie_toolbox_correct_answer_toggle} from "../../../@pie-lib/pie-toolbox-module@4.12.0/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
@@ -9339,7 +9339,8 @@ class MultipleChoice$1 extends React$2.Component {
9339
9339
  gridColumns: PropTypes$1.string,
9340
9340
  alwaysShowCorrect: PropTypes$1.bool,
9341
9341
  animationsDisabled: PropTypes$1.bool,
9342
- language: PropTypes$1.string
9342
+ language: PropTypes$1.string,
9343
+ onShowCorrectToggle: PropTypes$1.func
9343
9344
  };
9344
9345
  }
9345
9346
  constructor(props) {
@@ -9347,6 +9348,7 @@ class MultipleChoice$1 extends React$2.Component {
9347
9348
  MultipleChoice$1.prototype.__init.call(this);
9348
9349
  MultipleChoice$1.prototype.__init2.call(this);
9349
9350
  MultipleChoice$1.prototype.__init3.call(this);
9351
+ MultipleChoice$1.prototype.__init4.call(this);
9350
9352
  this.state = {
9351
9353
  selectedValue: null,
9352
9354
  selectedValues: [],
@@ -9382,22 +9384,30 @@ class MultipleChoice$1 extends React$2.Component {
9382
9384
  });
9383
9385
  };
9384
9386
  }
9385
- onToggle() {
9386
- if (this.props.mode === 'evaluate') {
9387
- this.setState({
9388
- showCorrect: !this.state.showCorrect
9389
- });
9390
- }
9387
+ __init3() {
9388
+ this.onToggle = () => {
9389
+ if (this.props.mode === 'evaluate') {
9390
+ this.setState({
9391
+ showCorrect: !this.state.showCorrect
9392
+ }, () => {
9393
+ this.props.onShowCorrectToggle();
9394
+ });
9395
+ }
9396
+ };
9391
9397
  }
9392
9398
  UNSAFE_componentWillReceiveProps(nextProps) {
9393
- if (!nextProps.correctResponse) {
9399
+ if (!nextProps.correctResponse && this.state.showCorrect !== false) {
9394
9400
  this.setState({
9395
9401
  showCorrect: false
9402
+ }, () => {
9403
+ this.props.onShowCorrectToggle();
9396
9404
  });
9397
9405
  }
9398
- if (nextProps.alwaysShowCorrect) {
9406
+ if (nextProps.alwaysShowCorrect && this.state.showCorrect !== true) {
9399
9407
  this.setState({
9400
9408
  showCorrect: true
9409
+ }, () => {
9410
+ this.props.onShowCorrectToggle();
9401
9411
  });
9402
9412
  }
9403
9413
  }
@@ -9410,7 +9420,7 @@ class MultipleChoice$1 extends React$2.Component {
9410
9420
  }
9411
9421
  return '';
9412
9422
  }
9413
- __init3() {
9423
+ __init4() {
9414
9424
  this.getCorrectness = (choice = {}) => {
9415
9425
  const isCorrect = choice.correct;
9416
9426
  const isChecked = this.isSelected(choice.value);
@@ -9451,14 +9461,14 @@ class MultipleChoice$1 extends React$2.Component {
9451
9461
  __self: this,
9452
9462
  __source: {
9453
9463
  fileName: _jsxFileName$1,
9454
- lineNumber: 195
9464
+ lineNumber: 202
9455
9465
  }
9456
9466
  }, "Multiple Choice Question") : React$2.createElement('h2', {
9457
9467
  className: classes.srOnly,
9458
9468
  __self: this,
9459
9469
  __source: {
9460
9470
  fileName: _jsxFileName$1,
9461
- lineNumber: 197
9471
+ lineNumber: 204
9462
9472
  }
9463
9473
  }, "Multiple Select Question");
9464
9474
  }
@@ -9478,7 +9488,7 @@ class MultipleChoice$1 extends React$2.Component {
9478
9488
  __self: this,
9479
9489
  __source: {
9480
9490
  fileName: _jsxFileName$1,
9481
- lineNumber: 225
9491
+ lineNumber: 232
9482
9492
  }
9483
9493
  });
9484
9494
  return React$2.createElement('div', {
@@ -9486,21 +9496,21 @@ class MultipleChoice$1 extends React$2.Component {
9486
9496
  __self: this,
9487
9497
  __source: {
9488
9498
  fileName: _jsxFileName$1,
9489
- lineNumber: 234
9499
+ lineNumber: 241
9490
9500
  }
9491
9501
  }, partLabel && React$2.createElement('h3', {
9492
9502
  className: classes.partLabel,
9493
9503
  __self: this,
9494
9504
  __source: {
9495
9505
  fileName: _jsxFileName$1,
9496
- lineNumber: 235
9506
+ lineNumber: 242
9497
9507
  }
9498
9508
  }, partLabel), this.renderHeading(), teacherInstructions && React$2.createElement('div', {
9499
9509
  className: classes.teacherInstructions,
9500
9510
  __self: this,
9501
9511
  __source: {
9502
9512
  fileName: _jsxFileName$1,
9503
- lineNumber: 240
9513
+ lineNumber: 247
9504
9514
  }
9505
9515
  }, !animationsDisabled ? React$2.createElement(Collapsible, {
9506
9516
  labels: {
@@ -9510,14 +9520,14 @@ class MultipleChoice$1 extends React$2.Component {
9510
9520
  __self: this,
9511
9521
  __source: {
9512
9522
  fileName: _jsxFileName$1,
9513
- lineNumber: 242
9523
+ lineNumber: 249
9514
9524
  }
9515
9525
  }, teacherInstructionsDiv) : teacherInstructionsDiv), React$2.createElement('fieldset', {
9516
9526
  className: classes.fieldset,
9517
9527
  __self: this,
9518
9528
  __source: {
9519
9529
  fileName: _jsxFileName$1,
9520
- lineNumber: 256
9530
+ lineNumber: 263
9521
9531
  }
9522
9532
  }, React$2.createElement(PreviewPrompt, {
9523
9533
  className: "prompt",
@@ -9527,7 +9537,7 @@ class MultipleChoice$1 extends React$2.Component {
9527
9537
  __self: this,
9528
9538
  __source: {
9529
9539
  fileName: _jsxFileName$1,
9530
- lineNumber: 257
9540
+ lineNumber: 264
9531
9541
  }
9532
9542
  }), !alwaysShowCorrect && React$2.createElement(CorrectAnswerToggle, {
9533
9543
  show: showCorrectAnswerToggle,
@@ -9537,7 +9547,7 @@ class MultipleChoice$1 extends React$2.Component {
9537
9547
  __self: this,
9538
9548
  __source: {
9539
9549
  fileName: _jsxFileName$1,
9540
- lineNumber: 260
9550
+ lineNumber: 267
9541
9551
  }
9542
9552
  }), React$2.createElement('div', {
9543
9553
  className: classNames({
@@ -9548,7 +9558,7 @@ class MultipleChoice$1 extends React$2.Component {
9548
9558
  __self: this,
9549
9559
  __source: {
9550
9560
  fileName: _jsxFileName$1,
9551
- lineNumber: 268
9561
+ lineNumber: 275
9552
9562
  }
9553
9563
  }, choices.map((choice, index) => React$2.createElement(StyledChoice, {
9554
9564
  choicesLayout: this.props.choicesLayout,
@@ -9570,7 +9580,7 @@ class MultipleChoice$1 extends React$2.Component {
9570
9580
  __self: this,
9571
9581
  __source: {
9572
9582
  fileName: _jsxFileName$1,
9573
- lineNumber: 276
9583
+ lineNumber: 283
9574
9584
  }
9575
9585
  })))));
9576
9586
  }
@@ -9593,7 +9603,8 @@ class Main extends React$1.Component {
9593
9603
  model: PropTypes.object,
9594
9604
  session: PropTypes.object,
9595
9605
  onChoiceChanged: PropTypes.func,
9596
- classes: PropTypes.object.isRequired
9606
+ classes: PropTypes.object.isRequired,
9607
+ onShowCorrectToggle: PropTypes.func
9597
9608
  };
9598
9609
  }
9599
9610
  static __initStatic2() {
@@ -9606,21 +9617,22 @@ class Main extends React$1.Component {
9606
9617
  super(props);
9607
9618
  }
9608
9619
  render() {
9609
- const {model, onChoiceChanged, session} = this.props;
9620
+ const {model, onChoiceChanged, session, onShowCorrectToggle} = this.props;
9610
9621
  return React$1.createElement(PreviewLayout, {
9611
9622
  __self: this,
9612
9623
  __source: {
9613
9624
  fileName: _jsxFileName,
9614
- lineNumber: 31
9625
+ lineNumber: 32
9615
9626
  }
9616
9627
  }, React$1.createElement(MultipleChoice$2, {
9617
9628
  ...model,
9618
9629
  session: session,
9619
9630
  onChoiceChanged: onChoiceChanged,
9631
+ onShowCorrectToggle: onShowCorrectToggle,
9620
9632
  __self: this,
9621
9633
  __source: {
9622
9634
  fileName: _jsxFileName,
9623
- lineNumber: 32
9635
+ lineNumber: 33
9624
9636
  }
9625
9637
  }));
9626
9638
  }
@@ -9640,14 +9652,14 @@ const Root = props => React$1.createElement(styles$b.MuiThemeProvider, {
9640
9652
  __self: undefined,
9641
9653
  __source: {
9642
9654
  fileName: _jsxFileName,
9643
- lineNumber: 47
9655
+ lineNumber: 53
9644
9656
  }
9645
9657
  }, React$1.createElement(Styled, {
9646
9658
  ...props,
9647
9659
  __self: undefined,
9648
9660
  __source: {
9649
9661
  fileName: _jsxFileName,
9650
- lineNumber: 48
9662
+ lineNumber: 54
9651
9663
  }
9652
9664
  }));
9653
9665
  const {concat: concat} = _dll_lodash;
@@ -9687,7 +9699,8 @@ class MultipleChoice extends HTMLElement {
9687
9699
  var element = React.createElement(Root, {
9688
9700
  model: this._model,
9689
9701
  session: this._session,
9690
- onChoiceChanged: this._onChange.bind(this)
9702
+ onChoiceChanged: this._onChange.bind(this),
9703
+ onShowCorrectToggle: this.onShowCorrectToggle.bind(this)
9691
9704
  });
9692
9705
  this.setAttribute('aria-label', this._model.choiceMode === 'radio' ? 'Multiple Choice Question' : 'Multiple Correct Answer Question');
9693
9706
  this.setAttribute('role', 'region');
@@ -9729,6 +9742,9 @@ class MultipleChoice extends HTMLElement {
9729
9742
  trailing: true
9730
9743
  });
9731
9744
  }
9745
+ onShowCorrectToggle() {
9746
+ renderMath(this);
9747
+ }
9732
9748
  setLangAttribute() {
9733
9749
  const language = this._model && typeof this._model.language ? this._model.language : '';
9734
9750
  const lang = language ? language.slice(0, 2) : 'en';
@@ -4,7 +4,7 @@
4
4
  "modules": [
5
5
  {
6
6
  "name": "@pie-lib/pie-toolbox-math-rendering-module",
7
- "version": "1.18.2"
7
+ "version": "1.18.3"
8
8
  },
9
9
  {
10
10
  "name": "@pie-lib/pie-toolbox-module",
package/module/print.js CHANGED
@@ -1,4 +1,4 @@
1
- import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_pie_lib__pie_toolbox_math_rendering_accessible, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.18.2/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_pie_lib__pie_toolbox_math_rendering_accessible, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.18.3/module/index.js";
2
2
  import {_dll_pie_lib__pie_toolbox_render_ui, _dll_pie_lib__pie_toolbox_correct_answer_toggle} from "../../../@pie-lib/pie-toolbox-module@4.12.0/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
@@ -9339,7 +9339,8 @@ class MultipleChoice extends React$2.Component {
9339
9339
  gridColumns: PropTypes$1.string,
9340
9340
  alwaysShowCorrect: PropTypes$1.bool,
9341
9341
  animationsDisabled: PropTypes$1.bool,
9342
- language: PropTypes$1.string
9342
+ language: PropTypes$1.string,
9343
+ onShowCorrectToggle: PropTypes$1.func
9343
9344
  };
9344
9345
  }
9345
9346
  constructor(props) {
@@ -9347,6 +9348,7 @@ class MultipleChoice extends React$2.Component {
9347
9348
  MultipleChoice.prototype.__init.call(this);
9348
9349
  MultipleChoice.prototype.__init2.call(this);
9349
9350
  MultipleChoice.prototype.__init3.call(this);
9351
+ MultipleChoice.prototype.__init4.call(this);
9350
9352
  this.state = {
9351
9353
  selectedValue: null,
9352
9354
  selectedValues: [],
@@ -9382,22 +9384,30 @@ class MultipleChoice extends React$2.Component {
9382
9384
  });
9383
9385
  };
9384
9386
  }
9385
- onToggle() {
9386
- if (this.props.mode === 'evaluate') {
9387
- this.setState({
9388
- showCorrect: !this.state.showCorrect
9389
- });
9390
- }
9387
+ __init3() {
9388
+ this.onToggle = () => {
9389
+ if (this.props.mode === 'evaluate') {
9390
+ this.setState({
9391
+ showCorrect: !this.state.showCorrect
9392
+ }, () => {
9393
+ this.props.onShowCorrectToggle();
9394
+ });
9395
+ }
9396
+ };
9391
9397
  }
9392
9398
  UNSAFE_componentWillReceiveProps(nextProps) {
9393
- if (!nextProps.correctResponse) {
9399
+ if (!nextProps.correctResponse && this.state.showCorrect !== false) {
9394
9400
  this.setState({
9395
9401
  showCorrect: false
9402
+ }, () => {
9403
+ this.props.onShowCorrectToggle();
9396
9404
  });
9397
9405
  }
9398
- if (nextProps.alwaysShowCorrect) {
9406
+ if (nextProps.alwaysShowCorrect && this.state.showCorrect !== true) {
9399
9407
  this.setState({
9400
9408
  showCorrect: true
9409
+ }, () => {
9410
+ this.props.onShowCorrectToggle();
9401
9411
  });
9402
9412
  }
9403
9413
  }
@@ -9410,7 +9420,7 @@ class MultipleChoice extends React$2.Component {
9410
9420
  }
9411
9421
  return '';
9412
9422
  }
9413
- __init3() {
9423
+ __init4() {
9414
9424
  this.getCorrectness = (choice = {}) => {
9415
9425
  const isCorrect = choice.correct;
9416
9426
  const isChecked = this.isSelected(choice.value);
@@ -9451,14 +9461,14 @@ class MultipleChoice extends React$2.Component {
9451
9461
  __self: this,
9452
9462
  __source: {
9453
9463
  fileName: _jsxFileName$1,
9454
- lineNumber: 195
9464
+ lineNumber: 202
9455
9465
  }
9456
9466
  }, "Multiple Choice Question") : React$2.createElement('h2', {
9457
9467
  className: classes.srOnly,
9458
9468
  __self: this,
9459
9469
  __source: {
9460
9470
  fileName: _jsxFileName$1,
9461
- lineNumber: 197
9471
+ lineNumber: 204
9462
9472
  }
9463
9473
  }, "Multiple Select Question");
9464
9474
  }
@@ -9478,7 +9488,7 @@ class MultipleChoice extends React$2.Component {
9478
9488
  __self: this,
9479
9489
  __source: {
9480
9490
  fileName: _jsxFileName$1,
9481
- lineNumber: 225
9491
+ lineNumber: 232
9482
9492
  }
9483
9493
  });
9484
9494
  return React$2.createElement('div', {
@@ -9486,21 +9496,21 @@ class MultipleChoice extends React$2.Component {
9486
9496
  __self: this,
9487
9497
  __source: {
9488
9498
  fileName: _jsxFileName$1,
9489
- lineNumber: 234
9499
+ lineNumber: 241
9490
9500
  }
9491
9501
  }, partLabel && React$2.createElement('h3', {
9492
9502
  className: classes.partLabel,
9493
9503
  __self: this,
9494
9504
  __source: {
9495
9505
  fileName: _jsxFileName$1,
9496
- lineNumber: 235
9506
+ lineNumber: 242
9497
9507
  }
9498
9508
  }, partLabel), this.renderHeading(), teacherInstructions && React$2.createElement('div', {
9499
9509
  className: classes.teacherInstructions,
9500
9510
  __self: this,
9501
9511
  __source: {
9502
9512
  fileName: _jsxFileName$1,
9503
- lineNumber: 240
9513
+ lineNumber: 247
9504
9514
  }
9505
9515
  }, !animationsDisabled ? React$2.createElement(Collapsible, {
9506
9516
  labels: {
@@ -9510,14 +9520,14 @@ class MultipleChoice extends React$2.Component {
9510
9520
  __self: this,
9511
9521
  __source: {
9512
9522
  fileName: _jsxFileName$1,
9513
- lineNumber: 242
9523
+ lineNumber: 249
9514
9524
  }
9515
9525
  }, teacherInstructionsDiv) : teacherInstructionsDiv), React$2.createElement('fieldset', {
9516
9526
  className: classes.fieldset,
9517
9527
  __self: this,
9518
9528
  __source: {
9519
9529
  fileName: _jsxFileName$1,
9520
- lineNumber: 256
9530
+ lineNumber: 263
9521
9531
  }
9522
9532
  }, React$2.createElement(PreviewPrompt, {
9523
9533
  className: "prompt",
@@ -9527,7 +9537,7 @@ class MultipleChoice extends React$2.Component {
9527
9537
  __self: this,
9528
9538
  __source: {
9529
9539
  fileName: _jsxFileName$1,
9530
- lineNumber: 257
9540
+ lineNumber: 264
9531
9541
  }
9532
9542
  }), !alwaysShowCorrect && React$2.createElement(CorrectAnswerToggle, {
9533
9543
  show: showCorrectAnswerToggle,
@@ -9537,7 +9547,7 @@ class MultipleChoice extends React$2.Component {
9537
9547
  __self: this,
9538
9548
  __source: {
9539
9549
  fileName: _jsxFileName$1,
9540
- lineNumber: 260
9550
+ lineNumber: 267
9541
9551
  }
9542
9552
  }), React$2.createElement('div', {
9543
9553
  className: classNames({
@@ -9548,7 +9558,7 @@ class MultipleChoice extends React$2.Component {
9548
9558
  __self: this,
9549
9559
  __source: {
9550
9560
  fileName: _jsxFileName$1,
9551
- lineNumber: 268
9561
+ lineNumber: 275
9552
9562
  }
9553
9563
  }, choices.map((choice, index) => React$2.createElement(StyledChoice, {
9554
9564
  choicesLayout: this.props.choicesLayout,
@@ -9570,7 +9580,7 @@ class MultipleChoice extends React$2.Component {
9570
9580
  __self: this,
9571
9581
  __source: {
9572
9582
  fileName: _jsxFileName$1,
9573
- lineNumber: 276
9583
+ lineNumber: 283
9574
9584
  }
9575
9585
  })))));
9576
9586
  }
@@ -9593,7 +9603,8 @@ class Main extends React$1.Component {
9593
9603
  model: PropTypes.object,
9594
9604
  session: PropTypes.object,
9595
9605
  onChoiceChanged: PropTypes.func,
9596
- classes: PropTypes.object.isRequired
9606
+ classes: PropTypes.object.isRequired,
9607
+ onShowCorrectToggle: PropTypes.func
9597
9608
  };
9598
9609
  }
9599
9610
  static __initStatic2() {
@@ -9606,21 +9617,22 @@ class Main extends React$1.Component {
9606
9617
  super(props);
9607
9618
  }
9608
9619
  render() {
9609
- const {model, onChoiceChanged, session} = this.props;
9620
+ const {model, onChoiceChanged, session, onShowCorrectToggle} = this.props;
9610
9621
  return React$1.createElement(PreviewLayout, {
9611
9622
  __self: this,
9612
9623
  __source: {
9613
9624
  fileName: _jsxFileName,
9614
- lineNumber: 31
9625
+ lineNumber: 32
9615
9626
  }
9616
9627
  }, React$1.createElement(MultipleChoice$1, {
9617
9628
  ...model,
9618
9629
  session: session,
9619
9630
  onChoiceChanged: onChoiceChanged,
9631
+ onShowCorrectToggle: onShowCorrectToggle,
9620
9632
  __self: this,
9621
9633
  __source: {
9622
9634
  fileName: _jsxFileName,
9623
- lineNumber: 32
9635
+ lineNumber: 33
9624
9636
  }
9625
9637
  }));
9626
9638
  }
@@ -9640,14 +9652,14 @@ const Root = props => React$1.createElement(styles$b.MuiThemeProvider, {
9640
9652
  __self: undefined,
9641
9653
  __source: {
9642
9654
  fileName: _jsxFileName,
9643
- lineNumber: 47
9655
+ lineNumber: 53
9644
9656
  }
9645
9657
  }, React$1.createElement(Styled, {
9646
9658
  ...props,
9647
9659
  __self: undefined,
9648
9660
  __source: {
9649
9661
  fileName: _jsxFileName,
9650
- lineNumber: 48
9662
+ lineNumber: 54
9651
9663
  }
9652
9664
  }));
9653
9665
  const React = _dll_react;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice",
3
3
  "repository": "pie-framework/pie-elements",
4
- "version": "8.21.4-next.3+4d5e9b38a",
4
+ "version": "8.21.4-next.33+30ae254b0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "dependencies": {
9
9
  "@material-ui/core": "^3.9.2",
10
- "@pie-lib/pie-toolbox": "1.25.3",
10
+ "@pie-lib/pie-toolbox": "1.26.0",
11
11
  "classnames": "^2.2.5",
12
12
  "debug": "^4.1.1",
13
13
  "enzyme-to-json": "^3.3.3",
@@ -18,7 +18,7 @@
18
18
  "react-test-renderer": "^16.3.2",
19
19
  "react-transition-group": "^2.3.1"
20
20
  },
21
- "gitHead": "4d5e9b38aae9ae001bc22c0a91da4d97eddd71dd",
21
+ "gitHead": "30ae254b0e3021389a52c7ab6cbf78a9868be728",
22
22
  "scripts": {
23
23
  "postpublish": "../../scripts/postpublish"
24
24
  },