@pie-element/multiple-choice 9.15.2 → 9.15.3-hotfix.1

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,17 @@
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
+ ## [9.15.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@9.15.2...@pie-element/multiple-choice@9.15.3) (2025-04-18)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib/pie-toolbox PD-4967 ([cf4c095](https://github.com/pie-framework/pie-elements/commit/cf4c095f21a2e9bdf74ce5a419ad5fc8d0d7f6ca))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [9.15.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@9.15.1...@pie-element/multiple-choice@9.15.2) (2025-04-17)
7
18
 
8
19
 
@@ -3,6 +3,17 @@
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
+ ## [7.6.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@7.6.2...@pie-element/multiple-choice-configure@7.6.3) (2025-04-18)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib/pie-toolbox PD-4967 ([cf4c095](https://github.com/pie-framework/pie-elements/commit/cf4c095f21a2e9bdf74ce5a419ad5fc8d0d7f6ca))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [7.6.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@7.6.1...@pie-element/multiple-choice-configure@7.6.2) (2025-04-17)
7
18
 
8
19
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice-configure",
3
- "version": "7.6.2",
3
+ "version": "7.6.3",
4
4
  "private": true,
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
@@ -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": "2.14.1",
11
+ "@pie-lib/pie-toolbox": "2.14.3",
12
12
  "debug": "^3.1.0",
13
13
  "lodash": "^4.17.15",
14
14
  "prop-types": "^15.6.2",
@@ -3,6 +3,17 @@
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
+ ## [5.9.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@5.9.2...@pie-element/multiple-choice-controller@5.9.3) (2025-04-18)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib/pie-toolbox PD-4967 ([cf4c095](https://github.com/pie-framework/pie-elements/commit/cf4c095f21a2e9bdf74ce5a419ad5fc8d0d7f6ca))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [5.9.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@5.9.1...@pie-element/multiple-choice-controller@5.9.2) (2025-04-17)
7
18
 
8
19
 
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice-controller",
3
3
  "private": true,
4
- "version": "5.9.2",
4
+ "version": "5.9.3",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
8
8
  "author": "",
9
9
  "license": "ISC",
10
10
  "dependencies": {
11
- "@pie-lib/pie-toolbox": "2.14.1",
11
+ "@pie-lib/pie-toolbox": "2.14.3",
12
12
  "debug": "^3.1.0",
13
13
  "lodash": "^4.17.15"
14
14
  }
