@pie-element/math-templated 7.1.1-next.12 → 7.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 +1 -0
- package/CHANGELOG.md +1144 -0
- package/LICENSE.md +5 -0
- package/README.md +0 -0
- package/configure/CHANGELOG.json +1 -0
- package/configure/CHANGELOG.md +1021 -0
- package/configure/lib/defaults.js +172 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/design.js +546 -0
- package/configure/lib/design.js.map +1 -0
- package/configure/lib/index.js +169 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/markupUtils.js +39 -0
- package/configure/lib/markupUtils.js.map +1 -0
- package/configure/lib/response.js +394 -0
- package/configure/lib/response.js.map +1 -0
- package/configure/lib/utils.js +15 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +26 -0
- package/controller/CHANGELOG.json +1 -0
- package/controller/CHANGELOG.md +874 -0
- package/controller/lib/defaults.js +28 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +360 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/package.json +17 -0
- package/docs/config-schema.json +2251 -0
- package/docs/config-schema.json.md +1658 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +42 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +14 -0
- package/docs/pie-schema.json +1231 -0
- package/docs/pie-schema.json.md +894 -0
- package/lib/index.js +76 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +877 -0
- package/lib/main.js.map +1 -0
- package/lib/print.js +88 -0
- package/lib/print.js.map +1 -0
- package/module/configure.js +1 -0
- package/module/controller.js +3711 -0
- package/module/demo.js +67 -0
- package/module/element.js +1 -0
- package/module/index.html +21 -0
- package/module/manifest.json +22 -0
- package/module/print-demo.js +105 -0
- package/module/print.html +18 -0
- package/module/print.js +1 -0
- package/package.json +22 -93
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/defaults.d.ts +0 -173
- package/dist/author/defaults.js +0 -123
- package/dist/author/design.d.ts +0 -35
- package/dist/author/design.js +0 -360
- package/dist/author/index.d.ts +0 -42
- package/dist/author/index.js +0 -97
- package/dist/author/markupUtils.d.ts +0 -11
- package/dist/author/markupUtils.js +0 -10
- package/dist/author/response.d.ts +0 -41
- package/dist/author/response.js +0 -238
- package/dist/author/utils.d.ts +0 -9
- package/dist/author/utils.js +0 -7
- package/dist/browser/author/index.js +0 -31954
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/browser-DJA4OL8j.js +0 -331
- package/dist/browser/browser-DJA4OL8j.js.map +0 -1
- package/dist/browser/controller/index.js +0 -37731
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -81
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/dist-Csid0rBE.js +0 -17046
- package/dist/browser/dist-Csid0rBE.js.map +0 -1
- package/dist/browser/dist-D9ARZhQk.js +0 -1426
- package/dist/browser/dist-D9ARZhQk.js.map +0 -1
- package/dist/browser/main-I_wWeaur.js +0 -1274
- package/dist/browser/main-I_wWeaur.js.map +0 -1
- package/dist/browser/math-templated.css +0 -2
- package/dist/browser/print/index.js +0 -47
- package/dist/browser/print/index.js.map +0 -1
- package/dist/controller/defaults.d.ts +0 -29
- package/dist/controller/defaults.js +0 -23
- package/dist/controller/index.d.ts +0 -45
- package/dist/controller/index.js +0 -154
- package/dist/delivery/index.d.ts +0 -20
- package/dist/delivery/index.js +0 -51
- package/dist/delivery/main.d.ts +0 -40
- package/dist/delivery/main.js +0 -492
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -205
- package/dist/index.js +0 -2
- package/dist/math-templated.css +0 -2
- package/dist/print/index.d.ts +0 -15
- package/dist/print/index.js +0 -47
- package/dist/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { C as e, t, u as n } from "../browser-DJA4OL8j.js";
|
|
2
|
-
import { w as r } from "../dist-Csid0rBE.js";
|
|
3
|
-
import { t as i } from "../main-I_wWeaur.js";
|
|
4
|
-
import a from "react";
|
|
5
|
-
import { createRoot as o } from "react-dom/client";
|
|
6
|
-
var s = (0, (/* @__PURE__ */ e(t(), 1)).default)("pie-element:math-templated:print"), c = (e, t) => {
|
|
7
|
-
let n = t.role === "instructor";
|
|
8
|
-
return e.prompt = e.promptEnabled === !1 ? void 0 : e.prompt, e.teacherInstructions = n && e.teacherInstructionsEnabled !== !1 ? e.teacherInstructions : void 0, e.rationale = n && e.rationaleEnabled !== !1 ? e.rationale : void 0, e.showTeacherInstructions = n, e.alwaysShowCorrect = n, e.printMode = !0, e.feedback = void 0, e.markup = e.markup || "{{0}}", {
|
|
9
|
-
...e,
|
|
10
|
-
disabled: !0,
|
|
11
|
-
env: {
|
|
12
|
-
mode: n ? "evaluate" : e.mode,
|
|
13
|
-
role: t.role
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
}, l = class extends HTMLElement {
|
|
17
|
-
constructor() {
|
|
18
|
-
super(), this._options = null, this._model = null, this._session = [], this._root = null, this._rerender = n(() => {
|
|
19
|
-
if (this._model && this._session) {
|
|
20
|
-
let e = c(this._model, this._options), t = this._options && a.createElement(i, {
|
|
21
|
-
model: e,
|
|
22
|
-
session: {}
|
|
23
|
-
});
|
|
24
|
-
this._root ||= o(this), this._root.render(t), queueMicrotask(() => {
|
|
25
|
-
s("render complete - render math"), r(this);
|
|
26
|
-
});
|
|
27
|
-
} else s("skip");
|
|
28
|
-
}, 50, {
|
|
29
|
-
leading: !1,
|
|
30
|
-
trailing: !0
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
set options(e) {
|
|
34
|
-
this._options = e;
|
|
35
|
-
}
|
|
36
|
-
set model(e) {
|
|
37
|
-
this._model = e, this._rerender();
|
|
38
|
-
}
|
|
39
|
-
connectedCallback() {}
|
|
40
|
-
disconnectedCallback() {
|
|
41
|
-
this._root && this._root.unmount();
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
//#endregion
|
|
45
|
-
export { l as default };
|
|
46
|
-
|
|
47
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/print/index.tsx"],"sourcesContent":["// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/math-templated/src/print.js\n * @auto-generated\n *\n * This file is automatically synced from pie-elements and converted to TypeScript.\n * Manual edits will be overwritten on next sync.\n * To make changes, edit the upstream JavaScript file and run sync again.\n */\n\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { debounce } from '@pie-element/shared-lodash';\nimport Main from '../delivery/main.js';\nimport { renderMath } from '@pie-element/shared-math-rendering-mathjax';\nimport debug from 'debug';\n\nconst log = debug('pie-element:math-templated:print');\n\n/**\n * Live in same package as main element - so we can access some of the shared comps!\n *\n * - update pslb to build print if src/print.js is there\n * - update demo el\n * - get configure/controller building\n */\n\nconst preparePrintModel = (model, opts) => {\n const instr = opts.role === 'instructor';\n\n model.prompt = model.promptEnabled !== false ? model.prompt : undefined;\n model.teacherInstructions =\n instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;\n model.rationale = instr && model.rationaleEnabled !== false ? model.rationale : undefined;\n model.showTeacherInstructions = instr;\n model.alwaysShowCorrect = instr;\n model.printMode = true;\n model.feedback = undefined;\n model.markup = model.markup || '{{0}}';\n\n return {\n ...model,\n disabled: true,\n env: { mode: instr ? 'evaluate' : model.mode, role: opts.role },\n };\n};\n\nexport default class MathTemplatedPrint extends HTMLElement {\n constructor() {\n super();\n this._options = null;\n this._model = null;\n this._session = [];\n this._root = null;\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n const printModel = preparePrintModel(this._model, this._options);\n\n const element =\n this._options &&\n React.createElement(Main, {\n model: printModel,\n session: {},\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n queueMicrotask(() => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n set options(o) {\n this._options = o;\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n connectedCallback() {}\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;AAiBA,IAAM,KAAA,IAAA,wBAAA,GAAA,SAAY,kCAAkC,GAU9C,KAAqB,GAAO,MAAS;CACzC,IAAM,IAAQ,EAAK,SAAS;CAY5B,OAVA,EAAM,SAAS,EAAM,kBAAkB,KAAuB,KAAA,IAAf,EAAM,QACrD,EAAM,sBACJ,KAAS,EAAM,+BAA+B,KAAQ,EAAM,sBAAsB,KAAA,GACpF,EAAM,YAAY,KAAS,EAAM,qBAAqB,KAAQ,EAAM,YAAY,KAAA,GAChF,EAAM,0BAA0B,GAChC,EAAM,oBAAoB,GAC1B,EAAM,YAAY,IAClB,EAAM,WAAW,KAAA,GACjB,EAAM,SAAS,EAAM,UAAU,SAExB;EACL,GAAG;EACH,UAAU;EACV,KAAK;GAAE,MAAM,IAAQ,aAAa,EAAM;GAAM,MAAM,EAAK;EAAK;CAChE;AACF,GAEqB,IAArB,cAAgD,YAAY;CAC1D,cAAc;EAMZ,AALA,MAAM,GACN,KAAK,WAAW,MAChB,KAAK,SAAS,MACd,KAAK,WAAW,CAAC,GACjB,KAAK,QAAQ,MACb,KAAK,YAAY,QACT;GACJ,IAAI,KAAK,UAAU,KAAK,UAAU;IAChC,IAAM,IAAa,EAAkB,KAAK,QAAQ,KAAK,QAAQ,GAEzD,IACJ,KAAK,YACL,EAAM,cAAc,GAAM;KACxB,OAAO;KACP,SAAS,CAAC;IACZ,CAAC;IAMH,AAJA,AACE,KAAK,UAAQ,EAAW,IAAI,GAE9B,KAAK,MAAM,OAAO,CAAO,GACzB,qBAAqB;KAEnB,AADA,EAAI,+BAA+B,GACnC,EAAW,IAAI;IACjB,CAAC;GACH,OACE,EAAI,MAAM;EAEd,GACA,IACA;GAAE,SAAS;GAAO,UAAU;EAAK,CACnC;CACF;CACA,IAAI,QAAQ,GAAG;EACb,KAAK,WAAW;CAClB;CAEA,IAAI,MAAM,GAAG;EAEX,AADA,KAAK,SAAS,GACd,KAAK,UAAU;CACjB;CAEA,oBAAoB,CAAC;CAErB,uBAAuB;EACrB,AAAI,KAAK,SACP,KAAK,MAAM,QAAQ;CAEvB;AACF"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/math-templated/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
|
-
model: {
|
|
11
|
-
allowTrailingZerosDefault: boolean;
|
|
12
|
-
equationEditor: string;
|
|
13
|
-
ignoreOrderDefault: boolean;
|
|
14
|
-
markup: string;
|
|
15
|
-
playerSpellCheckEnabled: boolean;
|
|
16
|
-
prompt: string;
|
|
17
|
-
promptEnabled: boolean;
|
|
18
|
-
rationale: string;
|
|
19
|
-
rationaleEnabled: boolean;
|
|
20
|
-
responses: {};
|
|
21
|
-
spellCheckEnabled: boolean;
|
|
22
|
-
teacherInstructions: string;
|
|
23
|
-
teacherInstructionsEnabled: boolean;
|
|
24
|
-
toolbarEditorPosition: string;
|
|
25
|
-
validationDefault: string;
|
|
26
|
-
};
|
|
27
|
-
configuration: {};
|
|
28
|
-
};
|
|
29
|
-
export default _default;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region src/controller/defaults.ts
|
|
2
|
-
var e = {
|
|
3
|
-
model: {
|
|
4
|
-
allowTrailingZerosDefault: !1,
|
|
5
|
-
equationEditor: "8",
|
|
6
|
-
ignoreOrderDefault: !1,
|
|
7
|
-
markup: "",
|
|
8
|
-
playerSpellCheckEnabled: !0,
|
|
9
|
-
prompt: "",
|
|
10
|
-
promptEnabled: !0,
|
|
11
|
-
rationale: "",
|
|
12
|
-
rationaleEnabled: !0,
|
|
13
|
-
responses: {},
|
|
14
|
-
spellCheckEnabled: !0,
|
|
15
|
-
teacherInstructions: "",
|
|
16
|
-
teacherInstructionsEnabled: !0,
|
|
17
|
-
toolbarEditorPosition: "bottom",
|
|
18
|
-
validationDefault: "literal"
|
|
19
|
-
},
|
|
20
|
-
configuration: {}
|
|
21
|
-
};
|
|
22
|
-
//#endregion
|
|
23
|
-
export { e as default };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/math-templated/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 getCorrectness: (question: any, env: any, session: any) => {
|
|
10
|
-
correctness: string;
|
|
11
|
-
score: number;
|
|
12
|
-
correct: boolean;
|
|
13
|
-
} | undefined;
|
|
14
|
-
export declare const getPartialScore: (question: any, session: any) => 1 | 0;
|
|
15
|
-
/**
|
|
16
|
-
* Generates detailed trace log for math-templated scoring evaluation
|
|
17
|
-
* @param {Object} question
|
|
18
|
-
* @param {Object} session
|
|
19
|
-
* @param {Object} env
|
|
20
|
-
* @returns {Array<string>} traceLog
|
|
21
|
-
*/
|
|
22
|
-
export declare const getLogTrace: (question: any, session: any, env: any) => string[];
|
|
23
|
-
export declare const outcome: (question: any, session: any, env: any) => Promise<unknown>;
|
|
24
|
-
export declare const createDefaultModel: (model?: {}) => {
|
|
25
|
-
responses: {};
|
|
26
|
-
allowTrailingZerosDefault: boolean;
|
|
27
|
-
equationEditor: string;
|
|
28
|
-
ignoreOrderDefault: boolean;
|
|
29
|
-
markup: string;
|
|
30
|
-
playerSpellCheckEnabled: boolean;
|
|
31
|
-
prompt: string;
|
|
32
|
-
promptEnabled: boolean;
|
|
33
|
-
rationale: string;
|
|
34
|
-
rationaleEnabled: boolean;
|
|
35
|
-
spellCheckEnabled: boolean;
|
|
36
|
-
teacherInstructions: string;
|
|
37
|
-
teacherInstructionsEnabled: boolean;
|
|
38
|
-
toolbarEditorPosition: string;
|
|
39
|
-
validationDefault: string;
|
|
40
|
-
};
|
|
41
|
-
export declare const normalizeSession: (s: any) => any;
|
|
42
|
-
export declare const prepareVal: (html: any) => any;
|
|
43
|
-
export declare const model: (question: any, session: any, env: any) => Promise<unknown>;
|
|
44
|
-
export declare const createCorrectResponseSession: (question: any, env: any) => Promise<unknown>;
|
|
45
|
-
export declare const validate: (model?: {}, config?: {}) => {};
|
package/dist/controller/index.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import e from "./defaults.js";
|
|
2
|
-
import { isEmpty as t } from "@pie-element/shared-lodash";
|
|
3
|
-
import n from "debug";
|
|
4
|
-
import r from "@pie-lib/translator";
|
|
5
|
-
import * as i from "@pie-framework/math-validation";
|
|
6
|
-
import { partialScoring as a } from "@pie-element/shared-controller-utils";
|
|
7
|
-
//#region src/controller/index.ts
|
|
8
|
-
var { translator: o } = r, s = n("@pie-element:math-templated:controller"), c = (e) => e ? "correct" : "incorrect", l = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), u = (t, n) => {
|
|
9
|
-
let r = !1, a = {
|
|
10
|
-
mode: t.validation || e.validationDefault,
|
|
11
|
-
...t.validation === "literal" && { literal: {
|
|
12
|
-
allowTrailingZeros: t.allowTrailingZeros || !1,
|
|
13
|
-
ignoreOrder: t.ignoreOrder || !1
|
|
14
|
-
} }
|
|
15
|
-
};
|
|
16
|
-
if (!r) {
|
|
17
|
-
let e = [t.answer, ...Object.values(t.alternates || {})];
|
|
18
|
-
try {
|
|
19
|
-
for (let t of e) if (r = i.latexEqual(n.value, t, a), r) break;
|
|
20
|
-
} catch (e) {
|
|
21
|
-
s("Parse failure when evaluating math", e, t, n), r = !1;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return r;
|
|
25
|
-
}, d = (e, t) => {
|
|
26
|
-
let n = e.responses;
|
|
27
|
-
if (t) {
|
|
28
|
-
let e = 0, r = 0, i = Object.keys(n || {}).length;
|
|
29
|
-
Object.keys(n).forEach((r) => {
|
|
30
|
-
let i = t["r" + r];
|
|
31
|
-
u(n[r] || {}, i) && e++;
|
|
32
|
-
});
|
|
33
|
-
let a = e === i;
|
|
34
|
-
return r = Number((e / Object.keys(n).length).toFixed(2)), {
|
|
35
|
-
correctness: c(a),
|
|
36
|
-
score: e > 0 ? r : 0,
|
|
37
|
-
correct: a
|
|
38
|
-
};
|
|
39
|
-
} else return {
|
|
40
|
-
correctness: "unanswered",
|
|
41
|
-
score: 0,
|
|
42
|
-
correct: !1
|
|
43
|
-
};
|
|
44
|
-
}, f = (e, t, n) => {
|
|
45
|
-
if (t.mode === "evaluate") return d(e, n && n.answers);
|
|
46
|
-
}, p = (e, n) => !n || t(n) ? 0 : 1, m = (e, t, n) => {
|
|
47
|
-
let r = [];
|
|
48
|
-
if (!t || !t.answers || Object.keys(t.answers).length === 0) return r.push("Student did not enter a response."), r;
|
|
49
|
-
let i = t.answers, o = Object.keys(e.responses || {}), s = o.length;
|
|
50
|
-
r.push(`${s} response area(s) defined in this question.`);
|
|
51
|
-
let c = 0, l = 0;
|
|
52
|
-
o.forEach((t, n) => {
|
|
53
|
-
let a = i[`r${t}`], o = a?.value?.trim(), s = e.responses[t] || {}, d = o ? o.replace(/\\/g, "") : "";
|
|
54
|
-
o ? (c++, r.push(`Response area ${n + 1}: student entered ${d}.`)) : r.push(`Response area ${n + 1}: no response entered.`);
|
|
55
|
-
let f = s.validation || e.validationDefault;
|
|
56
|
-
if (r.push(`Validation mode: ${f}.`), f === "literal") {
|
|
57
|
-
let e = s.allowTrailingZeros || !1, t = s.ignoreOrder || !1;
|
|
58
|
-
r.push(`Allow trailing zeros: ${e ? "enabled" : "disabled"}.`), r.push(`Ignore order: ${t ? "enabled" : "disabled"}.`);
|
|
59
|
-
}
|
|
60
|
-
let p = [s.answer].concat(Object.values(s.alternates || {}));
|
|
61
|
-
p.length > 1 && r.push(`Accepted answers: ${p.length} (including alternates).`), o && (u(s, a) ? (l++, r.push(`Response area ${n + 1} is correct.`)) : r.push(`Response area ${n + 1} is incorrect.`));
|
|
62
|
-
}), r.push(`${l} out of ${s} response area(s) are correct.`);
|
|
63
|
-
let d = a.enabled(e, n);
|
|
64
|
-
r.push(`Scoring method: ${d ? "partial scoring" : "all-or-nothing scoring"}.`), d ? r.push("Each correct response area contributes to the score.") : r.push("Student must answer all response areas correctly to receive full credit.");
|
|
65
|
-
let p = f(e, n, t);
|
|
66
|
-
return r.push(`Overall correctness: ${p.correctness}.`), r.push(`Final score: ${p.score}.`), r;
|
|
67
|
-
}, h = (e, n, r) => new Promise((i) => {
|
|
68
|
-
if (!n || t(n)) {
|
|
69
|
-
i({
|
|
70
|
-
score: 0,
|
|
71
|
-
empty: !0,
|
|
72
|
-
logTrace: ["Student did not enter a response."]
|
|
73
|
-
});
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
let o = a.enabled(e, r);
|
|
77
|
-
if (n = _(n), r.mode !== "evaluate") i({
|
|
78
|
-
score: void 0,
|
|
79
|
-
completed: void 0,
|
|
80
|
-
logTrace: []
|
|
81
|
-
});
|
|
82
|
-
else {
|
|
83
|
-
let t = f(e, r, n, !0).score;
|
|
84
|
-
i({
|
|
85
|
-
score: o ? t : +(t === 1),
|
|
86
|
-
logTrace: m(e, n, r)
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}), g = (t = {}) => {
|
|
90
|
-
let { validationDefault: n, allowTrailingZerosDefault: r, ignoreOrderDefault: i, responses: a = {} } = t, o = Object.keys(a).reduce((e, t) => {
|
|
91
|
-
let o = a[t];
|
|
92
|
-
return e[t] = {
|
|
93
|
-
...o,
|
|
94
|
-
validation: o.validation || n,
|
|
95
|
-
allowTrailingZeros: o.allowTrailingZeros || r,
|
|
96
|
-
ignoreOrder: o.ignoreOrder || i
|
|
97
|
-
}, e;
|
|
98
|
-
}, {});
|
|
99
|
-
return {
|
|
100
|
-
...e.model,
|
|
101
|
-
...t,
|
|
102
|
-
responses: o
|
|
103
|
-
};
|
|
104
|
-
}, _ = (e) => ({ ...e }), v = (e) => (e || "").replace(/<\/?[^>]+(>|$)/g, ""), y = (e) => v(e).trim(), b = (e, t, n) => new Promise((r) => {
|
|
105
|
-
t ||= {};
|
|
106
|
-
let i = g(e), a = f(i, n, t), { responses: c, language: l } = i, { note: d } = i, p = !1;
|
|
107
|
-
Object.keys(c).forEach((e) => {
|
|
108
|
-
let t = c[e] || {};
|
|
109
|
-
(t.alternates && Object.keys(t.alternates).length > 0 || t.validation !== "literal") && (p = !0);
|
|
110
|
-
}), d ||= o.t("mathInline.primaryCorrectWithAlternates", { lng: l });
|
|
111
|
-
let m = {
|
|
112
|
-
prompt: i.promptEnabled ? i.prompt : null,
|
|
113
|
-
markup: i.markup,
|
|
114
|
-
responses: n.mode === "gather" ? null : i.responses,
|
|
115
|
-
language: i.language,
|
|
116
|
-
equationEditor: i.equationEditor,
|
|
117
|
-
customKeys: i.customKeys,
|
|
118
|
-
disabled: n.mode !== "gather",
|
|
119
|
-
view: n.mode === "view",
|
|
120
|
-
correctness: a,
|
|
121
|
-
env: n,
|
|
122
|
-
extraCSSRules: i.extraCSSRules
|
|
123
|
-
}, { answers: h = {} } = t || {}, _ = {};
|
|
124
|
-
n.mode === "evaluate" && Object.keys(c).forEach((e) => {
|
|
125
|
-
let t = h["r" + e], n = c[e];
|
|
126
|
-
_[e] = u(n, t);
|
|
127
|
-
}), n.mode === "evaluate" ? (m.correctResponse = {}, m.showNote = p, m.note = d, m.feedback = _) : (m.responses = {}, m.showNote = !1), n.role === "instructor" && (n.mode === "view" || n.mode === "evaluate") ? (m.rationale = i.rationaleEnabled ? i.rationale : null, m.teacherInstructions = i.teacherInstructionsEnabled ? i.teacherInstructions : null) : (m.rationale = null, m.teacherInstructions = null), s("out: ", m), r(m);
|
|
128
|
-
}), x = (e, t) => new Promise((n) => {
|
|
129
|
-
t.mode !== "evaluate" && t.role === "instructor" ? n({
|
|
130
|
-
id: "1",
|
|
131
|
-
answers: Object.keys(e.responses).reduce((t, n) => (t["r" + n] = { value: e.responses[n].answer }, t), {})
|
|
132
|
-
}) : n(null);
|
|
133
|
-
}), S = (e = {}, n = {}) => {
|
|
134
|
-
let { responses: r, markup: i } = e, { maxResponseAreas: a } = n, o = {}, s = {};
|
|
135
|
-
[
|
|
136
|
-
"teacherInstructions",
|
|
137
|
-
"prompt",
|
|
138
|
-
"rationale"
|
|
139
|
-
].forEach((t) => {
|
|
140
|
-
n[t]?.required && !l(e[t]) && (s[t] = "This field is required.");
|
|
141
|
-
}), Object.entries(r || {}).forEach(([e, n], r) => {
|
|
142
|
-
let { answer: i } = n, a = [...Object.entries(n.alternates || {})].reverse(), s = {}, c = {};
|
|
143
|
-
i === "" && (c.answer = "Content should not be empty."), a.forEach(([e, t], n) => {
|
|
144
|
-
t === "" ? s[e] = "Content should not be empty." : (i === t || a.slice(n + 1).some(([, e]) => e === t)) && (s[e] = "Content should be unique.");
|
|
145
|
-
}), (!t(c) || !t(s)) && (o[r] = {
|
|
146
|
-
...c,
|
|
147
|
-
...s
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
let c = (i.match(/\{\{(\d+)\}\}/g) || []).length;
|
|
151
|
-
return c > a ? s.responseAreas = `No more than ${a} response areas should be defined.` : c < 1 && (s.responseAreas = "There should be at least 1 response area defined."), t(o) || (s.responses = o), s;
|
|
152
|
-
};
|
|
153
|
-
//#endregion
|
|
154
|
-
export { x as createCorrectResponseSession, g as createDefaultModel, f as getCorrectness, m as getLogTrace, p as getPartialScore, b as model, _ as normalizeSession, h as outcome, y as prepareVal, S as validate };
|
package/dist/delivery/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/math-templated/src/index.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
export default class MathTemplated extends HTMLElement {
|
|
10
|
-
constructor();
|
|
11
|
-
set model(m: any);
|
|
12
|
-
get model(): any;
|
|
13
|
-
set session(s: any);
|
|
14
|
-
get session(): any;
|
|
15
|
-
isSessionComplete(): boolean;
|
|
16
|
-
onSessionChange(session: any): void;
|
|
17
|
-
connectedCallback(): void;
|
|
18
|
-
render(): void;
|
|
19
|
-
disconnectedCallback(): void;
|
|
20
|
-
}
|
package/dist/delivery/index.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import e from "./main.js";
|
|
2
|
-
import t from "react";
|
|
3
|
-
import { createRoot as n } from "react-dom/client";
|
|
4
|
-
import { ModelSetEvent as r, SessionChangedEvent as i } from "@pie-element/shared-player-events";
|
|
5
|
-
import { debounce as a } from "@pie-element/shared-lodash";
|
|
6
|
-
//#region src/delivery/index.ts
|
|
7
|
-
var o = class extends HTMLElement {
|
|
8
|
-
constructor() {
|
|
9
|
-
super(), this._root = null, this.sessionChangedEventCaller = a(() => {
|
|
10
|
-
this.dispatchEvent(new i(this.tagName.toLowerCase(), !0));
|
|
11
|
-
}, 1e3);
|
|
12
|
-
}
|
|
13
|
-
set model(e) {
|
|
14
|
-
this._model = e, this.render(), this.dispatchEvent(new r(this.tagName.toLowerCase(), this.isSessionComplete(), this._model !== void 0));
|
|
15
|
-
}
|
|
16
|
-
get model() {
|
|
17
|
-
return this._model;
|
|
18
|
-
}
|
|
19
|
-
set session(e) {
|
|
20
|
-
this._session = e, this.render();
|
|
21
|
-
}
|
|
22
|
-
get session() {
|
|
23
|
-
return this._session;
|
|
24
|
-
}
|
|
25
|
-
isSessionComplete() {
|
|
26
|
-
return !0;
|
|
27
|
-
}
|
|
28
|
-
onSessionChange(e) {
|
|
29
|
-
Object.keys(e).map((t) => {
|
|
30
|
-
this._session[t] = e[t];
|
|
31
|
-
}), this.sessionChangedEventCaller(), this.render();
|
|
32
|
-
}
|
|
33
|
-
connectedCallback() {
|
|
34
|
-
this.render();
|
|
35
|
-
}
|
|
36
|
-
render() {
|
|
37
|
-
if (!(!this._model || !this._session) && this._model && this._session) {
|
|
38
|
-
let r = t.createElement(e, {
|
|
39
|
-
model: this._model,
|
|
40
|
-
session: this._session,
|
|
41
|
-
onSessionChange: this.onSessionChange.bind(this)
|
|
42
|
-
});
|
|
43
|
-
this._root ||= n(this), this._root.render(r);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
disconnectedCallback() {
|
|
47
|
-
this._root && this._root.unmount();
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
//#endregion
|
|
51
|
-
export { o as default };
|
package/dist/delivery/main.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/math-templated/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
|
-
export declare class Main extends React.Component {
|
|
12
|
-
static getResponseKey: (response: any) => any;
|
|
13
|
-
static propTypes: {
|
|
14
|
-
session: PropTypes.Validator<object>;
|
|
15
|
-
onSessionChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
16
|
-
model: PropTypes.Validator<object>;
|
|
17
|
-
};
|
|
18
|
-
constructor(props: any);
|
|
19
|
-
UNSAFE_componentWillMount(): void;
|
|
20
|
-
handleAnswerBlockDomUpdate: any;
|
|
21
|
-
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
22
|
-
shouldComponentUpdate(nextProps: any, nextState: any): boolean;
|
|
23
|
-
componentDidMount(): void;
|
|
24
|
-
componentDidUpdate(): void;
|
|
25
|
-
onSubFieldFocus: any;
|
|
26
|
-
toNodeData: any;
|
|
27
|
-
setInput: any;
|
|
28
|
-
onClick: any;
|
|
29
|
-
callOnSessionChange: any;
|
|
30
|
-
toggleShowCorrect: any;
|
|
31
|
-
subFieldChanged: any;
|
|
32
|
-
getFieldName: any;
|
|
33
|
-
onBlur: any;
|
|
34
|
-
setTooltipRef(ref: any): void;
|
|
35
|
-
renderTeacherInstructions: any;
|
|
36
|
-
renderRationale: any;
|
|
37
|
-
renderPlayerContent: any;
|
|
38
|
-
render(): React.JSX.Element;
|
|
39
|
-
}
|
|
40
|
-
export default Main;
|