@pie-element/ebsr 14.2.2-next.5 → 14.2.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 +1547 -0
- package/CHANGELOG.md +2297 -0
- package/LICENSE.md +5 -0
- package/README.md +62 -0
- package/configure/CHANGELOG.json +992 -0
- package/configure/CHANGELOG.md +2160 -0
- package/configure/lib/defaults.js +229 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +154 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/main.js +222 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/package.json +23 -0
- package/configure/src/__tests__/index.test.js +492 -0
- package/configure/src/defaults.js +173 -0
- package/configure/src/index.js +174 -0
- package/configure/src/main.jsx +235 -0
- package/controller/CHANGELOG.json +552 -0
- package/controller/CHANGELOG.md +1286 -0
- package/controller/lib/defaults.js +31 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +448 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/utils.js +18 -0
- package/controller/lib/utils.js.map +1 -0
- package/controller/package.json +18 -0
- package/controller/src/__tests__/index.test.js +591 -0
- package/controller/src/__tests__/utils.test.js +48 -0
- package/controller/src/defaults.js +25 -0
- package/controller/src/index.js +442 -0
- package/controller/src/utils.js +18 -0
- package/docs/config-schema.json +5787 -0
- package/docs/config-schema.json.md +4278 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +52 -0
- package/docs/demo/index.html +2 -0
- package/docs/demo/session.js +14 -0
- package/docs/pie-schema.json +2911 -0
- package/docs/pie-schema.json.md +2142 -0
- package/ebsr.png +0 -0
- package/lib/index.js +207 -0
- package/lib/index.js.map +1 -0
- package/lib/print.js +186 -0
- package/lib/print.js.map +1 -0
- package/module/configure.js +1 -0
- package/module/controller.js +5664 -0
- package/module/demo.js +77 -0
- package/module/element.js +1 -0
- package/module/index.html +21 -0
- package/module/manifest.json +14 -0
- package/module/print-demo.js +115 -0
- package/module/print.html +18 -0
- package/module/print.js +1 -0
- package/package.json +19 -88
- package/src/__tests__/index.test.js +129 -0
- package/src/index.js +222 -0
- package/src/print.js +207 -0
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/defaults.d.ts +0 -348
- package/dist/author/defaults.js +0 -161
- package/dist/author/index.d.ts +0 -34
- package/dist/author/index.js +0 -80
- package/dist/author/main.d.ts +0 -23
- package/dist/author/main.js +0 -123
- package/dist/browser/author/index.js +0 -45985
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/controller/index.js +0 -257
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -133
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/delivery-BVQ60bNy.js +0 -1282
- package/dist/browser/delivery-BVQ60bNy.js.map +0 -1
- package/dist/browser/dist-BcIm7NXG.js +0 -111
- package/dist/browser/dist-BcIm7NXG.js.map +0 -1
- package/dist/browser/dist-D9ARZhQk.js +0 -1426
- package/dist/browser/dist-D9ARZhQk.js.map +0 -1
- package/dist/browser/ebsr.css +0 -2
- package/dist/browser/print/index.js +0 -107
- package/dist/browser/print/index.js.map +0 -1
- package/dist/browser/private-tags-DHmoD865.js +0 -9579
- package/dist/browser/private-tags-DHmoD865.js.map +0 -1
- package/dist/controller/defaults.d.ts +0 -15
- package/dist/controller/defaults.js +0 -26
- package/dist/controller/index.d.ts +0 -42
- package/dist/controller/index.js +0 -185
- package/dist/controller/utils.d.ts +0 -10
- package/dist/controller/utils.js +0 -8
- package/dist/delivery/index.d.ts +0 -26
- package/dist/delivery/index.js +0 -133
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -165
- package/dist/index.js +0 -2
- package/dist/print/index.d.ts +0 -25
- package/dist/print/index.js +0 -107
- package/dist/private-tags.d.ts +0 -2
- package/dist/private-tags.js +0 -3
- package/dist/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/ebsr/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
|
-
partLabels: boolean;
|
|
11
|
-
partLabelType: string;
|
|
12
|
-
partA: any;
|
|
13
|
-
partB: any;
|
|
14
|
-
};
|
|
15
|
-
export default _default;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
//#region src/controller/defaults.ts
|
|
2
|
-
var e = (e) => ({
|
|
3
|
-
choiceMode: "radio",
|
|
4
|
-
choicePrefix: "letters",
|
|
5
|
-
choices: [],
|
|
6
|
-
choicesLayout: "vertical",
|
|
7
|
-
feedbackEnabled: !1,
|
|
8
|
-
gridColumns: 2,
|
|
9
|
-
prompt: "",
|
|
10
|
-
promptEnabled: !0,
|
|
11
|
-
rationale: "",
|
|
12
|
-
rationaleEnabled: !0,
|
|
13
|
-
spellCheckEnabled: !0,
|
|
14
|
-
studentInstructionsEnabled: !0,
|
|
15
|
-
teacherInstructions: "",
|
|
16
|
-
teacherInstructionsEnabled: !0,
|
|
17
|
-
toolbarEditorPosition: "bottom",
|
|
18
|
-
...e
|
|
19
|
-
}), t = {
|
|
20
|
-
partLabels: !0,
|
|
21
|
-
partLabelType: "Letters",
|
|
22
|
-
partA: e(),
|
|
23
|
-
partB: e()
|
|
24
|
-
};
|
|
25
|
-
//#endregion
|
|
26
|
-
export { t as default };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/ebsr/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: ({ partA, partB, language, ...question }: {
|
|
10
|
-
[x: string]: any;
|
|
11
|
-
partA?: {} | undefined;
|
|
12
|
-
partB?: {} | undefined;
|
|
13
|
-
language: any;
|
|
14
|
-
}) => {
|
|
15
|
-
partA: any;
|
|
16
|
-
partB: any;
|
|
17
|
-
partLabels: boolean;
|
|
18
|
-
partLabelType: string;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @param {*} question
|
|
23
|
-
* @param {*} session
|
|
24
|
-
* @param {*} env
|
|
25
|
-
* @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
|
|
26
|
-
*/
|
|
27
|
-
export declare function model(question: any, session: any, env: any, updateSession: any): Promise<unknown>;
|
|
28
|
-
export declare const createDefaultModel: (model?: {}) => Promise<unknown>;
|
|
29
|
-
/**
|
|
30
|
-
* Generates detailed trace log for math-templated scoring evaluation
|
|
31
|
-
* @param {Object} question
|
|
32
|
-
* @param {Object} session
|
|
33
|
-
* @param {Object} env
|
|
34
|
-
* @returns {Array<string>} traceLog
|
|
35
|
-
*/
|
|
36
|
-
export declare const getLogTrace: (question: any, session: any, env: any) => string[];
|
|
37
|
-
export declare function outcome(config: any, session: any, env: any): Promise<unknown>;
|
|
38
|
-
export declare const createCorrectResponseSession: (question: any, env: any) => Promise<unknown>;
|
|
39
|
-
export declare const validate: (model?: {}, config?: {}) => {
|
|
40
|
-
partA: {};
|
|
41
|
-
partB: {};
|
|
42
|
-
};
|
package/dist/controller/index.js
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import e from "./defaults.js";
|
|
2
|
-
import { isResponseCorrect as t } from "./utils.js";
|
|
3
|
-
import { get as n, 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
|
-
import s from "@pie-lib/translator";
|
|
6
|
-
//#region src/controller/index.ts
|
|
7
|
-
var { translator: c } = s, l = (e, t, n) => (r) => {
|
|
8
|
-
let i = {
|
|
9
|
-
label: r.label,
|
|
10
|
-
value: r.value
|
|
11
|
-
};
|
|
12
|
-
if (t.role === "instructor" && (t.mode === "view" || t.mode === "evaluate") ? i.rationale = e.rationaleEnabled ? r.rationale : null : i.rationale = null, t.mode === "evaluate" && (i.correct = !!r.correct, e.feedbackEnabled)) {
|
|
13
|
-
let e = r.feedback && r.feedback.type || "none";
|
|
14
|
-
e === "default" ? i.feedback = n[r.correct ? "correct" : "incorrect"] : e === "custom" && (i.feedback = r.feedback.value);
|
|
15
|
-
}
|
|
16
|
-
return i;
|
|
17
|
-
}, u = (e, n, r, i) => {
|
|
18
|
-
let a = Object.assign({
|
|
19
|
-
correct: "Correct",
|
|
20
|
-
incorrect: "Incorrect"
|
|
21
|
-
}, e.defaultFeedback), o = e.choices ? e.choices.map(l(e, i, a)) : [];
|
|
22
|
-
return {
|
|
23
|
-
...e,
|
|
24
|
-
choices: o,
|
|
25
|
-
disabled: i.mode !== "gather",
|
|
26
|
-
complete: { min: e.choices.filter((e) => e.correct).length },
|
|
27
|
-
responseCorrect: i.mode === "evaluate" ? t(e, n, r) : void 0
|
|
28
|
-
};
|
|
29
|
-
}, d = (e, t) => ({
|
|
30
|
-
...t,
|
|
31
|
-
...e,
|
|
32
|
-
choicesLayout: e.choicesLayout || e.verticalMode === !1 && "horizontal" || "vertical"
|
|
33
|
-
}), f = ({ partA: t = {}, partB: n = {}, language: r, ...i }) => ({
|
|
34
|
-
...e,
|
|
35
|
-
...i,
|
|
36
|
-
partA: d(t, {
|
|
37
|
-
...e.partA,
|
|
38
|
-
language: r
|
|
39
|
-
}),
|
|
40
|
-
partB: d(n, {
|
|
41
|
-
...e.partB,
|
|
42
|
-
language: r
|
|
43
|
-
})
|
|
44
|
-
});
|
|
45
|
-
async function p(e, t, o, s) {
|
|
46
|
-
let l = f(e), d = u(l.partA, "partA", t, o), p = u(l.partB, "partB", t, o), m = {}, h = (e) => (t, n, r) => new Promise((t) => {
|
|
47
|
-
m[e] = r.shuffledValues, t();
|
|
48
|
-
}), g = n(t, "value.partA"), _ = a(l.partA, g, o), { choices: v } = d || {}, { choices: y } = p || {};
|
|
49
|
-
!_ && v && v.length && (d.choices = await i(v, { shuffledValues: (t.shuffledValues || {}).partA }, h("partA"), "value"));
|
|
50
|
-
let b = n(t, "value.partB");
|
|
51
|
-
if (!a(l.partB, b, o) && y && y.length && (p.choices = await i(y, { shuffledValues: (t.shuffledValues || {}).partB }, h("partB"), "value")), r(m) || s && typeof s == "function" && s(t.id, t.element, { shuffledValues: m }).catch((e) => {
|
|
52
|
-
console.error("update session failed", e);
|
|
53
|
-
}), l.partLabels) {
|
|
54
|
-
let e = l.language;
|
|
55
|
-
d.partLabel = c.t("ebsr.part", {
|
|
56
|
-
lng: e,
|
|
57
|
-
index: l.partLabelType === "Letters" ? "A" : "1"
|
|
58
|
-
}), p.partLabel = c.t("ebsr.part", {
|
|
59
|
-
lng: e,
|
|
60
|
-
index: l.partLabelType === "Letters" ? "B" : "2"
|
|
61
|
-
});
|
|
62
|
-
} else d.partLabel = void 0, p.partLabel = void 0;
|
|
63
|
-
return o.role === "instructor" && (o.mode === "view" || o.mode === "evaluate") ? (d.teacherInstructions = l.partA.teacherInstructionsEnabled ? l.partA.teacherInstructions : null, p.teacherInstructions = l.partB.teacherInstructionsEnabled ? l.partB.teacherInstructions : null) : (d.teacherInstructions = null, p.teacherInstructions = null), d.prompt = l.partA.promptEnabled ? l.partA.prompt : null, p.prompt = l.partB.promptEnabled ? l.partB.prompt : null, new Promise((e) => {
|
|
64
|
-
e({
|
|
65
|
-
disabled: o.mode !== "gather",
|
|
66
|
-
mode: o.mode,
|
|
67
|
-
extraCSSRules: l.extraCSSRules,
|
|
68
|
-
partA: d,
|
|
69
|
-
partB: p
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
var m = (t = {}) => new Promise((n) => {
|
|
74
|
-
n({
|
|
75
|
-
...e,
|
|
76
|
-
...t
|
|
77
|
-
});
|
|
78
|
-
}), h = (e) => e.correct === !0, g = (e, t, n, r) => {
|
|
79
|
-
let { choices: i = [] } = e && e[n] || {}, a = i.length, { value: o } = t || {}, s = (e) => !!(o || []).find((t) => t === e.value), c = (e) => h(e) && !s(e), l = (e) => !h(e) && s(e), u = i.reduce((e, t) => c(t) || l(t) ? e - 1 : e, i.length);
|
|
80
|
-
return !r && u < a ? 0 : parseFloat(a ? (u / a).toFixed(2) : 0);
|
|
81
|
-
}, _ = (e, t, n) => {
|
|
82
|
-
let r = [];
|
|
83
|
-
if (!t || !t.value) return r.push("Student did not answer the question."), r;
|
|
84
|
-
let { value: i } = t, { partA: a, partB: s } = i, c = o.enabled(e, n);
|
|
85
|
-
r.push(`Scoring method: ${c ? "partial scoring" : "all-or-nothing scoring"}.`);
|
|
86
|
-
let l = e.partA.choiceMode === "radio" ? "multiple-choice (radio)" : "multiple-select (checkbox)";
|
|
87
|
-
r.push(`Part A question type: ${l}.`);
|
|
88
|
-
let u = a?.value || [], d = (e.partA.choices || []).filter((e) => e.correct).map((e) => e.value), f = u.filter((e) => d.includes(e)), p = u.filter((e) => !d.includes(e));
|
|
89
|
-
u.length && r.push(`Part A: student selected ${u.length} choice(s) (${f.length} correct, ${p.length} incorrect).`);
|
|
90
|
-
let m = g(e, a, "partA", c);
|
|
91
|
-
r.push(`Part A score: ${m}.`);
|
|
92
|
-
let h = e.partB.choiceMode === "radio" ? "multiple-choice (radio)" : "multiple-select (checkbox)";
|
|
93
|
-
r.push(`Part B question type: ${h}.`);
|
|
94
|
-
let _ = s?.value || [], v = (e.partB.choices || []).filter((e) => e.correct).map((e) => e.value), y = _.filter((e) => v.includes(e)), b = _.filter((e) => !v.includes(e));
|
|
95
|
-
_.length && r.push(`Part B: student selected ${_.length} choice(s) (${y.length} correct, ${b.length} incorrect).`);
|
|
96
|
-
let x = g(e, s, "partB", c);
|
|
97
|
-
if (r.push(`Part B score: ${x}.`), !c) r.push("Final score is awarded only if both Part A and Part B are completely correct."), r.push(`Final score: ${+(m === 1 && x === 1)}.`);
|
|
98
|
-
else {
|
|
99
|
-
r.push("With partial scoring enabled, Part A must be correct to earn any credit.");
|
|
100
|
-
let e = 0;
|
|
101
|
-
m === 1 && x === 1 ? e = 2 : m === 1 && x < 1 && (e = 1), r.push(`Final score: ${e}.`);
|
|
102
|
-
}
|
|
103
|
-
return r;
|
|
104
|
-
};
|
|
105
|
-
function v(e, t, n) {
|
|
106
|
-
return new Promise((r) => {
|
|
107
|
-
let { value: i } = t || {};
|
|
108
|
-
if ((!t || !i) && r({
|
|
109
|
-
score: 0,
|
|
110
|
-
scoreA: 0,
|
|
111
|
-
scoreB: 0,
|
|
112
|
-
empty: !0,
|
|
113
|
-
logTrace: ["Student did not answer the question."]
|
|
114
|
-
}), i) {
|
|
115
|
-
let { partA: a, partB: s } = i || {}, c = o.enabled(e, n), l = g(e, a, "partA", c), u = g(e, s, "partB", c), d = _(e, t, n);
|
|
116
|
-
r(c ? l === 1 ? u === 1 ? {
|
|
117
|
-
score: 2,
|
|
118
|
-
scoreA: l,
|
|
119
|
-
scoreB: u,
|
|
120
|
-
max: 2,
|
|
121
|
-
logTrace: d
|
|
122
|
-
} : {
|
|
123
|
-
score: 1,
|
|
124
|
-
scoreA: l,
|
|
125
|
-
scoreB: u,
|
|
126
|
-
max: 2,
|
|
127
|
-
logTrace: d
|
|
128
|
-
} : {
|
|
129
|
-
score: 0,
|
|
130
|
-
scoreA: l,
|
|
131
|
-
scoreB: u,
|
|
132
|
-
max: 2,
|
|
133
|
-
logTrace: d
|
|
134
|
-
} : {
|
|
135
|
-
score: +(l === 1 && u === 1),
|
|
136
|
-
scoreA: l,
|
|
137
|
-
scoreB: u,
|
|
138
|
-
max: 1,
|
|
139
|
-
logTrace: d
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
var y = (e) => {
|
|
145
|
-
let t = [];
|
|
146
|
-
return e.forEach((e) => {
|
|
147
|
-
let { correct: n, value: r } = e;
|
|
148
|
-
n && t.push(r);
|
|
149
|
-
}), t;
|
|
150
|
-
}, b = (e, t) => new Promise((n) => {
|
|
151
|
-
if (t.mode !== "evaluate" && t.role === "instructor") {
|
|
152
|
-
let { partA: t, partB: r } = e, i = y(t.choices), a = y(r.choices);
|
|
153
|
-
n({
|
|
154
|
-
value: {
|
|
155
|
-
partA: {
|
|
156
|
-
id: "partA",
|
|
157
|
-
value: i
|
|
158
|
-
},
|
|
159
|
-
partB: {
|
|
160
|
-
id: "partB",
|
|
161
|
-
value: a
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
id: "1"
|
|
165
|
-
});
|
|
166
|
-
} else n(null);
|
|
167
|
-
}), x = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), S = (e = {}, t = {}) => {
|
|
168
|
-
let { choices: n } = e, { minAnswerChoices: i = 2, maxAnswerChoices: a } = t, o = [...n || []].reverse(), s = {}, c = {}, l = {}, u = !1;
|
|
169
|
-
["teacherInstructions", "prompt"].forEach((n) => {
|
|
170
|
-
t[n]?.required && !x(e[n]) && (s[n] = "This field is required.");
|
|
171
|
-
}), o.forEach((e, n) => {
|
|
172
|
-
let { correct: r, value: i, label: a, rationale: s } = e;
|
|
173
|
-
r && (u = !0), x(a) ? o.slice(n + 1).some((e) => e.label === a) && (c[i] = "Content should be unique.") : c[i] = "Content should not be empty.", t.rationale?.required && !x(s) && (l[i] = "This field is required.");
|
|
174
|
-
});
|
|
175
|
-
let d = (n || []).length;
|
|
176
|
-
return d < i ? s.answerChoices = `There should be at least ${i} choices defined.` : d > a && (s.answerChoices = `No more than ${a} choices should be defined.`), u || (s.correctResponse = "No correct response defined."), r(c) || (s.choices = c), r(l) || (s.rationale = l), s;
|
|
177
|
-
}, C = (e = {}, t = {}) => {
|
|
178
|
-
let { partA: n, partB: r } = e || {}, { partA: i, partB: a } = t || {};
|
|
179
|
-
return {
|
|
180
|
-
partA: S(n, i),
|
|
181
|
-
partB: S(r, a)
|
|
182
|
-
};
|
|
183
|
-
};
|
|
184
|
-
//#endregion
|
|
185
|
-
export { b as createCorrectResponseSession, m as createDefaultModel, _ as getLogTrace, p as model, f as normalize, v as outcome, C as validate };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/ebsr/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 getCorrectResponse: (choices: any) => any;
|
|
10
|
-
export declare const isResponseCorrect: (question: any, key: any, session: any) => boolean;
|
package/dist/controller/utils.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { isEqual as e } from "@pie-element/shared-lodash";
|
|
2
|
-
//#region src/controller/utils.ts
|
|
3
|
-
var t = (e) => e && e.filter((e) => e.correct).map((e) => e.value).sort(), n = (n, r, i) => {
|
|
4
|
-
let a = t(n.choices);
|
|
5
|
-
return i && i.value ? e((i.value[r].value || []).sort(), a) : !1;
|
|
6
|
-
};
|
|
7
|
-
//#endregion
|
|
8
|
-
export { n as isResponseCorrect };
|
package/dist/delivery/index.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/ebsr/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 isSessionComplete: (session: any) => boolean;
|
|
10
|
-
export default class Ebsr extends HTMLElement {
|
|
11
|
-
constructor();
|
|
12
|
-
onSessionUpdated: any;
|
|
13
|
-
set model(m: any);
|
|
14
|
-
set session(s: any);
|
|
15
|
-
get session(): any;
|
|
16
|
-
setPartModel(part: any, key: any): void;
|
|
17
|
-
setPartSession(part: any, key: any): void;
|
|
18
|
-
dispatchSessionChanged(partSession: any, key: any): void;
|
|
19
|
-
get partA(): Element | null;
|
|
20
|
-
get partB(): Element | null;
|
|
21
|
-
connectedCallback(): void;
|
|
22
|
-
disconnectedCallback(): void;
|
|
23
|
-
_initPlayerObserver(): void;
|
|
24
|
-
_disconnectPlayerObserver(): void;
|
|
25
|
-
_render(): void;
|
|
26
|
-
}
|
package/dist/delivery/index.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { EBSR_MULTIPLE_CHOICE_TAG as e } from "../private-tags.js";
|
|
2
|
-
import { SessionChangedEvent as t } from "@pie-element/shared-player-events";
|
|
3
|
-
import n from "@pie-element/multiple-choice";
|
|
4
|
-
import { get as r } from "@pie-element/shared-lodash";
|
|
5
|
-
import i from "debug";
|
|
6
|
-
//#region src/delivery/index.tsx
|
|
7
|
-
var a = t.TYPE, o = e, s = i("pie-elements:ebsr"), c = class extends n {};
|
|
8
|
-
customElements.get(o) || customElements.define(o, c);
|
|
9
|
-
var l = (e) => Array.isArray(e) && e.length > 0, u = (e) => {
|
|
10
|
-
let t = r(e, "value.partA.value"), n = r(e, "value.partB.value");
|
|
11
|
-
return l(t) && l(n);
|
|
12
|
-
};
|
|
13
|
-
function d(e) {
|
|
14
|
-
let t = e.closest("pie-player") || e.closest("pie-item-player");
|
|
15
|
-
if (!t) return {
|
|
16
|
-
baseHeadingLevel: void 0,
|
|
17
|
-
includeSrHeading: !0
|
|
18
|
-
};
|
|
19
|
-
let n = (e, n, r) => {
|
|
20
|
-
let i = t[e];
|
|
21
|
-
return i ??= t.getAttribute(n) ?? t.getAttribute(r), i;
|
|
22
|
-
}, r = n("baseHeadingLevel", "base-heading-level", "baseheadinglevel"), i = parseInt(r, 10), a = Number.isFinite(i) && i >= 1 && i <= 6 ? i : void 0, o = n("includeSrHeading", "include-sr-heading", "includesrheading");
|
|
23
|
-
return {
|
|
24
|
-
baseHeadingLevel: a,
|
|
25
|
-
includeSrHeading: o == null ? !0 : o !== !1 && o !== "false"
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
var f = class extends HTMLElement {
|
|
29
|
-
constructor() {
|
|
30
|
-
super(), this._model = {}, this._session = {};
|
|
31
|
-
}
|
|
32
|
-
onSessionUpdated = (e) => {
|
|
33
|
-
if (e.target === this) return;
|
|
34
|
-
e.preventDefault(), e.stopImmediatePropagation();
|
|
35
|
-
let t = e.target.getAttribute("id");
|
|
36
|
-
if (t) {
|
|
37
|
-
let n = `part${t.toUpperCase()}`;
|
|
38
|
-
e.update && (this._model[n] = e.update), this.dispatchSessionChanged(e.srcElement._session, n);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
set model(e) {
|
|
42
|
-
this._model = e, customElements.whenDefined(o).then(() => {
|
|
43
|
-
this.setPartModel(this.partA, "partA"), this.setPartModel(this.partB, "partB");
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
set session(e) {
|
|
47
|
-
this._session = e, customElements.whenDefined(o).then(() => {
|
|
48
|
-
this.setPartSession(this.partA, "partA"), this.setPartSession(this.partB, "partB");
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
get session() {
|
|
52
|
-
return this._session;
|
|
53
|
-
}
|
|
54
|
-
setPartModel(e, t) {
|
|
55
|
-
if (this._model && this._model[t] && e) {
|
|
56
|
-
let { mode: n } = this._model;
|
|
57
|
-
e.model = {
|
|
58
|
-
...this._model[t],
|
|
59
|
-
mode: n,
|
|
60
|
-
keyMode: this._model[t].choicePrefix
|
|
61
|
-
};
|
|
62
|
-
let { includeSrHeading: r, baseHeadingLevel: i } = d(this);
|
|
63
|
-
e.includeSrHeading = r, e.baseHeadingLevel = i;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
setPartSession(e, t) {
|
|
67
|
-
if (this._session && this._model && e) {
|
|
68
|
-
let { value: n } = this._session;
|
|
69
|
-
e.session = n && n[t] ? n[t] : { id: t };
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
dispatchSessionChanged(e, n) {
|
|
73
|
-
this._session.value = {
|
|
74
|
-
...this._session.value,
|
|
75
|
-
[n]: e
|
|
76
|
-
}, s("[onSessionChanged] session: ", this._session);
|
|
77
|
-
let r = u(this._session);
|
|
78
|
-
this.dispatchEvent(new t(this.tagName.toLowerCase(), r));
|
|
79
|
-
}
|
|
80
|
-
get partA() {
|
|
81
|
-
return this.querySelector(`${o}#a`);
|
|
82
|
-
}
|
|
83
|
-
get partB() {
|
|
84
|
-
return this.querySelector(`${o}#b`);
|
|
85
|
-
}
|
|
86
|
-
connectedCallback() {
|
|
87
|
-
this._render(), this._initPlayerObserver(), this.addEventListener(a, this.onSessionUpdated);
|
|
88
|
-
}
|
|
89
|
-
disconnectedCallback() {
|
|
90
|
-
this._disconnectPlayerObserver(), this.removeEventListener(a, this.onSessionUpdated);
|
|
91
|
-
}
|
|
92
|
-
_initPlayerObserver() {
|
|
93
|
-
let e = this.closest("pie-player") || this.closest("pie-item-player");
|
|
94
|
-
e && (this._playerObserver = new MutationObserver(() => {
|
|
95
|
-
this._render();
|
|
96
|
-
}), this._playerObserver.observe(e, {
|
|
97
|
-
attributes: !0,
|
|
98
|
-
attributeFilter: [
|
|
99
|
-
"base-heading-level",
|
|
100
|
-
"baseheadinglevel",
|
|
101
|
-
"include-sr-heading",
|
|
102
|
-
"includesrheading"
|
|
103
|
-
]
|
|
104
|
-
}));
|
|
105
|
-
}
|
|
106
|
-
_disconnectPlayerObserver() {
|
|
107
|
-
this._playerObserver &&= (this._playerObserver.disconnect(), null);
|
|
108
|
-
}
|
|
109
|
-
_render() {
|
|
110
|
-
this.ariaLabel = "Two-Part Question", this.role = "region";
|
|
111
|
-
let { baseHeadingLevel: e, includeSrHeading: t } = d(this), n = e ? `h${Math.min(6, e)}` : "h2", r = t ? `<${n} class="srOnly">Two-Part Question</${n}>` : "";
|
|
112
|
-
this.innerHTML = `
|
|
113
|
-
<style>
|
|
114
|
-
.srOnly {
|
|
115
|
-
position: absolute;
|
|
116
|
-
width: 1px;
|
|
117
|
-
height: 1px;
|
|
118
|
-
padding: 0;
|
|
119
|
-
margin: -1px;
|
|
120
|
-
overflow: hidden;
|
|
121
|
-
left: -10000px;
|
|
122
|
-
top: auto;
|
|
123
|
-
}
|
|
124
|
-
${this._model?.extraCSSRules?.rules}
|
|
125
|
-
</style>
|
|
126
|
-
${r}
|
|
127
|
-
<${o} id="a"></${o}>
|
|
128
|
-
<${o} id="b"></${o}>
|
|
129
|
-
`, customElements.get(o) && (this.setPartModel(this.partA, "partA"), this.setPartModel(this.partB, "partB"), this.setPartSession(this.partA, "partA"), this.setPartSession(this.partB, "partB"));
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
//#endregion
|
|
133
|
-
export { f as default, u as isSessionComplete };
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './delivery/index.js';
|
package/dist/index.iife.d.ts
DELETED