package/lib/index.js CHANGED
@@ -93,6 +93,8 @@ var MultipleChoice = /*#__PURE__*/function (_HTMLElement) {
93
93
  _this = _super.call(this);
94
94
  _this._model = null;
95
95
  _this._session = null;
96
+ _this._options = null; // added for ebsr print mode detection
97
+
96
98
  _this.audioComplete = false;
97
99
  _this._boundHandleKeyDown = _this.handleKeyDown.bind((0, _assertThisInitialized2["default"])(_this));
98
100
  _this._keyboardEventsEnabled = false;
@@ -101,6 +103,7 @@ var MultipleChoice = /*#__PURE__*/function (_HTMLElement) {
101
103
  var element = /*#__PURE__*/_react["default"].createElement(_main["default"], {
102
104
  model: _this._model,
103
105
  session: _this._session,
106
+ options: _this._options,
104
107
  onChoiceChanged: _this._onChange.bind((0, _assertThisInitialized2["default"])(_this)),
105
108
  onShowCorrectToggle: _this.onShowCorrectToggle.bind((0, _assertThisInitialized2["default"])(_this))
106
109
  }); //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
@@ -173,6 +176,16 @@ var MultipleChoice = /*#__PURE__*/function (_HTMLElement) {
173
176
 
174
177
  this._dispatchResponseChanged();
175
178
  }
179
+ }, {
180
+ key: "options",
181
+ get: function get() {
182
+ return this._options;
183
+ },
184
+ set: function set(o) {
185
+ this._options = o;
186
+
187
+ this._rerender();
188
+ }
176
189
  }, {
177
190
  key: "_onChange",
178
191
  value: function _onChange(data) {
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["log","isComplete","session","model","audioComplete","autoplayAudioEnabled","completeAudioEnabled","value","choiceMode","minSelections","maxSelections","selections","length","MultipleChoice","_model","_session","_boundHandleKeyDown","handleKeyDown","bind","_keyboardEventsEnabled","_rerender","element","React","createElement","Main","onChoiceChanged","_onChange","onShowCorrectToggle","setAttribute","setLangAttribute","ReactDOM","render","keyboardEventsEnabled","enableKeyboardEvents","leading","trailing","_dispatchResponseChanged","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","_dispatchModelSet","ModelSetEvent","undefined","language","lang","slice","s","data","info","document","id","Object","assign","style","position","top","width","height","display","justifyContent","alignItems","background","zIndex","cursor","img","src","EnableAudioAutoplayImage","alt","appendChild","observer","MutationObserver","mutationsList","forEach","mutation","type","audio","querySelector","isInsidePrompt","closest","_createAudioInfoToast","container","enableAudio","play","removeChild","removeEventListener","setTimeout","paused","addEventListener","handlePlaying","audioStartTime","Date","getTime","handleEnded","audioEndTime","_audio","_handlePlaying","_handleEnded","_enableAudio","disconnect","observe","childList","subtree","window","event","keyToIndex","key","numOffset","letterOffset","test","charCodeAt","choiceIndex","choices","currentValue","choiceId","newValue","selected","includes","selector","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,wBAAN,CAAZ;;AAEO,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,OAAD,EAAUC,KAAV,EAAiBC,aAAjB,EAAmC;AAC3D,aAAuDD,KAAK,IAAI,EAAhE;AAAA,MAAQE,oBAAR,QAAQA,oBAAR;AAAA,MAA8BC,oBAA9B,QAA8BA,oBAA9B;;AAEA,MAAID,oBAAoB,IAAIC,oBAAxB,IAAgD,CAACF,aAArD,EAAoE;AAClE,WAAO,KAAP;AACD;;AAED,MAAI,CAACF,OAAD,IAAY,CAACA,OAAO,CAACK,KAAzB,EAAgC;AAC9B,WAAO,KAAP;AACD;;AAED,cAAyDJ,KAAK,IAAI,EAAlE;AAAA,MAAQK,UAAR,SAAQA,UAAR;AAAA,kCAAoBC,aAApB;AAAA,MAAoBA,aAApB,oCAAoC,CAApC;AAAA,MAAuCC,aAAvC,SAAuCA,aAAvC;;AACA,MAAMC,UAAU,GAAGT,OAAO,CAACK,KAAR,CAAcK,MAAd,IAAwB,CAA3C;;AAEA,MAAIJ,UAAU,KAAK,OAAnB,EAA4B;AAC1B,WAAO,CAAC,CAACG,UAAT;AACD;;AAED,MAAIA,UAAU,GAAGF,aAAb,IAA8BE,UAAU,GAAGD,aAA/C,EAA8D;AAC5D,WAAO,KAAP;AACD;;AAED,SAAO,IAAP;AACD,CAvBM;;;;IAyBcG,c;;;;;AACn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;;AAEA,UAAIK,WAAW,KAAKpE,SAAhB,IAA6BoE,WAAW,IAAI,CAAC,CAA7C,IAAkDA,WAAW,6BAAI,KAAKjG,MAAL,CAAYkG,OAAhB,yDAAI,qBAAqBpG,MAAzB,CAAjE,EAAkG;AAChG;AACD;;AAED,UAAMqG,YAAY,GAAG,KAAKlG,QAAL,CAAcR,KAAd,IAAuB,EAA5C;AACA,UAAM2G,QAAQ,GAAG,KAAKpG,MAAL,CAAYkG,OAAZ,CAAoBD,WAApB,EAAiCxG,KAAlD;AAEA,UAAM4G,QAAQ,GAAG;AACf5G,QAAAA,KAAK,EAAE2G,QADQ;AAEfE,QAAAA,QAAQ,EAAE,CAACH,YAAY,CAACI,QAAb,CAAsBH,QAAtB,CAFI;AAGfI,QAAAA,QAAQ,EAAE;AAHK,OAAjB;;AAMA,WAAK5F,SAAL,CAAeyF,QAAf;AACD;;;kDAhQyCI,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 { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering';\nimport { EnableAudioAutoplayImage } from '@pie-lib/pie-toolbox/render-ui';\nimport { updateSessionValue, updateSessionMetadata } from './session-updater';\n\nconst log = debug('pie-ui:multiple-choice');\n\nexport const isComplete = (session, model, audioComplete) => {\n const { autoplayAudioEnabled, completeAudioEnabled } = model || {};\n\n if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {\n return false;\n }\n\n if (!session || !session.value) {\n return false;\n }\n\n const { choiceMode, minSelections = 1, maxSelections } = model || {};\n const selections = session.value.length || 0;\n\n if (choiceMode === 'radio') {\n return !!selections;\n }\n\n if (selections < minSelections || selections > maxSelections) {\n return false;\n }\n\n return true;\n};\n\nexport default class MultipleChoice extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n this.audioComplete = false;\n this._boundHandleKeyDown = this.handleKeyDown.bind(this);\n this._keyboardEventsEnabled = false;\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 this.setLangAttribute();\n\n ReactDOM.render(element, this, () => {\n log('render complete - render math');\n renderMath(this);\n });\n\n if (this._model.keyboardEventsEnabled === true && !this._keyboardEventsEnabled) {\n this.enableKeyboardEvents();\n }\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n\n this._dispatchResponseChanged = debounce(() => {\n this.dispatchEvent(\n new SessionChangedEvent(this.tagName.toLowerCase(), isComplete(this._session, this._model, this.audioComplete)),\n );\n });\n\n this._dispatchModelSet = debounce(\n () => {\n this.dispatchEvent(\n new ModelSetEvent(\n this.tagName.toLowerCase(),\n isComplete(this._session, this._model),\n this._model !== undefined,\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 _createAudioInfoToast() {\n const info = document.createElement('div');\n info.id = 'play-audio-info';\n\n Object.assign(info.style, {\n position: 'absolute',\n top: 0,\n width:'100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n background: 'white',\n zIndex: '1000',\n cursor: 'pointer'\n });\n\n const img = document.createElement('img');\n img.src = EnableAudioAutoplayImage;\n img.alt = 'Click anywhere to enable audio autoplay';\n img.width = 500;\n img.height = 300;\n\n info.appendChild(img);\n return info;\n }\n\n connectedCallback() {\n this._rerender();\n\n // Observation: audio in Chrome will have the autoplay attribute,\n // while other browsers will not have the autoplay attribute and will need a user interaction to play the audio\n // This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox\n const observer = new MutationObserver((mutationsList, observer) => {\n mutationsList.forEach((mutation) => {\n if (mutation.type === 'childList') {\n const audio = this.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n if (!this._model) return;\n if (!this._model.autoplayAudioEnabled) return;\n if (audio && !isInsidePrompt) return;\n if (!audio) return;\n\n const info = this._createAudioInfoToast();\n const container = this.querySelector('#main-container');\n const enableAudio = () => {\n if (this.querySelector('#play-audio-info')) {\n audio.play();\n container.removeChild(info);\n }\n\n document.removeEventListener('click', enableAudio);\n };\n\n // if the audio is paused, it means the user has not interacted with the page yet and the audio will not play\n // FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked\n setTimeout(() => {\n if (audio.paused && !this.querySelector('#play-audio-info')) {\n // add info message as a toast to enable audio playback\n container.appendChild(info);\n document.addEventListener('click', enableAudio);\n } else {\n document.removeEventListener('click', enableAudio);\n }\n }, 500);\n\n // we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering\n const handlePlaying = () => {\n updateSessionMetadata(this._session, { audioStartTime: new Date().getTime() });\n\n const info = this.querySelector('#play-audio-info');\n if (info) {\n container.removeChild(info);\n }\n\n audio.removeEventListener('playing', handlePlaying);\n };\n\n audio.addEventListener('playing', handlePlaying);\n\n // we need to listen for the ended event to update the isComplete state\n const handleEnded = () => {\n updateSessionMetadata(this._session, { audioEndTime: new Date().getTime() });\n this.audioComplete = true;\n this._dispatchResponseChanged();\n audio.removeEventListener('ended', handleEnded);\n };\n\n audio.addEventListener('ended', handleEnded);\n\n // store references to remove later\n this._audio = audio;\n this._handlePlaying = handlePlaying;\n this._handleEnded = handleEnded;\n this._enableAudio = enableAudio;\n\n observer.disconnect();\n }\n });\n });\n\n observer.observe(this, { childList: true, subtree: true });\n }\n\n enableKeyboardEvents() {\n if (!this._keyboardEventsEnabled) {\n window.addEventListener('keydown', this._boundHandleKeyDown);\n this._keyboardEventsEnabled = true;\n }\n }\n\n disconnectedCallback() {\n if (this._keyboardEventsEnabled) {\n window.removeEventListener('keydown', this._boundHandleKeyDown);\n this._keyboardEventsEnabled = false;\n }\n\n document.removeEventListener('click', this._enableAudio);\n\n if (this._audio) {\n this._audio.removeEventListener('playing', this._handlePlaying);\n this._audio.removeEventListener('ended', this._handleEnded);\n this._audio = null;\n }\n }\n\n /**\n * Handles global keyboard events for selecting or toggling multiple-choice answers.\n * Maps keys (1-9, 0, a-j, A-J) to choices and updates the session state accordingly.\n * Ensures valid key presses toggle or select the appropriate choice based on the model.\n */\n handleKeyDown(event) {\n if (!this._model || !this._session) {\n return;\n }\n\n const keyToIndex = (key) => {\n const numOffset = key >= '1' && key <= '9' ? key - '1' : key === '0' ? 9 : -1;\n const letterOffset = /^[a-jA-J]$/.test(key) ? key.toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0) : -1;\n return numOffset >= 0 ? numOffset : letterOffset;\n };\n\n const choiceIndex = keyToIndex(event.key);\n\n if (choiceIndex === undefined || choiceIndex <= -1 || choiceIndex >= this._model.choices?.length) {\n return;\n }\n\n const currentValue = this._session.value || [];\n const choiceId = this._model.choices[choiceIndex].value;\n\n const newValue = {\n value: choiceId,\n selected: !currentValue.includes(choiceId),\n selector: 'Keyboard',\n };\n\n this._onChange(newValue);\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["log","isComplete","session","model","audioComplete","autoplayAudioEnabled","completeAudioEnabled","value","choiceMode","minSelections","maxSelections","selections","length","MultipleChoice","_model","_session","_options","_boundHandleKeyDown","handleKeyDown","bind","_keyboardEventsEnabled","_rerender","element","React","createElement","Main","options","onChoiceChanged","_onChange","onShowCorrectToggle","setAttribute","setLangAttribute","ReactDOM","render","keyboardEventsEnabled","enableKeyboardEvents","leading","trailing","_dispatchResponseChanged","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","_dispatchModelSet","ModelSetEvent","undefined","language","lang","slice","s","o","data","info","document","id","Object","assign","style","position","top","width","height","display","justifyContent","alignItems","background","zIndex","cursor","img","src","EnableAudioAutoplayImage","alt","appendChild","observer","MutationObserver","mutationsList","forEach","mutation","type","audio","querySelector","isInsidePrompt","closest","_createAudioInfoToast","container","enableAudio","play","removeChild","removeEventListener","setTimeout","paused","addEventListener","handlePlaying","audioStartTime","Date","getTime","handleEnded","audioEndTime","_audio","_handlePlaying","_handleEnded","_enableAudio","disconnect","observe","childList","subtree","window","event","keyToIndex","key","numOffset","letterOffset","test","charCodeAt","choiceIndex","choices","currentValue","choiceId","newValue","selected","includes","selector","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,wBAAN,CAAZ;;AAEO,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,OAAD,EAAUC,KAAV,EAAiBC,aAAjB,EAAmC;AAC3D,aAAuDD,KAAK,IAAI,EAAhE;AAAA,MAAQE,oBAAR,QAAQA,oBAAR;AAAA,MAA8BC,oBAA9B,QAA8BA,oBAA9B;;AAEA,MAAID,oBAAoB,IAAIC,oBAAxB,IAAgD,CAACF,aAArD,EAAoE;AAClE,WAAO,KAAP;AACD;;AAED,MAAI,CAACF,OAAD,IAAY,CAACA,OAAO,CAACK,KAAzB,EAAgC;AAC9B,WAAO,KAAP;AACD;;AAED,cAAyDJ,KAA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ourcesContent":["import Main from './main';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport debounce from 'lodash/debounce';\nimport debug from 'debug';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering';\nimport { EnableAudioAutoplayImage } from '@pie-lib/pie-toolbox/render-ui';\nimport { updateSessionValue, updateSessionMetadata } from './session-updater';\n\nconst log = debug('pie-ui:multiple-choice');\n\nexport const isComplete = (session, model, audioComplete) => {\n const { autoplayAudioEnabled, completeAudioEnabled } = model || {};\n\n if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {\n return false;\n }\n\n if (!session || !session.value) {\n return false;\n }\n\n const { choiceMode, minSelections = 1, maxSelections } = model || {};\n const selections = session.value.length || 0;\n\n if (choiceMode === 'radio') {\n return !!selections;\n }\n\n if (selections < minSelections || selections > maxSelections) {\n return false;\n }\n\n return true;\n};\n\nexport default class MultipleChoice extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n this._options = null; // added for ebsr print mode detection\n this.audioComplete = false;\n this._boundHandleKeyDown = this.handleKeyDown.bind(this);\n this._keyboardEventsEnabled = false;\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 options: this._options,\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 this.setLangAttribute();\n\n ReactDOM.render(element, this, () => {\n log('render complete - render math');\n renderMath(this);\n });\n\n if (this._model.keyboardEventsEnabled === true && !this._keyboardEventsEnabled) {\n this.enableKeyboardEvents();\n }\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n\n this._dispatchResponseChanged = debounce(() => {\n this.dispatchEvent(\n new SessionChangedEvent(this.tagName.toLowerCase(), isComplete(this._session, this._model, this.audioComplete)),\n );\n });\n\n this._dispatchModelSet = debounce(\n () => {\n this.dispatchEvent(\n new ModelSetEvent(\n this.tagName.toLowerCase(),\n isComplete(this._session, this._model),\n this._model !== undefined,\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 get options() {\n return this._options;\n }\n\n set options(o) {\n this._options = o;\n this._rerender();\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 _createAudioInfoToast() {\n const info = document.createElement('div');\n info.id = 'play-audio-info';\n\n Object.assign(info.style, {\n position: 'absolute',\n top: 0,\n width:'100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n background: 'white',\n zIndex: '1000',\n cursor: 'pointer'\n });\n\n const img = document.createElement('img');\n img.src = EnableAudioAutoplayImage;\n img.alt = 'Click anywhere to enable audio autoplay';\n img.width = 500;\n img.height = 300;\n\n info.appendChild(img);\n return info;\n }\n\n connectedCallback() {\n this._rerender();\n\n // Observation: audio in Chrome will have the autoplay attribute,\n // while other browsers will not have the autoplay attribute and will need a user interaction to play the audio\n // This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox\n const observer = new MutationObserver((mutationsList, observer) => {\n mutationsList.forEach((mutation) => {\n if (mutation.type === 'childList') {\n const audio = this.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n if (!this._model) return;\n if (!this._model.autoplayAudioEnabled) return;\n if (audio && !isInsidePrompt) return;\n if (!audio) return;\n\n const info = this._createAudioInfoToast();\n const container = this.querySelector('#main-container');\n const enableAudio = () => {\n if (this.querySelector('#play-audio-info')) {\n audio.play();\n container.removeChild(info);\n }\n\n document.removeEventListener('click', enableAudio);\n };\n\n // if the audio is paused, it means the user has not interacted with the page yet and the audio will not play\n // FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked\n setTimeout(() => {\n if (audio.paused && !this.querySelector('#play-audio-info')) {\n // add info message as a toast to enable audio playback\n container.appendChild(info);\n document.addEventListener('click', enableAudio);\n } else {\n document.removeEventListener('click', enableAudio);\n }\n }, 500);\n\n // we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering\n const handlePlaying = () => {\n updateSessionMetadata(this._session, { audioStartTime: new Date().getTime() });\n\n const info = this.querySelector('#play-audio-info');\n if (info) {\n container.removeChild(info);\n }\n\n audio.removeEventListener('playing', handlePlaying);\n };\n\n audio.addEventListener('playing', handlePlaying);\n\n // we need to listen for the ended event to update the isComplete state\n const handleEnded = () => {\n updateSessionMetadata(this._session, { audioEndTime: new Date().getTime() });\n this.audioComplete = true;\n this._dispatchResponseChanged();\n audio.removeEventListener('ended', handleEnded);\n };\n\n audio.addEventListener('ended', handleEnded);\n\n // store references to remove later\n this._audio = audio;\n this._handlePlaying = handlePlaying;\n this._handleEnded = handleEnded;\n this._enableAudio = enableAudio;\n\n observer.disconnect();\n }\n });\n });\n\n observer.observe(this, { childList: true, subtree: true });\n }\n\n enableKeyboardEvents() {\n if (!this._keyboardEventsEnabled) {\n window.addEventListener('keydown', this._boundHandleKeyDown);\n this._keyboardEventsEnabled = true;\n }\n }\n\n disconnectedCallback() {\n if (this._keyboardEventsEnabled) {\n window.removeEventListener('keydown', this._boundHandleKeyDown);\n this._keyboardEventsEnabled = false;\n }\n\n document.removeEventListener('click', this._enableAudio);\n\n if (this._audio) {\n this._audio.removeEventListener('playing', this._handlePlaying);\n this._audio.removeEventListener('ended', this._handleEnded);\n this._audio = null;\n }\n }\n\n /**\n * Handles global keyboard events for selecting or toggling multiple-choice answers.\n * Maps keys (1-9, 0, a-j, A-J) to choices and updates the session state accordingly.\n * Ensures valid key presses toggle or select the appropriate choice based on the model.\n */\n handleKeyDown(event) {\n if (!this._model || !this._session) {\n return;\n }\n\n const keyToIndex = (key) => {\n const numOffset = key >= '1' && key <= '9' ? key - '1' : key === '0' ? 9 : -1;\n const letterOffset = /^[a-jA-J]$/.test(key) ? key.toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0) : -1;\n return numOffset >= 0 ? numOffset : letterOffset;\n };\n\n const choiceIndex = keyToIndex(event.key);\n\n if (choiceIndex === undefined || choiceIndex <= -1 || choiceIndex >= this._model.choices?.length) {\n return;\n }\n\n const currentValue = this._session.value || [];\n const choiceId = this._model.choices[choiceIndex].value;\n\n const newValue = {\n value: choiceId,\n selected: !currentValue.includes(choiceId),\n selector: 'Keyboard',\n };\n\n this._onChange(newValue);\n }\n}\n"],"file":"index.js"}
package/lib/main.js CHANGED
@@ -56,7 +56,8 @@ var Main = /*#__PURE__*/function (_React$Component) {
56
56
  model = _this$props.model,
57
57
  onChoiceChanged = _this$props.onChoiceChanged,
58
58
  session = _this$props.session,
59
- onShowCorrectToggle = _this$props.onShowCorrectToggle;
59
+ onShowCorrectToggle = _this$props.onShowCorrectToggle,
60
+ options = _this$props.options;
60
61
  var extraCSSRules = model.extraCSSRules,
61
62
  fontSizeFactor = model.fontSizeFactor; // model.partLabel is a property used for ebsr
62
63
 
@@ -64,6 +65,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
64
65
  extraCSSRules: extraCSSRules,
65
66
  fontSizeFactor: fontSizeFactor
66
67
  }, /*#__PURE__*/_react["default"].createElement(_multipleChoice["default"], (0, _extends2["default"])({}, model, {
68
+ options: options,
67
69
  session: session,
68
70
  onChoiceChanged: onChoiceChanged,
69
71
  onShowCorrectToggle: onShowCorrectToggle
@@ -76,6 +78,7 @@ var Main = /*#__PURE__*/function (_React$Component) {
76
78
  (0, _defineProperty2["default"])(Main, "propTypes", {
77
79
  model: _propTypes["default"].object,
78
80
  session: _propTypes["default"].object,
81
+ options: _propTypes["default"].object,
79
82
  onChoiceChanged: _propTypes["default"].func,
80
83
  classes: _propTypes["default"].object.isRequired,
81
84
  onShowCorrectToggle: _propTypes["default"].func,
package/lib/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.jsx"],"names":["styles","Main","props","model","onChoiceChanged","session","onShowCorrectToggle","extraCSSRules","fontSizeFactor","React","Component","PropTypes","object","func","classes","isRequired","shape","names","arrayOf","string","rules","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;;;;;AAiBJ,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;AACA,UAAQC,aAAR,GAA0CJ,KAA1C,CAAQI,aAAR;AAAA,UAAuBC,cAAvB,GAA0CL,KAA1C,CAAuBK,cAAvB,CAFO,CAIP;;AACA,0BACE,gCAAC,uBAAD;AAAe,QAAA,aAAa,EAAED,aAA9B;AAA6C,QAAA,cAAc,EAAEC;AAA7D,sBACE,gCAAC,0BAAD,gCACML,KADN;AAEE,QAAA,OAAO,EAAEE,OAFX;AAGE,QAAA,eAAe,EAAED,eAHnB;AAIE,QAAA,mBAAmB,EAAEE;AAJvB,SADF,CADF;AAUD;;;EApCgBG,kBAAMC,S;;iCAAnBT,I,eACe;AACjBE,EAAAA,KAAK,EAAEQ,sBAAUC,MADA;AAEjBP,EAAAA,OAAO,EAAEM,sBAAUC,MAFF;AAGjBR,EAAAA,eAAe,EAAEO,sBAAUE,IAHV;AAIjBC,EAAAA,OAAO,EAAEH,sBAAUC,MAAV,CAAiBG,UAJT;AAKjBT,EAAAA,mBAAmB,EAAEK,sBAAUE,IALd;AAMjBN,EAAAA,aAAa,EAAEI,sBAAUK,KAAV,CAAgB;AAC7BC,IAAAA,KAAK,EAAEN,sBAAUO,OAAV,CAAkBP,sBAAUQ,MAA5B,CADsB;AAE7BC,IAAAA,KAAK,EAAET,sBAAUQ;AAFY,GAAhB;AANE,C;iCADflB,I,kBAakB;AACpBE,EAAAA,KAAK,EAAE,EADa;AAEpBE,EAAAA,OAAO,EAAE;AAFW,C;AA0BxB,IAAMgB,MAAM,GAAG,wBAAWrB,MAAX,EAAmB;AAAEsB,EAAAA,IAAI,EAAE;AAAR,CAAnB,EAAqCrB,IAArC,CAAf;AAEA,IAAMsB,KAAK,GAAG,4BAAe;AAC3BC,EAAAA,UAAU,EAAE;AACVC,IAAAA,eAAe,EAAE;AADP;AADe,CAAf,CAAd;;AAMA,IAAMC,IAAI,GAAG,SAAPA,IAAO,CAACxB,KAAD;AAAA,sBACX,gCAAC,wBAAD;AAAkB,IAAA,KAAK,EAAEqB;AAAzB,kBACE,gCAAC,MAAD,EAAYrB,KAAZ,CADF,CADW;AAAA,CAAb;;eAMewB,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 extraCSSRules: PropTypes.shape({\n names: PropTypes.arrayOf(PropTypes.string),\n rules: PropTypes.string,\n }),\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 const { extraCSSRules, fontSizeFactor } = model;\n\n // model.partLabel is a property used for ebsr\n return (\n <PreviewLayout extraCSSRules={extraCSSRules} fontSizeFactor={fontSizeFactor}>\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"}
1
+ {"version":3,"sources":["../src/main.jsx"],"names":["styles","Main","props","model","onChoiceChanged","session","onShowCorrectToggle","options","extraCSSRules","fontSizeFactor","React","Component","PropTypes","object","func","classes","isRequired","shape","names","arrayOf","string","rules","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;;;;;AAkBJ,gBAAYC,KAAZ,EAAmB;AAAA;AAAA,6BACXA,KADW;AAElB;;;;WAED,kBAAS;AACP,wBAA0E,KAAKA,KAA/E;AAAA,UAAQC,KAAR,eAAQA,KAAR;AAAA,UAAeC,eAAf,eAAeA,eAAf;AAAA,UAAgCC,OAAhC,eAAgCA,OAAhC;AAAA,UAAyCC,mBAAzC,eAAyCA,mBAAzC;AAAA,UAA8DC,OAA9D,eAA8DA,OAA9D;AACA,UAAQ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,sBACX,gCAAC,wBAAD;AAAkB,IAAA,KAAK,EAAEsB;AAAzB,kBACE,gCAAC,MAAD,EAAYtB,KAAZ,CADF,CADW;AAAA,CAAb;;eAMeyB,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 options: PropTypes.object,\n onChoiceChanged: PropTypes.func,\n classes: PropTypes.object.isRequired,\n onShowCorrectToggle: PropTypes.func,\n extraCSSRules: PropTypes.shape({\n names: PropTypes.arrayOf(PropTypes.string),\n rules: PropTypes.string,\n }),\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, options } = this.props;\n const { extraCSSRules, fontSizeFactor } = model;\n\n // model.partLabel is a property used for ebsr\n return (\n <PreviewLayout extraCSSRules={extraCSSRules} fontSizeFactor={fontSizeFactor}>\n <MultipleChoice\n {...model}\n options={options}\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"}
@@ -171,7 +171,7 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
171
171
  }
172
172
  });
173
173
  _this.state = {
174
- showCorrect: _this.props.alwaysShowCorrect || false,
174
+ showCorrect: _this.props.options && _this.props.alwaysShowCorrect || false,
175
175
  maxSelectionsErrorState: false
176
176
  };
177
177
  _this.onToggle = _this.onToggle.bind((0, _assertThisInitialized2["default"])(_this));
@@ -200,7 +200,7 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
200
200
  });
201
201
  }
202
202
 
203
- if (nextProps.alwaysShowCorrect && this.state.showCorrect !== true) {
203
+ if (nextProps.options && nextProps.alwaysShowCorrect && this.state.showCorrect !== true) {
204
204
  this.setState({
205
205
  showCorrect: true
206
206
  }, function () {
@@ -226,9 +226,20 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
226
226
  }, {
227
227
  key: "getChecked",
228
228
  value: function getChecked(choice) {
229
- if (this.state.showCorrect) {
229
+ // check for print context: options prop is passed from print.js and alwaysShowCorrect is true
230
+ var isPrintMode = this.props.options && this.props.alwaysShowCorrect;
231
+
232
+ if (isPrintMode) {
230
233
  return choice.correct || false;
231
- }
234
+ } // evaluate mode with show correct toggled
235
+
236
+
237
+ var isEvaluateMode = this.state.showCorrect && this.props.mode === 'evaluate';
238
+
239
+ if (isEvaluateMode) {
240
+ return choice.correct || false;
241
+ } // default behavior: show what the user has selected
242
+
232
243
 
233
244
  return this.isSelected(choice.value);
234
245
  } // renderHeading function was added for accessibility.
@@ -278,7 +289,8 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
278
289
  maxSelections = _this$props3.maxSelections,
279
290
  autoplayAudioEnabled = _this$props3.autoplayAudioEnabled,
280
291
  session = _this$props3.session,
281
- customAudioButton = _this$props3.customAudioButton;
292
+ customAudioButton = _this$props3.customAudioButton,
293
+ options = _this$props3.options;
282
294
  var _this$state = this.state,
283
295
  showCorrect = _this$state.showCorrect,
284
296
  maxSelectionsErrorState = _this$state.maxSelectionsErrorState;
@@ -339,7 +351,7 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
339
351
  tagName: 'legend',
340
352
  autoplayAudioEnabled: autoplayAudioEnabled,
341
353
  customAudioButton: customAudioButton
342
- }), !alwaysShowCorrect && /*#__PURE__*/_react["default"].createElement(_correctAnswerToggle.CorrectAnswerToggle, {
354
+ }), !(options && alwaysShowCorrect) && /*#__PURE__*/_react["default"].createElement(_correctAnswerToggle.CorrectAnswerToggle, {
343
355
  show: showCorrectAnswerToggle,
344
356
  toggled: showCorrect,
345
357
  onToggle: this.onToggle.bind(this),
@@ -410,7 +422,8 @@ exports.MultipleChoice = MultipleChoice;
410
422
  customAudioButton: {
411
423
  playImage: _propTypes["default"].string,
412
424
  pauseImage: _propTypes["default"].string
413
- }
425
+ },
426
+ options: _propTypes["default"].object
414
427
  });
415
428
  MultipleChoice.defaultProps = {
416
429
  session: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/multiple-choice.jsx"],"names":["translator","Translator","styles","theme","main","color","text","backgroundColor","background","position","partLabel","display","fontSize","margin","fontWeight","paddingBottom","spacing","unit","teacherInstructions","marginBottom","horizontalLayout","flexDirection","flexWrap","gridLayout","fieldset","border","padding","minWidth","srOnly","left","top","width","height","overflow","errorText","typography","palette","error","paddingTop","MultipleChoice","props","event","target","value","checked","maxSelections","onChoiceChanged","session","length","setState","maxSelectionsErrorState","selected","selector","mode","showCorrect","state","onShowCorrectToggle","choice","isCorrect","correct","isChecked","isSelected","undefined","alwaysShowCorrect","onToggle","bind","sessionValue","indexOf","nextProps","correctResponse","index","keyMode","String","fromCharCode","toUpperCase","choiceMode","classes","disabled","className","choices","gridColumns","prompt","responseCorrect","animationsDisabled","language","isSelectionButtonBelow","minSelections","autoplayAudioEnabled","customAudioButton","isEvaluateMode","showCorrectAnswerToggle","columnsStyle","gridTemplateColumns","selections","teacherInstructionsDiv","getMultipleChoiceMinSelectionErrorMessage","t","lng","renderHeading","hidden","visible","choicesLayout","map","selectedAnswerBackgroundColor","handleChange","hideTick","getChecked","getCorrectness","indexToSymbol","React","Component","PropTypes","string","oneOf","array","object","bool","func","isRequired","number","playImage","pauseImage","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;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AzBf;AA0BjB5B,EAAAA,iBAAiB,EAAE;AACjBgC,IAAAA,SAAS,EAAET,sBAAUC,MADJ;AAEjBS,IAAAA,UAAU,EAAEV,sBAAUC;AAFL;AA1BF,C;AA4SrBzE,cAAc,CAACmF,YAAf,GAA8B;AAC5B3E,EAAAA,OAAO,EAAE;AACPJ,IAAAA,KAAK,EAAE;AADA;AADmB,CAA9B;;eAMe,wBAAWzC,MAAX,EAAmBqC,cAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { CorrectAnswerToggle } from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport classNames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color, Collapsible, PreviewPrompt } from '@pie-lib/pie-toolbox/render-ui';\nimport Translator from '@pie-lib/pie-toolbox/translator';\n\nimport StyledChoice from './choice';\n\n// MultipleChoice\n\nconst { translator } = Translator;\n\nconst styles = (theme) => ({\n main: {\n color: color.text(),\n backgroundColor: color.background(),\n '& *': {\n '-webkit-font-smoothing': 'antialiased',\n },\n position: 'relative'\n },\n partLabel: {\n display: 'block',\n fontSize: 'inherit',\n margin: '0',\n fontWeight: 'normal',\n paddingBottom: theme.spacing.unit * 2,\n },\n teacherInstructions: {\n marginBottom: theme.spacing.unit * 2,\n },\n horizontalLayout: {\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n },\n gridLayout: {\n display: 'grid',\n },\n fieldset: {\n border: '0px',\n padding: '0.01em 0 0 0',\n margin: '0px',\n minWidth: '0px',\n },\n srOnly: {\n position: 'absolute',\n left: '-10000px',\n top: 'auto',\n width: '1px',\n height: '1px',\n overflow: 'hidden',\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing.unit,\n },\n});\n\nexport class MultipleChoice extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n mode: PropTypes.oneOf(['gather', 'view', 'evaluate']),\n choiceMode: PropTypes.oneOf(['radio', 'checkbox']),\n keyMode: PropTypes.oneOf(['numbers', 'letters', 'none']),\n choices: PropTypes.array,\n partLabel: PropTypes.string,\n prompt: PropTypes.string,\n teacherInstructions: PropTypes.string,\n session: PropTypes.object,\n disabled: PropTypes.bool,\n onChoiceChanged: PropTypes.func,\n responseCorrect: PropTypes.bool,\n classes: PropTypes.object.isRequired,\n correctResponse: PropTypes.array,\n choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),\n gridColumns: PropTypes.string,\n alwaysShowCorrect: PropTypes.bool,\n animationsDisabled: PropTypes.bool,\n language: PropTypes.string,\n selectedAnswerBackgroundColor: PropTypes.string,\n onShowCorrectToggle: PropTypes.func,\n isSelectionButtonBelow: PropTypes.bool,\n minSelections: PropTypes.number,\n maxSelections: PropTypes.number,\n autoplayAudioEnabled: PropTypes.bool,\n customAudioButton: {\n playImage: PropTypes.string,\n pauseImage: PropTypes.string,\n }\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n showCorrect: this.props.alwaysShowCorrect || false,\n maxSelectionsErrorState: false,\n };\n\n this.onToggle = this.onToggle.bind(this);\n }\n\n isSelected(value) {\n const sessionValue = this.props.session && this.props.session.value;\n\n return sessionValue && sessionValue.indexOf && sessionValue.indexOf(value) >= 0;\n }\n\n // handleChange was added for accessibility. Please see comments and videos from PD-2441.\n handleChange = (event) => {\n const { value, checked } = event.target;\n const { maxSelections, onChoiceChanged, session } = this.props;\n\n if (session.value && session.value.length >= maxSelections) {\n // show/hide max selections error when user select/deselect an answer\n this.setState({ maxSelectionsErrorState: checked });\n\n if (checked) {\n // prevent selecting more answers\n return;\n }\n }\n\n onChoiceChanged({ value, selected: checked, selector: 'Mouse' });\n };\n\n onToggle = () => {\n if (this.props.mode === 'evaluate') {\n this.setState({ showCorrect: !this.state.showCorrect }, () => {\n if (this.props.onShowCorrectToggle) {\n this.props.onShowCorrectToggle();\n }\n });\n }\n };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n if (!nextProps.correctResponse && this.state.showCorrect !== false) {\n this.setState({ showCorrect: false }, () => {\n if (this.props.onShowCorrectToggle) {\n this.props.onShowCorrectToggle();\n }\n });\n }\n\n if (nextProps.alwaysShowCorrect && this.state.showCorrect !== true) {\n this.setState({ showCorrect: true }, () => {\n if (this.props.onShowCorrectToggle) {\n this.props.onShowCorrectToggle();\n }\n });\n }\n }\n\n indexToSymbol(index) {\n if (this.props.keyMode === 'numbers') {\n return `${index + 1}`;\n }\n\n if (this.props.keyMode === 'letters') {\n return String.fromCharCode(97 + index).toUpperCase();\n }\n\n return '';\n }\n\n getCorrectness = (choice = {}) => {\n const isCorrect = choice.correct;\n const isChecked = this.isSelected(choice.value);\n\n if (this.state.showCorrect) {\n return isCorrect ? 'correct' : undefined;\n }\n\n if (isCorrect) {\n if (isChecked) {\n // A correct answer is selected: marked with a green checkmark\n return 'correct';\n } else {\n // A correct answer is NOT selected: marked with an orange X\n return 'incorrect';\n }\n } else {\n if (isChecked) {\n // An incorrect answer is selected: marked with an orange X\n return 'incorrect';\n } else {\n // An incorrect answer is NOT selected: not marked\n return undefined;\n }\n }\n };\n\n getChecked(choice) {\n if (this.state.showCorrect) {\n return choice.correct || false;\n }\n\n return this.isSelected(choice.value);\n }\n\n // renderHeading function was added for accessibility.\n renderHeading() {\n const { mode, choiceMode, classes } = this.props;\n\n if (mode !== 'gather') {\n return null;\n }\n\n return choiceMode === 'radio' ? (\n <h2 className={classes.srOnly}>Multiple Choice Question</h2>\n ) : (\n <h2 className={classes.srOnly}>Multiple Select Question</h2>\n );\n }\n\n render() {\n const {\n mode,\n disabled,\n className,\n choices = [],\n choiceMode,\n gridColumns,\n partLabel,\n prompt,\n responseCorrect,\n teacherInstructions,\n classes,\n alwaysShowCorrect,\n animationsDisabled,\n language,\n isSelectionButtonBelow,\n minSelections,\n maxSelections,\n autoplayAudioEnabled,\n session,\n customAudioButton\n } = this.props;\n const { showCorrect, maxSelectionsErrorState } = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;\n const columnsStyle = gridColumns > 1 ? { gridTemplateColumns: `repeat(${gridColumns}, 1fr)` } : undefined;\n const selections = (session.value && session.value.length) || 0;\n\n const teacherInstructionsDiv = (\n <PreviewPrompt\n tagName=\"div\"\n className=\"prompt\"\n defaultClassName=\"teacher-instructions\"\n prompt={teacherInstructions}\n />\n );\n\n const getMultipleChoiceMinSelectionErrorMessage = () => {\n if (minSelections && maxSelections) {\n return minSelections === maxSelections\n ? translator.t('translation:multipleChoice:minmaxSelections_equal', { lng: language, minSelections })\n : translator.t('translation:multipleChoice:minmaxSelections_range', { lng: language, minSelections, maxSelections });\n }\n\n if (minSelections) {\n return translator.t('translation:multipleChoice:minSelections', { lng: language, minSelections });\n }\n\n return '';\n };\n\n return (\n <div id={'main-container'} className={classNames(classes.main, className, 'multiple-choice')}>\n {partLabel && <h3 className={classes.partLabel}>{partLabel}</h3>}\n\n {this.renderHeading()}\n\n {teacherInstructions && (\n <div className={classes.teacherInstructions}>\n {!animationsDisabled ? (\n <Collapsible\n labels={{\n hidden: 'Show Teacher Instructions',\n visible: 'Hide Teacher Instructions',\n }}\n >\n {teacherInstructionsDiv}\n </Collapsible>\n ) : (\n teacherInstructionsDiv\n )}\n </div>\n )}\n\n <fieldset className={classes.fieldset}>\n <PreviewPrompt\n className=\"prompt\"\n defaultClassName=\"prompt\"\n prompt={prompt}\n tagName={'legend'}\n autoplayAudioEnabled={autoplayAudioEnabled}\n customAudioButton={customAudioButton}\n />\n\n {!alwaysShowCorrect && (\n <CorrectAnswerToggle\n show={showCorrectAnswerToggle}\n toggled={showCorrect}\n onToggle={this.onToggle.bind(this)}\n language={language}\n />\n )}\n\n <div\n className={classNames({\n [classes.gridLayout]: this.props.choicesLayout === 'grid',\n [classes.horizontalLayout]: this.props.choicesLayout === 'horizontal',\n })}\n style={columnsStyle}\n >\n {choices.map((choice, index) => (\n <StyledChoice\n choicesLayout={this.props.choicesLayout}\n selectedAnswerBackgroundColor={this.props.selectedAnswerBackgroundColor}\n gridColumns={gridColumns}\n key={`choice-${index}`}\n choice={choice}\n index={index}\n choicesLength={choices.length}\n showCorrect={showCorrect}\n isEvaluateMode={isEvaluateMode}\n choiceMode={choiceMode}\n disabled={disabled}\n onChoiceChanged={this.handleChange}\n hideTick={choice.hideTick}\n checked={this.getChecked(choice)}\n correctness={isEvaluateMode ? this.getCorrectness(choice) : undefined}\n displayKey={this.indexToSymbol(index)}\n isSelectionButtonBelow={isSelectionButtonBelow}\n />\n ))}\n </div>\n </fieldset>\n\n {choiceMode === 'checkbox' && (selections < minSelections) && (\n <div className={classes.errorText}>\n {getMultipleChoiceMinSelectionErrorMessage()}\n </div>\n )}\n {choiceMode === 'checkbox' && maxSelectionsErrorState && (\n <div className={classes.errorText}>\n {translator.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {\n lng: language,\n maxSelections,\n })}\n </div>\n )}\n </div>\n );\n }\n}\n\nMultipleChoice.defaultProps = {\n session: {\n value: [],\n },\n};\n\nexport default withStyles(styles)(MultipleChoice);\n"],"file":"multiple-choice.js"}
1
+ {"version":3,"sources":["../src/multiple-choice.jsx"],"names":["translator","Translator","styles","theme","main","color","text","backgroundColor","background","position","partLabel","display","fontSize","margin","fontWeight","paddingBottom","spacing","unit","teacherInstructions","marginBottom","horizontalLayout","flexDirection","flexWrap","gridLayout","fieldset","border","padding","minWidth","srOnly","left","top","width","height","overflow","errorText","typography","palette","error","paddingTop","MultipleChoice","props","event","target","value","checked","maxSelections","onChoiceChanged","session","length","setState","maxSelectionsErrorState","selected","selector","mode","showCorrect","state","onShowCorrectToggle","choice","isCorrect","correct","isChecked","isSelected","undefined","options","alwaysShowCorrect","onToggle","bind","sessionValue","indexOf","nextProps","correctResponse","index","keyMode","String","fromCharCode","toUpperCase","isPrintMode","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","choicesLayout","map","selectedAnswerBackgroundColor","handleChange","hideTick","getChecked","getCorrectness","indexToSymbol","React","Component","PropTypes","string","oneOf","array","object","bool","func","isRequired","number","playImage","pauseImage","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAEA;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;;AAEA,IAAME,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,IAAI,EAAE;AACJC,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADH;AAEJC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN,EAFb;AAGJ,aAAO;AACL,kCAA0B;AADrB,OAHH;AAMJC,MAAAA,QAAQ,EAAE;AANN,KADmB;AASzBC,IAAAA,SAAS,EAAE;AACTC,MAAAA,OAAO,EAAE,OADA;AAETC,MAAAA,QAAQ,EAAE,SAFD;AAGTC,MAAAA,MAAM,EAAE,GAHC;AAITC,MAAAA,UAAU,EAAE,QAJH;AAKTC,MAAAA,aAAa,EAAEZ,KAAK,CAACa,OAAN,CAAcC,IAAd,GAAqB;AAL3B,KATc;AAgBzBC,IAAAA,mBAAmB,EAAE;AACnBC,MAAAA,YAAY,EAAEhB,KAAK,CAACa,OAAN,CAAcC,IAAd,GAAqB;AADhB,KAhBI;AAmBzBG,IAAAA,gBAAgB,EAAE;AAChBT,MAAAA,OAAO,EAAE,MADO;AAEhBU,MAAAA,aAAa,EAAE,KAFC;AAGhBC,MAAAA,QAAQ,EAAE;AAHM,KAnBO;AAwBzBC,IAAAA,UAAU,EAAE;AACVZ,MAAAA,OAAO,EAAE;AADC,KAxBa;AA2BzBa,IAAAA,QAAQ,EAAE;AACRC,MAAAA,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A,eAAe,EAAE4B,sBAAUK,IAZV;AAajBvC,EAAAA,OAAO,EAAEkC,sBAAUI,MAAV,CAAiBG,UAbT;AAcjBlD,EAAAA,eAAe,EAAE2C,sBAAUG,KAdV;AAejBb,EAAAA,aAAa,EAAEU,sBAAUE,KAAV,CAAgB,CAAC,UAAD,EAAa,MAAb,EAAqB,YAArB,CAAhB,CAfE;AAgBjBhC,EAAAA,WAAW,EAAE8B,sBAAUC,MAhBN;AAiBjBlD,EAAAA,iBAAiB,EAAEiD,sBAAUK,IAjBZ;AAkBjBhC,EAAAA,kBAAkB,EAAE2B,sBAAUK,IAlBb;AAmBjB/B,EAAAA,QAAQ,EAAE0B,sBAAUC,MAnBH;AAoBjBT,EAAAA,6BAA6B,EAAEQ,sBAAUC,MApBxB;AAqBjB1D,EAAAA,mBAAmB,EAAEyD,sBAAUM,IArBd;AAsBjB/B,EAAAA,sBAAsB,EAAEyB,sBAAUK,IAtBjB;AAuBjB7B,EAAAA,aAAa,EAAEwB,sBAAUQ,MAvBR;AAwBjB5E,EAAAA,aAAa,EAAEoE,sBAAUQ,MAxBR;AAyBjB/B,EAAAA,oBAAoB,EAAEuB,sBAAUK,IAzBf;AA0BjB3B,EAAAA,iBAAiB,EAAE;AACjB+B,IAAAA,SAAS,EAAET,sBAAUC,MADJ;AAEjBS,IAAAA,UAAU,EAAEV,sBAAUC;AAFL,GA1BF;AA8BjBnD,EAAAA,OAAO,EAAEkD,sBAAUI;AA9BF,C;AAyTrB9E,cAAc,CAACqF,YAAf,GAA8B;AAC5B7E,EAAAA,OAAO,EAAE;AACPJ,IAAAA,KAAK,EAAE;AADA;AADmB,CAA9B;;eAMe,wBAAWzC,MAAX,EAAmBqC,cAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { CorrectAnswerToggle } from '@pie-lib/pie-toolbox/correct-answer-toggle';\nimport classNames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color, Collapsible, PreviewPrompt } from '@pie-lib/pie-toolbox/render-ui';\nimport Translator from '@pie-lib/pie-toolbox/translator';\n\nimport StyledChoice from './choice';\n\n// MultipleChoice\n\nconst { translator } = Translator;\n\nconst styles = (theme) => ({\n main: {\n color: color.text(),\n backgroundColor: color.background(),\n '& *': {\n '-webkit-font-smoothing': 'antialiased',\n },\n position: 'relative'\n },\n partLabel: {\n display: 'block',\n fontSize: 'inherit',\n margin: '0',\n fontWeight: 'normal',\n paddingBottom: theme.spacing.unit * 2,\n },\n teacherInstructions: {\n marginBottom: theme.spacing.unit * 2,\n },\n horizontalLayout: {\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n },\n gridLayout: {\n display: 'grid',\n },\n fieldset: {\n border: '0px',\n padding: '0.01em 0 0 0',\n margin: '0px',\n minWidth: '0px',\n },\n srOnly: {\n position: 'absolute',\n left: '-10000px',\n top: 'auto',\n width: '1px',\n height: '1px',\n overflow: 'hidden',\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing.unit,\n },\n});\n\nexport class MultipleChoice extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n mode: PropTypes.oneOf(['gather', 'view', 'evaluate']),\n choiceMode: PropTypes.oneOf(['radio', 'checkbox']),\n keyMode: PropTypes.oneOf(['numbers', 'letters', 'none']),\n choices: PropTypes.array,\n partLabel: PropTypes.string,\n prompt: PropTypes.string,\n teacherInstructions: PropTypes.string,\n session: PropTypes.object,\n disabled: PropTypes.bool,\n onChoiceChanged: PropTypes.func,\n responseCorrect: PropTypes.bool,\n classes: PropTypes.object.isRequired,\n correctResponse: PropTypes.array,\n choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),\n gridColumns: PropTypes.string,\n alwaysShowCorrect: PropTypes.bool,\n animationsDisabled: PropTypes.bool,\n language: PropTypes.string,\n selectedAnswerBackgroundColor: PropTypes.string,\n onShowCorrectToggle: PropTypes.func,\n isSelectionButtonBelow: PropTypes.bool,\n minSelections: PropTypes.number,\n maxSelections: PropTypes.number,\n autoplayAudioEnabled: PropTypes.bool,\n customAudioButton: {\n playImage: PropTypes.string,\n pauseImage: PropTypes.string,\n },\n options: PropTypes.object,\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n showCorrect: (this.props.options && this.props.alwaysShowCorrect) || false,\n maxSelectionsErrorState: false,\n };\n\n this.onToggle = this.onToggle.bind(this);\n }\n\n isSelected(value) {\n const sessionValue = this.props.session && this.props.session.value;\n\n return sessionValue && sessionValue.indexOf && sessionValue.indexOf(value) >= 0;\n }\n\n // handleChange was added for accessibility. Please see comments and videos from PD-2441.\n handleChange = (event) => {\n const { value, checked } = event.target;\n const { maxSelections, onChoiceChanged, session } = this.props;\n\n if (session.value && session.value.length >= maxSelections) {\n // show/hide max selections error when user select/deselect an answer\n this.setState({ maxSelectionsErrorState: checked });\n\n if (checked) {\n // prevent selecting more answers\n return;\n }\n }\n\n onChoiceChanged({ value, selected: checked, selector: 'Mouse' });\n };\n\n onToggle = () => {\n if (this.props.mode === 'evaluate') {\n this.setState({ showCorrect: !this.state.showCorrect }, () => {\n if (this.props.onShowCorrectToggle) {\n this.props.onShowCorrectToggle();\n }\n });\n }\n };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n if (!nextProps.correctResponse && this.state.showCorrect !== false) {\n this.setState({ showCorrect: false }, () => {\n if (this.props.onShowCorrectToggle) {\n this.props.onShowCorrectToggle();\n }\n });\n }\n\n if (nextProps.options && 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 <h2 className={classes.srOnly}>Multiple Choice Question</h2>\n ) : (\n <h2 className={classes.srOnly}>Multiple Select Question</h2>\n );\n }\n\n render() {\n const {\n mode,\n disabled,\n className,\n choices = [],\n choiceMode,\n gridColumns,\n partLabel,\n prompt,\n responseCorrect,\n teacherInstructions,\n classes,\n alwaysShowCorrect,\n animationsDisabled,\n language,\n isSelectionButtonBelow,\n minSelections,\n maxSelections,\n autoplayAudioEnabled,\n session,\n customAudioButton,\n options,\n } = this.props;\n const { showCorrect, maxSelectionsErrorState } = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;\n const columnsStyle = gridColumns > 1 ? { gridTemplateColumns: `repeat(${gridColumns}, 1fr)` } : undefined;\n const selections = (session.value && session.value.length) || 0;\n\n const teacherInstructionsDiv = (\n <PreviewPrompt\n tagName=\"div\"\n className=\"prompt\"\n defaultClassName=\"teacher-instructions\"\n prompt={teacherInstructions}\n />\n );\n\n const getMultipleChoiceMinSelectionErrorMessage = () => {\n if (minSelections && maxSelections) {\n return minSelections === maxSelections\n ? translator.t('translation:multipleChoice:minmaxSelections_equal', { lng: language, minSelections })\n : translator.t('translation:multipleChoice:minmaxSelections_range', { lng: language, minSelections, maxSelections });\n }\n\n if (minSelections) {\n return translator.t('translation:multipleChoice:minSelections', { lng: language, minSelections });\n }\n\n return '';\n };\n\n return (\n <div id={'main-container'} className={classNames(classes.main, className, 'multiple-choice')}>\n {partLabel && <h3 className={classes.partLabel}>{partLabel}</h3>}\n\n {this.renderHeading()}\n\n {teacherInstructions && (\n <div className={classes.teacherInstructions}>\n {!animationsDisabled ? (\n <Collapsible\n labels={{\n hidden: 'Show Teacher Instructions',\n visible: 'Hide Teacher Instructions',\n }}\n >\n {teacherInstructionsDiv}\n </Collapsible>\n ) : (\n teacherInstructionsDiv\n )}\n </div>\n )}\n\n <fieldset className={classes.fieldset}>\n <PreviewPrompt\n className=\"prompt\"\n defaultClassName=\"prompt\"\n prompt={prompt}\n tagName={'legend'}\n autoplayAudioEnabled={autoplayAudioEnabled}\n customAudioButton={customAudioButton}\n />\n\n {!(options && alwaysShowCorrect) && (\n <CorrectAnswerToggle\n show={showCorrectAnswerToggle}\n toggled={showCorrect}\n onToggle={this.onToggle.bind(this)}\n language={language}\n />\n )}\n\n <div\n className={classNames({\n [classes.gridLayout]: this.props.choicesLayout === 'grid',\n [classes.horizontalLayout]: this.props.choicesLayout === 'horizontal',\n })}\n style={columnsStyle}\n >\n {choices.map((choice, index) => (\n <StyledChoice\n choicesLayout={this.props.choicesLayout}\n selectedAnswerBackgroundColor={this.props.selectedAnswerBackgroundColor}\n gridColumns={gridColumns}\n key={`choice-${index}`}\n choice={choice}\n index={index}\n choicesLength={choices.length}\n showCorrect={showCorrect}\n isEvaluateMode={isEvaluateMode}\n choiceMode={choiceMode}\n disabled={disabled}\n onChoiceChanged={this.handleChange}\n hideTick={choice.hideTick}\n checked={this.getChecked(choice)}\n correctness={isEvaluateMode ? this.getCorrectness(choice) : undefined}\n displayKey={this.indexToSymbol(index)}\n isSelectionButtonBelow={isSelectionButtonBelow}\n />\n ))}\n </div>\n </fieldset>\n\n {choiceMode === 'checkbox' && (selections < minSelections) && (\n <div className={classes.errorText}>\n {getMultipleChoiceMinSelectionErrorMessage()}\n </div>\n )}\n {choiceMode === 'checkbox' && maxSelectionsErrorState && (\n <div className={classes.errorText}>\n {translator.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {\n lng: language,\n maxSelections,\n })}\n </div>\n )}\n </div>\n );\n }\n}\n\nMultipleChoice.defaultProps = {\n session: {\n value: [],\n },\n};\n\nexport default withStyles(styles)(MultipleChoice);\n"],"file":"multiple-choice.js"}
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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AtC;AAEA,SAAOxB,KAAP;AACD,CA3BD;;IA6BqByB,mB;;;;;AACnB,iCAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,QAAL,GAAgB,IAAhB;AACA,UAAKC,MAAL,GAAc,IAAd;AACA,UAAKC,QAAL,GAAgB,EAAhB;AACA,UAAKC,SAAL,GAAiB,0BACf,YAAM;AACJ,UAAI,MAAKF,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAME,UAAU,GAAG/B,iBAAiB,CAAC,MAAK4B,MAAN,EAAc,MAAKD,QAAnB,CAApC;;AAEA,YAAMK,OAAO,GACX,MAAKL,QAAL,iBACAM,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACxBlC,UAAAA,KAAK,EAAE8B,UADiB;AAExBK,UAAAA,OAAO,EAAE;AAFe,SAA1B,CAFF;;AAOAC,6BAASC,MAAT,CAAgBN,OAAhB,kDAA+B,YAAM;AACnCjC,UAAAA,GAAG,CAAC,+BAAD,CAAH;AACA;AACD,SAHD;AAID,OAdD,MAcO;AACLA,QAAAA,GAAG,CAAC,MAAD,CAAH;AACD;AACF,KAnBc,EAoBf,EApBe,EAqBf;AAAEwC,MAAAA,OAAO,EAAE,KAAX;AAAkBC,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/pie-toolbox/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":";;;;;;;;;;;;;;;;;;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 'react-dom';\nimport debounce from 'lodash/debounce';\nimport cloneDeep from 'lodash/cloneDeep';\nimport Main from './main';\nimport { renderMath } from '@pie-lib/pie-toolbox/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"}
@@ -1,5 +1,5 @@
1
- import {_dll_react, _dll_prop_types, _dll_react_dom, _dll_classnames, _dll_lodash, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.8.1/module/index.js";
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@6.0.1/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@3.9.0/module/index.js";
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@6.0.3/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) {
5
5
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -10175,7 +10175,7 @@ const {settings: settings} = _dll_pie_lib__pie_toolbox_config_ui;
10175
10175
  const {layout: layout} = _dll_pie_lib__pie_toolbox_config_ui;
10176
10176
  const {choiceUtils: utils$1} = _dll_pie_lib__pie_toolbox_config_ui;
10177
10177
  const {color: color} = _dll_pie_lib__pie_toolbox_render_ui;
10178
- const _jsxFileName = "/home/circleci/repo/packages/multiple-choice/configure/src/main.jsx";
10178
+ const _jsxFileName = "/Users/carlacostea/Pie_Work/pie-framework/pie-elements/packages/multiple-choice/configure/src/main.jsx";
10179
10179
  function _optionalChain$1(ops) {
10180
10180
  let lastAccessLHS = undefined;
10181
10181
  let value = ops[0];
package/module/element.js CHANGED
@@ -1,5 +1,5 @@
1
- import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.8.1/module/index.js";
2
- import {_dll_pie_lib__pie_toolbox_render_ui, _dll_pie_lib__pie_toolbox_correct_answer_toggle} from "../../../@pie-lib/pie-toolbox-module@6.0.1/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} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.9.0/module/index.js";
2
+ import {_dll_pie_lib__pie_toolbox_render_ui, _dll_pie_lib__pie_toolbox_correct_answer_toggle} from "../../../@pie-lib/pie-toolbox-module@6.0.3/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) {
5
5
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -11954,7 +11954,7 @@ var reactTransitionGroup = {
11954
11954
  const React$5 = _dll_react;
11955
11955
  const PropTypes$4 = _dll_prop_types;
11956
11956
  const {color: color$2} = _dll_pie_lib__pie_toolbox_render_ui;
11957
- const _jsxFileName$4 = "/home/circleci/repo/packages/multiple-choice/src/feedback-tick.jsx";
11957
+ const _jsxFileName$4 = "/Users/carlacostea/Pie_Work/pie-framework/pie-elements/packages/multiple-choice/src/feedback-tick.jsx";
11958
11958
  const stylesheet = {
11959
11959
  incorrect: {
11960
11960
  fill: `var(--feedback-incorrect-bg-color, ${color$2.incorrect()})`
@@ -12125,7 +12125,7 @@ const classNames$2 = _dll_classnames;
12125
12125
  const {Feedback: Feedback} = _dll_pie_lib__pie_toolbox_render_ui;
12126
12126
  const {color: color$1} = _dll_pie_lib__pie_toolbox_render_ui;
12127
12127
  const {PreviewPrompt: PreviewPrompt$1} = _dll_pie_lib__pie_toolbox_render_ui;
12128
- const _jsxFileName$3 = "/home/circleci/repo/packages/multiple-choice/src/choice-input.jsx";
12128
+ const _jsxFileName$3 = "/Users/carlacostea/Pie_Work/pie-framework/pie-elements/packages/multiple-choice/src/choice-input.jsx";
12129
12129
  const CLASS_NAME = 'multiple-choice-component';
12130
12130
  const styleSheet = theme => ({
12131
12131
  row: {
@@ -12479,7 +12479,7 @@ var ChoiceInput$1 = styles$b.withStyles(styleSheet)(ChoiceInput);
12479
12479
  const React$3 = _dll_react;
12480
12480
  const PropTypes$2 = _dll_prop_types;
12481
12481
  const classNames$1 = _dll_classnames;
12482
- const _jsxFileName$2 = "/home/circleci/repo/packages/multiple-choice/src/choice.jsx";
12482
+ const _jsxFileName$2 = "/Users/carlacostea/Pie_Work/pie-framework/pie-elements/packages/multiple-choice/src/choice.jsx";
12483
12483
  class Choice extends React$3.Component {
12484
12484
  constructor(...args) {
12485
12485
  super(...args);
@@ -12586,7 +12586,7 @@ const {CorrectAnswerToggle: CorrectAnswerToggle} = _dll_pie_lib__pie_toolbox_cor
12586
12586
  const {color: color} = _dll_pie_lib__pie_toolbox_render_ui;
12587
12587
  const {Collapsible: Collapsible} = _dll_pie_lib__pie_toolbox_render_ui;
12588
12588
  const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__pie_toolbox_render_ui;
12589
- const _jsxFileName$1 = "/home/circleci/repo/packages/multiple-choice/src/multiple-choice.jsx";
12589
+ const _jsxFileName$1 = "/Users/carlacostea/Pie_Work/pie-framework/pie-elements/packages/multiple-choice/src/multiple-choice.jsx";
12590
12590
  const {translator} = Translator;
12591
12591
  const styles$1 = theme => ({
12592
12592
  main: {
@@ -12666,7 +12666,8 @@ class MultipleChoice$1 extends React$2.Component {
12666
12666
  customAudioButton: {
12667
12667
  playImage: PropTypes$1.string,
12668
12668
  pauseImage: PropTypes$1.string
12669
- }
12669
+ },
12670
+ options: PropTypes$1.object
12670
12671
  };
12671
12672
  }
12672
12673
  constructor(props) {
@@ -12675,7 +12676,7 @@ class MultipleChoice$1 extends React$2.Component {
12675
12676
  MultipleChoice$1.prototype.__init2.call(this);
12676
12677
  MultipleChoice$1.prototype.__init3.call(this);
12677
12678
  this.state = {
12678
- showCorrect: this.props.alwaysShowCorrect || false,
12679
+ showCorrect: this.props.options && this.props.alwaysShowCorrect || false,
12679
12680
  maxSelectionsErrorState: false
12680
12681
  };
12681
12682
  this.onToggle = this.onToggle.bind(this);
@@ -12726,7 +12727,7 @@ class MultipleChoice$1 extends React$2.Component {
12726
12727
  }
12727
12728
  });
12728
12729
  }
12729
- if (nextProps.alwaysShowCorrect && this.state.showCorrect !== true) {
12730
+ if (nextProps.options && nextProps.alwaysShowCorrect && this.state.showCorrect !== true) {
12730
12731
  this.setState({
12731
12732
  showCorrect: true
12732
12733
  }, () => {
@@ -12768,7 +12769,12 @@ class MultipleChoice$1 extends React$2.Component {
12768
12769
  };
12769
12770
  }
12770
12771
  getChecked(choice) {
12771
- if (this.state.showCorrect) {
12772
+ const isPrintMode = this.props.options && this.props.alwaysShowCorrect;
12773
+ if (isPrintMode) {
12774
+ return choice.correct || false;
12775
+ }
12776
+ const isEvaluateMode = this.state.showCorrect && this.props.mode === 'evaluate';
12777
+ if (isEvaluateMode) {
12772
12778
  return choice.correct || false;
12773
12779
  }
12774
12780
  return this.isSelected(choice.value);
@@ -12783,19 +12789,19 @@ class MultipleChoice$1 extends React$2.Component {
12783
12789
  __self: this,
12784
12790
  __source: {
12785
12791
  fileName: _jsxFileName$1,
12786
- lineNumber: 215
12792
+ lineNumber: 227
12787
12793
  }
12788
12794
  }, "Multiple Choice Question") : React$2.createElement('h2', {
12789
12795
  className: classes.srOnly,
12790
12796
  __self: this,
12791
12797
  __source: {
12792
12798
  fileName: _jsxFileName$1,
12793
- lineNumber: 217
12799
+ lineNumber: 229
12794
12800
  }
12795
12801
  }, "Multiple Select Question");
12796
12802
  }
12797
12803
  render() {
12798
- const {mode, disabled, className, choices = [], choiceMode, gridColumns, partLabel, prompt, responseCorrect, teacherInstructions, classes, alwaysShowCorrect, animationsDisabled, language, isSelectionButtonBelow, minSelections, maxSelections, autoplayAudioEnabled, session, customAudioButton} = this.props;
12804
+ const {mode, disabled, className, choices = [], choiceMode, gridColumns, partLabel, prompt, responseCorrect, teacherInstructions, classes, alwaysShowCorrect, animationsDisabled, language, isSelectionButtonBelow, minSelections, maxSelections, autoplayAudioEnabled, session, customAudioButton, options} = this.props;
12799
12805
  const {showCorrect, maxSelectionsErrorState} = this.state;
12800
12806
  const isEvaluateMode = mode === 'evaluate';
12801
12807
  const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;
@@ -12811,7 +12817,7 @@ class MultipleChoice$1 extends React$2.Component {
12811
12817
  __self: this,
12812
12818
  __source: {
12813
12819
  fileName: _jsxFileName$1,
12814
- lineNumber: 251
12820
+ lineNumber: 264
12815
12821
  }
12816
12822
  });
12817
12823
  const getMultipleChoiceMinSelectionErrorMessage = () => {
@@ -12839,21 +12845,21 @@ class MultipleChoice$1 extends React$2.Component {
12839
12845
  __self: this,
12840
12846
  __source: {
12841
12847
  fileName: _jsxFileName$1,
12842
- lineNumber: 274
12848
+ lineNumber: 287
12843
12849
  }
12844
12850
  }, partLabel && React$2.createElement('h3', {
12845
12851
  className: classes.partLabel,
12846
12852
  __self: this,
12847
12853
  __source: {
12848
12854
  fileName: _jsxFileName$1,
12849
- lineNumber: 275
12855
+ lineNumber: 288
12850
12856
  }
12851
12857
  }, partLabel), this.renderHeading(), teacherInstructions && React$2.createElement('div', {
12852
12858
  className: classes.teacherInstructions,
12853
12859
  __self: this,
12854
12860
  __source: {
12855
12861
  fileName: _jsxFileName$1,
12856
- lineNumber: 280
12862
+ lineNumber: 293
12857
12863
  }
12858
12864
  }, !animationsDisabled ? React$2.createElement(Collapsible, {
12859
12865
  labels: {
@@ -12863,14 +12869,14 @@ class MultipleChoice$1 extends React$2.Component {
12863
12869
  __self: this,
12864
12870
  __source: {
12865
12871
  fileName: _jsxFileName$1,
12866
- lineNumber: 282
12872
+ lineNumber: 295
12867
12873
  }
12868
12874
  }, teacherInstructionsDiv) : teacherInstructionsDiv), React$2.createElement('fieldset', {
12869
12875
  className: classes.fieldset,
12870
12876
  __self: this,
12871
12877
  __source: {
12872
12878
  fileName: _jsxFileName$1,
12873
- lineNumber: 296
12879
+ lineNumber: 309
12874
12880
  }
12875
12881
  }, React$2.createElement(PreviewPrompt, {
12876
12882
  className: "prompt",
@@ -12882,9 +12888,9 @@ class MultipleChoice$1 extends React$2.Component {
12882
12888
  __self: this,
12883
12889
  __source: {
12884
12890
  fileName: _jsxFileName$1,
12885
- lineNumber: 297
12891
+ lineNumber: 310
12886
12892
  }
12887
- }), !alwaysShowCorrect && React$2.createElement(CorrectAnswerToggle, {
12893
+ }), !(options && alwaysShowCorrect) && React$2.createElement(CorrectAnswerToggle, {
12888
12894
  show: showCorrectAnswerToggle,
12889
12895
  toggled: showCorrect,
12890
12896
  onToggle: this.onToggle.bind(this),
@@ -12892,7 +12898,7 @@ class MultipleChoice$1 extends React$2.Component {
12892
12898
  __self: this,
12893
12899
  __source: {
12894
12900
  fileName: _jsxFileName$1,
12895
- lineNumber: 307
12901
+ lineNumber: 320
12896
12902
  }
12897
12903
  }), React$2.createElement('div', {
12898
12904
  className: classNames({
@@ -12903,7 +12909,7 @@ class MultipleChoice$1 extends React$2.Component {
12903
12909
  __self: this,
12904
12910
  __source: {
12905
12911
  fileName: _jsxFileName$1,
12906
- lineNumber: 315
12912
+ lineNumber: 328
12907
12913
  }
12908
12914
  }, choices.map((choice, index) => React$2.createElement(StyledChoice, {
12909
12915
  choicesLayout: this.props.choicesLayout,
@@ -12926,21 +12932,21 @@ class MultipleChoice$1 extends React$2.Component {
12926
12932
  __self: this,
12927
12933
  __source: {
12928
12934
  fileName: _jsxFileName$1,
12929
- lineNumber: 323
12935
+ lineNumber: 336
12930
12936
  }
12931
12937
  })))), choiceMode === 'checkbox' && selections < minSelections && React$2.createElement('div', {
12932
12938
  className: classes.errorText,
12933
12939
  __self: this,
12934
12940
  __source: {
12935
12941
  fileName: _jsxFileName$1,
12936
- lineNumber: 347
12942
+ lineNumber: 360
12937
12943
  }
12938
12944
  }, getMultipleChoiceMinSelectionErrorMessage()), choiceMode === 'checkbox' && maxSelectionsErrorState && React$2.createElement('div', {
12939
12945
  className: classes.errorText,
12940
12946
  __self: this,
12941
12947
  __source: {
12942
12948
  fileName: _jsxFileName$1,
12943
- lineNumber: 352
12949
+ lineNumber: 365
12944
12950
  }
12945
12951
  }, translator.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {
12946
12952
  lng: language,
@@ -12958,13 +12964,14 @@ var MultipleChoice$2 = styles$b.withStyles(styles$1)(MultipleChoice$1);
12958
12964
  const React$1 = _dll_react;
12959
12965
  const PropTypes = _dll_prop_types;
12960
12966
  const {PreviewLayout: PreviewLayout} = _dll_pie_lib__pie_toolbox_render_ui;
12961
- const _jsxFileName = "/home/circleci/repo/packages/multiple-choice/src/main.jsx";
12967
+ const _jsxFileName = "/Users/carlacostea/Pie_Work/pie-framework/pie-elements/packages/multiple-choice/src/main.jsx";
12962
12968
  const styles = () => ({});
12963
12969
  class Main extends React$1.Component {
12964
12970
  static __initStatic() {
12965
12971
  this.propTypes = {
12966
12972
  model: PropTypes.object,
12967
12973
  session: PropTypes.object,
12974
+ options: PropTypes.object,
12968
12975
  onChoiceChanged: PropTypes.func,
12969
12976
  classes: PropTypes.object.isRequired,
12970
12977
  onShowCorrectToggle: PropTypes.func,
@@ -12984,7 +12991,7 @@ class Main extends React$1.Component {
12984
12991
  super(props);
12985
12992
  }
12986
12993
  render() {
12987
- const {model, onChoiceChanged, session, onShowCorrectToggle} = this.props;
12994
+ const {model, onChoiceChanged, session, onShowCorrectToggle, options} = this.props;
12988
12995
  const {extraCSSRules, fontSizeFactor} = model;
12989
12996
  return React$1.createElement(PreviewLayout, {
12990
12997
  extraCSSRules: extraCSSRules,
@@ -12992,17 +12999,18 @@ class Main extends React$1.Component {
12992
12999
  __self: this,
12993
13000
  __source: {
12994
13001
  fileName: _jsxFileName,
12995
- lineNumber: 37
13002
+ lineNumber: 38
12996
13003
  }
12997
13004
  }, React$1.createElement(MultipleChoice$2, {
12998
13005
  ...model,
13006
+ options: options,
12999
13007
  session: session,
13000
13008
  onChoiceChanged: onChoiceChanged,
13001
13009
  onShowCorrectToggle: onShowCorrectToggle,
13002
13010
  __self: this,
13003
13011
  __source: {
13004
13012
  fileName: _jsxFileName,
13005
- lineNumber: 38
13013
+ lineNumber: 39
13006
13014
  }
13007
13015
  }));
13008
13016
  }
@@ -13022,14 +13030,14 @@ const Root = props => React$1.createElement(styles$b.MuiThemeProvider, {
13022
13030
  __self: undefined,
13023
13031
  __source: {
13024
13032
  fileName: _jsxFileName,
13025
- lineNumber: 58
13033
+ lineNumber: 60
13026
13034
  }
13027
13035
  }, React$1.createElement(Styled, {
13028
13036
  ...props,
13029
13037
  __self: undefined,
13030
13038
  __source: {
13031
13039
  fileName: _jsxFileName,
13032
- lineNumber: 59
13040
+ lineNumber: 61
13033
13041
  }
13034
13042
  }));
13035
13043
  var lib = {};
@@ -13148,6 +13156,7 @@ class MultipleChoice extends HTMLElement {
13148
13156
  super();
13149
13157
  this._model = null;
13150
13158
  this._session = null;
13159
+ this._options = null;
13151
13160
  this.audioComplete = false;
13152
13161
  this._boundHandleKeyDown = this.handleKeyDown.bind(this);
13153
13162
  this._keyboardEventsEnabled = false;
@@ -13156,6 +13165,7 @@ class MultipleChoice extends HTMLElement {
13156
13165
  var element = React.createElement(Root, {
13157
13166
  model: this._model,
13158
13167
  session: this._session,
13168
+ options: this._options,
13159
13169
  onChoiceChanged: this._onChange.bind(this),
13160
13170
  onShowCorrectToggle: this.onShowCorrectToggle.bind(this)
13161
13171
  });
@@ -13202,6 +13212,13 @@ class MultipleChoice extends HTMLElement {
13202
13212
  get session() {
13203
13213
  return this._session;
13204
13214
  }
13215
+ get options() {
13216
+ return this._options;
13217
+ }
13218
+ set options(o) {
13219
+ this._options = o;
13220
+ this._rerender();
13221
+ }
13205
13222
  set session(s) {
13206
13223
  this._session = s;
13207
13224
  this._rerender();
package/module/index.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <!doctype html>
3
3
  <html>
4
4
  <head>
5
- <title>@pie-element/multiple-choice@9.15.1</title>
5
+ <title>@pie-element/multiple-choice@9.15.3</title>
6
6
  <script
7
7
  type="module"
8
8
  src="https://cdn.jsdelivr.net/npm/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice",
3
- "version": "9.15.1",
3
+ "version": "9.15.3",
4
4
  "modules": [
5
5
  {
6
6
  "name": "@pie-lib/pie-toolbox-math-rendering-module",
7
- "version": "3.8.1"
7
+ "version": "3.9.0"
8
8
  },
9
9
  {
10
10
  "name": "@pie-lib/pie-toolbox-module",
11
- "version": "6.0.1"
11
+ "version": "6.0.3"
12
12
  }
13
13
  ]
14
14
  }
package/module/print.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <!doctype html>
3
3
  <html>
4
4
  <head>
5
- <title>@pie-element/multiple-choice@9.15.1</title>
5
+ <title>@pie-element/multiple-choice@9.15.3</title>
6
6
  <link
7
7
  href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
8
8
  rel="stylesheet"
package/module/print.js CHANGED
@@ -1,5 +1,5 @@
1
- import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_pie_lib__pie_toolbox_math_rendering, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.8.1/module/index.js";
2
- import {_dll_pie_lib__pie_toolbox_render_ui, _dll_pie_lib__pie_toolbox_correct_answer_toggle} from "../../../@pie-lib/pie-toolbox-module@6.0.1/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_pie_lib__pie_toolbox_math_rendering, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.9.0/module/index.js";
2
+ import {_dll_pie_lib__pie_toolbox_render_ui, _dll_pie_lib__pie_toolbox_correct_answer_toggle} from "../../../@pie-lib/pie-toolbox-module@6.0.3/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) {
5
5
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -11954,7 +11954,7 @@ var reactTransitionGroup = {
11954
11954
  const React$5 = _dll_react;
11955
11955
  const PropTypes$4 = _dll_prop_types;
11956
11956
  const {color: color$2} = _dll_pie_lib__pie_toolbox_render_ui;
11957
- const _jsxFileName$4 = "/home/circleci/repo/packages/multiple-choice/src/feedback-tick.jsx";
11957
+ const _jsxFileName$4 = "/Users/carlacostea/Pie_Work/pie-framework/pie-elements/packages/multiple-choice/src/feedback-tick.jsx";
11958
11958
  const stylesheet = {
11959
11959
  incorrect: {
11960
11960
  fill: `var(--feedback-incorrect-bg-color, ${color$2.incorrect()})`
@@ -12125,7 +12125,7 @@ const classNames$2 = _dll_classnames;
12125
12125
  const {Feedback: Feedback} = _dll_pie_lib__pie_toolbox_render_ui;
12126
12126
  const {color: color$1} = _dll_pie_lib__pie_toolbox_render_ui;
12127
12127
  const {PreviewPrompt: PreviewPrompt$1} = _dll_pie_lib__pie_toolbox_render_ui;
12128
- const _jsxFileName$3 = "/home/circleci/repo/packages/multiple-choice/src/choice-input.jsx";
12128
+ const _jsxFileName$3 = "/Users/carlacostea/Pie_Work/pie-framework/pie-elements/packages/multiple-choice/src/choice-input.jsx";
12129
12129
  const CLASS_NAME = 'multiple-choice-component';
12130
12130
  const styleSheet = theme => ({
12131
12131
  row: {
@@ -12479,7 +12479,7 @@ var ChoiceInput$1 = styles$b.withStyles(styleSheet)(ChoiceInput);
12479
12479
  const React$3 = _dll_react;
12480
12480
  const PropTypes$2 = _dll_prop_types;
12481
12481
  const classNames$1 = _dll_classnames;
12482
- const _jsxFileName$2 = "/home/circleci/repo/packages/multiple-choice/src/choice.jsx";
12482
+ const _jsxFileName$2 = "/Users/carlacostea/Pie_Work/pie-framework/pie-elements/packages/multiple-choice/src/choice.jsx";
12483
12483
  class Choice extends React$3.Component {
12484
12484
  constructor(...args) {
12485
12485
  super(...args);
@@ -12586,7 +12586,7 @@ const {CorrectAnswerToggle: CorrectAnswerToggle} = _dll_pie_lib__pie_toolbox_cor
12586
12586
  const {color: color} = _dll_pie_lib__pie_toolbox_render_ui;
12587
12587
  const {Collapsible: Collapsible} = _dll_pie_lib__pie_toolbox_render_ui;
12588
12588
  const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__pie_toolbox_render_ui;
12589
- const _jsxFileName$1 = "/home/circleci/repo/packages/multiple-choice/src/multiple-choice.jsx";
12589
+ const _jsxFileName$1 = "/Users/carlacostea/Pie_Work/pie-framework/pie-elements/packages/multiple-choice/src/multiple-choice.jsx";
12590
12590
  const {translator} = Translator;
12591
12591
  const styles$1 = theme => ({
12592
12592
  main: {
@@ -12666,7 +12666,8 @@ class MultipleChoice extends React$2.Component {
12666
12666
  customAudioButton: {
12667
12667
  playImage: PropTypes$1.string,
12668
12668
  pauseImage: PropTypes$1.string
12669
- }
12669
+ },
12670
+ options: PropTypes$1.object
12670
12671
  };
12671
12672
  }
12672
12673
  constructor(props) {
@@ -12675,7 +12676,7 @@ class MultipleChoice extends React$2.Component {
12675
12676
  MultipleChoice.prototype.__init2.call(this);
12676
12677
  MultipleChoice.prototype.__init3.call(this);
12677
12678
  this.state = {
12678
- showCorrect: this.props.alwaysShowCorrect || false,
12679
+ showCorrect: this.props.options && this.props.alwaysShowCorrect || false,
12679
12680
  maxSelectionsErrorState: false
12680
12681
  };
12681
12682
  this.onToggle = this.onToggle.bind(this);
@@ -12726,7 +12727,7 @@ class MultipleChoice extends React$2.Component {
12726
12727
  }
12727
12728
  });
12728
12729
  }
12729
- if (nextProps.alwaysShowCorrect && this.state.showCorrect !== true) {
12730
+ if (nextProps.options && nextProps.alwaysShowCorrect && this.state.showCorrect !== true) {
12730
12731
  this.setState({
12731
12732
  showCorrect: true
12732
12733
  }, () => {
@@ -12768,7 +12769,12 @@ class MultipleChoice extends React$2.Component {
12768
12769
  };
12769
12770
  }
12770
12771
  getChecked(choice) {
12771
- if (this.state.showCorrect) {
12772
+ const isPrintMode = this.props.options && this.props.alwaysShowCorrect;
12773
+ if (isPrintMode) {
12774
+ return choice.correct || false;
12775
+ }
12776
+ const isEvaluateMode = this.state.showCorrect && this.props.mode === 'evaluate';
12777
+ if (isEvaluateMode) {
12772
12778
  return choice.correct || false;
12773
12779
  }
12774
12780
  return this.isSelected(choice.value);
@@ -12783,19 +12789,19 @@ class MultipleChoice extends React$2.Component {
12783
12789
  __self: this,
12784
12790
  __source: {
12785
12791
  fileName: _jsxFileName$1,
12786
- lineNumber: 215
12792
+ lineNumber: 227
12787
12793
  }
12788
12794
  }, "Multiple Choice Question") : React$2.createElement('h2', {
12789
12795
  className: classes.srOnly,
12790
12796
  __self: this,
12791
12797
  __source: {
12792
12798
  fileName: _jsxFileName$1,
12793
- lineNumber: 217
12799
+ lineNumber: 229
12794
12800
  }
12795
12801
  }, "Multiple Select Question");
12796
12802
  }
12797
12803
  render() {
12798
- const {mode, disabled, className, choices = [], choiceMode, gridColumns, partLabel, prompt, responseCorrect, teacherInstructions, classes, alwaysShowCorrect, animationsDisabled, language, isSelectionButtonBelow, minSelections, maxSelections, autoplayAudioEnabled, session, customAudioButton} = this.props;
12804
+ const {mode, disabled, className, choices = [], choiceMode, gridColumns, partLabel, prompt, responseCorrect, teacherInstructions, classes, alwaysShowCorrect, animationsDisabled, language, isSelectionButtonBelow, minSelections, maxSelections, autoplayAudioEnabled, session, customAudioButton, options} = this.props;
12799
12805
  const {showCorrect, maxSelectionsErrorState} = this.state;
12800
12806
  const isEvaluateMode = mode === 'evaluate';
12801
12807
  const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;
@@ -12811,7 +12817,7 @@ class MultipleChoice extends React$2.Component {
12811
12817
  __self: this,
12812
12818
  __source: {
12813
12819
  fileName: _jsxFileName$1,
12814
- lineNumber: 251
12820
+ lineNumber: 264
12815
12821
  }
12816
12822
  });
12817
12823
  const getMultipleChoiceMinSelectionErrorMessage = () => {
@@ -12839,21 +12845,21 @@ class MultipleChoice extends React$2.Component {
12839
12845
  __self: this,
12840
12846
  __source: {
12841
12847
  fileName: _jsxFileName$1,
12842
- lineNumber: 274
12848
+ lineNumber: 287
12843
12849
  }
12844
12850
  }, partLabel && React$2.createElement('h3', {
12845
12851
  className: classes.partLabel,
12846
12852
  __self: this,
12847
12853
  __source: {
12848
12854
  fileName: _jsxFileName$1,
12849
- lineNumber: 275
12855
+ lineNumber: 288
12850
12856
  }
12851
12857
  }, partLabel), this.renderHeading(), teacherInstructions && React$2.createElement('div', {
12852
12858
  className: classes.teacherInstructions,
12853
12859
  __self: this,
12854
12860
  __source: {
12855
12861
  fileName: _jsxFileName$1,
12856
- lineNumber: 280
12862
+ lineNumber: 293
12857
12863
  }
12858
12864
  }, !animationsDisabled ? React$2.createElement(Collapsible, {
12859
12865
  labels: {
@@ -12863,14 +12869,14 @@ class MultipleChoice extends React$2.Component {
12863
12869
  __self: this,
12864
12870
  __source: {
12865
12871
  fileName: _jsxFileName$1,
12866
- lineNumber: 282
12872
+ lineNumber: 295
12867
12873
  }
12868
12874
  }, teacherInstructionsDiv) : teacherInstructionsDiv), React$2.createElement('fieldset', {
12869
12875
  className: classes.fieldset,
12870
12876
  __self: this,
12871
12877
  __source: {
12872
12878
  fileName: _jsxFileName$1,
12873
- lineNumber: 296
12879
+ lineNumber: 309
12874
12880
  }
12875
12881
  }, React$2.createElement(PreviewPrompt, {
12876
12882
  className: "prompt",
@@ -12882,9 +12888,9 @@ class MultipleChoice extends React$2.Component {
12882
12888
  __self: this,
12883
12889
  __source: {
12884
12890
  fileName: _jsxFileName$1,
12885
- lineNumber: 297
12891
+ lineNumber: 310
12886
12892
  }
12887
- }), !alwaysShowCorrect && React$2.createElement(CorrectAnswerToggle, {
12893
+ }), !(options && alwaysShowCorrect) && React$2.createElement(CorrectAnswerToggle, {
12888
12894
  show: showCorrectAnswerToggle,
12889
12895
  toggled: showCorrect,
12890
12896
  onToggle: this.onToggle.bind(this),
@@ -12892,7 +12898,7 @@ class MultipleChoice extends React$2.Component {
12892
12898
  __self: this,
12893
12899
  __source: {
12894
12900
  fileName: _jsxFileName$1,
12895
- lineNumber: 307
12901
+ lineNumber: 320
12896
12902
  }
12897
12903
  }), React$2.createElement('div', {
12898
12904
  className: classNames({
@@ -12903,7 +12909,7 @@ class MultipleChoice extends React$2.Component {
12903
12909
  __self: this,
12904
12910
  __source: {
12905
12911
  fileName: _jsxFileName$1,
12906
- lineNumber: 315
12912
+ lineNumber: 328
12907
12913
  }
12908
12914
  }, choices.map((choice, index) => React$2.createElement(StyledChoice, {
12909
12915
  choicesLayout: this.props.choicesLayout,
@@ -12926,21 +12932,21 @@ class MultipleChoice extends React$2.Component {
12926
12932
  __self: this,
12927
12933
  __source: {
12928
12934
  fileName: _jsxFileName$1,
12929
- lineNumber: 323
12935
+ lineNumber: 336
12930
12936
  }
12931
12937
  })))), choiceMode === 'checkbox' && selections < minSelections && React$2.createElement('div', {
12932
12938
  className: classes.errorText,
12933
12939
  __self: this,
12934
12940
  __source: {
12935
12941
  fileName: _jsxFileName$1,
12936
- lineNumber: 347
12942
+ lineNumber: 360
12937
12943
  }
12938
12944
  }, getMultipleChoiceMinSelectionErrorMessage()), choiceMode === 'checkbox' && maxSelectionsErrorState && React$2.createElement('div', {
12939
12945
  className: classes.errorText,
12940
12946
  __self: this,
12941
12947
  __source: {
12942
12948
  fileName: _jsxFileName$1,
12943
- lineNumber: 352
12949
+ lineNumber: 365
12944
12950
  }
12945
12951
  }, translator.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {
12946
12952
  lng: language,
@@ -12958,13 +12964,14 @@ var MultipleChoice$1 = styles$b.withStyles(styles$1)(MultipleChoice);
12958
12964
  const React$1 = _dll_react;
12959
12965
  const PropTypes = _dll_prop_types;
12960
12966
  const {PreviewLayout: PreviewLayout} = _dll_pie_lib__pie_toolbox_render_ui;
12961
- const _jsxFileName = "/home/circleci/repo/packages/multiple-choice/src/main.jsx";
12967
+ const _jsxFileName = "/Users/carlacostea/Pie_Work/pie-framework/pie-elements/packages/multiple-choice/src/main.jsx";
12962
12968
  const styles = () => ({});
12963
12969
  class Main extends React$1.Component {
12964
12970
  static __initStatic() {
12965
12971
  this.propTypes = {
12966
12972
  model: PropTypes.object,
12967
12973
  session: PropTypes.object,
12974
+ options: PropTypes.object,
12968
12975
  onChoiceChanged: PropTypes.func,
12969
12976
  classes: PropTypes.object.isRequired,
12970
12977
  onShowCorrectToggle: PropTypes.func,
@@ -12984,7 +12991,7 @@ class Main extends React$1.Component {
12984
12991
  super(props);
12985
12992
  }
12986
12993
  render() {
12987
- const {model, onChoiceChanged, session, onShowCorrectToggle} = this.props;
12994
+ const {model, onChoiceChanged, session, onShowCorrectToggle, options} = this.props;
12988
12995
  const {extraCSSRules, fontSizeFactor} = model;
12989
12996
  return React$1.createElement(PreviewLayout, {
12990
12997
  extraCSSRules: extraCSSRules,
@@ -12992,17 +12999,18 @@ class Main extends React$1.Component {
12992
12999
  __self: this,
12993
13000
  __source: {
12994
13001
  fileName: _jsxFileName,
12995
- lineNumber: 37
13002
+ lineNumber: 38
12996
13003
  }
12997
13004
  }, React$1.createElement(MultipleChoice$1, {
12998
13005
  ...model,
13006
+ options: options,
12999
13007
  session: session,
13000
13008
  onChoiceChanged: onChoiceChanged,
13001
13009
  onShowCorrectToggle: onShowCorrectToggle,
13002
13010
  __self: this,
13003
13011
  __source: {
13004
13012
  fileName: _jsxFileName,
13005
- lineNumber: 38
13013
+ lineNumber: 39
13006
13014
  }
13007
13015
  }));
13008
13016
  }
@@ -13022,14 +13030,14 @@ const Root = props => React$1.createElement(styles$b.MuiThemeProvider, {
13022
13030
  __self: undefined,
13023
13031
  __source: {
13024
13032
  fileName: _jsxFileName,
13025
- lineNumber: 58
13033
+ lineNumber: 60
13026
13034
  }
13027
13035
  }, React$1.createElement(Styled, {
13028
13036
  ...props,
13029
13037
  __self: undefined,
13030
13038
  __source: {
13031
13039
  fileName: _jsxFileName,
13032
- lineNumber: 59
13040
+ lineNumber: 61
13033
13041
  }
13034
13042
  }));
13035
13043
  const React = _dll_react;
@@ -13071,7 +13079,8 @@ class MultipleChoicePrint extends HTMLElement {
13071
13079
  const printModel = preparePrintModel(this._model, this._options);
13072
13080
  const element = this._options && React.createElement(Root, {
13073
13081
  model: printModel,
13074
- session: {}
13082
+ session: {},
13083
+ options: this._options
13075
13084
  });
13076
13085
  ReactDOM.render(element, this, () => {
13077
13086
  log('render complete - render math');
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice",
3
3
  "repository": "pie-framework/pie-elements",
4
- "version": "9.15.2",
4
+ "version": "9.15.3-hotfix.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "dependencies": {
9
9
  "@material-ui/core": "^3.9.2",
10
10
  "@pie-framework/pie-player-events": "^0.1.0",
11
- "@pie-lib/pie-toolbox": "2.14.1",
11
+ "@pie-lib/pie-toolbox": "2.14.3",
12
12
  "classnames": "^2.2.5",
13
13
  "debug": "^4.1.1",
14
14
  "enzyme-to-json": "^3.3.3",
@@ -19,7 +19,7 @@
19
19
  "react-test-renderer": "^16.3.2",
20
20
  "react-transition-group": "^2.3.1"
21
21
  },
22
- "gitHead": "0b36d7c9fac17d590aefee1f591872366493343a",
22
+ "gitHead": "0e14ff981bcdc8a89a0e58484026496701bfdbc3",
23
23
  "scripts": {
24
24
  "postpublish": "../../scripts/postpublish"
25
25
  },
package/LICENSE.md DELETED
@@ -1,5 +0,0 @@
1
- Copyright 2019 CoreSpring Inc
2
-
3
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4
-
5
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.