@pie-element/image-cloze-association 10.2.0-beta.0 → 10.2.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,20 +3,78 @@
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
- # [10.2.0-beta.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@10.1.0...@pie-element/image-cloze-association@10.2.0-beta.0) (2026-08-07)
6
+ # [10.2.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@10.1.11...@pie-element/image-cloze-association@10.2.0) (2026-08-21)
7
+
8
+ ### Bug Fixes
9
+
10
+ - move [@pie-lib](https://github.com/pie-lib) deps back to latest, off next prereleases PIE-927 ([a53e012](https://github.com/pie-framework/pie-elements/commit/a53e0127eb4ac95ece54e1e2bd669ae4974f4251))
11
+ - read the prompt container by class, not by the id pie-lib removed PIE-927 ([aaaf6c2](https://github.com/pie-framework/pie-elements/commit/aaaf6c2f189de3b39f9de85969aeb2e50376c548))
12
+
13
+ ### Features
14
+
15
+ - bump libs PIE-856, PIE-681, PIE-927 ([cb26d7a](https://github.com/pie-framework/pie-elements/commit/cb26d7afa6c99522533c321d5ff8ce3148a66e9e))
16
+
17
+ ## [10.1.11](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@10.1.10...@pie-element/image-cloze-association@10.1.11) (2026-08-19)
18
+
19
+ ### Bug Fixes
20
+
21
+ - bump libs and shared modules PIE-681, PIE-708 ([08af8b5](https://github.com/pie-framework/pie-elements/commit/08af8b5802aecc8ee5454a1b6d60277d7ec94204))
22
+
23
+ ## [10.1.10](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@10.1.8...@pie-element/image-cloze-association@10.1.10) (2026-08-13)
24
+
25
+ **Note:** Version bump only for package @pie-element/image-cloze-association
26
+
27
+ ## [10.1.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@10.1.7...@pie-element/image-cloze-association@10.1.9) (2026-08-11)
28
+
29
+ **Note:** Version bump only for package @pie-element/image-cloze-association
30
+
31
+ ## [10.1.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@10.1.7...@pie-element/image-cloze-association@10.1.8) (2026-07-31)
32
+
33
+ **Note:** Version bump only for package @pie-element/image-cloze-association
34
+
35
+ ## [10.1.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@10.1.6...@pie-element/image-cloze-association@10.1.7) (2026-07-08)
7
36
 
8
37
  ### Bug Fixes
9
38
 
10
39
  - bump libs & shared modules PIE-706, PIE-702, PIE-679, PIE-698 ([5b1a8c4](https://github.com/pie-framework/pie-elements/commit/5b1a8c4c3eba2126fc43d78fd0187e7cd11d5424))
11
- - bump shared modules and libs PIE-600, PIE-602 ([ce99f6a](https://github.com/pie-framework/pie-elements/commit/ce99f6af50cb855b666a6df9340f9f5445fde4c4))
12
- - bump shared modules and libs PIE-661 PIE-664 PIE-683 PIE-666 PIE-656 PIE-657 PIE-658 PIE-659 PIE-670 ([ebd6be4](https://github.com/pie-framework/pie-elements/commit/ebd6be4fd48fca41ad4c4908f606b25334731aed))
13
- - bump shared modules and libs PIE-674, PIE-662, PIE-705, PIE-674, PIE-963 ([78a3f64](https://github.com/pie-framework/pie-elements/commit/78a3f64652c9581c61bd4159f3210fc1e32d8bcf))
40
+
41
+ ## [10.1.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@10.1.5...@pie-element/image-cloze-association@10.1.6) (2026-07-02)
42
+
43
+ ### Bug Fixes
44
+
14
45
  - bump shared modules and libs PIE-695, PIE-697, PIE-699, PIE-680, PIE-714, PIE-665, PIE-656 ([4b76ae7](https://github.com/pie-framework/pie-elements/commit/4b76ae75d1c5ea6d55f7c6fb53f299dfcbda2b1f))
46
+ - sync libs versions ([48b5be9](https://github.com/pie-framework/pie-elements/commit/48b5be9559eb5b5235ca05f51c5f0161032a7041))
47
+
48
+ ## [10.1.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@10.1.4...@pie-element/image-cloze-association@10.1.5) (2026-06-22)
49
+
50
+ ### Bug Fixes
51
+
52
+ - bump shared modules and libs PIE-674, PIE-662, PIE-705, PIE-674, PIE-963 ([78a3f64](https://github.com/pie-framework/pie-elements/commit/78a3f64652c9581c61bd4159f3210fc1e32d8bcf))
53
+ - handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
54
+
55
+ ## [10.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@10.1.3...@pie-element/image-cloze-association@10.1.4) (2026-06-17)
56
+
57
+ ### Bug Fixes
58
+
59
+ - bump shared modules and libs PIE-661 PIE-664 PIE-683 PIE-666 PIE-656 PIE-657 PIE-658 PIE-659 PIE-670 ([ebd6be4](https://github.com/pie-framework/pie-elements/commit/ebd6be4fd48fca41ad4c4908f606b25334731aed))
60
+
61
+ ## [10.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@10.1.2...@pie-element/image-cloze-association@10.1.3) (2026-06-12)
62
+
63
+ ### Bug Fixes
64
+
15
65
  - bump shared modules and libsPIE-603, PIE-604, PIE-663, PIE-662, PIE-678 ([e61c7a7](https://github.com/pie-framework/pie-elements/commit/e61c7a7d23744586337dfbb17a18ebfc656c202f))
66
+
67
+ ## [10.1.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@10.1.1...@pie-element/image-cloze-association@10.1.2) (2026-06-04)
68
+
69
+ ### Bug Fixes
70
+
71
+ - bump shared modules and libs PIE-600, PIE-602 ([ce99f6a](https://github.com/pie-framework/pie-elements/commit/ce99f6af50cb855b666a6df9340f9f5445fde4c4))
16
72
  - dedupe @tiptap/\* and react-transition-group PIE-624 ([87f07f3](https://github.com/pie-framework/pie-elements/commit/87f07f31c38b0fe876f87229c48adc566c369bb9))
17
- - handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
18
73
  - **image-cloze-association:** preserve response areas position PIE-430 ([ae083d6](https://github.com/pie-framework/pie-elements/commit/ae083d660a56b050939deaab488ecf281ad14437))
19
- - sync libs versions ([48b5be9](https://github.com/pie-framework/pie-elements/commit/48b5be9559eb5b5235ca05f51c5f0161032a7041))
74
+
75
+ ## [10.1.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@10.1.0...@pie-element/image-cloze-association@10.1.1) (2026-05-21)
76
+
77
+ **Note:** Version bump only for package @pie-element/image-cloze-association
20
78
 
21
79
  # [10.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association@10.1.0-next.1...@pie-element/image-cloze-association@10.1.0) (2026-05-21)
22
80
 
@@ -3,19 +3,72 @@
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.2.0-beta.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@9.1.0...@pie-element/image-cloze-association-configure@9.2.0-beta.0) (2026-08-07)
6
+ # [9.2.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@9.1.11...@pie-element/image-cloze-association-configure@9.2.0) (2026-08-21)
7
+
8
+ ### Features
9
+
10
+ - bump libs PIE-856, PIE-681, PIE-927 ([cb26d7a](https://github.com/pie-framework/pie-elements/commit/cb26d7afa6c99522533c321d5ff8ce3148a66e9e))
11
+
12
+ ## [9.1.11](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@9.1.10...@pie-element/image-cloze-association-configure@9.1.11) (2026-08-19)
13
+
14
+ ### Bug Fixes
15
+
16
+ - bump libs and shared modules PIE-681, PIE-708 ([08af8b5](https://github.com/pie-framework/pie-elements/commit/08af8b5802aecc8ee5454a1b6d60277d7ec94204))
17
+
18
+ ## [9.1.10](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@9.1.8...@pie-element/image-cloze-association-configure@9.1.10) (2026-08-13)
19
+
20
+ **Note:** Version bump only for package @pie-element/image-cloze-association-configure
21
+
22
+ ## [9.1.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@9.1.7...@pie-element/image-cloze-association-configure@9.1.9) (2026-08-11)
23
+
24
+ **Note:** Version bump only for package @pie-element/image-cloze-association-configure
25
+
26
+ ## [9.1.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@9.1.7...@pie-element/image-cloze-association-configure@9.1.8) (2026-07-31)
27
+
28
+ **Note:** Version bump only for package @pie-element/image-cloze-association-configure
29
+
30
+ ## [9.1.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@9.1.6...@pie-element/image-cloze-association-configure@9.1.7) (2026-07-08)
7
31
 
8
32
  ### Bug Fixes
9
33
 
10
34
  - bump libs & shared modules PIE-706, PIE-702, PIE-679, PIE-698 ([5b1a8c4](https://github.com/pie-framework/pie-elements/commit/5b1a8c4c3eba2126fc43d78fd0187e7cd11d5424))
11
- - bump shared modules and libs PIE-600, PIE-602 ([ce99f6a](https://github.com/pie-framework/pie-elements/commit/ce99f6af50cb855b666a6df9340f9f5445fde4c4))
12
- - bump shared modules and libs PIE-661 PIE-664 PIE-683 PIE-666 PIE-656 PIE-657 PIE-658 PIE-659 PIE-670 ([ebd6be4](https://github.com/pie-framework/pie-elements/commit/ebd6be4fd48fca41ad4c4908f606b25334731aed))
13
- - bump shared modules and libs PIE-674, PIE-662, PIE-705, PIE-674, PIE-963 ([78a3f64](https://github.com/pie-framework/pie-elements/commit/78a3f64652c9581c61bd4159f3210fc1e32d8bcf))
35
+
36
+ ## [9.1.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@9.1.5...@pie-element/image-cloze-association-configure@9.1.6) (2026-07-02)
37
+
38
+ ### Bug Fixes
39
+
14
40
  - bump shared modules and libs PIE-695, PIE-697, PIE-699, PIE-680, PIE-714, PIE-665, PIE-656 ([4b76ae7](https://github.com/pie-framework/pie-elements/commit/4b76ae75d1c5ea6d55f7c6fb53f299dfcbda2b1f))
15
- - bump shared modules and libsPIE-603, PIE-604, PIE-663, PIE-662, PIE-678 ([e61c7a7](https://github.com/pie-framework/pie-elements/commit/e61c7a7d23744586337dfbb17a18ebfc656c202f))
16
- - handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
17
41
  - sync libs versions ([48b5be9](https://github.com/pie-framework/pie-elements/commit/48b5be9559eb5b5235ca05f51c5f0161032a7041))
18
42
 
43
+ ## [9.1.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@9.1.4...@pie-element/image-cloze-association-configure@9.1.5) (2026-06-22)
44
+
45
+ ### Bug Fixes
46
+
47
+ - bump shared modules and libs PIE-674, PIE-662, PIE-705, PIE-674, PIE-963 ([78a3f64](https://github.com/pie-framework/pie-elements/commit/78a3f64652c9581c61bd4159f3210fc1e32d8bcf))
48
+ - handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
49
+
50
+ ## [9.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@9.1.3...@pie-element/image-cloze-association-configure@9.1.4) (2026-06-17)
51
+
52
+ ### Bug Fixes
53
+
54
+ - bump shared modules and libs PIE-661 PIE-664 PIE-683 PIE-666 PIE-656 PIE-657 PIE-658 PIE-659 PIE-670 ([ebd6be4](https://github.com/pie-framework/pie-elements/commit/ebd6be4fd48fca41ad4c4908f606b25334731aed))
55
+
56
+ ## [9.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@9.1.2...@pie-element/image-cloze-association-configure@9.1.3) (2026-06-12)
57
+
58
+ ### Bug Fixes
59
+
60
+ - bump shared modules and libsPIE-603, PIE-604, PIE-663, PIE-662, PIE-678 ([e61c7a7](https://github.com/pie-framework/pie-elements/commit/e61c7a7d23744586337dfbb17a18ebfc656c202f))
61
+
62
+ ## [9.1.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@9.1.1...@pie-element/image-cloze-association-configure@9.1.2) (2026-06-04)
63
+
64
+ ### Bug Fixes
65
+
66
+ - bump shared modules and libs PIE-600, PIE-602 ([ce99f6a](https://github.com/pie-framework/pie-elements/commit/ce99f6af50cb855b666a6df9340f9f5445fde4c4))
67
+
68
+ ## [9.1.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@9.1.0...@pie-element/image-cloze-association-configure@9.1.1) (2026-05-21)
69
+
70
+ **Note:** Version bump only for package @pie-element/image-cloze-association-configure
71
+
19
72
  # [9.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-configure@9.1.0-next.1...@pie-element/image-cloze-association-configure@9.1.0) (2026-05-21)
20
73
 
21
74
  ### Bug Fixes
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/image-cloze-association-configure",
3
3
  "private": true,
4
- "version": "9.2.0-beta.0",
4
+ "version": "9.2.0",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
@@ -12,8 +12,8 @@
12
12
  "@mui/icons-material": "^7.3.4",
13
13
  "@mui/material": "^7.3.4",
14
14
  "@pie-framework/pie-configure-events": "^1.3.0",
15
- "@pie-lib/config-ui": "13.1.0-beta",
16
- "@pie-lib/editable-html-tip-tap": "2.2.0-beta",
15
+ "@pie-lib/config-ui": "13.0.16",
16
+ "@pie-lib/editable-html-tip-tap": "2.1.14",
17
17
  "debug": "^4.1.1",
18
18
  "prop-types": "^15.8.1",
19
19
  "react": "18.3.1",
@@ -3,12 +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
- # [8.2.0-beta.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-controller@8.1.0...@pie-element/image-cloze-association-controller@8.2.0-beta.0) (2026-08-07)
6
+ ## [8.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-controller@8.1.2...@pie-element/image-cloze-association-controller@8.1.4) (2026-08-13)
7
+
8
+ **Note:** Version bump only for package @pie-element/image-cloze-association-controller
9
+
10
+ ## [8.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-controller@8.1.2...@pie-element/image-cloze-association-controller@8.1.3) (2026-08-11)
11
+
12
+ **Note:** Version bump only for package @pie-element/image-cloze-association-controller
13
+
14
+ ## [8.1.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-controller@8.1.1...@pie-element/image-cloze-association-controller@8.1.2) (2026-07-02)
7
15
 
8
16
  ### Bug Fixes
9
17
 
10
18
  - bump shared modules and libs PIE-695, PIE-697, PIE-699, PIE-680, PIE-714, PIE-665, PIE-656 ([4b76ae7](https://github.com/pie-framework/pie-elements/commit/4b76ae75d1c5ea6d55f7c6fb53f299dfcbda2b1f))
11
19
 
20
+ ## [8.1.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-controller@8.1.0...@pie-element/image-cloze-association-controller@8.1.1) (2026-05-21)
21
+
22
+ **Note:** Version bump only for package @pie-element/image-cloze-association-controller
23
+
12
24
  # [8.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/image-cloze-association-controller@8.1.0-next.1...@pie-element/image-cloze-association-controller@8.1.0) (2026-05-21)
13
25
 
14
26
  ### Bug Fixes
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/image-cloze-association-controller",
3
3
  "private": true,
4
- "version": "8.2.0-beta.0",
4
+ "version": "8.1.4",
5
5
  "description": "",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
package/lib/index.js CHANGED
@@ -37,7 +37,7 @@ class ImageClozeAssociation extends HTMLElement {
37
37
  if (autoplayAudioEnabled && completeAudioEnabled && !this.audioComplete) {
38
38
  if (elementContext) {
39
39
  const audio = elementContext.querySelector('audio');
40
- const isInsidePrompt = audio && audio.closest('#preview-prompt');
40
+ const isInsidePrompt = audio && audio.closest('.preview-prompt');
41
41
 
42
42
  // only require audio completion if audio exists and is inside the prompt
43
43
  if (audio && isInsidePrompt) {
@@ -129,7 +129,7 @@ class ImageClozeAssociation extends HTMLElement {
129
129
  mutationsList.forEach(mutation => {
130
130
  if (mutation.type === 'childList') {
131
131
  const audio = this.querySelector('audio');
132
- const isInsidePrompt = audio && audio.closest('#preview-prompt');
132
+ const isInsidePrompt = audio && audio.closest('.preview-prompt');
133
133
  if (!this._model) return;
134
134
  if (!this._model.autoplayAudioEnabled) return;
135
135
  if (audio && !isInsidePrompt) return;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_mathRendering","_renderUi","_piePlayerEvents","_root","ImageClozeAssociation","HTMLElement","constructor","model","m","_model","dispatchEvent","ModelSetEvent","tagName","toLowerCase","isComplete","_render","autoplayAudioEnabled","completeAudioEnabled","completeResponses","duplicateResponses","hasUnplacedChoices","maxResponsePerZone","responseAreasToBeFilled","elementContext","audioComplete","audio","querySelector","isInsidePrompt","closest","_session","answers","Array","isArray","filledResponseAreas","Map","map","item","containerIndex","values","length","areResponseAreasFilled","allAnswersValue","answer","value","requiredAnswersPlaced","some","response","every","val","includes","session","s","updateAnswer","data","selector","SessionChangedEvent","_createAudioInfoToast","info","document","createElement","id","Object","assign","style","position","top","width","height","display","justifyContent","alignItems","background","zIndex","cursor","img","src","EnableAudioAutoplayImage","alt","appendChild","connectedCallback","observer","MutationObserver","mutationsList","forEach","mutation","type","container","enableAudio","play","removeChild","removeEventListener","setTimeout","paused","addEventListener","handlePlaying","handleEnded","_audio","_handlePlaying","_handleEnded","_enableAudio","disconnect","observe","childList","subtree","disconnectedCallback","unmount","el","React","ImageClozeAssociationComponent","bind","createRoot","render","queueMicrotask","renderMath","exports","default"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { EnableAudioAutoplayImage } from '@pie-lib/render-ui';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\n\nimport ImageClozeAssociationComponent from './root';\n\nexport default class ImageClozeAssociation extends HTMLElement {\n constructor() {\n super();\n this._root = null;\n }\n\n set model(m) {\n this._model = m;\n\n this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this.isComplete(), !!this._model));\n this._render();\n }\n\n isComplete() {\n const {\n autoplayAudioEnabled,\n completeAudioEnabled,\n completeResponses,\n duplicateResponses,\n hasUnplacedChoices,\n maxResponsePerZone,\n responseAreasToBeFilled,\n } = this._model || {};\n const elementContext = this;\n\n // check audio completion if audio settings are enabled and audio actually exists\n if (autoplayAudioEnabled && completeAudioEnabled && !this.audioComplete) {\n if (elementContext) {\n const audio = elementContext.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n // only require audio completion if audio exists and is inside the prompt\n if (audio && isInsidePrompt) {\n return false;\n }\n }\n }\n\n if (!this._session || !this._session.answers) {\n return false;\n }\n\n const { answers } = this._session;\n\n if (!Array.isArray(answers)) {\n return false;\n }\n\n // filter answers by containerIndex and count the ones with content\n const filledResponseAreas = [...new Map(answers.map((item) => [item.containerIndex, item])).values()].length;\n // check if an answer choice was added to at least as many response areas\n // as the number of populated response areas in the correct answer\n const areResponseAreasFilled = filledResponseAreas >= responseAreasToBeFilled;\n\n if (maxResponsePerZone > 1) {\n if (duplicateResponses) {\n // an answer choice can be used multiple times\n return areResponseAreasFilled;\n }\n\n // any correct answer have any unplaced answer choices (by the author)\n if (hasUnplacedChoices) {\n return areResponseAreasFilled;\n }\n\n const allAnswersValue = answers.map((answer) => answer.value);\n\n // check if any correct answer have any unplaced answer choices (by the student)\n const requiredAnswersPlaced = completeResponses.some((response) =>\n response.every((val) => allAnswersValue.includes(val)),\n );\n\n // true - all choices (required for a correct response) were placed into a response area\n return requiredAnswersPlaced;\n }\n\n return areResponseAreasFilled;\n }\n\n set session(s) {\n if (s && !s.answers) {\n s.answers = [];\n }\n\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n updateAnswer(data) {\n this._session.answers = data;\n this._session.selector = 'Mouse';\n\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));\n\n this._render();\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._render();\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 const info = this.querySelector('#play-audio-info');\n\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 this.audioComplete = true;\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));\n\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 disconnectedCallback() {\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 if (this._root) {\n this._root.unmount();\n this._root = null;\n }\n }\n\n _render() {\n if (this._model && this._session) {\n const el = React.createElement(ImageClozeAssociationComponent, {\n model: this._model,\n session: this._session,\n updateAnswer: this.updateAnswer.bind(this),\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(el);\n queueMicrotask(() => {\n renderMath(this);\n });\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,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AC7F,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACsG,OAAO,CAAC,CAAC;MACpB,IAAI,CAACtG,KAAK,GAAG,IAAI;IACnB;EACF;EAEAY,OAAOA,CAAA,EAAG;IACR,IAAI,IAAI,CAACN,MAAM,IAAI,IAAI,CAACoB,QAAQ,EAAE;MAChC,MAAM6E,EAAE,gBAAGC,cAAK,CAAChD,aAAa,CAACiD,aAA8B,EAAE;QAC7DrG,KAAK,EAAE,IAAI,CAACE,MAAM;QAClByC,OAAO,EAAE,IAAI,CAACrB,QAAQ;QACtBuB,YAAY,EAAE,IAAI,CAACA,YAAY,CAACyD,IAAI,CAAC,IAAI;MAC3C,CAAC,CAAC;MAEF,IAAI,CAAC,IAAI,CAAC1G,KAAK,EAAE;QACf,IAAI,CAACA,KAAK,GAAG,IAAA2G,kBAAU,EAAC,IAAI,CAAC;MAC/B;MACA,IAAI,CAAC3G,KAAK,CAAC4G,MAAM,CAACL,EAAE,CAAC;MACrBM,cAAc,CAAC,MAAM;QACnB,IAAAC,yBAAU,EAAC,IAAI,CAAC;MAClB,CAAC,CAAC;IACJ;EACF;AACF;AAACC,OAAA,CAAAC,OAAA,GAAA/G,qBAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_mathRendering","_renderUi","_piePlayerEvents","_root","ImageClozeAssociation","HTMLElement","constructor","model","m","_model","dispatchEvent","ModelSetEvent","tagName","toLowerCase","isComplete","_render","autoplayAudioEnabled","completeAudioEnabled","completeResponses","duplicateResponses","hasUnplacedChoices","maxResponsePerZone","responseAreasToBeFilled","elementContext","audioComplete","audio","querySelector","isInsidePrompt","closest","_session","answers","Array","isArray","filledResponseAreas","Map","map","item","containerIndex","values","length","areResponseAreasFilled","allAnswersValue","answer","value","requiredAnswersPlaced","some","response","every","val","includes","session","s","updateAnswer","data","selector","SessionChangedEvent","_createAudioInfoToast","info","document","createElement","id","Object","assign","style","position","top","width","height","display","justifyContent","alignItems","background","zIndex","cursor","img","src","EnableAudioAutoplayImage","alt","appendChild","connectedCallback","observer","MutationObserver","mutationsList","forEach","mutation","type","container","enableAudio","play","removeChild","removeEventListener","setTimeout","paused","addEventListener","handlePlaying","handleEnded","_audio","_handlePlaying","_handleEnded","_enableAudio","disconnect","observe","childList","subtree","disconnectedCallback","unmount","el","React","ImageClozeAssociationComponent","bind","createRoot","render","queueMicrotask","renderMath","exports","default"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { EnableAudioAutoplayImage } from '@pie-lib/render-ui';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\n\nimport ImageClozeAssociationComponent from './root';\n\nexport default class ImageClozeAssociation extends HTMLElement {\n constructor() {\n super();\n this._root = null;\n }\n\n set model(m) {\n this._model = m;\n\n this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this.isComplete(), !!this._model));\n this._render();\n }\n\n isComplete() {\n const {\n autoplayAudioEnabled,\n completeAudioEnabled,\n completeResponses,\n duplicateResponses,\n hasUnplacedChoices,\n maxResponsePerZone,\n responseAreasToBeFilled,\n } = this._model || {};\n const elementContext = this;\n\n // check audio completion if audio settings are enabled and audio actually exists\n if (autoplayAudioEnabled && completeAudioEnabled && !this.audioComplete) {\n if (elementContext) {\n const audio = elementContext.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('.preview-prompt');\n\n // only require audio completion if audio exists and is inside the prompt\n if (audio && isInsidePrompt) {\n return false;\n }\n }\n }\n\n if (!this._session || !this._session.answers) {\n return false;\n }\n\n const { answers } = this._session;\n\n if (!Array.isArray(answers)) {\n return false;\n }\n\n // filter answers by containerIndex and count the ones with content\n const filledResponseAreas = [...new Map(answers.map((item) => [item.containerIndex, item])).values()].length;\n // check if an answer choice was added to at least as many response areas\n // as the number of populated response areas in the correct answer\n const areResponseAreasFilled = filledResponseAreas >= responseAreasToBeFilled;\n\n if (maxResponsePerZone > 1) {\n if (duplicateResponses) {\n // an answer choice can be used multiple times\n return areResponseAreasFilled;\n }\n\n // any correct answer have any unplaced answer choices (by the author)\n if (hasUnplacedChoices) {\n return areResponseAreasFilled;\n }\n\n const allAnswersValue = answers.map((answer) => answer.value);\n\n // check if any correct answer have any unplaced answer choices (by the student)\n const requiredAnswersPlaced = completeResponses.some((response) =>\n response.every((val) => allAnswersValue.includes(val)),\n );\n\n // true - all choices (required for a correct response) were placed into a response area\n return requiredAnswersPlaced;\n }\n\n return areResponseAreasFilled;\n }\n\n set session(s) {\n if (s && !s.answers) {\n s.answers = [];\n }\n\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n updateAnswer(data) {\n this._session.answers = data;\n this._session.selector = 'Mouse';\n\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));\n\n this._render();\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._render();\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 const info = this.querySelector('#play-audio-info');\n\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 this.audioComplete = true;\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));\n\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 disconnectedCallback() {\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 if (this._root) {\n this._root.unmount();\n this._root = null;\n }\n }\n\n _render() {\n if (this._model && this._session) {\n const el = React.createElement(ImageClozeAssociationComponent, {\n model: this._model,\n session: this._session,\n updateAnswer: this.updateAnswer.bind(this),\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(el);\n queueMicrotask(() => {\n renderMath(this);\n });\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC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AAmB,CAAC,OAAO,EAAE,IAAI,CAACQ,YAAY,CAAC;MAC3D,IAAI,CAACF,MAAM,GAAG,IAAI;IACpB;IAEA,IAAI,IAAI,CAAC7F,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACsG,OAAO,CAAC,CAAC;MACpB,IAAI,CAACtG,KAAK,GAAG,IAAI;IACnB;EACF;EAEAY,OAAOA,CAAA,EAAG;IACR,IAAI,IAAI,CAACN,MAAM,IAAI,IAAI,CAACoB,QAAQ,EAAE;MAChC,MAAM6E,EAAE,gBAAGC,cAAK,CAAChD,aAAa,CAACiD,aAA8B,EAAE;QAC7DrG,KAAK,EAAE,IAAI,CAACE,MAAM;QAClByC,OAAO,EAAE,IAAI,CAACrB,QAAQ;QACtBuB,YAAY,EAAE,IAAI,CAACA,YAAY,CAACyD,IAAI,CAAC,IAAI;MAC3C,CAAC,CAAC;MAEF,IAAI,CAAC,IAAI,CAAC1G,KAAK,EAAE;QACf,IAAI,CAACA,KAAK,GAAG,IAAA2G,kBAAU,EAAC,IAAI,CAAC;MAC/B;MACA,IAAI,CAAC3G,KAAK,CAAC4G,MAAM,CAACL,EAAE,CAAC;MACrBM,cAAc,CAAC,MAAM;QACnB,IAAAC,yBAAU,EAAC,IAAI,CAAC;MAClB,CAAC,CAAC;IACJ;EACF;AACF;AAACC,OAAA,CAAAC,OAAA,GAAA/G,qBAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/image-cloze-association",
3
3
  "repository": "pie-framework/pie-elements",
4
- "version": "10.2.0-beta.0",
4
+ "version": "10.2.0",
5
5
  "description": "",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -13,10 +13,10 @@
13
13
  "@mui/icons-material": "^7.3.4",
14
14
  "@mui/material": "^7.3.4",
15
15
  "@pie-framework/pie-player-events": "^0.1.0",
16
- "@pie-lib/correct-answer-toggle": "4.0.5",
17
- "@pie-lib/drag": "4.0.6",
16
+ "@pie-lib/correct-answer-toggle": "4.0.6",
17
+ "@pie-lib/drag": "4.1.1",
18
18
  "@pie-lib/math-rendering": "5.1.0",
19
- "@pie-lib/render-ui": "6.1.3",
19
+ "@pie-lib/render-ui": "7.0.0",
20
20
  "@pie-lib/translator": "4.0.2",
21
21
  "classnames": "^2.2.6",
22
22
  "humps": "^2.0.1",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "author": "pie framework developers",
29
29
  "license": "ISC",
30
- "gitHead": "fe47b94dd1957aaae2617f391d9e29142fb11b82",
30
+ "gitHead": "e299866c75466c3c3f12469e783c129c800f24fb",
31
31
  "scripts": {
32
32
  "postpublish": "../../scripts/postpublish"
33
33
  },
package/src/index.js CHANGED
@@ -35,7 +35,7 @@ export default class ImageClozeAssociation extends HTMLElement {
35
35
  if (autoplayAudioEnabled && completeAudioEnabled && !this.audioComplete) {
36
36
  if (elementContext) {
37
37
  const audio = elementContext.querySelector('audio');
38
- const isInsidePrompt = audio && audio.closest('#preview-prompt');
38
+ const isInsidePrompt = audio && audio.closest('.preview-prompt');
39
39
 
40
40
  // only require audio completion if audio exists and is inside the prompt
41
41
  if (audio && isInsidePrompt) {
@@ -144,7 +144,7 @@ export default class ImageClozeAssociation extends HTMLElement {
144
144
  mutationsList.forEach((mutation) => {
145
145
  if (mutation.type === 'childList') {
146
146
  const audio = this.querySelector('audio');
147
- const isInsidePrompt = audio && audio.closest('#preview-prompt');
147
+ const isInsidePrompt = audio && audio.closest('.preview-prompt');
148
148
 
149
149
  if (!this._model) return;
150
150
  if (!this._model.autoplayAudioEnabled) return;