@pie-element/drag-in-the-blank 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 +1042 -0
- package/CHANGELOG.md +2183 -0
- package/LICENSE.md +5 -0
- package/README.md +1 -0
- package/configure/CHANGELOG.json +652 -0
- package/configure/CHANGELOG.md +1883 -0
- package/configure/lib/choice.js +137 -0
- package/configure/lib/choice.js.map +1 -0
- package/configure/lib/choices.js +319 -0
- package/configure/lib/choices.js.map +1 -0
- package/configure/lib/defaults.js +169 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +144 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/main.js +440 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/lib/markupUtils.js +83 -0
- package/configure/lib/markupUtils.js.map +1 -0
- package/configure/package.json +25 -0
- package/configure/utils.js +17 -0
- package/controller/CHANGELOG.json +457 -0
- package/controller/CHANGELOG.md +1284 -0
- package/controller/lib/defaults.js +24 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +251 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/utils.js +39 -0
- package/controller/lib/utils.js.map +1 -0
- package/controller/package.json +16 -0
- package/docs/config-schema.json +2580 -0
- package/docs/config-schema.json.md +1905 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +41 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +10 -0
- package/docs/pie-schema.json +1181 -0
- package/docs/pie-schema.json.md +853 -0
- package/lib/index.js +206 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +126 -0
- package/lib/main.js.map +1 -0
- package/package.json +22 -87
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/choice.d.ts +0 -22
- package/dist/author/choice.js +0 -88
- package/dist/author/choices.d.ts +0 -41
- package/dist/author/choices.js +0 -172
- package/dist/author/defaults.d.ts +0 -171
- package/dist/author/defaults.js +0 -123
- package/dist/author/index.d.ts +0 -42
- package/dist/author/index.js +0 -92
- package/dist/author/main.d.ts +0 -36
- package/dist/author/main.js +0 -301
- package/dist/author/markupUtils.d.ts +0 -17
- package/dist/author/markupUtils.js +0 -38
- package/dist/author/utils.d.ts +0 -9
- package/dist/author/utils.js +0 -7
- package/dist/browser/author/index.js +0 -39603
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/controller/index.js +0 -176
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -3414
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/dist-BkH5WSi5.js +0 -121
- package/dist/browser/dist-BkH5WSi5.js.map +0 -1
- package/dist/browser/drag-in-the-blank.css +0 -2
- package/dist/browser/drag-provider-D0fyq5lq.js +0 -10946
- package/dist/browser/drag-provider-D0fyq5lq.js.map +0 -1
- package/dist/controller/defaults.d.ts +0 -26
- package/dist/controller/defaults.js +0 -20
- package/dist/controller/index.d.ts +0 -41
- package/dist/controller/index.js +0 -104
- package/dist/controller/utils.d.ts +0 -16
- package/dist/controller/utils.js +0 -14
- package/dist/delivery/index.d.ts +0 -21
- package/dist/delivery/index.js +0 -105
- package/dist/delivery/main.d.ts +0 -28
- package/dist/delivery/main.js +0 -83
- 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/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/drag-in-the-blank/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
|
-
choices: never[];
|
|
11
|
-
choicesPosition: string;
|
|
12
|
-
correctResponse: {};
|
|
13
|
-
disabled: boolean;
|
|
14
|
-
duplicates: boolean;
|
|
15
|
-
markup: string;
|
|
16
|
-
mode: string;
|
|
17
|
-
prompt: string;
|
|
18
|
-
promptEnabled: boolean;
|
|
19
|
-
rationale: string;
|
|
20
|
-
rationaleEnabled: boolean;
|
|
21
|
-
studentInstructionsEnabled: boolean;
|
|
22
|
-
teacherInstructions: string;
|
|
23
|
-
teacherInstructionsEnabled: boolean;
|
|
24
|
-
toolbarEditorPosition: string;
|
|
25
|
-
};
|
|
26
|
-
export default _default;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
//#region src/controller/defaults.ts
|
|
2
|
-
var e = {
|
|
3
|
-
choices: [],
|
|
4
|
-
choicesPosition: "below",
|
|
5
|
-
correctResponse: {},
|
|
6
|
-
disabled: !1,
|
|
7
|
-
duplicates: !0,
|
|
8
|
-
markup: "",
|
|
9
|
-
mode: "gather",
|
|
10
|
-
prompt: "",
|
|
11
|
-
promptEnabled: !0,
|
|
12
|
-
rationale: "",
|
|
13
|
-
rationaleEnabled: !0,
|
|
14
|
-
studentInstructionsEnabled: !0,
|
|
15
|
-
teacherInstructions: "",
|
|
16
|
-
teacherInstructionsEnabled: !0,
|
|
17
|
-
toolbarEditorPosition: "bottom"
|
|
18
|
-
};
|
|
19
|
-
//#endregion
|
|
20
|
-
export { e as default };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/drag-in-the-blank/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
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @param {*} question
|
|
13
|
-
* @param {*} session
|
|
14
|
-
* @param {*} env
|
|
15
|
-
* @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
|
|
16
|
-
*/
|
|
17
|
-
export declare function model(question: any, session: any, env: any, updateSession: any): Promise<any>;
|
|
18
|
-
export declare const getScore: (config: any, session: any) => number;
|
|
19
|
-
/**
|
|
20
|
-
* Generates detailed trace log for scoring evaluation
|
|
21
|
-
* @param {Object} model - the question model
|
|
22
|
-
* @param {Object} session - the student session
|
|
23
|
-
* @param {Object} env - the environment
|
|
24
|
-
* @returns {Array} traceLog - array of trace messages
|
|
25
|
-
*/
|
|
26
|
-
export declare const getLogTrace: (model: any, session: any, env: any) => string[];
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* The score is partial by default for checkbox mode, allOrNothing for radio mode.
|
|
30
|
-
* To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =
|
|
31
|
-
* false. the value in `env` will override the value in `model`.
|
|
32
|
-
* @param {Object} model - the main model
|
|
33
|
-
* @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)
|
|
34
|
-
* @param {*} session
|
|
35
|
-
* @param {Object} env
|
|
36
|
-
* @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides
|
|
37
|
-
* `model.partialScoring`.
|
|
38
|
-
*/
|
|
39
|
-
export declare function outcome(model: any, session: any, env?: {}): Promise<unknown>;
|
|
40
|
-
export declare const createCorrectResponseSession: (question: any, env: any) => Promise<unknown>;
|
|
41
|
-
export declare const validate: (model?: {}, config?: {}) => {};
|
package/dist/controller/index.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { choiceIsEmpty as e, getAllCorrectResponses as t } from "./utils.js";
|
|
2
|
-
import n from "./defaults.js";
|
|
3
|
-
import { isEmpty as r } from "@pie-element/shared-lodash";
|
|
4
|
-
import { getShuffledChoices as i, lockChoices as a, partialScoring as o } from "@pie-element/shared-controller-utils";
|
|
5
|
-
//#region src/controller/index.ts
|
|
6
|
-
var s = (e) => ({
|
|
7
|
-
...n,
|
|
8
|
-
...e
|
|
9
|
-
});
|
|
10
|
-
async function c(n, r, o, c) {
|
|
11
|
-
let u = s(n), d = {};
|
|
12
|
-
if (o.mode === "evaluate") {
|
|
13
|
-
let e = t(u) || {}, n = e.possibleResponses, i = e.numberOfPossibleResponses || 0, a, { value: o } = r || {};
|
|
14
|
-
for (let e = 0; e < i; e++) {
|
|
15
|
-
let t = Object.keys(n).reduce((t, r) => {
|
|
16
|
-
let i = n[r], a = o && o[r] || "";
|
|
17
|
-
return t.feedback[r] = i[e] === a, t.feedback[r] && (t.correctResponses += 1), t;
|
|
18
|
-
}, {
|
|
19
|
-
correctResponses: 0,
|
|
20
|
-
feedback: {}
|
|
21
|
-
});
|
|
22
|
-
(a === void 0 || t.correctResponses > a) && (a = t.correctResponses, d = t.feedback);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
let f = u.choices && u.choices.filter((t) => !e(t));
|
|
26
|
-
a(u, r, o) || (f = await i(f, r, c, "id"));
|
|
27
|
-
let p = Object.values(u.correctResponse || {}).filter((e) => !!e).length, m = o.mode === "evaluate", h = {
|
|
28
|
-
...u,
|
|
29
|
-
prompt: u.promptEnabled ? u.prompt : null,
|
|
30
|
-
choices: f,
|
|
31
|
-
feedback: d,
|
|
32
|
-
mode: o.mode,
|
|
33
|
-
disabled: o.mode !== "gather",
|
|
34
|
-
responseCorrect: m ? l(u, r) === 1 : void 0,
|
|
35
|
-
correctResponse: m ? u.correctResponse : void 0,
|
|
36
|
-
responseAreasToBeFilled: p
|
|
37
|
-
};
|
|
38
|
-
return o.role === "instructor" && (o.mode === "view" || o.mode === "evaluate") ? (h.rationale = u.rationaleEnabled ? u.rationale : null, h.teacherInstructions = u.teacherInstructionsEnabled ? u.teacherInstructions : null) : (h.rationale = null, h.teacherInstructions = null), h;
|
|
39
|
-
}
|
|
40
|
-
var l = (e, n) => {
|
|
41
|
-
let r = t(e), i = r.possibleResponses, a = Object.keys(e.correctResponse).length, o = r.numberOfPossibleResponses || 0, s = 0, { value: c } = n || {};
|
|
42
|
-
for (let e = 0; e < o; e++) {
|
|
43
|
-
let t = Object.keys(i).reduce((t, n) => {
|
|
44
|
-
let r = i[n], a = c && c[n] || "";
|
|
45
|
-
return r[e] === a ? t : t - 1;
|
|
46
|
-
}, a);
|
|
47
|
-
if (t > s && (s = t), t === a) break;
|
|
48
|
-
}
|
|
49
|
-
let l = a ? (s / a).toFixed(2) : 0;
|
|
50
|
-
return parseFloat(l);
|
|
51
|
-
}, u = (e, n, r) => {
|
|
52
|
-
let i = [], { value: a } = n || {}, s = Object.keys(e.correctResponse || {}), c = s.length;
|
|
53
|
-
if (i.push(`${c} response area(s) defined in this question.`), a && Object.keys(a).length > 0) {
|
|
54
|
-
let t = Object.entries(a).filter(([e, t]) => t && t.trim()).length;
|
|
55
|
-
i.push(`Student added choices to ${t} out of ${c} response area(s).`), s.forEach((t) => {
|
|
56
|
-
let n = a && a[t] || "", r = e.correctResponse[t] || "";
|
|
57
|
-
n.trim() ? i.push(`Response area ${t}: student placed '${n}' (correct answer: '${r}').`) : i.push(`Response area ${t}: left empty (correct answer: '${r}').`);
|
|
58
|
-
});
|
|
59
|
-
} else i.push("Student did not add any choices to response areas.");
|
|
60
|
-
let u = t(e);
|
|
61
|
-
u.possibleResponses;
|
|
62
|
-
let d = u.numberOfPossibleResponses || 0;
|
|
63
|
-
d > 1 && i.push(`${d} alternate response combinations are accepted for this question.`);
|
|
64
|
-
let f = o.enabled(e, r) ? "partial scoring" : "all-or-nothing scoring";
|
|
65
|
-
i.push(`Score calculated using ${f}.`);
|
|
66
|
-
let p = l(e, n);
|
|
67
|
-
return i.push(`Final score: ${p}.`), i;
|
|
68
|
-
};
|
|
69
|
-
function d(e, t, n = {}) {
|
|
70
|
-
return new Promise((i) => {
|
|
71
|
-
if (!t || r(t)) i({
|
|
72
|
-
score: 0,
|
|
73
|
-
empty: !0,
|
|
74
|
-
traceLog: ["Student did not add any choices to response areas. Score is 0."]
|
|
75
|
-
});
|
|
76
|
-
else {
|
|
77
|
-
let r = u(e, t, n), a = l(e, t);
|
|
78
|
-
i({
|
|
79
|
-
score: o.enabled(e, n) ? a : +(a === 1),
|
|
80
|
-
empty: !1,
|
|
81
|
-
traceLog: r
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
var f = (e, t) => new Promise((n) => {
|
|
87
|
-
t.mode !== "evaluate" && t.role === "instructor" ? n({
|
|
88
|
-
value: e.correctResponse,
|
|
89
|
-
id: "1"
|
|
90
|
-
}) : n(null);
|
|
91
|
-
}), p = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), m = (e = {}, t = {}) => {
|
|
92
|
-
let { choices: n, correctResponse: r, markup: i } = e, { minChoices: a = 2, maxChoices: o, maxResponseAreas: s } = t, c = {};
|
|
93
|
-
[
|
|
94
|
-
"teacherInstructions",
|
|
95
|
-
"prompt",
|
|
96
|
-
"rationale"
|
|
97
|
-
].forEach((n) => {
|
|
98
|
-
t[n]?.required && !p(e[n]) && (c[n] = "This field is required.");
|
|
99
|
-
});
|
|
100
|
-
let l = ((i || "").match(/\{\{(\d+)\}\}/g) || []).length, u = (n || []).length;
|
|
101
|
-
return (Object.values(r)?.filter((e) => !e)).length && (c.correctResponseError = "There should be a choice defined for each response area."), l > s ? c.responseAreasError = `No more than ${s} response areas should be defined.` : l < 1 && (c.responseAreasError = "There should be at least 1 response area defined."), u < a ? c.choicesError = `There should be at least ${a} tokens defined.` : u > o && (c.choicesError = `No more than ${o} tokens should be defined.`), c;
|
|
102
|
-
};
|
|
103
|
-
//#endregion
|
|
104
|
-
export { f as createCorrectResponseSession, u as getLogTrace, l as getScore, c as model, s as normalize, d as outcome, m as validate };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/drag-in-the-blank/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 getAllCorrectResponses: ({ correctResponse, alternateResponses }: {
|
|
10
|
-
correctResponse: any;
|
|
11
|
-
alternateResponses: any;
|
|
12
|
-
}) => {
|
|
13
|
-
possibleResponses: {};
|
|
14
|
-
numberOfPossibleResponses: undefined;
|
|
15
|
-
};
|
|
16
|
-
export declare const choiceIsEmpty: (choice: any) => boolean;
|
package/dist/controller/utils.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { cloneDeep as e, reduce as t } from "@pie-element/shared-lodash";
|
|
2
|
-
//#region src/controller/utils.ts
|
|
3
|
-
var n = /<(?!img)[^>]*>?/gm, r = ({ correctResponse: n, alternateResponses: r }) => t(n || {}, (t, n, i) => (t.possibleResponses[i] = [n], r && r[i] && (t.possibleResponses[i] = [...t.possibleResponses[i], ...e(r[i])]), (t.numberOfPossibleResponses === void 0 || t.numberOfPossibleResponses > t.possibleResponses[i].length) && (t.numberOfPossibleResponses = t.possibleResponses[i].length), t), {
|
|
4
|
-
possibleResponses: {},
|
|
5
|
-
numberOfPossibleResponses: void 0
|
|
6
|
-
}), i = (e) => {
|
|
7
|
-
if (e) {
|
|
8
|
-
let { value: t = "" } = e;
|
|
9
|
-
return (t.replace(n, "") || "").trim() === "";
|
|
10
|
-
}
|
|
11
|
-
return !1;
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
14
|
-
export { i as choiceIsEmpty, r as getAllCorrectResponses };
|
package/dist/delivery/index.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/drag-in-the-blank/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 isComplete: (session: any, model: any, audioComplete: any, elementContext: any) => boolean;
|
|
10
|
-
export default class DragInTheBlank extends HTMLElement {
|
|
11
|
-
constructor();
|
|
12
|
-
set model(m: any);
|
|
13
|
-
set session(s: any);
|
|
14
|
-
get session(): any;
|
|
15
|
-
_render: any;
|
|
16
|
-
dispatchChangedEvent: any;
|
|
17
|
-
changeSession: any;
|
|
18
|
-
_createAudioInfoToast(): HTMLDivElement;
|
|
19
|
-
connectedCallback(): void;
|
|
20
|
-
disconnectedCallback(): void;
|
|
21
|
-
}
|
package/dist/delivery/index.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import e from "./main.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 = (e, t, n, r) => {
|
|
16
|
-
let { autoplayAudioEnabled: i, completeAudioEnabled: a, responseAreasToBeFilled: o } = t || {};
|
|
17
|
-
if (i && a && !n && r) {
|
|
18
|
-
let e = r.querySelector("audio"), t = e && e.closest("#preview-prompt");
|
|
19
|
-
if (e && t) return !1;
|
|
20
|
-
}
|
|
21
|
-
return !e || !e.value ? !1 : Object.values(e.value || {}).filter((e) => !!e).length >= o;
|
|
22
|
-
}, h = class extends HTMLElement {
|
|
23
|
-
constructor() {
|
|
24
|
-
super(), this._model = null, this._session = null, this._audioInitialized = !1, this.audioComplete = !1, this._root = null;
|
|
25
|
-
}
|
|
26
|
-
set model(e) {
|
|
27
|
-
this._model = e, this.dispatchEvent(new o(this.tagName.toLowerCase(), m(this._session, this._model, this.audioComplete, this), !!this._model)), this._audioInitialized = !1, this._render();
|
|
28
|
-
}
|
|
29
|
-
set session(e) {
|
|
30
|
-
this._session = e, this._render();
|
|
31
|
-
}
|
|
32
|
-
get session() {
|
|
33
|
-
return this._session;
|
|
34
|
-
}
|
|
35
|
-
_render = () => {
|
|
36
|
-
if (this._model && this._session) {
|
|
37
|
-
let i = t.createElement(e, {
|
|
38
|
-
model: this._model,
|
|
39
|
-
value: this._session.value,
|
|
40
|
-
onChange: this.changeSession
|
|
41
|
-
});
|
|
42
|
-
this._root ||= n(this), this._root.render(i), setTimeout(() => r(this), 0);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
dispatchChangedEvent = () => {
|
|
46
|
-
this.dispatchEvent(new s(this.tagName.toLowerCase(), m(this._session, this._model, this.audioComplete, this)));
|
|
47
|
-
};
|
|
48
|
-
changeSession = (e) => {
|
|
49
|
-
this.session.value = e, this.session.selector = "Mouse", this.dispatchChangedEvent(), this._render();
|
|
50
|
-
};
|
|
51
|
-
_createAudioInfoToast() {
|
|
52
|
-
let e = document.createElement("div");
|
|
53
|
-
e.id = "play-audio-info", Object.assign(e.style, {
|
|
54
|
-
position: "absolute",
|
|
55
|
-
top: 0,
|
|
56
|
-
width: "100%",
|
|
57
|
-
height: "100%",
|
|
58
|
-
display: "flex",
|
|
59
|
-
justifyContent: "center",
|
|
60
|
-
alignItems: "center",
|
|
61
|
-
background: "white",
|
|
62
|
-
zIndex: "1000",
|
|
63
|
-
cursor: "pointer"
|
|
64
|
-
});
|
|
65
|
-
let t = document.createElement("img");
|
|
66
|
-
return t.src = u, t.alt = "Click anywhere to enable audio autoplay", t.width = 500, t.height = 300, e.appendChild(t), e;
|
|
67
|
-
}
|
|
68
|
-
connectedCallback() {
|
|
69
|
-
this._render(), new MutationObserver((e, t) => {
|
|
70
|
-
e.forEach((e) => {
|
|
71
|
-
if (e.type === "childList") {
|
|
72
|
-
if (this._audioInitialized) return;
|
|
73
|
-
let e = this.querySelector("audio"), n = e && e.closest("#preview-prompt");
|
|
74
|
-
if (!this._model || !this._model.autoplayAudioEnabled || e && !n || !e) return;
|
|
75
|
-
let r = this._createAudioInfoToast(), i = this.querySelector("#main-container"), a = () => {
|
|
76
|
-
this.querySelector("#play-audio-info") && (e.play(), i.removeChild(r)), document.removeEventListener("click", a);
|
|
77
|
-
};
|
|
78
|
-
setTimeout(() => {
|
|
79
|
-
e.paused && !this.querySelector("#play-audio-info") ? (i.appendChild(r), document.addEventListener("click", a)) : document.removeEventListener("click", a);
|
|
80
|
-
}, 500);
|
|
81
|
-
let o = () => {
|
|
82
|
-
this._session.audioStartTime = this._session.audioStartTime || (/* @__PURE__ */ new Date()).getTime();
|
|
83
|
-
let t = this.querySelector("#play-audio-info");
|
|
84
|
-
t && i.removeChild(t), e.removeEventListener("playing", o);
|
|
85
|
-
};
|
|
86
|
-
e.addEventListener("playing", o);
|
|
87
|
-
let s = () => {
|
|
88
|
-
this._session.audioEndTime = this._session.audioEndTime || (/* @__PURE__ */ new Date()).getTime();
|
|
89
|
-
let { audioStartTime: t, audioEndTime: n, waitTime: r } = this._session;
|
|
90
|
-
!r && t && n && (this._session.waitTime = n - t), this.audioComplete = !0, this.dispatchChangedEvent(), e.removeEventListener("ended", s);
|
|
91
|
-
};
|
|
92
|
-
e.addEventListener("ended", s), this._audio = e, this._handlePlaying = o, this._handleEnded = s, this._enableAudio = a, this._audioInitialized = !0, t.disconnect();
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}).observe(this, {
|
|
96
|
-
childList: !0,
|
|
97
|
-
subtree: !0
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
disconnectedCallback() {
|
|
101
|
-
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();
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
//#endregion
|
|
105
|
-
export { h as default, m as isComplete };
|
package/dist/delivery/main.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/drag-in-the-blank/src/main.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
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
export declare class Main extends React.Component {
|
|
12
|
-
static propTypes: {
|
|
13
|
-
model: PropTypes.Requireable<object>;
|
|
14
|
-
value: PropTypes.Requireable<object>;
|
|
15
|
-
feedback: PropTypes.Requireable<object>;
|
|
16
|
-
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
17
|
-
};
|
|
18
|
-
static defaultProps: {
|
|
19
|
-
value: {};
|
|
20
|
-
};
|
|
21
|
-
state: {
|
|
22
|
-
showCorrectAnswer: boolean;
|
|
23
|
-
};
|
|
24
|
-
toggleShowCorrect: any;
|
|
25
|
-
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
26
|
-
render(): React.JSX.Element;
|
|
27
|
-
}
|
|
28
|
-
export default Main;
|
package/dist/delivery/main.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import e from "react";
|
|
2
|
-
import * as t from "@pie-lib/render-ui";
|
|
3
|
-
import { Collapsible as n, PreviewPrompt as r, UiLayout as i, color as a, hasMedia as o, hasText as s } from "@pie-lib/render-ui";
|
|
4
|
-
import c from "prop-types";
|
|
5
|
-
import l from "@pie-lib/correct-answer-toggle";
|
|
6
|
-
import { DragInTheBlank as u } from "@pie-lib/mask-markup";
|
|
7
|
-
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
8
|
-
import { styled as p } from "@mui/material/styles";
|
|
9
|
-
//#region src/delivery/main.tsx
|
|
10
|
-
function m(e) {
|
|
11
|
-
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
12
|
-
}
|
|
13
|
-
function h(e, t) {
|
|
14
|
-
return !e || m(e) ? e : m(e.default) ? e.default : t && m(e[t]) ? e[t] : t && m(e[t]?.default) ? e[t].default : e;
|
|
15
|
-
}
|
|
16
|
-
var g = h(i, "UiLayout") || h(x.UiLayout, "UiLayout"), _ = h(r, "PreviewPrompt") || h(x.PreviewPrompt, "PreviewPrompt"), v = h(n, "Collapsible") || h(x.Collapsible, "Collapsible"), y = t, b = y.default, x = b && typeof b == "object" ? b : y, S = p(g)({
|
|
17
|
-
color: a.text(),
|
|
18
|
-
backgroundColor: a.background(),
|
|
19
|
-
"& tr > td": { color: a.text() },
|
|
20
|
-
position: "relative"
|
|
21
|
-
}), C = p(v)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), w = p(v)(({ theme: e }) => ({ marginTop: e.spacing(2) })), T = class extends e.Component {
|
|
22
|
-
static propTypes = {
|
|
23
|
-
model: c.object,
|
|
24
|
-
value: c.object,
|
|
25
|
-
feedback: c.object,
|
|
26
|
-
onChange: c.func
|
|
27
|
-
};
|
|
28
|
-
static defaultProps = { value: {} };
|
|
29
|
-
state = { showCorrectAnswer: !1 };
|
|
30
|
-
toggleShowCorrect = () => {
|
|
31
|
-
this.setState({ showCorrectAnswer: !this.state.showCorrectAnswer });
|
|
32
|
-
};
|
|
33
|
-
UNSAFE_componentWillReceiveProps(e) {
|
|
34
|
-
let { model: t } = e;
|
|
35
|
-
t && !t.correctResponse && this.state.showCorrectAnswer !== !1 && this.setState({ showCorrectAnswer: !1 });
|
|
36
|
-
}
|
|
37
|
-
render() {
|
|
38
|
-
let { showCorrectAnswer: e } = this.state, { model: t, onChange: n, value: r } = this.props, { extraCSSRules: i, prompt: a, mode: c, language: p, fontSizeFactor: m, autoplayAudioEnabled: h, customAudioButton: g } = t, v = {
|
|
39
|
-
...t,
|
|
40
|
-
value: r
|
|
41
|
-
}, y = c === "evaluate", b = t.rationale && (s(t.rationale) || o(t.rationale));
|
|
42
|
-
return /* @__PURE__ */ f(S, {
|
|
43
|
-
extraCSSRules: i,
|
|
44
|
-
id: "main-container",
|
|
45
|
-
fontSizeFactor: m,
|
|
46
|
-
children: [
|
|
47
|
-
t.teacherInstructions && (s(t.teacherInstructions) || o(t.teacherInstructions)) && /* @__PURE__ */ d(C, {
|
|
48
|
-
labels: {
|
|
49
|
-
hidden: "Show Teacher Instructions",
|
|
50
|
-
visible: "Hide Teacher Instructions"
|
|
51
|
-
},
|
|
52
|
-
children: /* @__PURE__ */ d(_, { prompt: t.teacherInstructions })
|
|
53
|
-
}),
|
|
54
|
-
a && /* @__PURE__ */ d(_, {
|
|
55
|
-
className: "prompt",
|
|
56
|
-
prompt: a,
|
|
57
|
-
autoplayAudioEnabled: h,
|
|
58
|
-
customAudioButton: g
|
|
59
|
-
}),
|
|
60
|
-
/* @__PURE__ */ d(l, {
|
|
61
|
-
show: y,
|
|
62
|
-
toggled: e,
|
|
63
|
-
onToggle: this.toggleShowCorrect,
|
|
64
|
-
language: p
|
|
65
|
-
}),
|
|
66
|
-
/* @__PURE__ */ d(u, {
|
|
67
|
-
...v,
|
|
68
|
-
onChange: n,
|
|
69
|
-
showCorrectAnswer: e
|
|
70
|
-
}),
|
|
71
|
-
b && /* @__PURE__ */ d(w, {
|
|
72
|
-
labels: {
|
|
73
|
-
hidden: "Show Rationale",
|
|
74
|
-
visible: "Hide Rationale"
|
|
75
|
-
},
|
|
76
|
-
children: /* @__PURE__ */ d(_, { prompt: t.rationale })
|
|
77
|
-
})
|
|
78
|
-
]
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
//#endregion
|
|
83
|
-
export { T as default };
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './delivery/index.js';
|
package/dist/index.iife.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* IIFE entry point for drag-in-the-blank element
|
|
3
|
-
* This file is only used for IIFE builds and includes auto-registration
|
|
4
|
-
*
|
|
5
|
-
* @sync-generated - Auto-generated during sync from pie-elements
|
|
6
|
-
*/
|
|
7
|
-
import Element from './index.js';
|
|
8
|
-
export default Element;
|