@pie-element/image-cloze-association 8.0.1 → 8.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 +20 -0
- package/configure/CHANGELOG.md +19 -0
- package/configure/package.json +3 -3
- package/controller/CHANGELOG.md +20 -0
- package/controller/lib/index.js +7 -1
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +41 -2
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +2 -2
- package/controller/src/index.js +7 -1
- package/controller/src/utils.js +24 -0
- package/lib/index.js +44 -3
- package/lib/index.js.map +1 -1
- package/package.json +8 -25
- package/src/__tests__/index.test.js +17 -2
- package/src/index.js +40 -3
- package/esm/configure.js +0 -7714
- package/esm/configure.js.map +0 -1
- package/esm/controller.js +0 -444
- package/esm/controller.js.map +0 -1
- package/esm/element.js +0 -11333
- package/esm/element.js.map +0 -1
package/src/index.js
CHANGED
|
@@ -15,7 +15,14 @@ export default class ImageClozeAssociation extends HTMLElement {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
isComplete() {
|
|
18
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
autoplayAudioEnabled,
|
|
20
|
+
completeAudioEnabled,
|
|
21
|
+
completeResponses,
|
|
22
|
+
duplicateResponses,
|
|
23
|
+
maxResponsePerZone,
|
|
24
|
+
responseAreasToBeFilled,
|
|
25
|
+
} = this._model || {};
|
|
19
26
|
const elementContext = this;
|
|
20
27
|
|
|
21
28
|
// check audio completion if audio settings are enabled and audio actually exists
|
|
@@ -35,11 +42,41 @@ export default class ImageClozeAssociation extends HTMLElement {
|
|
|
35
42
|
return false;
|
|
36
43
|
}
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
const { answers } = this._session;
|
|
46
|
+
|
|
47
|
+
if (!Array.isArray(answers)) {
|
|
39
48
|
return false;
|
|
40
49
|
}
|
|
41
50
|
|
|
42
|
-
|
|
51
|
+
// filter answers by containerIndex and count the ones with content
|
|
52
|
+
const filledResponseAreas = [...new Map(answers.map((item) => [item.containerIndex, item])).values()].length;
|
|
53
|
+
// check if an answer choice was added to at least as many response areas
|
|
54
|
+
// as the number of populated response areas in the correct answer
|
|
55
|
+
const areResponseAreasFilled = filledResponseAreas >= responseAreasToBeFilled;
|
|
56
|
+
|
|
57
|
+
if (maxResponsePerZone > 1) {
|
|
58
|
+
if (duplicateResponses) {
|
|
59
|
+
// an answer choice can be used multiple times
|
|
60
|
+
return areResponseAreasFilled;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const allAnswersValue = answers.map((answer) => answer.value);
|
|
64
|
+
|
|
65
|
+
// check if any correct answer have any unplaced answer choices
|
|
66
|
+
const requiredAnswersPlaced = completeResponses.some((response) =>
|
|
67
|
+
response.every((val) => allAnswersValue.includes(val)),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
if (!requiredAnswersPlaced) {
|
|
71
|
+
// correct answer have unplaced answer choices
|
|
72
|
+
return areResponseAreasFilled;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// all choices (required for a correct response) were placed into a response area
|
|
76
|
+
return requiredAnswersPlaced;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return areResponseAreasFilled;
|
|
43
80
|
}
|
|
44
81
|
|
|
45
82
|
set session(s) {
|