@pie-element/placement-ordering 14.1.2-next.5 → 14.1.3
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 +1312 -0
- package/CHANGELOG.md +2444 -0
- package/LICENSE.md +5 -0
- package/README.md +57 -0
- package/configure/CHANGELOG.json +952 -0
- package/configure/CHANGELOG.md +2139 -0
- package/configure/lib/choice-editor.js +252 -0
- package/configure/lib/choice-editor.js.map +1 -0
- package/configure/lib/choice-tile.js +205 -0
- package/configure/lib/choice-tile.js.map +1 -0
- package/configure/lib/defaults.js +211 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/design.js +427 -0
- package/configure/lib/design.js.map +1 -0
- package/configure/lib/help.js +14 -0
- package/configure/lib/help.js.map +1 -0
- package/configure/lib/index.js +155 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/utils.js +108 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +26 -0
- package/controller/CHANGELOG.json +517 -0
- package/controller/CHANGELOG.md +1518 -0
- package/controller/lib/defaults.js +29 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +285 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/scoring.js +109 -0
- package/controller/lib/scoring.js.map +1 -0
- package/controller/package.json +15 -0
- package/docs/config-schema.json +2964 -0
- package/docs/config-schema.json.md +2190 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +50 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +7 -0
- package/docs/pie-schema.json +1613 -0
- package/docs/pie-schema.json.md +973 -0
- package/icon.png +0 -0
- package/lib/index.js +122 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +32 -0
- package/lib/main.js.map +1 -0
- package/lib/ordering.js +165 -0
- package/lib/ordering.js.map +1 -0
- package/lib/placement-ordering.js +419 -0
- package/lib/placement-ordering.js.map +1 -0
- package/lib/tile.js +259 -0
- package/lib/tile.js.map +1 -0
- package/lib/tiler.js +165 -0
- package/lib/tiler.js.map +1 -0
- package/lib/utils.js +18 -0
- package/lib/utils.js.map +1 -0
- package/package.json +21 -88
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/choice-editor.d.ts +0 -39
- package/dist/author/choice-editor.js +0 -156
- package/dist/author/choice-tile.d.ts +0 -40
- package/dist/author/choice-tile.js +0 -132
- package/dist/author/defaults.d.ts +0 -213
- package/dist/author/defaults.js +0 -159
- package/dist/author/design.d.ts +0 -21
- package/dist/author/design.js +0 -273
- package/dist/author/help.d.ts +0 -11
- package/dist/author/index.d.ts +0 -45
- package/dist/author/index.js +0 -85
- package/dist/author/utils.d.ts +0 -15
- package/dist/author/utils.js +0 -62
- package/dist/browser/author/index.js +0 -46600
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/browser-DHPggtaA.js +0 -376
- package/dist/browser/browser-DHPggtaA.js.map +0 -1
- package/dist/browser/controller/index.js +0 -242
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -1035
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/dist-D9ARZhQk.js +0 -1426
- package/dist/browser/dist-D9ARZhQk.js.map +0 -1
- package/dist/browser/drag-provider-C1slTlsc.js +0 -10555
- package/dist/browser/drag-provider-C1slTlsc.js.map +0 -1
- package/dist/browser/placement-ordering.css +0 -2
- package/dist/controller/defaults.d.ts +0 -31
- package/dist/controller/defaults.js +0 -25
- package/dist/controller/index.d.ts +0 -29
- package/dist/controller/index.js +0 -123
- package/dist/controller/scoring.d.ts +0 -27
- package/dist/controller/scoring.js +0 -30
- package/dist/delivery/index.d.ts +0 -26
- package/dist/delivery/index.js +0 -70
- package/dist/delivery/main.d.ts +0 -19
- package/dist/delivery/main.js +0 -22
- package/dist/delivery/ordering.d.ts +0 -18
- package/dist/delivery/ordering.js +0 -93
- package/dist/delivery/placement-ordering.d.ts +0 -28
- package/dist/delivery/placement-ordering.js +0 -213
- package/dist/delivery/tile.d.ts +0 -28
- package/dist/delivery/tile.js +0 -165
- package/dist/delivery/tiler.d.ts +0 -42
- package/dist/delivery/tiler.js +0 -89
- package/dist/delivery/utils.d.ts +0 -9
- package/dist/delivery/utils.js +0 -8
- 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,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/placement-ordering/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
|
-
choiceLabel: string;
|
|
11
|
-
choiceLabelEnabled: boolean;
|
|
12
|
-
choices: never[];
|
|
13
|
-
correctResponse: never[];
|
|
14
|
-
feedbackEnabled: boolean;
|
|
15
|
-
numberedGuides: boolean;
|
|
16
|
-
orientation: string;
|
|
17
|
-
partialScoring: boolean;
|
|
18
|
-
placementArea: boolean;
|
|
19
|
-
prompt: string;
|
|
20
|
-
promptEnabled: boolean;
|
|
21
|
-
rationale: string;
|
|
22
|
-
rationaleEnabled: boolean;
|
|
23
|
-
removeTilesAfterPlacing: boolean;
|
|
24
|
-
scoringType: string;
|
|
25
|
-
studentInstructionsEnabled: boolean;
|
|
26
|
-
targetLabel: string;
|
|
27
|
-
teacherInstructions: string;
|
|
28
|
-
teacherInstructionsEnabled: boolean;
|
|
29
|
-
toolbarEditorPosition: string;
|
|
30
|
-
};
|
|
31
|
-
export default _default;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//#region src/controller/defaults.ts
|
|
2
|
-
var e = {
|
|
3
|
-
choiceLabel: "",
|
|
4
|
-
choiceLabelEnabled: !0,
|
|
5
|
-
choices: [],
|
|
6
|
-
correctResponse: [],
|
|
7
|
-
feedbackEnabled: !1,
|
|
8
|
-
numberedGuides: !1,
|
|
9
|
-
orientation: "vertical",
|
|
10
|
-
partialScoring: !0,
|
|
11
|
-
placementArea: !1,
|
|
12
|
-
prompt: "",
|
|
13
|
-
promptEnabled: !0,
|
|
14
|
-
rationale: "",
|
|
15
|
-
rationaleEnabled: !0,
|
|
16
|
-
removeTilesAfterPlacing: !0,
|
|
17
|
-
scoringType: "auto",
|
|
18
|
-
studentInstructionsEnabled: !0,
|
|
19
|
-
targetLabel: "",
|
|
20
|
-
teacherInstructions: "",
|
|
21
|
-
teacherInstructionsEnabled: !0,
|
|
22
|
-
toolbarEditorPosition: "bottom"
|
|
23
|
-
};
|
|
24
|
-
//#endregion
|
|
25
|
-
export { e as default };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/placement-ordering/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 questionError: () => Error;
|
|
10
|
-
/**
|
|
11
|
-
* Generates detailed trace log for placement-ordering scoring evaluation
|
|
12
|
-
* @param {Object} question - the question model
|
|
13
|
-
* @param {Object} session - the student session
|
|
14
|
-
* @param {Object} env - the environment
|
|
15
|
-
* @returns {Array<string>} traceLog
|
|
16
|
-
*/
|
|
17
|
-
export declare const getLogTrace: (question: any, session: any, env: any) => string[];
|
|
18
|
-
export declare function outcome(question: any, session: any, env: any): Promise<unknown>;
|
|
19
|
-
export declare function createDefaultModel(model?: {}): Promise<unknown>;
|
|
20
|
-
export declare const normalize: (question: any) => any;
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {*} question
|
|
24
|
-
* @param {*} session
|
|
25
|
-
* @param {*} env
|
|
26
|
-
*/
|
|
27
|
-
export declare function model(question: any, session: any, env: any): Promise<{}>;
|
|
28
|
-
export declare const createCorrectResponseSession: (question: any, env: any) => Promise<unknown>;
|
|
29
|
-
export declare const validate: (model?: {}, config?: {}) => {};
|
package/dist/controller/index.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { flattenCorrect as e, getAllCorrectResponses as t, score as n } from "./scoring.js";
|
|
2
|
-
import r from "./defaults.js";
|
|
3
|
-
import { every as i, isArray as a, isEmpty as o, isEqual as s, map as c, reduce as l } from "@pie-element/shared-lodash";
|
|
4
|
-
import u from "debug";
|
|
5
|
-
import d from "@pie-lib/translator";
|
|
6
|
-
import { getFeedbackForCorrectness as f } from "@pie-element/shared-feedback";
|
|
7
|
-
import { partialScoring as p } from "@pie-element/shared-controller-utils";
|
|
8
|
-
//#region src/controller/index.ts
|
|
9
|
-
var m = u("@pie-element:placement-ordering:controller"), { translator: h } = d, g = () => /* @__PURE__ */ Error("Question is missing required array: correctResponse"), _ = (e, r, i) => {
|
|
10
|
-
let a = [], o = r?.value || [];
|
|
11
|
-
e?.correctResponse;
|
|
12
|
-
let c = e?.placementArea === !0;
|
|
13
|
-
if (!o.length) return c ? a.push("Student did not place any tiles in the target area.") : a.push("Student did not reorder any tiles."), a.push("Final score: 0."), a;
|
|
14
|
-
let l = t(e), u = {
|
|
15
|
-
score: 0,
|
|
16
|
-
response: []
|
|
17
|
-
};
|
|
18
|
-
l.forEach((e) => {
|
|
19
|
-
let t = 0;
|
|
20
|
-
o.forEach((n, r) => {
|
|
21
|
-
e[r] === n && t++;
|
|
22
|
-
}), t > u.score && (u = {
|
|
23
|
-
score: t,
|
|
24
|
-
response: e
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
let d = u.score, f = o.length - d;
|
|
28
|
-
d > 0 && a.push(`${d} tile(s) placed in the correct order.`), f > 0 && a.push(`${f} tile(s) placed in an incorrect order.`), l.some((e) => s(e, o));
|
|
29
|
-
let m = p.enabled(e, i || {});
|
|
30
|
-
m ? (a.push("Score calculated using partial scoring."), a.push("Each tile placed in the correct position contributes to the score.")) : (a.push("Score calculated using all-or-nothing scoring."), c ? a.push("Student must place all tiles in the correct positions within the target area to receive full credit.") : a.push("Student must arrange all tiles in the correct order to receive full credit."));
|
|
31
|
-
let h = n(e, r), g = m ? h : +(h === 1);
|
|
32
|
-
return a.push(`Final score: ${g}.`), a;
|
|
33
|
-
};
|
|
34
|
-
function v(e, t, r) {
|
|
35
|
-
return new Promise((i, a) => {
|
|
36
|
-
if (!t || o(t)) {
|
|
37
|
-
i({
|
|
38
|
-
score: 0,
|
|
39
|
-
empty: !0,
|
|
40
|
-
logTrace: ["Student did not interact with the placement-ordering item."]
|
|
41
|
-
});
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (!e || !e.correctResponse || o(e.correctResponse)) a(g());
|
|
45
|
-
else try {
|
|
46
|
-
let a = n(e, t);
|
|
47
|
-
i({
|
|
48
|
-
score: p.enabled(e, r || {}) ? a : +(a === 1),
|
|
49
|
-
logTrace: _(e, t, r)
|
|
50
|
-
});
|
|
51
|
-
} catch (e) {
|
|
52
|
-
a(e);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function y(e = {}) {
|
|
57
|
-
return new Promise((t) => {
|
|
58
|
-
t({
|
|
59
|
-
...r,
|
|
60
|
-
...e
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
var b = (e) => ({
|
|
65
|
-
...r,
|
|
66
|
-
rationaleEnabled: !0,
|
|
67
|
-
feedbackEnabled: !1,
|
|
68
|
-
promptEnabled: !0,
|
|
69
|
-
teacherInstructionsEnabled: !0,
|
|
70
|
-
studentInstructionsEnabled: !0,
|
|
71
|
-
...e
|
|
72
|
-
});
|
|
73
|
-
async function x(r, o, u) {
|
|
74
|
-
let d = b(r), g = {};
|
|
75
|
-
if (r.alternateResponses && i(r.alternateResponses, a) && (m("Deprecated structure of alternateResponses is in use"), console.error("Deprecated structure of alternateResponses is in use")), g.env = u, g.extraCSSRules = d.extraCSSRules, g.outcomes = [], g.completeLength = (d.correctResponse || []).length, g.choices = (d.choices || []).filter((e) => e.label), g.note = d.note, g.showNote = d.alternateResponses && d.alternateResponses.length > 0, g.language = d.language, m("[model] removing tileSize for the moment."), g.prompt = d.promptEnabled ? d.prompt : null, g.config = {
|
|
76
|
-
orientation: d.orientation || "vertical",
|
|
77
|
-
includeTargets: d.placementArea,
|
|
78
|
-
choiceLabelEnabled: d.choiceLabelEnabled,
|
|
79
|
-
targetLabel: d.targetLabel,
|
|
80
|
-
choiceLabel: d.choiceLabel,
|
|
81
|
-
showOrdering: d.numberedGuides,
|
|
82
|
-
allowSameChoiceInTargets: !d.removeTilesAfterPlacing
|
|
83
|
-
}, g.disabled = u.mode !== "gather", g.note ||= h.t("common:commonCorrectAnswerWithAlternates", { lng: d.language }), u.role === "instructor" && (u.mode === "view" || u.mode === "evaluate") ? (g.rationale = d.rationaleEnabled ? d.rationale : null, g.teacherInstructions = d.teacherInstructionsEnabled ? d.teacherInstructions : null) : (g.rationale = null, g.teacherInstructions = null), u.mode === "evaluate") {
|
|
84
|
-
let i = o && o.value || [], a = t(d), m = a.reduce((e, t) => {
|
|
85
|
-
let n = l(i, (e, n, r) => e + (Array.isArray(t) && t[r] === n ? 1 : 0), 0);
|
|
86
|
-
return n > e.score ? {
|
|
87
|
-
arr: t,
|
|
88
|
-
score: n
|
|
89
|
-
} : e;
|
|
90
|
-
}, {
|
|
91
|
-
arr: [],
|
|
92
|
-
score: 0
|
|
93
|
-
});
|
|
94
|
-
g.outcomes = c(i, (e, t) => ({
|
|
95
|
-
id: e,
|
|
96
|
-
outcome: m.arr[t] === e ? "correct" : "incorrect"
|
|
97
|
-
}));
|
|
98
|
-
let h = a.some((e) => s(e, i)), _ = n(r, o), v = _ === 1, y = !v && p.enabled(d, u || {}) && _ !== 0;
|
|
99
|
-
return g.correctness = v ? "correct" : y ? "partial" : "incorrect", h || (g.correctResponse = e(d)), d.feedback || (d.feedbackEnabled = !1), g.feedback = d.feedbackEnabled ? await f(g.correctness, d.feedback) : void 0, g;
|
|
100
|
-
} else return g;
|
|
101
|
-
}
|
|
102
|
-
var S = (t, n) => new Promise((r) => {
|
|
103
|
-
n.mode !== "evaluate" && n.role === "instructor" ? r({
|
|
104
|
-
id: "1",
|
|
105
|
-
value: e(t)
|
|
106
|
-
}) : r(null);
|
|
107
|
-
}), C = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), w = (e = {}, t = {}) => {
|
|
108
|
-
let { choices: n, correctResponse: r } = e, i = {};
|
|
109
|
-
[
|
|
110
|
-
"teacherInstructions",
|
|
111
|
-
"prompt",
|
|
112
|
-
"rationale"
|
|
113
|
-
].forEach((n) => {
|
|
114
|
-
t[n]?.required && !C(e[n]) && (i[n] = "This field is required.");
|
|
115
|
-
});
|
|
116
|
-
let a = [...n || []].reverse(), c = {};
|
|
117
|
-
return a.forEach((e, t) => {
|
|
118
|
-
let { id: n, label: r } = e;
|
|
119
|
-
C(r) ? a.slice(t + 1).some((e) => e.label === r) && (c[n] = "Content should be unique.") : c[n] = "Content should not be empty.";
|
|
120
|
-
}), s((n || []).map((e) => e.id), (r || []).map((e) => e.id || e)) && (i.orderError = "The correct ordering should not be identical to the initial ordering."), o(c) || (i.choicesErrors = c), i;
|
|
121
|
-
};
|
|
122
|
-
//#endregion
|
|
123
|
-
export { S as createCorrectResponseSession, y as createDefaultModel, _ as getLogTrace, x as model, b as normalize, v as outcome, g as questionError, w as validate };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/placement-ordering/controller/src/scoring.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 illegalArgumentError: (answer: any) => Error;
|
|
10
|
-
export declare const pairwiseCombinationScore: (correct: any, answer: any, opts: any) => number;
|
|
11
|
-
/**
|
|
12
|
-
* Flattens the correctResponse into an array of ordered identifiers representing the
|
|
13
|
-
* correct response.
|
|
14
|
-
*/
|
|
15
|
-
export declare const flattenCorrect: (question: any) => any;
|
|
16
|
-
/**
|
|
17
|
-
* Returns all correct responses for this question
|
|
18
|
-
* @param question - array
|
|
19
|
-
*/
|
|
20
|
-
export declare const getAllCorrectResponses: (question: any) => any[];
|
|
21
|
-
/**
|
|
22
|
-
* Returns the score for a session. If weighted scoring is present in the correctResponse
|
|
23
|
-
* field for the question, this will be used. If partial scoring is present in the question
|
|
24
|
-
* model, this will be used. Otherwise the default scoring mechanism (0 for any incorrect, 1
|
|
25
|
-
* for all correct) will be used.
|
|
26
|
-
*/
|
|
27
|
-
export declare const score: (question: any, session: any) => number;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { differenceWith as e, isEqual as t, uniq as n } from "@pie-element/shared-lodash";
|
|
2
|
-
import r from "debug";
|
|
3
|
-
import { combination as i } from "js-combinatorics";
|
|
4
|
-
//#region src/controller/scoring.ts
|
|
5
|
-
var a = r("pie-elements:placement-ordering:controller"), o = (e) => /* @__PURE__ */ Error(`Cant score answer: ${e} it has duplicates and allowDuplicates is false`), s = (r, s, c) => {
|
|
6
|
-
if (c = {
|
|
7
|
-
allowDuplicates: !1,
|
|
8
|
-
orderMustBeComplete: !1,
|
|
9
|
-
...c
|
|
10
|
-
}, !c.allowDuplicates && !t(n(r), r)) throw o(s);
|
|
11
|
-
if (c.allowDuplicates === !1 && s.length !== n(s).length) return 0;
|
|
12
|
-
if (s = c.allowDuplicates === !1 ? n(s) : s, a("answer:", s), !Array.isArray(r) || r.length === 0) throw Error("correct must be non empty an array");
|
|
13
|
-
if (r.length === 1) return +!!t(r, s);
|
|
14
|
-
if (!Array.isArray(s) || s.length < 2 || s.length > r.length || r.length !== s.length && c.orderMustBeComplete) return 0;
|
|
15
|
-
let l = i(r, 2).toArray(), u = i(s, 2).toArray(), d = e(u, l, t), f = l.length - u.length, p = l.length, m = ((p - d.length - f) / p).toFixed(2);
|
|
16
|
-
return parseFloat(m);
|
|
17
|
-
}, c = (e) => e.correctResponse ? e.correctResponse.map((e) => e && e.id ? e.id : e) : [], l = (e) => {
|
|
18
|
-
let t = (e.alternateResponses || []).map((e) => Array.isArray(e) ? e : e.response).filter((e) => e !== void 0);
|
|
19
|
-
return [c(e), ...t];
|
|
20
|
-
}, u = (e, t) => {
|
|
21
|
-
let { value: n } = t || {};
|
|
22
|
-
if (!n) return 0;
|
|
23
|
-
let r = l(e), i = (e.configure && e.configure.removeTilesAfterPlacing) !== !1, a = 0;
|
|
24
|
-
return r.forEach((e) => {
|
|
25
|
-
let t = s(e, n, { allowDuplicates: i });
|
|
26
|
-
t >= a && (a = t);
|
|
27
|
-
}), a;
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
30
|
-
export { c as flattenCorrect, l as getAllCorrectResponses, u as score };
|
package/dist/delivery/index.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/placement-ordering/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 isValidSession: ({ model, session }: {
|
|
10
|
-
model: any;
|
|
11
|
-
session: any;
|
|
12
|
-
}) => any;
|
|
13
|
-
export default class Ordering extends HTMLElement {
|
|
14
|
-
constructor();
|
|
15
|
-
_scheduleMathRender: any;
|
|
16
|
-
_initMathObserver(): void;
|
|
17
|
-
_disconnectMathObserver(): void;
|
|
18
|
-
isComplete: (value: any) => any;
|
|
19
|
-
sessionChange: any;
|
|
20
|
-
set model(newModel: any);
|
|
21
|
-
set session(newSession: any);
|
|
22
|
-
get session(): any;
|
|
23
|
-
render(): void;
|
|
24
|
-
connectedCallback(): void;
|
|
25
|
-
disconnectedCallback(): void;
|
|
26
|
-
}
|
package/dist/delivery/index.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import e from "./main.js";
|
|
2
|
-
import t from "react";
|
|
3
|
-
import { createRoot as n } from "react-dom/client";
|
|
4
|
-
import { compact as r } from "@pie-element/shared-lodash";
|
|
5
|
-
import i from "debug";
|
|
6
|
-
import { renderMath as a } from "@pie-element/shared-math-rendering-mathjax";
|
|
7
|
-
import { SessionChangedEvent as o } from "@pie-element/shared-player-events";
|
|
8
|
-
//#region src/delivery/index.ts
|
|
9
|
-
var s = i("pie-elements:placement-ordering"), c = ({ model: e, session: t }) => {
|
|
10
|
-
let { config: n } = e, i = (t && r(t.value) || []).length === e.choices.length;
|
|
11
|
-
return n.includeTargets || i;
|
|
12
|
-
}, l = class extends HTMLElement {
|
|
13
|
-
constructor() {
|
|
14
|
-
super(), this._root = null, this._mathObserver = null, this._mathRenderPending = !1;
|
|
15
|
-
}
|
|
16
|
-
_scheduleMathRender = () => {
|
|
17
|
-
this._mathRenderPending || (this._mathRenderPending = !0, requestAnimationFrame(() => {
|
|
18
|
-
this._mathObserver && this._mathObserver.disconnect(), a(this), this._mathRenderPending = !1, setTimeout(() => {
|
|
19
|
-
this._mathObserver && this._mathObserver.observe(this, {
|
|
20
|
-
childList: !0,
|
|
21
|
-
subtree: !0
|
|
22
|
-
});
|
|
23
|
-
}, 50);
|
|
24
|
-
}));
|
|
25
|
-
};
|
|
26
|
-
_initMathObserver() {
|
|
27
|
-
this._mathObserver || (this._mathObserver = new MutationObserver(this._scheduleMathRender), this._mathObserver.observe(this, {
|
|
28
|
-
childList: !0,
|
|
29
|
-
subtree: !0
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
_disconnectMathObserver() {
|
|
33
|
-
this._mathObserver &&= (this._mathObserver.disconnect(), null);
|
|
34
|
-
}
|
|
35
|
-
isComplete = (e) => e && r(e).length === this._model.completeLength;
|
|
36
|
-
sessionChange = (e) => {
|
|
37
|
-
this._session.value = e.value, this.render(), this.dispatchEvent(new o(this.tagName.toLowerCase(), this._session && this.isComplete(this._session.value)));
|
|
38
|
-
};
|
|
39
|
-
set model(e) {
|
|
40
|
-
this._model = e, this.render(), this.dispatchEvent(new CustomEvent("model-set", {
|
|
41
|
-
bubbles: !0,
|
|
42
|
-
detail: { complete: !1 }
|
|
43
|
-
}));
|
|
44
|
-
}
|
|
45
|
-
set session(e) {
|
|
46
|
-
this._session = e, this.render();
|
|
47
|
-
}
|
|
48
|
-
get session() {
|
|
49
|
-
return this._session;
|
|
50
|
-
}
|
|
51
|
-
render() {
|
|
52
|
-
if (this._model && this._session) {
|
|
53
|
-
s("[render] session: ", this._session.value), s("[render] model: ", this._model), this._initMathObserver();
|
|
54
|
-
let r = t.createElement(e, {
|
|
55
|
-
model: this._model,
|
|
56
|
-
session: this._session,
|
|
57
|
-
onSessionChange: this.sessionChange
|
|
58
|
-
});
|
|
59
|
-
this._root ||= n(this), this._root.render(r);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
connectedCallback() {
|
|
63
|
-
this._initMathObserver();
|
|
64
|
-
}
|
|
65
|
-
disconnectedCallback() {
|
|
66
|
-
this._disconnectMathObserver(), this._root && this._root.unmount();
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
//#endregion
|
|
70
|
-
export { l as default, c as isValidSession };
|
package/dist/delivery/main.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/placement-ordering/src/main.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 class Main extends React.Component {
|
|
12
|
-
static propTypes: {
|
|
13
|
-
model: PropTypes.Validator<object>;
|
|
14
|
-
session: PropTypes.Requireable<object>;
|
|
15
|
-
onSessionChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
16
|
-
};
|
|
17
|
-
render(): React.JSX.Element;
|
|
18
|
-
}
|
|
19
|
-
export default Main;
|
package/dist/delivery/main.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import e from "./placement-ordering.js";
|
|
2
|
-
import t from "react";
|
|
3
|
-
import n from "prop-types";
|
|
4
|
-
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
-
//#region src/delivery/main.tsx
|
|
6
|
-
var i = class extends t.Component {
|
|
7
|
-
static propTypes = {
|
|
8
|
-
model: n.object.isRequired,
|
|
9
|
-
session: n.oneOfType([n.array.isRequired, n.object.isRequired]),
|
|
10
|
-
onSessionChange: n.func.isRequired
|
|
11
|
-
};
|
|
12
|
-
render() {
|
|
13
|
-
let { model: t, session: n, onSessionChange: i } = this.props;
|
|
14
|
-
return /* @__PURE__ */ r(e, {
|
|
15
|
-
model: t,
|
|
16
|
-
session: n,
|
|
17
|
-
onSessionChange: i
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
//#endregion
|
|
22
|
-
export { i as default };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/placement-ordering/src/ordering.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 push: (arr: any, fromIndex: any, toIndex: any) => any[];
|
|
10
|
-
export declare const swap: (arr: any, fromIndex: any, toIndex: any) => any;
|
|
11
|
-
export declare function buildState(choices: any, response: any, outcomes: any, opts: any): {
|
|
12
|
-
choices: any;
|
|
13
|
-
response: any;
|
|
14
|
-
opts: any;
|
|
15
|
-
outcomes: any;
|
|
16
|
-
tiles: any;
|
|
17
|
-
};
|
|
18
|
-
export declare function reducer(action: any, state: any): any;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { assign as e, cloneDeep as t, isEmpty as n, map as r } from "@pie-element/shared-lodash";
|
|
2
|
-
import i from "debug";
|
|
3
|
-
//#region src/delivery/ordering.ts
|
|
4
|
-
var a = i("pie-elements:placement-ordering:ordering"), o = (e, t, n) => {
|
|
5
|
-
let r = e.find((e, n) => n === t), i = e.filter((e, n) => n !== t);
|
|
6
|
-
return [
|
|
7
|
-
...i.slice(0, n),
|
|
8
|
-
r,
|
|
9
|
-
...i.slice(n)
|
|
10
|
-
];
|
|
11
|
-
}, s = (e, n, r) => {
|
|
12
|
-
if (a("[swap]", e, n, r), !e || e.length <= 1 || n === void 0 || r === void 0) throw Error(`swap requires a non-empty array, fromIndex, toIndex: ${e}, ${n} ${r}`);
|
|
13
|
-
let i = t(e), o = e[r];
|
|
14
|
-
return i[r] = i[n], i[n] = o, i;
|
|
15
|
-
};
|
|
16
|
-
function c(e, n) {
|
|
17
|
-
let r = t(e.response);
|
|
18
|
-
if (r[n.index] === n.id) r[n.index] = void 0;
|
|
19
|
-
else throw Error(`Tried to remove from index: ${n.index}, but the id doesn't match: array: ${r}, target: ${n.id}`);
|
|
20
|
-
return r;
|
|
21
|
-
}
|
|
22
|
-
function l(e, n, r) {
|
|
23
|
-
let { response: i, opts: c } = e, l = t(i);
|
|
24
|
-
if (c.includeTargets) return n.type === "choice" && r.type === "target" ? (l[r.index] = n.id, l) : n.type === "target" && r.type === "choice" ? (l[n.index] = void 0, l) : n.type === "target" && r.type === "target" ? s(i, n.index, r.index) : (a("do nothing to the response"), i);
|
|
25
|
-
{
|
|
26
|
-
let t = e.response.findIndex((e) => e !== void 0 && e === n.id), i = e.response.findIndex((e) => e !== void 0 && e === r.id);
|
|
27
|
-
return a("fromIndex: ", t, "toIndex:", i), o(e.response, t, i);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function u(e, t, n, r) {
|
|
31
|
-
if (r.includeTargets) {
|
|
32
|
-
let i = [];
|
|
33
|
-
for (let r = 0; r < t.length; r++) {
|
|
34
|
-
let a = t[r], o = e.find((e) => a != null && e.id === a), s = n[r], c = Object.assign({
|
|
35
|
-
type: "target",
|
|
36
|
-
index: r,
|
|
37
|
-
empty: o === void 0
|
|
38
|
-
}, o, s, { draggable: o !== void 0 });
|
|
39
|
-
i.push(c);
|
|
40
|
-
}
|
|
41
|
-
return e.map((e) => t.indexOf(e.id) !== -1 && !r.allowSameChoiceInTargets ? {
|
|
42
|
-
type: "choice",
|
|
43
|
-
empty: !0,
|
|
44
|
-
droppable: !0,
|
|
45
|
-
draggable: !1
|
|
46
|
-
} : Object.assign({}, e, {
|
|
47
|
-
type: "choice",
|
|
48
|
-
droppable: !1,
|
|
49
|
-
draggable: !0
|
|
50
|
-
})).concat(i);
|
|
51
|
-
} else return t.reduce((t, r, i) => {
|
|
52
|
-
let a = Object.assign({
|
|
53
|
-
type: "empty",
|
|
54
|
-
draggable: !1,
|
|
55
|
-
droppable: !0
|
|
56
|
-
}, e.find((e) => e.id === r), n[i]), o = Object.assign({
|
|
57
|
-
type: "choice",
|
|
58
|
-
draggable: !0,
|
|
59
|
-
droppable: !0
|
|
60
|
-
}, e.find((e) => e.id === r), n[i]);
|
|
61
|
-
return i === 0 && t.push(a), t.push(o, a), t;
|
|
62
|
-
}, []);
|
|
63
|
-
}
|
|
64
|
-
function d(t, i, a, o) {
|
|
65
|
-
return o = e({ includeTargets: !0 }, o), a ||= [], i = !i || n(i) ? o.includeTargets ? Array(t.length) : r(t, (e) => e.id) : i, {
|
|
66
|
-
choices: t,
|
|
67
|
-
response: i,
|
|
68
|
-
opts: o,
|
|
69
|
-
outcomes: a,
|
|
70
|
-
tiles: u(t, i, a, o)
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function f(e, t) {
|
|
74
|
-
switch (e.type) {
|
|
75
|
-
case "move": {
|
|
76
|
-
let { from: n, to: r } = e, i = l(t, n, r), a = u(t.choices, i, t.outcomes, t.opts);
|
|
77
|
-
return Object.assign({}, t, {
|
|
78
|
-
response: i,
|
|
79
|
-
tiles: a
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
case "remove": {
|
|
83
|
-
let { target: n } = e, r = c(t, n), i = u(t.choices, r, t.outcomes, t.opts);
|
|
84
|
-
return Object.assign({}, t, {
|
|
85
|
-
response: r,
|
|
86
|
-
tiles: i
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return t;
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
93
|
-
export { d as buildState, f as reducer };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/placement-ordering/src/placement-ordering.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
|
-
export declare class PlacementOrdering extends React.Component {
|
|
12
|
-
static propTypes: {
|
|
13
|
-
onSessionChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
14
|
-
model: PropTypes.Validator<object>;
|
|
15
|
-
session: PropTypes.Requireable<object>;
|
|
16
|
-
};
|
|
17
|
-
constructor(props: any);
|
|
18
|
-
toggleCorrect: (showingCorrect: any) => void;
|
|
19
|
-
componentDidUpdate(): void;
|
|
20
|
-
validateSession: any;
|
|
21
|
-
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
22
|
-
onDropChoice: any;
|
|
23
|
-
onRemoveChoice: any;
|
|
24
|
-
createOrdering: any;
|
|
25
|
-
onDragEnd: any;
|
|
26
|
-
render(): React.JSX.Element;
|
|
27
|
-
}
|
|
28
|
-
export default PlacementOrdering;
|