@pie-element/multiple-choice 9.11.1-next.6 → 9.12.1-next.0

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,24 @@
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.12.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@9.11.0...@pie-element/multiple-choice@9.12.0) (2025-02-12)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib/pie-toolbox PD-4717 ([4bc5bea](https://github.com/pie-framework/pie-elements/commit/4bc5beafe3c04efe64809ff95c5863a6142cbb02))
12
+ * **multiple-choice:** multiple event listeners conflict on re-render PD-4411 ([2cdc929](https://github.com/pie-framework/pie-elements/commit/2cdc9292b34c87393605f7bec3628871f3e514b8))
13
+
14
+
15
+ ### Features
16
+
17
+ * **multiple-choice:** adjust container to append audio autoplay button PD-4783 ([8ed342a](https://github.com/pie-framework/pie-elements/commit/8ed342a01669c5297560a0ea20239298ccd0a886))
18
+ * **multiple-choice:** change warning for audio autoplay with play button gif PD-4783 ([791080c](https://github.com/pie-framework/pie-elements/commit/791080c9e621ca467795c980488895d14566be00))
19
+
20
+
21
+
22
+
23
+
6
24
  # [9.11.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@9.10.0...@pie-element/multiple-choice@9.11.0) (2025-02-07)
7
25
 
8
26
 
@@ -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.4.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@7.4.0...@pie-element/multiple-choice-configure@7.4.1) (2025-02-12)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib/pie-toolbox PD-4717 ([4bc5bea](https://github.com/pie-framework/pie-elements/commit/4bc5beafe3c04efe64809ff95c5863a6142cbb02))
12
+
13
+
14
+
15
+
16
+
6
17
  # [7.4.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@7.3.1...@pie-element/multiple-choice-configure@7.4.0) (2025-02-07)
7
18
 
8
19
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice-configure",
3
- "version": "7.4.0",
3
+ "version": "7.4.1",
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.9.0",
11
+ "@pie-lib/pie-toolbox": "2.9.1",
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.7.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@5.7.0...@pie-element/multiple-choice-controller@5.7.1) (2025-02-12)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-lib/pie-toolbox PD-4717 ([4bc5bea](https://github.com/pie-framework/pie-elements/commit/4bc5beafe3c04efe64809ff95c5863a6142cbb02))
12
+
13
+
14
+
15
+
16
+
6
17
  # [5.7.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@5.6.0...@pie-element/multiple-choice-controller@5.7.0) (2025-02-07)
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.7.0",
4
+ "version": "5.7.1",
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.9.0",
11
+ "@pie-lib/pie-toolbox": "2.9.1",
12
12
  "debug": "^3.1.0",
13
13
  "lodash": "^4.17.15"
14
14
  }
package/lib/index.js CHANGED
@@ -92,6 +92,8 @@ var MultipleChoice = /*#__PURE__*/function (_HTMLElement) {
92
92
  _this._model = null;
93
93
  _this._session = null;
94
94
  _this.audioComplete = false;
95
+ _this._boundHandleKeyDown = _this.handleKeyDown.bind((0, _assertThisInitialized2["default"])(_this));
96
+ _this._keyboardEventsEnabled = false;
95
97
  _this._rerender = (0, _debounce["default"])(function () {
96
98
  if (_this._model && _this._session) {
97
99
  var element = /*#__PURE__*/_react["default"].createElement(_main["default"], {
@@ -113,7 +115,7 @@ var MultipleChoice = /*#__PURE__*/function (_HTMLElement) {
113
115
  (0, _mathRendering.renderMath)((0, _assertThisInitialized2["default"])(_this));
114
116
  });
115
117
 
116
- if (_this._model.keyboardEventsEnabled === true) {
118
+ if (_this._model.keyboardEventsEnabled === true && !_this._keyboardEventsEnabled) {
117
119
  _this.enableKeyboardEvents();
118
120
  }
119
121
  } else {
@@ -289,12 +291,18 @@ var MultipleChoice = /*#__PURE__*/function (_HTMLElement) {
289
291
  }, {
290
292
  key: "enableKeyboardEvents",
291
293
  value: function enableKeyboardEvents() {
292
- window.addEventListener('keydown', this.handleKeyDown.bind(this));
294
+ if (!this._keyboardEventsEnabled) {
295
+ window.addEventListener('keydown', this._boundHandleKeyDown);
296
+ this._keyboardEventsEnabled = true;
297
+ }
293
298
  }
294
299
  }, {
295
300
  key: "disconnectedCallback",
296
301
  value: function disconnectedCallback() {
297
- window.removeEventListener('keydown', this.handleKeyDown.bind(this));
302
+ if (this._keyboardEventsEnabled) {
303
+ window.removeEventListener('keydown', this._boundHandleKeyDown);
304
+ this._keyboardEventsEnabled = false;
305
+ }
298
306
  }
299
307
  /**
300
308
  * Handles global keyboard events for selecting or toggling multiple-choice answers.
@@ -325,7 +333,8 @@ var MultipleChoice = /*#__PURE__*/function (_HTMLElement) {
325
333
  var choiceId = this._model.choices[choiceIndex].value;
326
334
  var newValue = {
327
335
  value: choiceId,
328
- selected: !currentValue.includes(choiceId)
336
+ selected: !currentValue.includes(choiceId),
337
+ selector: 'Keyboard'
329
338
  };
330
339
 
331
340
  this._onChange(newValue);
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","_rerender","element","React","createElement","Main","onChoiceChanged","_onChange","bind","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","img","src","alt","appendChild","observer","MutationObserver","mutationsList","forEach","mutation","type","audio","querySelector","isInsidePrompt","closest","_createAudioInfoToast","container","enableAudio","play","audioStartTime","Date","getTime","removeChild","removeEventListener","setTimeout","paused","addEventListener","handlePlaying","handleEnded","audioEndTime","disconnect","observe","childList","subtree","window","handleKeyDown","event","keyToIndex","key","numOffset","letterOffset","test","charCodeAt","choiceIndex","choices","currentValue","choiceId","newValue","selected","includes","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;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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AAC1E;AACD;;AAED,UAAM6F,YAAY,GAAG,KAAK1F,QAAL,CAAcR,KAAd,IAAuB,EAA5C;AACA,UAAMmG,QAAQ,GAAG,KAAK5F,MAAL,CAAY0F,OAAZ,CAAoBD,WAApB,EAAiChG,KAAlD;AAEA,UAAMoG,QAAQ,GAAG;AACfpG,QAAAA,KAAK,EAAEmG,QADQ;AAEfE,QAAAA,QAAQ,EAAE,CAACH,YAAY,CAACI,QAAb,CAAsBH,QAAtB;AAFI,OAAjB;;AAKA,WAAKpF,SAAL,CAAeqF,QAAf;AACD;;;kDA3OyCG,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 { 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\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) {\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 });\n\n const img = document.createElement('img');\n img.src = 'https://student.assessment.renaissance.com/ce/quizenginecap/assets/img/playAppsSel.gif';\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 if (this._model && !this._model.autoplayAudioEnabled) {\n return;\n }\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 (audio && !isInsidePrompt) return;\n if (!audio) return;\n\n const info = this._createAudioInfoToast();\n const container = this.querySelector('[class*=\"main\"]');\n const enableAudio = () => {\n if (this.querySelector('#play-audio-info')) {\n audio.play();\n updateSessionMetadata(this._session, { audioStartTime: new Date().getTime() });\n container.removeChild(info);\n\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 const info = this.querySelector('#play-audio-info');\n\n if (info) {\n this.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 observer.disconnect();\n }\n });\n });\n\n observer.observe(this, { childList: true, subtree: true });\n }\n\n enableKeyboardEvents() {\n window.addEventListener('keydown', this.handleKeyDown.bind(this));\n }\n\n disconnectedCallback() {\n window.removeEventListener('keydown', this.handleKeyDown.bind(this));\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 >= 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 };\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","_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","img","src","alt","appendChild","observer","MutationObserver","mutationsList","forEach","mutation","type","audio","querySelector","isInsidePrompt","closest","_createAudioInfoToast","container","enableAudio","play","audioStartTime","Date","getTime","removeChild","removeEventListener","setTimeout","paused","addEventListener","handlePlaying","handleEnded","audioEndTime","disconnect","observe","childList","subtree","window","event","keyToIndex","key","numOffset","letterOffset","test","charCodeAt","choiceIndex","choices","currentValue","choiceId","newValue","selected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AAI,GAAP,IAAcA,GAAG,IAAI,GAArB,GAA2BA,GAAG,GAAG,GAAjC,GAAuCA,GAAG,KAAK,GAAR,GAAc,CAAd,GAAkB,CAAC,CAA5E;AACA,YAAME,YAAY,GAAG,aAAaC,IAAb,CAAkBH,GAAlB,IAAyBA,GAAG,CAAC5D,WAAJ,GAAkBgE,UAAlB,CAA6B,CAA7B,IAAkC,IAAIA,UAAJ,CAAe,CAAf,CAA3D,GAA+E,CAAC,CAArG;AACA,eAAOH,SAAS,IAAI,CAAb,GAAiBA,SAAjB,GAA6BC,YAApC;AACD,OAJD;;AAMA,UAAMG,WAAW,GAAGN,UAAU,CAACD,KAAK,CAACE,GAAP,CAA9B;;AAEA,UAAIK,WAAW,KAAK9D,SAAhB,IAA6B8D,WAAW,IAAI,KAAK3F,MAAL,CAAY4F,OAAZ,CAAoB9F,MAApE,EAA4E;AAC1E;AACD;;AAED,UAAM+F,YAAY,GAAG,KAAK5F,QAAL,CAAcR,KAAd,IAAuB,EAA5C;AACA,UAAMqG,QAAQ,GAAG,KAAK9F,MAAL,CAAY4F,OAAZ,CAAoBD,WAApB,EAAiClG,KAAlD;AAEA,UAAMsG,QAAQ,GAAG;AACftG,QAAAA,KAAK,EAAEqG,QADQ;AAEfE,QAAAA,QAAQ,EAAE,CAACH,YAAY,CAACI,QAAb,CAAsBH,QAAtB,CAFI;AAGfI,QAAAA,QAAQ,EAAE;AAHK,OAAjB;;AAMA,WAAKtF,SAAL,CAAemF,QAAf;AACD;;;kDApPyCI,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 { 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 });\n\n const img = document.createElement('img');\n img.src = 'https://student.assessment.renaissance.com/ce/quizenginecap/assets/img/playAppsSel.gif';\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 if (this._model && !this._model.autoplayAudioEnabled) {\n return;\n }\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 (audio && !isInsidePrompt) return;\n if (!audio) return;\n\n const info = this._createAudioInfoToast();\n const container = this.querySelector('[class*=\"main\"]');\n const enableAudio = () => {\n if (this.querySelector('#play-audio-info')) {\n audio.play();\n updateSessionMetadata(this._session, { audioStartTime: new Date().getTime() });\n container.removeChild(info);\n\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 const info = this.querySelector('#play-audio-info');\n\n if (info) {\n this.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 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\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 >= 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"}
@@ -110,10 +110,7 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
110
110
  var _this$props = _this.props,
111
111
  maxSelections = _this$props.maxSelections,
112
112
  onChoiceChanged = _this$props.onChoiceChanged,
113
- session = _this$props.session; // get input method used for selection
114
-
115
- var detail = event.nativeEvent.detail;
116
- var selector = detail ? 'Mouse' : 'Keyboard';
113
+ session = _this$props.session;
117
114
 
118
115
  if (session.value && session.value.length >= maxSelections) {
119
116
  // show/hide max selections error when user select/deselect an answer
@@ -130,7 +127,7 @@ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
130
127
  onChoiceChanged({
131
128
  value: value,
132
129
  selected: checked,
133
- selector: selector
130
+ selector: 'Mouse'
134
131
  });
135
132
  });
136
133
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onToggle", function () {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/multiple-choice.jsx"],"names":["translator","Translator","styles","theme","main","color","text","backgroundColor","background","partLabel","display","fontSize","margin","fontWeight","paddingBottom","spacing","unit","teacherInstructions","marginBottom","horizontalLayout","flexDirection","flexWrap","gridLayout","fieldset","border","padding","minWidth","srOnly","position","left","top","width","height","overflow","errorText","typography","palette","error","paddingTop","MultipleChoice","props","event","target","value","checked","maxSelections","onChoiceChanged","session","detail","nativeEvent","selector","length","setState","maxSelectionsErrorState","selected","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","isEvaluateMode","showCorrectAnswerToggle","columnsStyle","gridTemplateColumns","selections","addAutoplayAudio","test","navigator","userAgent","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","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;AAHH,KADmB;AAQzBC,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,EAAEX,KAAK,CAACY,OAAN,CAAcC,IAAd,GAAqB;AAL3B,KARc;AAezBC,IAAAA,mBAAmB,EAAE;AACnBC,MAAAA,YAAY,EAAEf,KAAK,CAACY,OAAN,CAAcC,IAAd,GAAqB;AADhB,KAfI;AAkBzBG,IAAAA,gBAAgB,EAAE;AAChBT,MAAAA,OAAO,EAAE,MADO;AAEhBU,MAAAA,aAAa,EAAE,KAFC;AAGhBC,MAAAA,QAAQ,EAAE;AAHM,KAlBO;AAuBzBC,IAAAA,UAAU,EAAE;AACVZ,MAAAA,OAAO,EAAE;AADC,KAvBa;AA0BzBa,IAAAA,QAAQ,EAAE;AACRC,MAAAA,MAAM,EAAE,KADA;AAERC,MAAAA,OAAO,EAAE,cAFD;AAGRb,MAAAA,MAAM,EAAE,KAHA;AAIRc,MAAAA,QAAQ,EAAE;AAJF,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K,IAjBZ;AAkBjBpC,EAAAA,kBAAkB,EAAE+B,sBAAUK,IAlBb;AAmBjBnC,EAAAA,QAAQ,EAAE8B,sBAAUC,MAnBH;AAoBjBT,EAAAA,6BAA6B,EAAEQ,sBAAUC,MApBxB;AAqBjB3D,EAAAA,mBAAmB,EAAE0D,sBAAUM,IArBd;AAsBjBnC,EAAAA,sBAAsB,EAAE6B,sBAAUK,IAtBjB;AAuBjBjC,EAAAA,aAAa,EAAE4B,sBAAUQ,MAvBR;AAwBjB/E,EAAAA,aAAa,EAAEuE,sBAAUQ,MAxBR;AAyBjBnC,EAAAA,oBAAoB,EAAE2B,sBAAUK;AAzBf,C;AA4SrBlF,cAAc,CAACsF,YAAf,GAA8B;AAC5B9E,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 },\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 };\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 // get input method used for selection\n const { detail } = event.nativeEvent;\n let selector = detail ? 'Mouse' : 'Keyboard';\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 });\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 } = 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 // Safari, Firefox, and Edge do not support autoplay audio smoothly in our use case\n const addAutoplayAudio = autoplayAudioEnabled && !(/Safari|Firefox|Edg/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent));\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 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={addAutoplayAudio}\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","partLabel","display","fontSize","margin","fontWeight","paddingBottom","spacing","unit","teacherInstructions","marginBottom","horizontalLayout","flexDirection","flexWrap","gridLayout","fieldset","border","padding","minWidth","srOnly","position","left","top","width","height","overflow","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","isEvaluateMode","showCorrectAnswerToggle","columnsStyle","gridTemplateColumns","selections","addAutoplayAudio","test","navigator","userAgent","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","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;AAHH,KADmB;AAQzBC,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,EAAEX,KAAK,CAACY,OAAN,CAAcC,IAAd,GAAqB;AAL3B,KARc;AAezBC,IAAAA,mBAAmB,EAAE;AACnBC,MAA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AAajB3C,EAAAA,OAAO,EAAEsC,sBAAUI,MAAV,CAAiBG,UAbT;AAcjBpD,EAAAA,eAAe,EAAE6C,sBAAUG,KAdV;AAejBb,EAAAA,aAAa,EAAEU,sBAAUE,KAAV,CAAgB,CAAC,UAAD,EAAa,MAAb,EAAqB,YAArB,CAAhB,CAfE;AAgBjBpC,EAAAA,WAAW,EAAEkC,sBAAUC,MAhBN;AAiBjBpD,EAAAA,iBAAiB,EAAEmD,sBAAUK,IAjBZ;AAkBjBpC,EAAAA,kBAAkB,EAAE+B,sBAAUK,IAlBb;AAmBjBnC,EAAAA,QAAQ,EAAE8B,sBAAUC,MAnBH;AAoBjBT,EAAAA,6BAA6B,EAAEQ,sBAAUC,MApBxB;AAqBjB3D,EAAAA,mBAAmB,EAAE0D,sBAAUM,IArBd;AAsBjBnC,EAAAA,sBAAsB,EAAE6B,sBAAUK,IAtBjB;AAuBjBjC,EAAAA,aAAa,EAAE4B,sBAAUQ,MAvBR;AAwBjB7E,EAAAA,aAAa,EAAEqE,sBAAUQ,MAxBR;AAyBjBnC,EAAAA,oBAAoB,EAAE2B,sBAAUK;AAzBf,C;AAwSrBhF,cAAc,CAACoF,YAAf,GAA8B;AAC5B5E,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 },\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 };\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 } = 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 // Safari, Firefox, and Edge do not support autoplay audio smoothly in our use case\n const addAutoplayAudio = autoplayAudioEnabled && !(/Safari|Firefox|Edg/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent));\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 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={addAutoplayAudio}\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,5 +1,5 @@
1
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.3.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@5.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@5.10.0/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
5
5
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
package/module/element.js CHANGED
@@ -1,5 +1,5 @@
1
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.3.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@5.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@5.10.0/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
5
5
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -12682,8 +12682,6 @@ class MultipleChoice$1 extends React$2.Component {
12682
12682
  this.handleChange = event => {
12683
12683
  const {value, checked} = event.target;
12684
12684
  const {maxSelections, onChoiceChanged, session} = this.props;
12685
- const {detail} = event.nativeEvent;
12686
- let selector = detail ? 'Mouse' : 'Keyboard';
12687
12685
  if (session.value && session.value.length >= maxSelections) {
12688
12686
  this.setState({
12689
12687
  maxSelectionsErrorState: checked
@@ -12695,7 +12693,7 @@ class MultipleChoice$1 extends React$2.Component {
12695
12693
  onChoiceChanged({
12696
12694
  value,
12697
12695
  selected: checked,
12698
- selector
12696
+ selector: 'Mouse'
12699
12697
  });
12700
12698
  };
12701
12699
  }
@@ -12779,14 +12777,14 @@ class MultipleChoice$1 extends React$2.Component {
12779
12777
  __self: this,
12780
12778
  __source: {
12781
12779
  fileName: _jsxFileName$1,
12782
- lineNumber: 214
12780
+ lineNumber: 210
12783
12781
  }
12784
12782
  }, "Multiple Choice Question") : React$2.createElement('h2', {
12785
12783
  className: classes.srOnly,
12786
12784
  __self: this,
12787
12785
  __source: {
12788
12786
  fileName: _jsxFileName$1,
12789
- lineNumber: 216
12787
+ lineNumber: 212
12790
12788
  }
12791
12789
  }, "Multiple Select Question");
12792
12790
  }
@@ -12808,7 +12806,7 @@ class MultipleChoice$1 extends React$2.Component {
12808
12806
  __self: this,
12809
12807
  __source: {
12810
12808
  fileName: _jsxFileName$1,
12811
- lineNumber: 251
12809
+ lineNumber: 247
12812
12810
  }
12813
12811
  });
12814
12812
  const getMultipleChoiceMinSelectionErrorMessage = () => {
@@ -12835,21 +12833,21 @@ class MultipleChoice$1 extends React$2.Component {
12835
12833
  __self: this,
12836
12834
  __source: {
12837
12835
  fileName: _jsxFileName$1,
12838
- lineNumber: 274
12836
+ lineNumber: 270
12839
12837
  }
12840
12838
  }, partLabel && React$2.createElement('h3', {
12841
12839
  className: classes.partLabel,
12842
12840
  __self: this,
12843
12841
  __source: {
12844
12842
  fileName: _jsxFileName$1,
12845
- lineNumber: 275
12843
+ lineNumber: 271
12846
12844
  }
12847
12845
  }, partLabel), this.renderHeading(), teacherInstructions && React$2.createElement('div', {
12848
12846
  className: classes.teacherInstructions,
12849
12847
  __self: this,
12850
12848
  __source: {
12851
12849
  fileName: _jsxFileName$1,
12852
- lineNumber: 280
12850
+ lineNumber: 276
12853
12851
  }
12854
12852
  }, !animationsDisabled ? React$2.createElement(Collapsible, {
12855
12853
  labels: {
@@ -12859,14 +12857,14 @@ class MultipleChoice$1 extends React$2.Component {
12859
12857
  __self: this,
12860
12858
  __source: {
12861
12859
  fileName: _jsxFileName$1,
12862
- lineNumber: 282
12860
+ lineNumber: 278
12863
12861
  }
12864
12862
  }, teacherInstructionsDiv) : teacherInstructionsDiv), React$2.createElement('fieldset', {
12865
12863
  className: classes.fieldset,
12866
12864
  __self: this,
12867
12865
  __source: {
12868
12866
  fileName: _jsxFileName$1,
12869
- lineNumber: 296
12867
+ lineNumber: 292
12870
12868
  }
12871
12869
  }, React$2.createElement(PreviewPrompt, {
12872
12870
  className: "prompt",
@@ -12877,7 +12875,7 @@ class MultipleChoice$1 extends React$2.Component {
12877
12875
  __self: this,
12878
12876
  __source: {
12879
12877
  fileName: _jsxFileName$1,
12880
- lineNumber: 297
12878
+ lineNumber: 293
12881
12879
  }
12882
12880
  }), !alwaysShowCorrect && React$2.createElement(CorrectAnswerToggle, {
12883
12881
  show: showCorrectAnswerToggle,
@@ -12887,7 +12885,7 @@ class MultipleChoice$1 extends React$2.Component {
12887
12885
  __self: this,
12888
12886
  __source: {
12889
12887
  fileName: _jsxFileName$1,
12890
- lineNumber: 306
12888
+ lineNumber: 302
12891
12889
  }
12892
12890
  }), React$2.createElement('div', {
12893
12891
  className: classNames({
@@ -12898,7 +12896,7 @@ class MultipleChoice$1 extends React$2.Component {
12898
12896
  __self: this,
12899
12897
  __source: {
12900
12898
  fileName: _jsxFileName$1,
12901
- lineNumber: 314
12899
+ lineNumber: 310
12902
12900
  }
12903
12901
  }, choices.map((choice, index) => React$2.createElement(StyledChoice, {
12904
12902
  choicesLayout: this.props.choicesLayout,
@@ -12921,21 +12919,21 @@ class MultipleChoice$1 extends React$2.Component {
12921
12919
  __self: this,
12922
12920
  __source: {
12923
12921
  fileName: _jsxFileName$1,
12924
- lineNumber: 322
12922
+ lineNumber: 318
12925
12923
  }
12926
12924
  })))), choiceMode === 'checkbox' && selections < minSelections && React$2.createElement('div', {
12927
12925
  className: classes.errorText,
12928
12926
  __self: this,
12929
12927
  __source: {
12930
12928
  fileName: _jsxFileName$1,
12931
- lineNumber: 346
12929
+ lineNumber: 342
12932
12930
  }
12933
12931
  }, getMultipleChoiceMinSelectionErrorMessage()), choiceMode === 'checkbox' && maxSelectionsErrorState && React$2.createElement('div', {
12934
12932
  className: classes.errorText,
12935
12933
  __self: this,
12936
12934
  __source: {
12937
12935
  fileName: _jsxFileName$1,
12938
- lineNumber: 351
12936
+ lineNumber: 347
12939
12937
  }
12940
12938
  }, translator.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {
12941
12939
  lng: language,
@@ -13122,6 +13120,8 @@ class MultipleChoice extends HTMLElement {
13122
13120
  this._model = null;
13123
13121
  this._session = null;
13124
13122
  this.audioComplete = false;
13123
+ this._boundHandleKeyDown = this.handleKeyDown.bind(this);
13124
+ this._keyboardEventsEnabled = false;
13125
13125
  this._rerender = debounce(() => {
13126
13126
  if (this._model && this._session) {
13127
13127
  var element = React.createElement(Root, {
@@ -13137,7 +13137,7 @@ class MultipleChoice extends HTMLElement {
13137
13137
  log('render complete - render math');
13138
13138
  renderMath(this);
13139
13139
  });
13140
- if (this._model.keyboardEventsEnabled === true) {
13140
+ if (this._model.keyboardEventsEnabled === true && !this._keyboardEventsEnabled) {
13141
13141
  this.enableKeyboardEvents();
13142
13142
  }
13143
13143
  } else {
@@ -13264,10 +13264,16 @@ class MultipleChoice extends HTMLElement {
13264
13264
  });
13265
13265
  }
13266
13266
  enableKeyboardEvents() {
13267
- window.addEventListener('keydown', this.handleKeyDown.bind(this));
13267
+ if (!this._keyboardEventsEnabled) {
13268
+ window.addEventListener('keydown', this._boundHandleKeyDown);
13269
+ this._keyboardEventsEnabled = true;
13270
+ }
13268
13271
  }
13269
13272
  disconnectedCallback() {
13270
- window.removeEventListener('keydown', this.handleKeyDown.bind(this));
13273
+ if (this._keyboardEventsEnabled) {
13274
+ window.removeEventListener('keydown', this._boundHandleKeyDown);
13275
+ this._keyboardEventsEnabled = false;
13276
+ }
13271
13277
  }
13272
13278
  handleKeyDown(event) {
13273
13279
  if (!this._model || !this._session) {
@@ -13286,7 +13292,8 @@ class MultipleChoice extends HTMLElement {
13286
13292
  const choiceId = this._model.choices[choiceIndex].value;
13287
13293
  const newValue = {
13288
13294
  value: choiceId,
13289
- selected: !currentValue.includes(choiceId)
13295
+ selected: !currentValue.includes(choiceId),
13296
+ selector: 'Keyboard'
13290
13297
  };
13291
13298
  this._onChange(newValue);
13292
13299
  }
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.11.0</title>
5
+ <title>@pie-element/multiple-choice@9.12.0</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,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/multiple-choice",
3
- "version": "9.11.0",
3
+ "version": "9.12.0",
4
4
  "modules": [
5
5
  {
6
6
  "name": "@pie-lib/pie-toolbox-math-rendering-module",
@@ -8,7 +8,7 @@
8
8
  },
9
9
  {
10
10
  "name": "@pie-lib/pie-toolbox-module",
11
- "version": "5.9.0"
11
+ "version": "5.10.0"
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.11.0</title>
5
+ <title>@pie-element/multiple-choice@9.12.0</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
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.3.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@5.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@5.10.0/module/index.js";
3
3
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
  function getDefaultExportFromCjs(x) {
5
5
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -12682,8 +12682,6 @@ class MultipleChoice extends React$2.Component {
12682
12682
  this.handleChange = event => {
12683
12683
  const {value, checked} = event.target;
12684
12684
  const {maxSelections, onChoiceChanged, session} = this.props;
12685
- const {detail} = event.nativeEvent;
12686
- let selector = detail ? 'Mouse' : 'Keyboard';
12687
12685
  if (session.value && session.value.length >= maxSelections) {
12688
12686
  this.setState({
12689
12687
  maxSelectionsErrorState: checked
@@ -12695,7 +12693,7 @@ class MultipleChoice extends React$2.Component {
12695
12693
  onChoiceChanged({
12696
12694
  value,
12697
12695
  selected: checked,
12698
- selector
12696
+ selector: 'Mouse'
12699
12697
  });
12700
12698
  };
12701
12699
  }
@@ -12779,14 +12777,14 @@ class MultipleChoice extends React$2.Component {
12779
12777
  __self: this,
12780
12778
  __source: {
12781
12779
  fileName: _jsxFileName$1,
12782
- lineNumber: 214
12780
+ lineNumber: 210
12783
12781
  }
12784
12782
  }, "Multiple Choice Question") : React$2.createElement('h2', {
12785
12783
  className: classes.srOnly,
12786
12784
  __self: this,
12787
12785
  __source: {
12788
12786
  fileName: _jsxFileName$1,
12789
- lineNumber: 216
12787
+ lineNumber: 212
12790
12788
  }
12791
12789
  }, "Multiple Select Question");
12792
12790
  }
@@ -12808,7 +12806,7 @@ class MultipleChoice extends React$2.Component {
12808
12806
  __self: this,
12809
12807
  __source: {
12810
12808
  fileName: _jsxFileName$1,
12811
- lineNumber: 251
12809
+ lineNumber: 247
12812
12810
  }
12813
12811
  });
12814
12812
  const getMultipleChoiceMinSelectionErrorMessage = () => {
@@ -12835,21 +12833,21 @@ class MultipleChoice extends React$2.Component {
12835
12833
  __self: this,
12836
12834
  __source: {
12837
12835
  fileName: _jsxFileName$1,
12838
- lineNumber: 274
12836
+ lineNumber: 270
12839
12837
  }
12840
12838
  }, partLabel && React$2.createElement('h3', {
12841
12839
  className: classes.partLabel,
12842
12840
  __self: this,
12843
12841
  __source: {
12844
12842
  fileName: _jsxFileName$1,
12845
- lineNumber: 275
12843
+ lineNumber: 271
12846
12844
  }
12847
12845
  }, partLabel), this.renderHeading(), teacherInstructions && React$2.createElement('div', {
12848
12846
  className: classes.teacherInstructions,
12849
12847
  __self: this,
12850
12848
  __source: {
12851
12849
  fileName: _jsxFileName$1,
12852
- lineNumber: 280
12850
+ lineNumber: 276
12853
12851
  }
12854
12852
  }, !animationsDisabled ? React$2.createElement(Collapsible, {
12855
12853
  labels: {
@@ -12859,14 +12857,14 @@ class MultipleChoice extends React$2.Component {
12859
12857
  __self: this,
12860
12858
  __source: {
12861
12859
  fileName: _jsxFileName$1,
12862
- lineNumber: 282
12860
+ lineNumber: 278
12863
12861
  }
12864
12862
  }, teacherInstructionsDiv) : teacherInstructionsDiv), React$2.createElement('fieldset', {
12865
12863
  className: classes.fieldset,
12866
12864
  __self: this,
12867
12865
  __source: {
12868
12866
  fileName: _jsxFileName$1,
12869
- lineNumber: 296
12867
+ lineNumber: 292
12870
12868
  }
12871
12869
  }, React$2.createElement(PreviewPrompt, {
12872
12870
  className: "prompt",
@@ -12877,7 +12875,7 @@ class MultipleChoice extends React$2.Component {
12877
12875
  __self: this,
12878
12876
  __source: {
12879
12877
  fileName: _jsxFileName$1,
12880
- lineNumber: 297
12878
+ lineNumber: 293
12881
12879
  }
12882
12880
  }), !alwaysShowCorrect && React$2.createElement(CorrectAnswerToggle, {
12883
12881
  show: showCorrectAnswerToggle,
@@ -12887,7 +12885,7 @@ class MultipleChoice extends React$2.Component {
12887
12885
  __self: this,
12888
12886
  __source: {
12889
12887
  fileName: _jsxFileName$1,
12890
- lineNumber: 306
12888
+ lineNumber: 302
12891
12889
  }
12892
12890
  }), React$2.createElement('div', {
12893
12891
  className: classNames({
@@ -12898,7 +12896,7 @@ class MultipleChoice extends React$2.Component {
12898
12896
  __self: this,
12899
12897
  __source: {
12900
12898
  fileName: _jsxFileName$1,
12901
- lineNumber: 314
12899
+ lineNumber: 310
12902
12900
  }
12903
12901
  }, choices.map((choice, index) => React$2.createElement(StyledChoice, {
12904
12902
  choicesLayout: this.props.choicesLayout,
@@ -12921,21 +12919,21 @@ class MultipleChoice extends React$2.Component {
12921
12919
  __self: this,
12922
12920
  __source: {
12923
12921
  fileName: _jsxFileName$1,
12924
- lineNumber: 322
12922
+ lineNumber: 318
12925
12923
  }
12926
12924
  })))), choiceMode === 'checkbox' && selections < minSelections && React$2.createElement('div', {
12927
12925
  className: classes.errorText,
12928
12926
  __self: this,
12929
12927
  __source: {
12930
12928
  fileName: _jsxFileName$1,
12931
- lineNumber: 346
12929
+ lineNumber: 342
12932
12930
  }
12933
12931
  }, getMultipleChoiceMinSelectionErrorMessage()), choiceMode === 'checkbox' && maxSelectionsErrorState && React$2.createElement('div', {
12934
12932
  className: classes.errorText,
12935
12933
  __self: this,
12936
12934
  __source: {
12937
12935
  fileName: _jsxFileName$1,
12938
- lineNumber: 351
12936
+ lineNumber: 347
12939
12937
  }
12940
12938
  }, translator.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {
12941
12939
  lng: language,
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.11.1-next.6+5c374061c",
4
+ "version": "9.12.1-next.0+c040d8d08",
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.9.0",
11
+ "@pie-lib/pie-toolbox": "2.9.1",
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": "5c374061c150a5937762cee20d5dd656778e8b2e",
22
+ "gitHead": "c040d8d08c48faa9c552f129d1d369f0d6bf2590",
23
23
  "scripts": {
24
24
  "postpublish": "../../scripts/postpublish"
25
25
  },