@pie-element/image-cloze-association 10.1.2-next.2 → 10.1.2
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.json +437 -0
- package/CHANGELOG.md +1997 -0
- package/LICENSE.md +5 -0
- package/README.md +1 -0
- package/configure/CHANGELOG.json +197 -0
- package/configure/CHANGELOG.md +1600 -0
- package/configure/lib/defaults.js +86 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +99 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/root.js +135 -0
- package/configure/lib/root.js.map +1 -0
- package/configure/package.json +23 -0
- package/configure/src/__tests__/index.test.js +155 -0
- package/configure/src/defaults.js +59 -0
- package/configure/src/index.js +114 -0
- package/configure/src/root.jsx +116 -0
- package/controller/CHANGELOG.json +137 -0
- package/controller/CHANGELOG.md +1149 -0
- package/controller/lib/defaults.js +14 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +304 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/utils.js +70 -0
- package/controller/lib/utils.js.map +1 -0
- package/controller/package.json +19 -0
- package/controller/src/__tests__/index.test.js +711 -0
- package/controller/src/defaults.js +7 -0
- package/controller/src/index.js +322 -0
- package/controller/src/utils.js +72 -0
- package/docs/config-schema.json +1382 -0
- package/docs/config-schema.json.md +1021 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +74 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +16 -0
- package/docs/pie-schema.json +1085 -0
- package/docs/pie-schema.json.md +810 -0
- package/lib/constants.js +12 -0
- package/lib/constants.js.map +1 -0
- package/lib/evaluation-icon.js +60 -0
- package/lib/evaluation-icon.js.map +1 -0
- package/lib/image-container.js +94 -0
- package/lib/image-container.js.map +1 -0
- package/lib/image-drop-target.js +130 -0
- package/lib/image-drop-target.js.map +1 -0
- package/lib/index.js +220 -0
- package/lib/index.js.map +1 -0
- package/lib/interactive-section.js +104 -0
- package/lib/interactive-section.js.map +1 -0
- package/lib/possible-response.js +161 -0
- package/lib/possible-response.js.map +1 -0
- package/lib/possible-responses.js +58 -0
- package/lib/possible-responses.js.map +1 -0
- package/lib/root.js +491 -0
- package/lib/root.js.map +1 -0
- package/lib/static-html-span.js +35 -0
- package/lib/static-html-span.js.map +1 -0
- package/lib/utils-correctness.js +89 -0
- package/lib/utils-correctness.js.map +1 -0
- package/package.json +21 -86
- package/src/__tests__/index.test.js +174 -0
- package/src/__tests__/root.test.jsx +99 -0
- package/src/__tests__/utils.test.js +207 -0
- package/src/constants.js +5 -0
- package/src/evaluation-icon.jsx +54 -0
- package/src/image-container.jsx +90 -0
- package/src/image-drop-target.jsx +140 -0
- package/src/index.js +245 -0
- package/src/interactive-section.jsx +94 -0
- package/src/possible-response.jsx +152 -0
- package/src/possible-responses.jsx +52 -0
- package/src/root.jsx +490 -0
- package/src/static-html-span.jsx +30 -0
- package/src/utils-correctness.js +95 -0
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/defaults.d.ts +0 -88
- package/dist/author/defaults.js +0 -58
- package/dist/author/index.d.ts +0 -34
- package/dist/author/index.js +0 -71
- package/dist/author/root.d.ts +0 -14
- package/dist/author/root.js +0 -80
- package/dist/browser/Check-DL1c-mLM.js +0 -10708
- package/dist/browser/Check-DL1c-mLM.js.map +0 -1
- package/dist/browser/author/index.js +0 -38597
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/controller/index.js +0 -171
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -2699
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/dist-BphSS14E.js +0 -346
- package/dist/browser/dist-BphSS14E.js.map +0 -1
- package/dist/browser/humps-CZ4RCLab.js +0 -67
- package/dist/browser/humps-CZ4RCLab.js.map +0 -1
- package/dist/browser/image-cloze-association.css +0 -2
- package/dist/controller/defaults.d.ts +0 -16
- package/dist/controller/defaults.js +0 -10
- package/dist/controller/index.d.ts +0 -23
- package/dist/controller/index.js +0 -122
- package/dist/controller/utils.d.ts +0 -14
- package/dist/controller/utils.js +0 -36
- package/dist/delivery/constants.d.ts +0 -14
- package/dist/delivery/evaluation-icon.d.ts +0 -28
- package/dist/delivery/evaluation-icon.js +0 -38
- package/dist/delivery/image-container.d.ts +0 -13
- package/dist/delivery/image-container.js +0 -61
- package/dist/delivery/image-drop-target.d.ts +0 -45
- package/dist/delivery/image-drop-target.js +0 -90
- package/dist/delivery/index.d.ts +0 -20
- package/dist/delivery/index.js +0 -110
- package/dist/delivery/interactive-section.d.ts +0 -15
- package/dist/delivery/interactive-section.js +0 -72
- package/dist/delivery/possible-response.d.ts +0 -34
- package/dist/delivery/possible-response.js +0 -100
- package/dist/delivery/possible-responses.d.ts +0 -31
- package/dist/delivery/possible-responses.js +0 -41
- package/dist/delivery/root.d.ts +0 -21
- package/dist/delivery/root.js +0 -278
- package/dist/delivery/static-html-span.d.ts +0 -14
- package/dist/delivery/static-html-span.js +0 -22
- package/dist/delivery/utils-correctness.d.ts +0 -10
- package/dist/delivery/utils-correctness.js +0 -43
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -152
- package/dist/index.js +0 -2
- package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
- package/dist/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/image-cloze-association/controller/src/defaults.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
declare const _default: {
|
|
10
|
-
rationale: string;
|
|
11
|
-
rationaleEnabled: boolean;
|
|
12
|
-
studentInstructionsEnabled: boolean;
|
|
13
|
-
teacherInstructions: string;
|
|
14
|
-
teacherInstructionsEnabled: boolean;
|
|
15
|
-
};
|
|
16
|
-
export default _default;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/image-cloze-association/controller/src/index.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
export declare const normalize: (question: any) => any;
|
|
10
|
-
export declare const model: (question: any, session: any, env: any) => Promise<unknown>;
|
|
11
|
-
export declare const isResponseCorrect: (correctResponses: any, session: any) => boolean;
|
|
12
|
-
export declare const getPartialScore: (question: any, session: any) => number;
|
|
13
|
-
/**
|
|
14
|
-
* Generates detailed trace log for scoring evaluation
|
|
15
|
-
* @param {Object} model - the question model
|
|
16
|
-
* @param {Object} session - the student session
|
|
17
|
-
* @param {Object} env - the environment
|
|
18
|
-
* @returns {Array} traceLog - array of trace messages
|
|
19
|
-
*/
|
|
20
|
-
export declare const getLogTrace: (model: any, session: any, env: any) => string[];
|
|
21
|
-
export declare const outcome: (config: any, session: any, env?: {}) => Promise<unknown>;
|
|
22
|
-
export declare const createCorrectResponseSession: (question: any, env: any) => Promise<unknown>;
|
|
23
|
-
export declare const validate: (model?: {}, config?: {}) => {};
|
package/dist/controller/index.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import e from "./defaults.js";
|
|
2
|
-
import { getAllUniqueCorrectness as t, getCompleteResponseDetails as n } from "./utils.js";
|
|
3
|
-
import { cloneDeep as r, isEmpty as i, shuffle as a } from "@pie-element/shared-lodash";
|
|
4
|
-
import { camelizeKeys as o } from "humps";
|
|
5
|
-
import s from "debug";
|
|
6
|
-
import { partialScoring as c } from "@pie-element/shared-controller-utils";
|
|
7
|
-
//#region src/controller/index.ts
|
|
8
|
-
var l = s("pie-elements:image-cloze-association:controller"), u = (t) => ({
|
|
9
|
-
...e,
|
|
10
|
-
...t
|
|
11
|
-
}), d = (e, t, r) => {
|
|
12
|
-
let i = u(e), s = o(i);
|
|
13
|
-
return new Promise((e) => {
|
|
14
|
-
let o = r.mode === "evaluate", { responseAreasToBeFilled: c, possibleResponses: l, hasUnplacedChoices: u } = n(s.validation, s.possibleResponses), d = {
|
|
15
|
-
disabled: r.mode !== "gather",
|
|
16
|
-
mode: r.mode,
|
|
17
|
-
...s,
|
|
18
|
-
responseCorrect: o ? _(s, t) === 1 : void 0,
|
|
19
|
-
validation: o ? s.validation : void 0,
|
|
20
|
-
responseAreasToBeFilled: c,
|
|
21
|
-
completeResponses: l,
|
|
22
|
-
hasUnplacedChoices: u
|
|
23
|
-
};
|
|
24
|
-
i.shuffle && (d.possibleResponses = a(i.possible_responses)), r.role === "instructor" && (r.mode === "view" || r.mode === "evaluate") ? (d.teacherInstructions = s.teacherInstructionsEnabled ? s.teacherInstructions : null, d.rationale = s.rationale ? s.rationale : null) : (d.teacherInstructions = null, d.rationale = null), e(d);
|
|
25
|
-
});
|
|
26
|
-
}, f = (e, t) => {
|
|
27
|
-
let n = r(e), a = !0, o = 0;
|
|
28
|
-
return !t || i(t) ? !1 : (n.forEach((e) => o += (e.images || []).length), t.answers && o === t.answers.length ? t.answers.forEach((e) => {
|
|
29
|
-
let t = (n[e.containerIndex]?.images || []).indexOf(e.value);
|
|
30
|
-
t >= 0 ? n[e.containerIndex].images.splice(t, 1) : a = !1;
|
|
31
|
-
}) : a = !1, a);
|
|
32
|
-
}, p = (e) => r(e.filter((e) => e.images && e.images.length)), m = (e, t) => {
|
|
33
|
-
let { validation: { altResponses: n } } = e, { validation: { validResponse: { value: r } } } = e, i = f(r, t);
|
|
34
|
-
return !i && n && n.length && n.forEach((e) => {
|
|
35
|
-
f(e.value, t) && (i = !0);
|
|
36
|
-
}), i;
|
|
37
|
-
}, h = (e, t, n) => {
|
|
38
|
-
let r = t.filter((t) => t.containerIndex === e), i = r.filter((e) => !e.isCorrect), a = (n.value[e].images || []).length;
|
|
39
|
-
if (r.length > a) {
|
|
40
|
-
let e = r.length - a;
|
|
41
|
-
return i.slice(-e);
|
|
42
|
-
}
|
|
43
|
-
return [];
|
|
44
|
-
}, g = (e, n) => {
|
|
45
|
-
let { validation: { validResponse: r }, maxResponsePerZone: a } = e, o = 0, s = 0, c = 0;
|
|
46
|
-
if (!n || i(n)) return 0;
|
|
47
|
-
if (r.value.forEach((e) => c += (e.images || []).length), n.answers && n.answers.length) {
|
|
48
|
-
let e = t(n.answers, r.value);
|
|
49
|
-
o = e.filter((e) => e.isCorrect).length, s = e.filter((e) => !e.isCorrect).length, n.answers.forEach((t) => {
|
|
50
|
-
if (a > 1) {
|
|
51
|
-
let n = h(t.containerIndex, e, r);
|
|
52
|
-
n.length && n.forEach((e) => {
|
|
53
|
-
e.id === t.id && --o;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}), (!a || a <= 1) && (o -= s);
|
|
57
|
-
} else o = 0;
|
|
58
|
-
o = o < 0 ? 0 : o;
|
|
59
|
-
let l = p(r.value), u = a > 1 ? c : (l || []).length, d = (o / u).toFixed(2);
|
|
60
|
-
return parseFloat(d);
|
|
61
|
-
}, _ = (e, t, n = {}) => {
|
|
62
|
-
let r = c.enabled(e, n), i = m(e, t);
|
|
63
|
-
return r ? g(e, t) : +!!i;
|
|
64
|
-
}, v = (e, t, n) => {
|
|
65
|
-
let r = [], { answers: i } = t || {}, a = e.validation?.validResponse?.value || [], o = a.length;
|
|
66
|
-
if (r.push(`${o} placement container(s) defined in this question.`), i && i.length > 0) {
|
|
67
|
-
r.push(`Student placed ${i.length} image(s) into placement containers.`);
|
|
68
|
-
let e = {};
|
|
69
|
-
i.forEach((t) => {
|
|
70
|
-
e[t.containerIndex] || (e[t.containerIndex] = []), e[t.containerIndex].push(t.value);
|
|
71
|
-
}), a.forEach((t, n) => {
|
|
72
|
-
let i = t.images || [], a = e[n] || [];
|
|
73
|
-
if (i.length > 0) if (a.length === 0) r.push(`Container ${n + 1}: student left empty (should contain ${i.length} image(s)).`);
|
|
74
|
-
else {
|
|
75
|
-
let e = a.filter((e) => i.includes(e)).length, t = a.length - e;
|
|
76
|
-
e > 0 && t === 0 ? r.push(`Container ${n + 1}: student placed ${e} correct image(s).`) : e === 0 && t > 0 ? r.push(`Container ${n + 1}: student placed ${t} incorrect image(s).`) : r.push(`Container ${n + 1}: student placed ${e} correct and ${t} incorrect image(s).`);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
} else r.push("Student did not place any images into placement containers.");
|
|
80
|
-
let s = e.validation?.altResponses || [];
|
|
81
|
-
s.length > 0 && r.push(`${s.length} alternate response combination(s) are accepted for this question.`);
|
|
82
|
-
let l = c.enabled(e, n) ? "partial scoring" : "all-or-nothing scoring";
|
|
83
|
-
r.push(`Score calculated using ${l}.`);
|
|
84
|
-
let u = _(e, t, n);
|
|
85
|
-
return r.push(`Final score: ${u}.`), r;
|
|
86
|
-
}, y = (e, t, n = {}) => new Promise((r) => {
|
|
87
|
-
if (l("outcome..."), !t || i(t)) r({
|
|
88
|
-
score: 0,
|
|
89
|
-
empty: !0,
|
|
90
|
-
traceLog: ["Student did not place any images into placement containers. Score is 0."]
|
|
91
|
-
});
|
|
92
|
-
else {
|
|
93
|
-
let i = o(e), a = v(i, t, n);
|
|
94
|
-
r({
|
|
95
|
-
score: _(i, t, n),
|
|
96
|
-
empty: !1,
|
|
97
|
-
traceLog: a
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}), b = (e, t) => new Promise((n) => {
|
|
101
|
-
if (t.mode !== "evaluate" && t.role === "instructor") {
|
|
102
|
-
let { validation: { valid_response: { value: t } } } = e, r = [];
|
|
103
|
-
t && t.forEach((e, t) => {
|
|
104
|
-
(e.images || []).forEach((e) => {
|
|
105
|
-
r.push({
|
|
106
|
-
value: e,
|
|
107
|
-
containerIndex: t
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
}), n({
|
|
111
|
-
answers: r,
|
|
112
|
-
id: "1"
|
|
113
|
-
});
|
|
114
|
-
} else n(null);
|
|
115
|
-
}), x = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), S = (e = {}, t = {}) => {
|
|
116
|
-
let n = {};
|
|
117
|
-
return ["teacherInstructions"].forEach((r) => {
|
|
118
|
-
t[r]?.required && !x(e[r]) && (n[r] = "This field is required.");
|
|
119
|
-
}), n;
|
|
120
|
-
};
|
|
121
|
-
//#endregion
|
|
122
|
-
export { b as createCorrectResponseSession, v as getLogTrace, g as getPartialScore, f as isResponseCorrect, d as model, u as normalize, y as outcome, S as validate };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/image-cloze-association/controller/src/utils.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
export declare const getAllUniqueCorrectness: (answers: any, validResponses: any) => any;
|
|
10
|
-
export declare const getCompleteResponseDetails: (validation: any, allChoices: any) => {
|
|
11
|
-
responseAreasToBeFilled: any;
|
|
12
|
-
possibleResponses: any[];
|
|
13
|
-
hasUnplacedChoices: boolean;
|
|
14
|
-
};
|
package/dist/controller/utils.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//#region src/controller/utils.ts
|
|
2
|
-
var e = (e, t) => (e || []).map((e) => ({
|
|
3
|
-
...e,
|
|
4
|
-
isCorrect: (t[e.containerIndex] && t[e.containerIndex].images || []).includes(e.value)
|
|
5
|
-
})), t = (e, t) => (t[e.containerIndex] && t[e.containerIndex].images || []).filter((t) => t === e.value), n = (n, r) => {
|
|
6
|
-
let i = e(n, r);
|
|
7
|
-
return n.forEach((e) => {
|
|
8
|
-
let a = n.filter((t) => t.value === e.value && t.containerIndex === e.containerIndex);
|
|
9
|
-
a.length > 1 && (a.shift(), a.forEach((e, n) => {
|
|
10
|
-
i = (i || []).map((i) => {
|
|
11
|
-
if (i.id === e.id) {
|
|
12
|
-
let e = t(i, r);
|
|
13
|
-
return {
|
|
14
|
-
...i,
|
|
15
|
-
isCorrect: e.length > n + 1
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
return i;
|
|
19
|
-
});
|
|
20
|
-
}));
|
|
21
|
-
}), i;
|
|
22
|
-
}, r = (e, t) => {
|
|
23
|
-
let n = (e) => (e?.value || []).map((e) => e.images), r = (e) => (e || []).filter((e) => e.length).length, { validResponse: i, altResponses: a } = e || {}, o = n(i), s = [o.flat()], c = r(o);
|
|
24
|
-
(a || []).forEach((e) => {
|
|
25
|
-
let t = n(e), i = r(t);
|
|
26
|
-
s.push(t.flat()), i < c && (c = i);
|
|
27
|
-
});
|
|
28
|
-
let l = s.some((e) => !t.every((t) => e.includes(t)));
|
|
29
|
-
return {
|
|
30
|
-
responseAreasToBeFilled: c,
|
|
31
|
-
possibleResponses: s,
|
|
32
|
-
hasUnplacedChoices: l
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
//#endregion
|
|
36
|
-
export { n as getAllUniqueCorrectness, r as getCompleteResponseDetails };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/image-cloze-association/src/constants.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
declare const _default: {
|
|
10
|
-
types: {
|
|
11
|
-
response: string;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export default _default;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/image-cloze-association/src/evaluation-icon.jsx
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
declare const EvaluationIcon: {
|
|
12
|
-
({ containerStyle, isCorrect, filled }: {
|
|
13
|
-
containerStyle: any;
|
|
14
|
-
isCorrect: any;
|
|
15
|
-
filled: any;
|
|
16
|
-
}): React.JSX.Element | null;
|
|
17
|
-
propTypes: {
|
|
18
|
-
containerStyle: PropTypes.Requireable<object>;
|
|
19
|
-
filled: PropTypes.Requireable<boolean>;
|
|
20
|
-
isCorrect: PropTypes.Requireable<NonNullable<number | boolean | null | undefined>>;
|
|
21
|
-
};
|
|
22
|
-
defaultProps: {
|
|
23
|
-
containerStyle: {};
|
|
24
|
-
filled: boolean;
|
|
25
|
-
isCorrect: undefined;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export default EvaluationIcon;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import "react";
|
|
2
|
-
import { color as e } from "@pie-lib/render-ui";
|
|
3
|
-
import t from "prop-types";
|
|
4
|
-
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
-
import { styled as r } from "@mui/material/styles";
|
|
6
|
-
import i from "@mui/icons-material/Check";
|
|
7
|
-
import a from "@mui/icons-material/Close";
|
|
8
|
-
//#region src/delivery/evaluation-icon.tsx
|
|
9
|
-
var o = r("svg")(() => ({
|
|
10
|
-
"&.correctEmpty": { color: e.correct() },
|
|
11
|
-
"&.correctFilled": {
|
|
12
|
-
color: e.background(),
|
|
13
|
-
backgroundColor: e.correct()
|
|
14
|
-
},
|
|
15
|
-
"&.incorrectEmpty": { color: e.incorrect() },
|
|
16
|
-
"&.incorrectFilled": {
|
|
17
|
-
color: e.background(),
|
|
18
|
-
backgroundColor: e.incorrect()
|
|
19
|
-
}
|
|
20
|
-
})), s = (e, t) => `${e ? "correct" : "incorrect"}${t ? "Filled" : "Empty"}`, c = ({ containerStyle: e, isCorrect: t, filled: r }) => {
|
|
21
|
-
let c = t ? i : a, l = t !== void 0, u = l ? s(t, r) : "";
|
|
22
|
-
return l ? /* @__PURE__ */ n(c, {
|
|
23
|
-
component: o,
|
|
24
|
-
className: u,
|
|
25
|
-
style: e
|
|
26
|
-
}) : null;
|
|
27
|
-
};
|
|
28
|
-
c.propTypes = {
|
|
29
|
-
containerStyle: t.object,
|
|
30
|
-
filled: t.bool,
|
|
31
|
-
isCorrect: t.oneOfType([t.bool, t.number])
|
|
32
|
-
}, c.defaultProps = {
|
|
33
|
-
containerStyle: {},
|
|
34
|
-
filled: !1,
|
|
35
|
-
isCorrect: void 0
|
|
36
|
-
};
|
|
37
|
-
//#endregion
|
|
38
|
-
export { c as default };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/image-cloze-association/src/image-container.jsx
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
import React, { Component } from 'react';
|
|
10
|
-
declare class ImageContainer extends Component {
|
|
11
|
-
render(): React.JSX.Element;
|
|
12
|
-
}
|
|
13
|
-
export default ImageContainer;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import e from "./image-drop-target.js";
|
|
2
|
-
import { Component as t } from "react";
|
|
3
|
-
import n from "prop-types";
|
|
4
|
-
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
5
|
-
import { styled as a } from "@mui/material/styles";
|
|
6
|
-
//#region src/delivery/image-container.tsx
|
|
7
|
-
var o = a("div")(({ theme: e }) => ({
|
|
8
|
-
margin: e.spacing(2),
|
|
9
|
-
position: "relative",
|
|
10
|
-
width: "fit-content"
|
|
11
|
-
})), s = class extends t {
|
|
12
|
-
render() {
|
|
13
|
-
let { answers: t, canDrag: n, draggingElement: a, image: { height: s, src: c, width: l } = {}, onAnswerSelect: u, onDragAnswerBegin: d, onDragAnswerEnd: f, responseContainers: p, showDashedBorder: m, responseAreaFill: h, answerChoiceTransparency: g, responseContainerPadding: _, imageDropTargetPadding: v, maxResponsePerZone: y } = this.props;
|
|
14
|
-
return /* @__PURE__ */ i(o, { children: [/* @__PURE__ */ r("img", {
|
|
15
|
-
src: c,
|
|
16
|
-
height: s,
|
|
17
|
-
width: l
|
|
18
|
-
}), (p || []).map((i, o) => {
|
|
19
|
-
let c = i.height.replace("%", "") / 100 * s, p = i.width.replace("%", "") / 100 * l, b = i.x / 100 * l, x = i.y / 100 * s;
|
|
20
|
-
return /* @__PURE__ */ r(e, {
|
|
21
|
-
answers: t.filter((e) => e.containerIndex === i.index),
|
|
22
|
-
canDrag: n,
|
|
23
|
-
containerStyle: {
|
|
24
|
-
height: c,
|
|
25
|
-
width: p,
|
|
26
|
-
left: b,
|
|
27
|
-
top: x
|
|
28
|
-
},
|
|
29
|
-
draggingElement: a,
|
|
30
|
-
index: i.index,
|
|
31
|
-
onDrop: (e) => u(e, i.index),
|
|
32
|
-
onDragAnswerBegin: d,
|
|
33
|
-
onDragAnswerEnd: f,
|
|
34
|
-
showDashedBorder: m,
|
|
35
|
-
responseAreaFill: h,
|
|
36
|
-
answerChoiceTransparency: g,
|
|
37
|
-
responseContainerPadding: _,
|
|
38
|
-
imageDropTargetPadding: v,
|
|
39
|
-
maxResponsePerZone: y
|
|
40
|
-
}, i.id + o);
|
|
41
|
-
})] });
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
s.propTypes = {
|
|
45
|
-
answers: n.array.isRequired,
|
|
46
|
-
canDrag: n.bool.isRequired,
|
|
47
|
-
draggingElement: n.shape({}).isRequired,
|
|
48
|
-
image: n.object.isRequired,
|
|
49
|
-
onAnswerSelect: n.func.isRequired,
|
|
50
|
-
onDragAnswerBegin: n.func.isRequired,
|
|
51
|
-
onDragAnswerEnd: n.func.isRequired,
|
|
52
|
-
responseContainers: n.array.isRequired,
|
|
53
|
-
showDashedBorder: n.bool,
|
|
54
|
-
answerChoiceTransparency: n.bool,
|
|
55
|
-
responseAreaFill: n.string,
|
|
56
|
-
responseContainerPadding: n.string,
|
|
57
|
-
imageDropTargetPadding: n.string,
|
|
58
|
-
maxResponsePerZone: n.number
|
|
59
|
-
};
|
|
60
|
-
//#endregion
|
|
61
|
-
export { s as default };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/image-cloze-association/src/image-drop-target.jsx
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
declare const ImageDropTarget: {
|
|
12
|
-
({ answers, canDrag, containerStyle, draggingElement, onDragAnswerBegin, onDragAnswerEnd, showDashedBorder, responseAreaFill, responseContainerPadding, imageDropTargetPadding, answerChoiceTransparency, maxResponsePerZone, onDrop, index, }: {
|
|
13
|
-
answers: any;
|
|
14
|
-
canDrag: any;
|
|
15
|
-
containerStyle: any;
|
|
16
|
-
draggingElement: any;
|
|
17
|
-
onDragAnswerBegin: any;
|
|
18
|
-
onDragAnswerEnd: any;
|
|
19
|
-
showDashedBorder: any;
|
|
20
|
-
responseAreaFill: any;
|
|
21
|
-
responseContainerPadding?: string | undefined;
|
|
22
|
-
imageDropTargetPadding: any;
|
|
23
|
-
answerChoiceTransparency: any;
|
|
24
|
-
maxResponsePerZone: any;
|
|
25
|
-
onDrop: any;
|
|
26
|
-
index: any;
|
|
27
|
-
}): React.JSX.Element;
|
|
28
|
-
propTypes: {
|
|
29
|
-
answer: PropTypes.Requireable<object>;
|
|
30
|
-
answers: PropTypes.Requireable<any[]>;
|
|
31
|
-
canDrag: PropTypes.Validator<boolean>;
|
|
32
|
-
containerStyle: PropTypes.Validator<object>;
|
|
33
|
-
draggingElement: PropTypes.Validator<object>;
|
|
34
|
-
onDragAnswerBegin: PropTypes.Validator<(...args: any[]) => any>;
|
|
35
|
-
onDragAnswerEnd: PropTypes.Validator<(...args: any[]) => any>;
|
|
36
|
-
onDrop: PropTypes.Validator<(...args: any[]) => any>;
|
|
37
|
-
showDashedBorder: PropTypes.Requireable<boolean>;
|
|
38
|
-
responseAreaFill: PropTypes.Requireable<string>;
|
|
39
|
-
answerChoiceTransparency: PropTypes.Requireable<boolean>;
|
|
40
|
-
responseContainerPadding: PropTypes.Requireable<string>;
|
|
41
|
-
imageDropTargetPadding: PropTypes.Requireable<string>;
|
|
42
|
-
maxResponsePerZone: PropTypes.Requireable<number>;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
export default ImageDropTarget;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import e from "../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
|
|
2
|
-
import t from "./possible-response.js";
|
|
3
|
-
import { useEffect as n, useRef as r, useState as i } from "react";
|
|
4
|
-
import { color as a } from "@pie-lib/render-ui";
|
|
5
|
-
import o from "prop-types";
|
|
6
|
-
import { useDroppable as s } from "@dnd-kit/core";
|
|
7
|
-
import { jsx as c } from "react/jsx-runtime";
|
|
8
|
-
import { styled as l } from "@mui/material/styles";
|
|
9
|
-
//#region src/delivery/image-drop-target.tsx
|
|
10
|
-
var u = l("div")(() => ({
|
|
11
|
-
display: "flex",
|
|
12
|
-
flexWrap: "wrap"
|
|
13
|
-
})), d = l("div")(() => ({
|
|
14
|
-
position: "absolute",
|
|
15
|
-
boxSizing: "border-box",
|
|
16
|
-
"&.active": {
|
|
17
|
-
border: `2px solid ${a.text()}`,
|
|
18
|
-
backgroundColor: "rgba(230, 242, 252, .8)"
|
|
19
|
-
},
|
|
20
|
-
"&.dashed": { border: `2px dashed ${a.text()}` },
|
|
21
|
-
"&.is-over": {
|
|
22
|
-
border: "1px solid rgb(158, 158, 158)",
|
|
23
|
-
backgroundColor: "rgb(224, 224, 224)"
|
|
24
|
-
}
|
|
25
|
-
})), f = ({ answers: a, canDrag: o, containerStyle: l, draggingElement: f, onDragAnswerBegin: p, onDragAnswerEnd: m, showDashedBorder: h, responseAreaFill: g, responseContainerPadding: _ = "10px", imageDropTargetPadding: v, answerChoiceTransparency: y, maxResponsePerZone: b, onDrop: x, index: S }) => {
|
|
26
|
-
let [C, w] = i(!1), T = r(null), E = r(null), { setNodeRef: D, isOver: O } = s({
|
|
27
|
-
id: `response-container-${S}`,
|
|
28
|
-
data: {
|
|
29
|
-
containerIndex: S,
|
|
30
|
-
onDrop: x
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
n(() => {
|
|
34
|
-
let e = T.current;
|
|
35
|
-
if (!e) return;
|
|
36
|
-
let t = (e) => {
|
|
37
|
-
e.preventDefault();
|
|
38
|
-
};
|
|
39
|
-
return e.addEventListener("touchstart", t, { passive: !1 }), () => {
|
|
40
|
-
e.removeEventListener("touchstart", t);
|
|
41
|
-
};
|
|
42
|
-
}, []);
|
|
43
|
-
let k = !!f.id;
|
|
44
|
-
return /* @__PURE__ */ c(d, {
|
|
45
|
-
ref: (e) => {
|
|
46
|
-
T.current = e, D(e);
|
|
47
|
-
},
|
|
48
|
-
className: e({
|
|
49
|
-
"is-over": O,
|
|
50
|
-
dashed: h && !k,
|
|
51
|
-
active: k
|
|
52
|
-
}),
|
|
53
|
-
style: {
|
|
54
|
-
padding: b === 1 ? "0" : _,
|
|
55
|
-
...l,
|
|
56
|
-
...g && !k && { backgroundColor: g }
|
|
57
|
-
},
|
|
58
|
-
children: a.length ? /* @__PURE__ */ c(u, {
|
|
59
|
-
ref: (e) => {
|
|
60
|
-
E.current = e?.getBoundingClientRect().height;
|
|
61
|
-
},
|
|
62
|
-
children: a.map((e) => /* @__PURE__ */ c(t, {
|
|
63
|
-
data: e,
|
|
64
|
-
canDrag: o,
|
|
65
|
-
onDragBegin: () => p(e),
|
|
66
|
-
onDragEnd: m,
|
|
67
|
-
answerChoiceTransparency: y,
|
|
68
|
-
containerStyle: { padding: v || (C ? "2px" : "6px 10px") }
|
|
69
|
-
}, e.id))
|
|
70
|
-
}) : null
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
f.propTypes = {
|
|
74
|
-
answer: o.object,
|
|
75
|
-
answers: o.array,
|
|
76
|
-
canDrag: o.bool.isRequired,
|
|
77
|
-
containerStyle: o.object.isRequired,
|
|
78
|
-
draggingElement: o.object.isRequired,
|
|
79
|
-
onDragAnswerBegin: o.func.isRequired,
|
|
80
|
-
onDragAnswerEnd: o.func.isRequired,
|
|
81
|
-
onDrop: o.func.isRequired,
|
|
82
|
-
showDashedBorder: o.bool,
|
|
83
|
-
responseAreaFill: o.string,
|
|
84
|
-
answerChoiceTransparency: o.bool,
|
|
85
|
-
responseContainerPadding: o.string,
|
|
86
|
-
imageDropTargetPadding: o.string,
|
|
87
|
-
maxResponsePerZone: o.number
|
|
88
|
-
};
|
|
89
|
-
//#endregion
|
|
90
|
-
export { f as default };
|
package/dist/delivery/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/image-cloze-association/src/index.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
export default class ImageClozeAssociation extends HTMLElement {
|
|
10
|
-
constructor();
|
|
11
|
-
set model(m: any);
|
|
12
|
-
isComplete(): any;
|
|
13
|
-
set session(s: any);
|
|
14
|
-
get session(): any;
|
|
15
|
-
updateAnswer(data: any): void;
|
|
16
|
-
_createAudioInfoToast(): HTMLDivElement;
|
|
17
|
-
connectedCallback(): void;
|
|
18
|
-
disconnectedCallback(): void;
|
|
19
|
-
_render(): void;
|
|
20
|
-
}
|
package/dist/delivery/index.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import e from "./root.js";
|
|
2
|
-
import t from "react";
|
|
3
|
-
import { createRoot as n } from "react-dom/client";
|
|
4
|
-
import { renderMath as r } from "@pie-element/shared-math-rendering-mathjax";
|
|
5
|
-
import * as i from "@pie-lib/render-ui";
|
|
6
|
-
import { EnableAudioAutoplayImage as a } from "@pie-lib/render-ui";
|
|
7
|
-
import { ModelSetEvent as o, SessionChangedEvent as s } from "@pie-element/shared-player-events";
|
|
8
|
-
//#region src/delivery/index.ts
|
|
9
|
-
function c(e) {
|
|
10
|
-
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
11
|
-
}
|
|
12
|
-
function l(e, t) {
|
|
13
|
-
return !e || c(e) ? e : c(e.default) ? e.default : t && c(e[t]) ? e[t] : t && c(e[t]?.default) ? e[t].default : e;
|
|
14
|
-
}
|
|
15
|
-
var u = l(a, "EnableAudioAutoplayImage") || l(p.EnableAudioAutoplayImage, "EnableAudioAutoplayImage"), d = i, f = d.default, p = f && typeof f == "object" ? f : d, m = class extends HTMLElement {
|
|
16
|
-
constructor() {
|
|
17
|
-
super(), this._root = null;
|
|
18
|
-
}
|
|
19
|
-
set model(e) {
|
|
20
|
-
this._model = e, this.dispatchEvent(new o(this.tagName.toLowerCase(), this.isComplete(), !!this._model)), this._render();
|
|
21
|
-
}
|
|
22
|
-
isComplete() {
|
|
23
|
-
let { autoplayAudioEnabled: e, completeAudioEnabled: t, completeResponses: n, duplicateResponses: r, hasUnplacedChoices: i, maxResponsePerZone: a, responseAreasToBeFilled: o } = this._model || {}, s = this;
|
|
24
|
-
if (e && t && !this.audioComplete && s) {
|
|
25
|
-
let e = s.querySelector("audio"), t = e && e.closest("#preview-prompt");
|
|
26
|
-
if (e && t) return !1;
|
|
27
|
-
}
|
|
28
|
-
if (!this._session || !this._session.answers) return !1;
|
|
29
|
-
let { answers: c } = this._session;
|
|
30
|
-
if (!Array.isArray(c)) return !1;
|
|
31
|
-
let l = [...new Map(c.map((e) => [e.containerIndex, e])).values()].length >= o;
|
|
32
|
-
if (a > 1) {
|
|
33
|
-
if (r || i) return l;
|
|
34
|
-
let e = c.map((e) => e.value);
|
|
35
|
-
return n.some((t) => t.every((t) => e.includes(t)));
|
|
36
|
-
}
|
|
37
|
-
return l;
|
|
38
|
-
}
|
|
39
|
-
set session(e) {
|
|
40
|
-
e && !e.answers && (e.answers = []), this._session = e, this._render();
|
|
41
|
-
}
|
|
42
|
-
get session() {
|
|
43
|
-
return this._session;
|
|
44
|
-
}
|
|
45
|
-
updateAnswer(e) {
|
|
46
|
-
this._session.answers = e, this._session.selector = "Mouse", this.dispatchEvent(new s(this.tagName.toLowerCase(), this.isComplete())), this._render();
|
|
47
|
-
}
|
|
48
|
-
_createAudioInfoToast() {
|
|
49
|
-
let e = document.createElement("div");
|
|
50
|
-
e.id = "play-audio-info", Object.assign(e.style, {
|
|
51
|
-
position: "absolute",
|
|
52
|
-
top: 0,
|
|
53
|
-
width: "100%",
|
|
54
|
-
height: "100%",
|
|
55
|
-
display: "flex",
|
|
56
|
-
justifyContent: "center",
|
|
57
|
-
alignItems: "center",
|
|
58
|
-
background: "white",
|
|
59
|
-
zIndex: "1000",
|
|
60
|
-
cursor: "pointer"
|
|
61
|
-
});
|
|
62
|
-
let t = document.createElement("img");
|
|
63
|
-
return t.src = u, t.alt = "Click anywhere to enable audio autoplay", t.width = 500, t.height = 300, e.appendChild(t), e;
|
|
64
|
-
}
|
|
65
|
-
connectedCallback() {
|
|
66
|
-
this._render(), new MutationObserver((e, t) => {
|
|
67
|
-
e.forEach((e) => {
|
|
68
|
-
if (e.type === "childList") {
|
|
69
|
-
let e = this.querySelector("audio"), n = e && e.closest("#preview-prompt");
|
|
70
|
-
if (!this._model || !this._model.autoplayAudioEnabled || e && !n || !e) return;
|
|
71
|
-
let r = this._createAudioInfoToast(), i = this.querySelector("#main-container"), a = () => {
|
|
72
|
-
this.querySelector("#play-audio-info") && (e.play(), i.removeChild(r)), document.removeEventListener("click", a);
|
|
73
|
-
};
|
|
74
|
-
setTimeout(() => {
|
|
75
|
-
e.paused && !this.querySelector("#play-audio-info") ? (i.appendChild(r), document.addEventListener("click", a)) : document.removeEventListener("click", a);
|
|
76
|
-
}, 500);
|
|
77
|
-
let o = () => {
|
|
78
|
-
let t = this.querySelector("#play-audio-info");
|
|
79
|
-
t && i.removeChild(t), e.removeEventListener("playing", o);
|
|
80
|
-
};
|
|
81
|
-
e.addEventListener("playing", o);
|
|
82
|
-
let c = () => {
|
|
83
|
-
this.audioComplete = !0, this.dispatchEvent(new s(this.tagName.toLowerCase(), this.isComplete())), e.removeEventListener("ended", c);
|
|
84
|
-
};
|
|
85
|
-
e.addEventListener("ended", c), this._audio = e, this._handlePlaying = o, this._handleEnded = c, this._enableAudio = a, t.disconnect();
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}).observe(this, {
|
|
89
|
-
childList: !0,
|
|
90
|
-
subtree: !0
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
disconnectedCallback() {
|
|
94
|
-
document.removeEventListener("click", this._enableAudio), this._audio &&= (this._audio.removeEventListener("playing", this._handlePlaying), this._audio.removeEventListener("ended", this._handleEnded), null), this._root && this._root.unmount();
|
|
95
|
-
}
|
|
96
|
-
_render() {
|
|
97
|
-
if (this._model && this._session) {
|
|
98
|
-
let i = t.createElement(e, {
|
|
99
|
-
model: this._model,
|
|
100
|
-
session: this._session,
|
|
101
|
-
updateAnswer: this.updateAnswer.bind(this)
|
|
102
|
-
});
|
|
103
|
-
this._root ||= n(this), this._root.render(i), queueMicrotask(() => {
|
|
104
|
-
r(this);
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
//#endregion
|
|
110
|
-
export { m as default };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/image-cloze-association/src/interactive-section.jsx
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
import React from 'react';
|
|
10
|
-
declare class InteractiveSection extends React.Component {
|
|
11
|
-
getClassname(): string;
|
|
12
|
-
getPositionDirection(choicePosition: any): string;
|
|
13
|
-
render(): React.JSX.Element;
|
|
14
|
-
}
|
|
15
|
-
export default InteractiveSection;
|