@pie-element/simple-cloze 0.1.4-next.6 → 0.1.4-next.8
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/author.js +2 -0
- package/dist/author/index.d.ts +8 -0
- package/dist/author/index.js +181 -242
- package/dist/author/index.js.map +1 -1
- package/dist/browser/author/index.js +3136 -3044
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/{client-Dt8SOe5Z.js → client-BSTc3boO.js} +650 -755
- package/dist/browser/client-BSTc3boO.js.map +1 -0
- package/dist/browser/controller/index.js +42 -32
- package/dist/browser/controller/index.js.map +1 -1
- package/dist/browser/delivery/index.js +205 -156
- package/dist/browser/delivery/index.js.map +1 -1
- package/dist/browser/i18n-BaF24Jzw.js +1610 -0
- package/dist/browser/i18n-BaF24Jzw.js.map +1 -0
- package/dist/browser/plain-text-iaQZhkGe.js +53 -0
- package/dist/browser/plain-text-iaQZhkGe.js.map +1 -0
- package/dist/browser/print/index.js +64 -21
- package/dist/browser/print/index.js.map +1 -1
- package/dist/controller/defaults.d.ts +1 -0
- package/dist/controller/index.d.ts +51 -8
- package/dist/controller/index.js +121 -29
- package/dist/controller/index.js.map +1 -1
- package/dist/controller/plain-text.d.ts +11 -0
- package/dist/delivery/index.d.ts +2 -20
- package/dist/delivery/index.js +2896 -392
- package/dist/delivery/index.js.map +1 -1
- package/dist/i18n.d.ts +7 -0
- package/dist/index.iife.js +9 -3
- package/dist/index.js +2 -4912
- package/dist/print/index.d.ts +7 -0
- package/dist/print/index.js +2773 -28
- package/dist/print/index.js.map +1 -1
- package/dist/runtime-support.js +5 -5
- package/dist/runtime-support.js.map +1 -1
- package/module/print.js +2381 -600
- package/module/print.js.map +1 -1
- package/package.json +3 -4
- package/dist/browser/client-Dt8SOe5Z.js.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -1,52 +1,62 @@
|
|
|
1
|
+
import { t as e } from "../plain-text-iaQZhkGe.js";
|
|
1
2
|
//#region src/controller/defaults.ts
|
|
2
|
-
var
|
|
3
|
+
var t = {
|
|
3
4
|
model: {
|
|
4
5
|
prompt: "<p>Enter your answer:</p>",
|
|
5
6
|
promptEnabled: !0,
|
|
6
|
-
correctAnswer: ""
|
|
7
|
+
correctAnswer: "",
|
|
8
|
+
teacherInstructionsEnabled: !0
|
|
7
9
|
},
|
|
8
10
|
configuration: { prompt: {
|
|
9
11
|
label: "Prompt",
|
|
10
12
|
settings: !0
|
|
11
13
|
} }
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
}, n = (t) => e(t).toLowerCase(), r = (e) => typeof e == "string" && e.replace(/(<(?!img|iframe|source)([^>]+)>)/gi, "").replace(/ /gi, " ").trim().length > 0, i = (e, t) => {
|
|
15
|
+
let r = n(t?.value);
|
|
16
|
+
if (!r) return "unanswered";
|
|
17
|
+
let i = n(e?.correctAnswer);
|
|
18
|
+
return i && r === i ? "correct" : "incorrect";
|
|
19
|
+
}, a = (e, t) => +(i(e, t) === "correct"), o = (e, t, r) => {
|
|
20
|
+
let i = ["Response is compared with the answer key as plain text, ignoring case and extra spaces."];
|
|
21
|
+
return n(e?.correctAnswer) ? i.push(t === "correct" ? "Response matches the answer key." : "Response does not match the answer key.") : i.push("No correct answer is defined, so no response can score."), i.push(`Final score: ${r}.`), i;
|
|
22
|
+
}, s = (e, t, n = {}) => new Promise((n) => {
|
|
23
|
+
let r = i(e, t);
|
|
24
|
+
if (r === "unanswered") {
|
|
25
|
+
n({
|
|
19
26
|
score: 0,
|
|
20
|
-
empty: !0
|
|
27
|
+
empty: !0,
|
|
28
|
+
traceLog: ["Student did not enter a response. Score is 0."]
|
|
21
29
|
});
|
|
22
30
|
return;
|
|
23
31
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
let a = +(r === "correct");
|
|
33
|
+
n({
|
|
34
|
+
score: a,
|
|
35
|
+
empty: !1,
|
|
36
|
+
traceLog: o(e, r, a)
|
|
27
37
|
});
|
|
28
|
-
}),
|
|
29
|
-
...
|
|
30
|
-
...
|
|
31
|
-
}),
|
|
32
|
-
t
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
}), c = (e = {}) => ({
|
|
39
|
+
...t.model,
|
|
40
|
+
...e
|
|
41
|
+
}), l = (e) => ({ ...e }), u = (t, n, r) => new Promise((a) => {
|
|
42
|
+
let o = n || {}, s = r || {}, l = c(t || {}), u = {
|
|
43
|
+
prompt: l.promptEnabled ? l.prompt : null,
|
|
44
|
+
disabled: s.mode !== "gather",
|
|
45
|
+
mode: s.mode,
|
|
46
|
+
role: s.role,
|
|
47
|
+
language: l.language
|
|
38
48
|
};
|
|
39
|
-
|
|
40
|
-
}),
|
|
41
|
-
|
|
49
|
+
s.mode === "evaluate" && (u.correctness = i(l, o), u.correctAnswer = e(l.correctAnswer)), s.role === "instructor" && (s.mode === "view" || s.mode === "evaluate") ? u.teacherInstructions = l.teacherInstructionsEnabled ? l.teacherInstructions : null : u.teacherInstructions = null, a(u);
|
|
50
|
+
}), d = (t, n) => new Promise((r) => {
|
|
51
|
+
n?.mode !== "evaluate" && n?.role === "instructor" ? r({
|
|
42
52
|
id: "1",
|
|
43
|
-
|
|
44
|
-
}) :
|
|
45
|
-
}),
|
|
46
|
-
let
|
|
47
|
-
return (
|
|
53
|
+
value: e(t?.correctAnswer)
|
|
54
|
+
}) : r(null);
|
|
55
|
+
}), f = (e = {}, t = {}) => {
|
|
56
|
+
let i = {};
|
|
57
|
+
return t?.prompt?.required && !r(e?.prompt) && (i.prompt = "This field is required."), n(e?.correctAnswer) || (i.correctAnswer = "No correct answer defined."), i;
|
|
48
58
|
};
|
|
49
59
|
//#endregion
|
|
50
|
-
export {
|
|
60
|
+
export { d as createCorrectResponseSession, c as createDefaultModel, i as getCorrectness, a as getPartialScore, u as model, l as normalizeSession, s as outcome, f as validate };
|
|
51
61
|
|
|
52
62
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/controller/defaults.ts","../../../src/controller/index.ts"],"sourcesContent":["export default {\n model: {\n prompt: '<p>Enter your answer:</p>',\n promptEnabled: true,\n correctAnswer: '',\n },\n configuration: {\n prompt: {\n label: 'Prompt',\n settings: true,\n },\n },\n};\n","import defaults from './defaults';\n\nconst
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/controller/defaults.ts","../../../src/controller/index.ts"],"sourcesContent":["export default {\n model: {\n prompt: '<p>Enter your answer:</p>',\n promptEnabled: true,\n correctAnswer: '',\n teacherInstructionsEnabled: true,\n },\n configuration: {\n prompt: {\n label: 'Prompt',\n settings: true,\n },\n },\n};\n","import defaults from './defaults';\nimport { toPlainText } from './plain-text';\n\nexport type SimpleClozeQuestion = {\n id?: string;\n element?: string;\n prompt?: string;\n promptEnabled?: boolean;\n correctAnswer?: string;\n teacherInstructions?: string;\n teacherInstructionsEnabled?: boolean;\n /** The learner-facing strings' language, as `@pie-lib/translator` reads it (`en_US`, `es_ES`, …). */\n language?: string;\n [key: string]: unknown;\n};\n\nexport type SimpleClozeSession = {\n id?: string;\n element?: string;\n /** The learner's typed answer. */\n value?: unknown;\n [key: string]: unknown;\n};\n\nexport type SimpleClozeEnv = {\n mode?: string;\n role?: string;\n [key: string]: unknown;\n};\n\nexport type SimpleClozeCorrectness = 'correct' | 'incorrect' | 'unanswered';\n\nexport type SimpleClozeOutcome = {\n score: number;\n empty: boolean;\n traceLog: string[];\n};\n\ntype FieldConfig = { required?: boolean };\nexport type SimpleClozeValidationConfig = {\n prompt?: FieldConfig;\n [key: string]: unknown;\n};\n\n/**\n * Both sides compare as plain text, case-insensitively: an answer key authored\n * as HTML matches the text a learner types.\n */\nconst comparable = (value: unknown): string => toPlainText(value).toLowerCase();\n\n// Strips tags except img, iframe and source (media counts as content), as\n// multiple-choice's `getContent` does.\nconst hasContent = (html: unknown): boolean =>\n typeof html === 'string' &&\n html\n .replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '')\n .replace(/ /gi, ' ')\n .trim().length > 0;\n\n/**\n * A response with no text is unanswered; an answer key with no text matches\n * nothing, so a blank key never scores.\n */\nexport const getCorrectness = (\n question: SimpleClozeQuestion | null | undefined,\n session: SimpleClozeSession | null | undefined\n): SimpleClozeCorrectness => {\n const response = comparable(session?.value);\n if (!response) {\n return 'unanswered';\n }\n\n const key = comparable(question?.correctAnswer);\n if (key && response === key) {\n return 'correct';\n }\n\n return 'incorrect';\n};\n\n/** Single response, all-or-nothing: 1 when it matches the answer key, else 0. */\nexport const getPartialScore = (\n question: SimpleClozeQuestion | null | undefined,\n session: SimpleClozeSession | null | undefined\n): number => (getCorrectness(question, session) === 'correct' ? 1 : 0);\n\nconst getTraceLog = (\n question: SimpleClozeQuestion | null | undefined,\n correctness: SimpleClozeCorrectness,\n score: number\n): string[] => {\n const traceLog = [\n 'Response is compared with the answer key as plain text, ignoring case and extra spaces.',\n ];\n if (!comparable(question?.correctAnswer)) {\n traceLog.push('No correct answer is defined, so no response can score.');\n } else {\n traceLog.push(\n correctness === 'correct'\n ? 'Response matches the answer key.'\n : 'Response does not match the answer key.'\n );\n }\n traceLog.push(`Final score: ${score}.`);\n return traceLog;\n};\n\nexport const outcome = (\n question: SimpleClozeQuestion | null | undefined,\n session: SimpleClozeSession | null | undefined,\n _env: SimpleClozeEnv = {}\n): Promise<SimpleClozeOutcome> =>\n new Promise((resolve) => {\n const correctness = getCorrectness(question, session);\n\n if (correctness === 'unanswered') {\n resolve({\n score: 0,\n empty: true,\n traceLog: ['Student did not enter a response. Score is 0.'],\n });\n return;\n }\n\n const score = correctness === 'correct' ? 1 : 0;\n resolve({ score, empty: false, traceLog: getTraceLog(question, correctness, score) });\n });\n\nexport const createDefaultModel = (model: SimpleClozeQuestion = {}): SimpleClozeQuestion => ({\n ...defaults.model,\n ...model,\n});\n\nexport const normalizeSession = (s: SimpleClozeSession | null | undefined): SimpleClozeSession => ({\n ...s,\n});\n\nexport const model = (\n question: SimpleClozeQuestion | null | undefined,\n session: SimpleClozeSession | null | undefined,\n env: SimpleClozeEnv | null | undefined\n): Promise<Record<string, unknown>> => {\n return new Promise((resolve) => {\n const safeSession = session || {};\n const safeEnv = env || {};\n const normalizedQuestion = createDefaultModel(question || {});\n\n const out: Record<string, unknown> = {\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n disabled: safeEnv.mode !== 'gather',\n mode: safeEnv.mode,\n role: safeEnv.role,\n language: normalizedQuestion.language,\n };\n\n if (safeEnv.mode === 'evaluate') {\n out.correctness = getCorrectness(normalizedQuestion, safeSession);\n // The key is shown in the text input, so it goes out as plain text.\n out.correctAnswer = toPlainText(normalizedQuestion.correctAnswer);\n }\n\n if (safeEnv.role === 'instructor' && (safeEnv.mode === 'view' || safeEnv.mode === 'evaluate')) {\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.teacherInstructions = null;\n }\n\n resolve(out);\n });\n};\n\nexport const createCorrectResponseSession = (\n question: SimpleClozeQuestion | null | undefined,\n env: SimpleClozeEnv | null | undefined\n): Promise<SimpleClozeSession | null> => {\n return new Promise((resolve) => {\n if (env?.mode !== 'evaluate' && env?.role === 'instructor') {\n // The player sets `id` and `element` on the entry from the item config.\n resolve({ id: '1', value: toPlainText(question?.correctAnswer) });\n } else {\n resolve(null);\n }\n });\n};\n\nexport const validate = (\n model: SimpleClozeQuestion = {},\n config: SimpleClozeValidationConfig = {}\n): Record<string, string> => {\n const errors: Record<string, string> = {};\n\n if (config?.prompt?.required && !hasContent(model?.prompt)) {\n errors.prompt = 'This field is required.';\n }\n\n if (!comparable(model?.correctAnswer)) {\n errors.correctAnswer = 'No correct answer defined.';\n }\n\n return errors;\n};\n"],"mappings":";;AAAA,IAAA,IAAe;CACb,OAAO;EACL,QAAQ;EACR,eAAe;EACf,eAAe;EACf,4BAA4B;CAC9B;CACA,eAAe,EACb,QAAQ;EACN,OAAO;EACP,UAAU;CACZ,EACF;AACF,GCmCM,KAAc,MAA2B,EAAY,CAAK,CAAC,CAAC,YAAY,GAIxE,KAAc,MAClB,OAAO,KAAS,YAChB,EACG,QAAQ,sCAAsC,EAAE,CAAC,CACjD,QAAQ,YAAY,GAAG,CAAC,CACxB,KAAK,CAAC,CAAC,SAAS,GAMR,KACX,GACA,MAC2B;CAC3B,IAAM,IAAW,EAAW,GAAS,KAAK;CAC1C,IAAI,CAAC,GACH,OAAO;CAGT,IAAM,IAAM,EAAW,GAAU,aAAa;CAK9C,OAJI,KAAO,MAAa,IACf,YAGF;AACT,GAGa,KACX,GACA,MACY,IAAe,GAAU,CAAO,MAAM,YAE9C,KACJ,GACA,GACA,MACa;CACb,IAAM,IAAW,CACf,yFACF;CAWA,OAVK,EAAW,GAAU,aAAa,IAGrC,EAAS,KACP,MAAgB,YACZ,qCACA,yCACN,IANA,EAAS,KAAK,yDAAyD,GAQzE,EAAS,KAAK,gBAAgB,EAAM,EAAE,GAC/B;AACT,GAEa,KACX,GACA,GACA,IAAuB,CAAC,MAExB,IAAI,SAAS,MAAY;CACvB,IAAM,IAAc,EAAe,GAAU,CAAO;CAEpD,IAAI,MAAgB,cAAc;EAChC,EAAQ;GACN,OAAO;GACP,OAAO;GACP,UAAU,CAAC,+CAA+C;EAC5D,CAAC;EACD;CACF;CAEA,IAAM,IAAQ,QAAgB;CAC9B,EAAQ;EAAE;EAAO,OAAO;EAAO,UAAU,EAAY,GAAU,GAAa,CAAK;CAAE,CAAC;AACtF,CAAC,GAEU,KAAsB,IAA6B,CAAC,OAA4B;CAC3F,GAAG,EAAS;CACZ,GAAG;AACL,IAEa,KAAoB,OAAkE,EACjG,GAAG,EACL,IAEa,KACX,GACA,GACA,MAEO,IAAI,SAAS,MAAY;CAC9B,IAAM,IAAc,KAAW,CAAC,GAC1B,IAAU,KAAO,CAAC,GAClB,IAAqB,EAAmB,KAAY,CAAC,CAAC,GAEtD,IAA+B;EACnC,QAAQ,EAAmB,gBAAgB,EAAmB,SAAS;EACvE,UAAU,EAAQ,SAAS;EAC3B,MAAM,EAAQ;EACd,MAAM,EAAQ;EACd,UAAU,EAAmB;CAC/B;CAgBA,AAdI,EAAQ,SAAS,eACnB,EAAI,cAAc,EAAe,GAAoB,CAAW,GAEhE,EAAI,gBAAgB,EAAY,EAAmB,aAAa,IAG9D,EAAQ,SAAS,iBAAiB,EAAQ,SAAS,UAAU,EAAQ,SAAS,cAChF,EAAI,sBAAsB,EAAmB,6BACzC,EAAmB,sBACnB,OAEJ,EAAI,sBAAsB,MAG5B,EAAQ,CAAG;AACb,CAAC,GAGU,KACX,GACA,MAEO,IAAI,SAAS,MAAY;CAC9B,AAAI,GAAK,SAAS,cAAc,GAAK,SAAS,eAE5C,EAAQ;EAAE,IAAI;EAAK,OAAO,EAAY,GAAU,aAAa;CAAE,CAAC,IAEhE,EAAQ,IAAI;AAEhB,CAAC,GAGU,KACX,IAA6B,CAAC,GAC9B,IAAsC,CAAC,MACZ;CAC3B,IAAM,IAAiC,CAAC;CAUxC,OARI,GAAQ,QAAQ,YAAY,CAAC,EAAW,GAAO,MAAM,MACvD,EAAO,SAAS,4BAGb,EAAW,GAAO,aAAa,MAClC,EAAO,gBAAgB,+BAGlB;AACT"}
|
|
@@ -1,6 +1,171 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as e, C as t, E as n, F as r, M as i, N as a, O as o, S as s, T as c, _ as l, a as u, b as d, c as f, g as p, j as m, k as h, l as g, m as _, n as v, p as y, r as b, s as x, t as S, u as C, v as w, x as T, y as E } from "../client-BSTc3boO.js";
|
|
2
|
+
import { n as D, r as O, t as k } from "../i18n-BaF24Jzw.js";
|
|
3
|
+
//#region src/delivery/TeacherInstructions.svelte
|
|
4
|
+
var A = p("<div class=\"teacher-instructions pie-teacher-instructions svelte-1jhejbv\"><button type=\"button\" class=\"teacher-instructions-toggle pie-teacher-instructions-toggle svelte-1jhejbv\"> </button> <div class=\"teacher-instructions-content pie-teacher-instructions-content svelte-1jhejbv\"></div></div>"), j = {
|
|
5
|
+
hash: "svelte-1jhejbv",
|
|
6
|
+
code: ".teacher-instructions.svelte-1jhejbv {margin-bottom:1rem;}.teacher-instructions-toggle.svelte-1jhejbv {padding:0;border:0;border-bottom:1px dotted currentColor;background:transparent;font:inherit;color:var(--pie-primary, #3f51b5);cursor:pointer;}.teacher-instructions-toggle.svelte-1jhejbv:focus-visible {outline:2px solid var(--pie-button-focus-outline, #3b82f6);outline-offset:2px;}.teacher-instructions-content.svelte-1jhejbv {padding-top:1rem;}"
|
|
7
|
+
};
|
|
8
|
+
function M(s, l) {
|
|
9
|
+
a(l, !0), f(s, j);
|
|
10
|
+
let p = v(l, "html", 7), m = v(l, "language", 7), b = h(!1), x = `simple-cloze-teacher-instructions-${Math.random().toString(36).slice(2, 10)}`;
|
|
11
|
+
var S = {
|
|
12
|
+
get html() {
|
|
13
|
+
return p();
|
|
14
|
+
},
|
|
15
|
+
set html(t) {
|
|
16
|
+
p(t), e();
|
|
17
|
+
},
|
|
18
|
+
get language() {
|
|
19
|
+
return m();
|
|
20
|
+
},
|
|
21
|
+
set language(t) {
|
|
22
|
+
m(t), e();
|
|
23
|
+
}
|
|
24
|
+
}, C = A(), w = t(C), O = c(w, !0), k = n(w, 2);
|
|
25
|
+
return g(k, p, !0), r(k), r(C), T((e) => {
|
|
26
|
+
u(w, "aria-expanded", d(b)), u(w, "aria-controls", x), y(O, e), u(k, "id", x), u(k, "hidden", !d(b));
|
|
27
|
+
}, [() => D(d(b) ? "hideTeacherInstructions" : "showTeacherInstructions", m())]), E("click", w, () => o(b, !d(b))), _(s, C), i(S);
|
|
28
|
+
}
|
|
29
|
+
w(["click"]), S(M, {
|
|
30
|
+
html: {},
|
|
31
|
+
language: {}
|
|
32
|
+
}, [], [], { mode: "open" });
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/delivery/SimpleCloze.svelte
|
|
35
|
+
var ee = p("<div class=\"simple-cloze-prompt svelte-1glps5n\"></div>"), te = l("<svg preserveAspectRatio=\"xMinYMin meet\" version=\"1.1\" viewBox=\"-283 359 34 35\" focusable=\"false\" class=\"svelte-1glps5n\"><circle cx=\"-266\" cy=\"375.9\" r=\"14\" fill=\"#bce2ff\"></circle><path d=\"M-280.5,375.9c0-8,6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5s-6.5,14.5-14.5,14.5S-280.5,383.9-280.5,375.9z M-279.5,375.9c0,7.4,6.1,13.5,13.5,13.5c7.4,0,13.5-6.1,13.5-13.5s-6.1-13.5-13.5-13.5C-273.4,362.4-279.5,368.5-279.5,375.9z\" fill=\"#bce2ff\"></path><polygon points=\"-265.4,383.1 -258.6,377.2 -261.2,374.2 -264.3,376.9 -268.9,368.7 -272.4,370.6\" fill=\"#1a9cff\"></polygon></svg>"), ne = l("<svg preserveAspectRatio=\"xMinYMin meet\" version=\"1.1\" viewBox=\"-129.5 127 34 35\" focusable=\"false\" class=\"svelte-1glps5n\"><path style=\"fill: #D0CAC5; stroke: #E6E3E0; stroke-width: 0.75; stroke-miterlimit: 10;\" d=\"M-112.9,160.4c-8.5,0-15.5-6.9-15.5-15.5c0-8.5,6.9-15.5,15.5-15.5s15.5,6.9,15.5,15.5 C-97.4,153.5-104.3,160.4-112.9,160.4z\"></path><path style=\"fill: #B3ABA4; stroke: #CDC7C2; stroke-width: 0.5; stroke-miterlimit: 10;\" d=\"M-113.2,159c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-105.2,159-113.2,159z\"></path><circle cx=\"-114.2\" cy=\"143.5\" r=\"14\" fill=\"white\"></circle><path d=\"M-114.2,158c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-106.2,158-114.2,158z M-114.2,130c-7.4,0-13.5,6.1-13.5,13.5s6.1,13.5,13.5,13.5s13.5-6.1,13.5-13.5S-106.8,130-114.2,130z\" fill=\"#bce2ff\"></path><polygon points=\"-114.8,150.7 -121.6,144.8 -119,141.8 -115.9,144.5 -111.3,136.3 -107.8,138.2\" fill=\"#1a9cff\"></polygon></svg>"), re = p("<button type=\"button\" class=\"simple-cloze-toggle svelte-1glps5n\"><span class=\"simple-cloze-toggle-icon svelte-1glps5n\" aria-hidden=\"true\"><!></span> <span class=\"simple-cloze-toggle-label svelte-1glps5n\"> </span></button>"), ie = p("<span class=\"correctness-icon correctness-icon--correct svelte-1glps5n\" aria-hidden=\"true\"><svg fill=\"currentColor\" viewBox=\"0 0 24 24\" focusable=\"false\" class=\"svelte-1glps5n\"><path d=\"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z\"></path></svg></span>"), ae = p("<span class=\"correctness-icon correctness-icon--incorrect svelte-1glps5n\" aria-hidden=\"true\"><svg fill=\"currentColor\" viewBox=\"0 0 24 24\" focusable=\"false\" class=\"svelte-1glps5n\"><path d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z\"></path></svg></span>"), oe = p("<div class=\"simple-cloze-root svelte-1glps5n\"><!> <!> <!> <div class=\"simple-cloze-response svelte-1glps5n\"><!> <input type=\"text\" spellcheck=\"false\"/> <span class=\"sr-only svelte-1glps5n\" role=\"status\"> </span></div></div>"), se = {
|
|
36
|
+
hash: "svelte-1glps5n",
|
|
37
|
+
code: "\n /*\n * Self-contained: players ship no Tailwind, so nothing here relies on host\n * utility classes or a CSS reset. Colours are `--pie-*` theme variables with\n * the fallbacks `@pie-lib/render-ui`'s `color` module uses.\n */.simple-cloze-root.svelte-1glps5n {padding:1rem;color:var(--pie-text, black);}.simple-cloze-prompt.svelte-1glps5n {margin-bottom:1rem;}.simple-cloze-prompt.svelte-1glps5n p {margin:0.5em 0;}.simple-cloze-prompt.svelte-1glps5n strong {font-weight:600;}.simple-cloze-toggle.svelte-1glps5n {display:flex;align-items:center;gap:0.5rem;margin:0 0 0.75rem;padding:0;border:0;background:transparent;color:inherit;font:inherit;cursor:pointer;user-select:none;}.simple-cloze-toggle.svelte-1glps5n:hover .simple-cloze-toggle-label:where(.svelte-1glps5n) {text-decoration:underline;}.simple-cloze-toggle.svelte-1glps5n:focus-visible {outline:2px solid var(--pie-button-focus-outline, #3b82f6);outline-offset:2px;}.simple-cloze-toggle-icon.svelte-1glps5n {display:inline-flex;}.simple-cloze-toggle-icon.svelte-1glps5n svg:where(.svelte-1glps5n) {width:25px;height:25px;}.simple-cloze-toggle-label.svelte-1glps5n {font-size:0.875rem;line-height:1.25rem;}.simple-cloze-response.svelte-1glps5n {position:relative;display:inline-block;}.simple-cloze-input.svelte-1glps5n {box-sizing:border-box;margin:0;padding:0.5rem 0.75rem;\n /* The text colour, as ECR's input border: a light grey fails 3:1 (WCAG 1.4.11). */border:1px solid var(--pie-text, black);border-radius:0.25rem;background-color:transparent;color:var(--pie-text, black);font:inherit;}.simple-cloze-input.svelte-1glps5n:disabled {opacity:1;color:var(--pie-text, black);-webkit-text-fill-color:currentColor;}.simple-cloze-input.svelte-1glps5n:focus-visible {outline:2px solid var(--pie-button-focus-outline, #3b82f6);outline-offset:2px;}.simple-cloze-input--correct.svelte-1glps5n {border:2px solid var(--pie-correct-tertiary, #0ea449);}.simple-cloze-input--incorrect.svelte-1glps5n {border:2px solid var(--pie-incorrect-icon, #bf0d00);}.simple-cloze-input[readonly].svelte-1glps5n {font-weight:600;}.correctness-icon.svelte-1glps5n {position:absolute;top:-8px;left:-8px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;padding:2px;color:var(--pie-white, #ffffff);}.correctness-icon.svelte-1glps5n svg:where(.svelte-1glps5n) {width:12px;height:12px;}.correctness-icon--correct.svelte-1glps5n {background-color:var(--pie-correct-tertiary, #0ea449);}.correctness-icon--incorrect.svelte-1glps5n {background-color:var(--pie-incorrect-icon, #bf0d00);}.sr-only.svelte-1glps5n {position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;}"
|
|
38
|
+
};
|
|
39
|
+
function N(l, p) {
|
|
40
|
+
a(p, !0), f(l, se);
|
|
41
|
+
let S = v(p, "model", 7, null), w = v(p, "session", 7, null), A = v(p, "onSessionChange", 7), j = `simple-cloze-${Math.random().toString(36).slice(2, 10)}`, N = `${j}-prompt`, P = `${j}-feedback`, F = h(null), I = h(null), L = h(!1), R = m(() => S()?.mode === "evaluate"), z = m(() => S()?.correctness), B = m(() => d(z) === "correct"), V = m(() => d(z) === "incorrect"), ce = m(() => d(z) === "unanswered"), H = m(() => typeof S()?.prompt == "string" ? S().prompt : ""), U = m(() => typeof S()?.correctAnswer == "string" ? S().correctAnswer : ""), le = m(() => typeof w()?.value == "string" ? w().value : ""), W = m(() => d(R) && !d(B) && !!d(U).trim()), G = m(() => d(L) && d(W)), K = m(() => d(R) ? d(G) ? k("correctAnswerShown", S()?.language) : d(B) ? k("correct", S()?.language) : d(V) ? k("incorrect", S()?.language) : d(ce) ? k("unanswered", S()?.language) : "" : "");
|
|
42
|
+
s(() => {
|
|
43
|
+
d(W) || o(L, !1);
|
|
44
|
+
}), s(() => {
|
|
45
|
+
if (!d(I)) return;
|
|
46
|
+
let e = d(G) ? d(U) : d(le);
|
|
47
|
+
d(I).value !== e && (d(I).value = e);
|
|
48
|
+
}), s(() => {
|
|
49
|
+
if (!d(F) || !d(H)) return;
|
|
50
|
+
let e = (e) => console.warn("simple-cloze: MathJax render failed", e);
|
|
51
|
+
try {
|
|
52
|
+
Promise.resolve(O(d(F))).catch(e);
|
|
53
|
+
} catch (t) {
|
|
54
|
+
e(t);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
function ue(e) {
|
|
58
|
+
let t = e.target.value;
|
|
59
|
+
A()?.({
|
|
60
|
+
...w(),
|
|
61
|
+
value: t
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function de() {
|
|
65
|
+
d(W) && o(L, !d(L));
|
|
66
|
+
}
|
|
67
|
+
var fe = {
|
|
68
|
+
get model() {
|
|
69
|
+
return S();
|
|
70
|
+
},
|
|
71
|
+
set model(t = null) {
|
|
72
|
+
S(t), e();
|
|
73
|
+
},
|
|
74
|
+
get session() {
|
|
75
|
+
return w();
|
|
76
|
+
},
|
|
77
|
+
set session(t = null) {
|
|
78
|
+
w(t), e();
|
|
79
|
+
},
|
|
80
|
+
get onSessionChange() {
|
|
81
|
+
return A();
|
|
82
|
+
},
|
|
83
|
+
set onSessionChange(t) {
|
|
84
|
+
A(t), e();
|
|
85
|
+
}
|
|
86
|
+
}, q = oe(), J = t(q), pe = (e) => {
|
|
87
|
+
{
|
|
88
|
+
let t = m(() => S()?.language);
|
|
89
|
+
M(e, {
|
|
90
|
+
get html() {
|
|
91
|
+
return S().teacherInstructions;
|
|
92
|
+
},
|
|
93
|
+
get language() {
|
|
94
|
+
return d(t);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
C(J, (e) => {
|
|
100
|
+
S()?.teacherInstructions && e(pe);
|
|
101
|
+
});
|
|
102
|
+
var Y = n(J, 2), me = (e) => {
|
|
103
|
+
var t = ee();
|
|
104
|
+
g(t, () => d(H), !0), r(t), b(t, (e) => o(F, e), () => d(F)), T(() => u(t, "id", N)), _(e, t);
|
|
105
|
+
};
|
|
106
|
+
C(Y, (e) => {
|
|
107
|
+
d(H) && e(me);
|
|
108
|
+
});
|
|
109
|
+
var X = n(Y, 2), he = (e) => {
|
|
110
|
+
var i = re(), a = t(i), o = t(a), s = (e) => {
|
|
111
|
+
_(e, te());
|
|
112
|
+
}, l = (e) => {
|
|
113
|
+
_(e, ne());
|
|
114
|
+
};
|
|
115
|
+
C(o, (e) => {
|
|
116
|
+
d(G) ? e(s) : e(l, -1);
|
|
117
|
+
}), r(a);
|
|
118
|
+
var f = c(n(a, 2), !0);
|
|
119
|
+
r(i), T((e) => {
|
|
120
|
+
u(i, "aria-pressed", d(G)), y(f, e);
|
|
121
|
+
}, [() => D(d(G) ? "hideCorrectAnswer" : "showCorrectAnswer", S()?.language)]), E("click", i, de), _(e, i);
|
|
122
|
+
};
|
|
123
|
+
C(X, (e) => {
|
|
124
|
+
d(W) && e(he);
|
|
125
|
+
});
|
|
126
|
+
var Z = n(X, 2), Q = t(Z), ge = (e) => {
|
|
127
|
+
_(e, ie());
|
|
128
|
+
}, _e = (e) => {
|
|
129
|
+
_(e, ae());
|
|
130
|
+
};
|
|
131
|
+
C(Q, (e) => {
|
|
132
|
+
d(R) && (d(B) || d(G)) ? e(ge) : d(R) && d(V) && e(_e, 1);
|
|
133
|
+
});
|
|
134
|
+
var $ = n(Q, 2);
|
|
135
|
+
let ve;
|
|
136
|
+
b($, (e) => o(I, e), () => d(I));
|
|
137
|
+
var ye = n($, 2), be = c(ye, !0);
|
|
138
|
+
return r(Z), r(q), T((e, t) => {
|
|
139
|
+
ve = x($, 1, "simple-cloze-input svelte-1glps5n", null, ve, {
|
|
140
|
+
"simple-cloze-input--correct": d(R) && (d(B) || d(G)),
|
|
141
|
+
"simple-cloze-input--incorrect": d(R) && d(V) && !d(G)
|
|
142
|
+
}), u($, "placeholder", e), u($, "aria-labelledby", d(H) ? N : void 0), u($, "aria-label", t), u($, "aria-describedby", d(K) ? P : void 0), $.disabled = S()?.disabled, $.readOnly = d(G), u(ye, "id", P), y(be, d(K));
|
|
143
|
+
}, [() => k("placeholder", S()?.language), () => d(H) ? void 0 : k("answerInput", S()?.language)]), E("input", $, ue), _(l, q), i(fe);
|
|
144
|
+
}
|
|
145
|
+
w(["click", "input"]), S(N, {
|
|
146
|
+
model: { type: "Object" },
|
|
147
|
+
session: { type: "Object" },
|
|
148
|
+
onSessionChange: {}
|
|
149
|
+
}, [], []);
|
|
150
|
+
//#endregion
|
|
2
151
|
//#region ../../lib-svelte/delivery-events/dist/index2.js
|
|
3
|
-
|
|
152
|
+
function P(e) {
|
|
153
|
+
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
154
|
+
}
|
|
155
|
+
function F(e, t) {
|
|
156
|
+
if (e === t) return e;
|
|
157
|
+
if (!P(e) || !P(t) || Object.isFrozen(e) || !Object.isExtensible(e)) return t;
|
|
158
|
+
try {
|
|
159
|
+
for (let n of Object.keys(e)) n in t || delete e[n];
|
|
160
|
+
Object.assign(e, t);
|
|
161
|
+
} catch {
|
|
162
|
+
return t;
|
|
163
|
+
}
|
|
164
|
+
return e;
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region ../../shared/player-events/dist/index.js
|
|
168
|
+
var I = class e extends CustomEvent {
|
|
4
169
|
static {
|
|
5
170
|
this.TYPE = "model-set";
|
|
6
171
|
}
|
|
@@ -15,7 +180,7 @@ var E = class e extends CustomEvent {
|
|
|
15
180
|
}
|
|
16
181
|
}), this.component = t, this.complete = n;
|
|
17
182
|
}
|
|
18
|
-
},
|
|
183
|
+
}, L = class e extends CustomEvent {
|
|
19
184
|
static {
|
|
20
185
|
this.TYPE = "session-changed";
|
|
21
186
|
}
|
|
@@ -29,166 +194,50 @@ var E = class e extends CustomEvent {
|
|
|
29
194
|
}
|
|
30
195
|
}), this.component = t, this.complete = n;
|
|
31
196
|
}
|
|
32
|
-
}, O = (e) => {
|
|
33
|
-
let t = e;
|
|
34
|
-
return t ? typeof t.onSessionChange == "function" || typeof t.onAudioStarted == "function" || typeof t.onAudioEnded == "function" : !1;
|
|
35
197
|
};
|
|
36
|
-
function k(e, t = {}) {
|
|
37
|
-
let n = t.hostPredicate ?? O, r = e;
|
|
38
|
-
for (; r;) {
|
|
39
|
-
if (n(r)) return r;
|
|
40
|
-
r = r.parentElement;
|
|
41
|
-
}
|
|
42
|
-
if (typeof document < "u" && t.fallbackSelector) {
|
|
43
|
-
let e = document.querySelector(t.fallbackSelector);
|
|
44
|
-
if (n(e)) return e;
|
|
45
|
-
}
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
function A(e) {
|
|
49
|
-
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
50
|
-
}
|
|
51
|
-
function j(e, t) {
|
|
52
|
-
if (e === t) return e;
|
|
53
|
-
if (!A(e) || !A(t) || Object.isFrozen(e) || !Object.isExtensible(e)) return t;
|
|
54
|
-
try {
|
|
55
|
-
for (let n of Object.keys(e)) n in t || delete e[n];
|
|
56
|
-
Object.assign(e, t);
|
|
57
|
-
} catch {
|
|
58
|
-
return t;
|
|
59
|
-
}
|
|
60
|
-
return e;
|
|
61
|
-
}
|
|
62
|
-
function M({ sourceEl: e, fallbackSelector: t, component: n, complete: r, session: i }) {
|
|
63
|
-
let a = k(e, { fallbackSelector: t });
|
|
64
|
-
return a ? typeof a.onSessionChange == "function" ? (a.onSessionChange(i), a) : (a.dispatchEvent(new D(n, r)), a) : null;
|
|
65
|
-
}
|
|
66
198
|
//#endregion
|
|
67
|
-
//#region
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
199
|
+
//#region ../../lib-svelte/delivery-events/dist/index3.js
|
|
200
|
+
function R(e, t) {
|
|
201
|
+
let n = e.element;
|
|
202
|
+
if (!n) throw TypeError("defineDeliveryElement: the component was not compiled with `customElement`");
|
|
203
|
+
class r extends n {
|
|
204
|
+
#e;
|
|
205
|
+
#t;
|
|
206
|
+
constructor() {
|
|
207
|
+
super(), this.onSessionChange = (e) => {
|
|
208
|
+
this.writeSession(e), this.dispatchSessionChanged();
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
set model(e) {
|
|
212
|
+
this.#e = e, super.model = e, queueMicrotask(() => {
|
|
213
|
+
this.dispatchEvent(new I(this.tagName.toLowerCase(), this.isComplete(), this.#e !== void 0));
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
get model() {
|
|
217
|
+
return this.#e;
|
|
218
|
+
}
|
|
219
|
+
set session(e) {
|
|
220
|
+
this.#t = e, super.session = e, this.dispatchSessionChanged();
|
|
221
|
+
}
|
|
222
|
+
get session() {
|
|
223
|
+
return this.#t;
|
|
224
|
+
}
|
|
225
|
+
isComplete() {
|
|
226
|
+
return t.isComplete(this.#e, this.#t);
|
|
227
|
+
}
|
|
228
|
+
writeSession(e) {
|
|
229
|
+
this.#t = F(this.#t, e), super.session = e;
|
|
230
|
+
}
|
|
231
|
+
dispatchSessionChanged() {
|
|
232
|
+
this.dispatchEvent(new L(this.tagName.toLowerCase(), this.isComplete()));
|
|
86
233
|
}
|
|
87
|
-
}), l(() => {
|
|
88
|
-
w && (e(T) && x?.model?.correctAnswer ? w.value = x.model.correctAnswer : e(T) || (w.value = x?.session?.response || ""));
|
|
89
|
-
});
|
|
90
|
-
function E(e) {
|
|
91
|
-
let t = e.target, n = t.value;
|
|
92
|
-
M({
|
|
93
|
-
sourceEl: t,
|
|
94
|
-
fallbackSelector: "simple-cloze",
|
|
95
|
-
component: "simple-cloze",
|
|
96
|
-
session: {
|
|
97
|
-
...x.session,
|
|
98
|
-
response: n
|
|
99
|
-
},
|
|
100
|
-
complete: n.trim().length > 0
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
function D() {
|
|
104
|
-
_(T, !e(T));
|
|
105
234
|
}
|
|
106
|
-
|
|
107
|
-
var H = B(), U = t(H), W = (e) => {
|
|
108
|
-
var t = P();
|
|
109
|
-
p(t, () => x.model.prompt, !0), s(t), u(e, t);
|
|
110
|
-
};
|
|
111
|
-
m(U, (e) => {
|
|
112
|
-
x?.model?.prompt && e(W);
|
|
113
|
-
});
|
|
114
|
-
var G = v(U, 2), K = (n) => {
|
|
115
|
-
var r = L(), i = t(r), o = (e) => {
|
|
116
|
-
u(e, F());
|
|
117
|
-
}, l = (e) => {
|
|
118
|
-
u(e, I());
|
|
119
|
-
};
|
|
120
|
-
m(i, (t) => {
|
|
121
|
-
e(T) ? t(o) : t(l, -1);
|
|
122
|
-
});
|
|
123
|
-
var d = a(v(i, 2));
|
|
124
|
-
s(r), C(() => {
|
|
125
|
-
y(r, "aria-pressed", e(T)), ee(d, `${e(T) ? "Hide" : "Show"} correct answer`);
|
|
126
|
-
}), c("click", r, D), u(n, r);
|
|
127
|
-
};
|
|
128
|
-
m(G, (t) => {
|
|
129
|
-
e(O) && e(j) && t(K);
|
|
130
|
-
});
|
|
131
|
-
var q = v(G, 2), J = t(q), Y = (e) => {
|
|
132
|
-
u(e, R());
|
|
133
|
-
};
|
|
134
|
-
m(J, (t) => {
|
|
135
|
-
e(O) && (e(A) || e(T)) && t(Y);
|
|
136
|
-
});
|
|
137
|
-
var X = v(J, 2), Z = (e) => {
|
|
138
|
-
u(e, z());
|
|
139
|
-
};
|
|
140
|
-
m(X, (t) => {
|
|
141
|
-
e(O) && e(j) && !e(T) && t(Z);
|
|
142
|
-
});
|
|
143
|
-
var Q = v(X, 2);
|
|
144
|
-
let $;
|
|
145
|
-
g(Q, (e) => w = e, () => w), s(q), s(H), C(() => {
|
|
146
|
-
Q.disabled = x?.model?.disabled, Q.readOnly = e(T), $ = f(Q, "", $, {
|
|
147
|
-
border: e(O) && (e(A) || e(T)) ? "solid 2px #0EA449" : e(O) && e(j) && !e(T) ? "solid 2px #BF0D00" : "solid 1px #d1d5db",
|
|
148
|
-
color: e(O) && (e(A) || e(j)) ? "black" : ""
|
|
149
|
-
});
|
|
150
|
-
}), u(d, H), n();
|
|
235
|
+
return r;
|
|
151
236
|
}
|
|
152
|
-
w(["click"]), x(H, {
|
|
153
|
-
model: { type: "Object" },
|
|
154
|
-
session: { type: "Object" }
|
|
155
|
-
}, [], []);
|
|
156
237
|
//#endregion
|
|
157
238
|
//#region src/delivery/index.ts
|
|
158
|
-
var
|
|
159
|
-
_internalSession = null;
|
|
160
|
-
_playerSession = null;
|
|
161
|
-
_model = null;
|
|
162
|
-
_isComplete = () => {
|
|
163
|
-
let e = this._internalSession?.response;
|
|
164
|
-
return typeof e == "string" && e.trim().length > 0;
|
|
165
|
-
};
|
|
166
|
-
_dispatchModelSet = () => {
|
|
167
|
-
this.dispatchEvent(new E(this.tagName.toLowerCase(), this._isComplete(), this._model !== void 0));
|
|
168
|
-
};
|
|
169
|
-
_dispatchSessionChanged = () => {
|
|
170
|
-
this.dispatchEvent(new D(this.tagName.toLowerCase(), this._isComplete()));
|
|
171
|
-
};
|
|
172
|
-
set model(e) {
|
|
173
|
-
this._model = e, super.model = e, this._dispatchModelSet();
|
|
174
|
-
}
|
|
175
|
-
get model() {
|
|
176
|
-
return this._model;
|
|
177
|
-
}
|
|
178
|
-
set session(e) {
|
|
179
|
-
this._playerSession = e, this._internalSession = e, super.session = e, this._dispatchSessionChanged();
|
|
180
|
-
}
|
|
181
|
-
get session() {
|
|
182
|
-
return this._internalSession;
|
|
183
|
-
}
|
|
184
|
-
onSessionChange = (e) => {
|
|
185
|
-
j(this._playerSession, e), this._internalSession = e, super.session = e, this._dispatchSessionChanged();
|
|
186
|
-
};
|
|
187
|
-
connectedCallback() {
|
|
188
|
-
super.connectedCallback(), this.onSessionChange = this.onSessionChange;
|
|
189
|
-
}
|
|
190
|
-
};
|
|
239
|
+
var z = R(N, { isComplete: (e, t) => typeof t?.value == "string" && t.value.trim().length > 0 });
|
|
191
240
|
//#endregion
|
|
192
|
-
export {
|
|
241
|
+
export { z as default };
|
|
193
242
|
|
|
194
243
|
//# sourceMappingURL=index.js.map
|