@pie-element/math-inline 12.1.1-next.17 → 12.1.1-next.174
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 +2627 -0
- package/CHANGELOG.md +2473 -0
- package/LICENSE.md +5 -0
- package/README.md +3 -0
- package/configure/CHANGELOG.json +1652 -0
- package/configure/CHANGELOG.md +2101 -0
- package/configure/lib/configure.js +186 -0
- package/configure/lib/configure.js.map +1 -0
- package/configure/lib/defaults.js +185 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/general-config-block.js +525 -0
- package/configure/lib/general-config-block.js.map +1 -0
- package/configure/lib/index.js +140 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/response.js +369 -0
- package/configure/lib/response.js.map +1 -0
- package/configure/lib/utils.js +31 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +29 -0
- package/controller/CHANGELOG.json +1002 -0
- package/controller/CHANGELOG.md +1536 -0
- package/controller/lib/defaults.js +43 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +383 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/utils.js +11 -0
- package/controller/lib/utils.js.map +1 -0
- package/controller/package.json +26 -0
- package/docs/config-schema.json +2071 -0
- package/docs/config-schema.json.md +1533 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +41 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +11 -0
- package/docs/pie-schema.json +1472 -0
- package/docs/pie-schema.json.md +845 -0
- package/lib/index.js +94 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +1030 -0
- package/lib/main.js.map +1 -0
- package/lib/print.js +92 -0
- package/lib/print.js.map +1 -0
- package/lib/simple-question-block.js +148 -0
- package/lib/simple-question-block.js.map +1 -0
- package/lib/utils.js +11 -0
- package/lib/utils.js.map +1 -0
- package/package.json +25 -100
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/configure.d.ts +0 -25
- package/dist/author/configure.js +0 -114
- package/dist/author/defaults.d.ts +0 -186
- package/dist/author/defaults.js +0 -145
- package/dist/author/general-config-block.d.ts +0 -35
- package/dist/author/general-config-block.js +0 -390
- package/dist/author/index.d.ts +0 -61
- package/dist/author/index.js +0 -80
- package/dist/author/response.d.ts +0 -40
- package/dist/author/response.js +0 -238
- package/dist/author/utils.d.ts +0 -14
- package/dist/author/utils.js +0 -13
- package/dist/browser/author/index.js +0 -35601
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/controller/index.js +0 -37791
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -84
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/dist--pvq7WNe.js +0 -324
- package/dist/browser/dist--pvq7WNe.js.map +0 -1
- package/dist/browser/dist-D8taXDhz.js +0 -16748
- package/dist/browser/dist-D8taXDhz.js.map +0 -1
- package/dist/browser/dist-DiGNNRzu.js +0 -1426
- package/dist/browser/dist-DiGNNRzu.js.map +0 -1
- package/dist/browser/main-AjqUtC75.js +0 -973
- package/dist/browser/main-AjqUtC75.js.map +0 -1
- package/dist/browser/math-inline.css +0 -2
- package/dist/browser/print/index.js +0 -50
- package/dist/browser/print/index.js.map +0 -1
- package/dist/controller/defaults.d.ts +0 -44
- package/dist/controller/defaults.js +0 -39
- package/dist/controller/index.d.ts +0 -22
- package/dist/controller/index.js +0 -171
- package/dist/controller/utils.d.ts +0 -12
- package/dist/controller/utils.js +0 -7
- package/dist/delivery/index.d.ts +0 -22
- package/dist/delivery/index.js +0 -55
- package/dist/delivery/main.d.ts +0 -44
- package/dist/delivery/main.js +0 -606
- package/dist/delivery/simple-question-block.d.ts +0 -27
- package/dist/delivery/simple-question-block.js +0 -94
- package/dist/delivery/utils.d.ts +0 -12
- package/dist/delivery/utils.js +0 -7
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -224
- package/dist/index.js +0 -2
- package/dist/math-inline.css +0 -2
- package/dist/print/index.d.ts +0 -15
- package/dist/print/index.js +0 -50
- package/dist/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { p as e, s as t, y as n } from "../dist--pvq7WNe.js";
|
|
2
|
-
import { R as r } from "../dist-D8taXDhz.js";
|
|
3
|
-
import { t as i } from "../main-AjqUtC75.js";
|
|
4
|
-
import a from "react";
|
|
5
|
-
import { createRoot as o } from "react-dom/client";
|
|
6
|
-
var s = (0, (/* @__PURE__ */ n(e(), 1)).default)("pie-element:math-inline: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.expression = e.expression || "{{response}}", e.animationsDisabled = !0, {
|
|
9
|
-
...e,
|
|
10
|
-
disabled: !0,
|
|
11
|
-
config: {
|
|
12
|
-
...e,
|
|
13
|
-
env: {
|
|
14
|
-
mode: n ? "evaluate" : e.mode,
|
|
15
|
-
role: t.role
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
}, l = class extends HTMLElement {
|
|
20
|
-
constructor() {
|
|
21
|
-
super(), this._options = null, this._model = null, this._session = [], this._root = null, this._rerender = t(() => {
|
|
22
|
-
if (this._model && this._session) {
|
|
23
|
-
let e = c(this._model, this._options), t = this._options && a.createElement(i, {
|
|
24
|
-
model: e,
|
|
25
|
-
session: {}
|
|
26
|
-
});
|
|
27
|
-
this._root ||= o(this), this._root.render(t), queueMicrotask(() => {
|
|
28
|
-
s("render complete - render math"), r(this);
|
|
29
|
-
});
|
|
30
|
-
} else s("skip");
|
|
31
|
-
}, 50, {
|
|
32
|
-
leading: !1,
|
|
33
|
-
trailing: !0
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
set options(e) {
|
|
37
|
-
this._options = e;
|
|
38
|
-
}
|
|
39
|
-
set model(e) {
|
|
40
|
-
this._model = e, this._rerender();
|
|
41
|
-
}
|
|
42
|
-
connectedCallback() {}
|
|
43
|
-
disconnectedCallback() {
|
|
44
|
-
this._root && this._root.unmount();
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
//#endregion
|
|
48
|
-
export { l as default };
|
|
49
|
-
|
|
50
|
-
//# 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-inline/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-inline: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.expression = model.expression || '{{response}}';\n\n model.animationsDisabled = true;\n return {\n ...model,\n disabled: true,\n config: {\n ...model,\n env: { mode: instr ? 'evaluate' : model.mode, role: opts.role },\n },\n };\n};\n\nexport default class MathInlinePrint 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,EAAA,CAAA,QAAA,CAAY,+BAA+B,GAU3C,KAAqB,GAAO,MAAS;CACzC,IAAM,IAAQ,EAAK,SAAS;CAa5B,OAXA,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,aAAa,EAAM,cAAc,gBAEvC,EAAM,qBAAqB,IACpB;EACL,GAAG;EACH,UAAU;EACV,QAAQ;GACN,GAAG;GACH,KAAK;IAAE,MAAM,IAAQ,aAAa,EAAM;IAAM,MAAM,EAAK;GAAK;EAChE;CACF;AACF,GAEqB,IAArB,cAA6C,YAAY;CACvD,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,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/math-inline/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
|
-
allowTrailingZerosDefault: boolean;
|
|
11
|
-
customKeys: never[];
|
|
12
|
-
equationEditor: string;
|
|
13
|
-
expression: string;
|
|
14
|
-
feedback: {
|
|
15
|
-
correct: {
|
|
16
|
-
default: string;
|
|
17
|
-
type: string;
|
|
18
|
-
};
|
|
19
|
-
incorrect: {
|
|
20
|
-
default: string;
|
|
21
|
-
type: string;
|
|
22
|
-
};
|
|
23
|
-
partial: {
|
|
24
|
-
default: string;
|
|
25
|
-
type: string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
feedbackEnabled: boolean;
|
|
29
|
-
ignoreOrderDefault: boolean;
|
|
30
|
-
partialScoring: boolean;
|
|
31
|
-
prompt: string;
|
|
32
|
-
promptEnabled: boolean;
|
|
33
|
-
rationale: string;
|
|
34
|
-
rationaleEnabled: boolean;
|
|
35
|
-
responseType: string;
|
|
36
|
-
responses: never[];
|
|
37
|
-
scoringType: string;
|
|
38
|
-
studentInstructionsEnabled: boolean;
|
|
39
|
-
teacherInstructions: string;
|
|
40
|
-
teacherInstructionsEnabled: boolean;
|
|
41
|
-
toolbarEditorPosition: string;
|
|
42
|
-
validationDefault: string;
|
|
43
|
-
};
|
|
44
|
-
export default _default;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { ResponseTypes as e } from "./utils.js";
|
|
2
|
-
//#region src/controller/defaults.ts
|
|
3
|
-
var t = {
|
|
4
|
-
allowTrailingZerosDefault: !1,
|
|
5
|
-
customKeys: [],
|
|
6
|
-
equationEditor: "8",
|
|
7
|
-
expression: "",
|
|
8
|
-
feedback: {
|
|
9
|
-
correct: {
|
|
10
|
-
default: "Correct",
|
|
11
|
-
type: "none"
|
|
12
|
-
},
|
|
13
|
-
incorrect: {
|
|
14
|
-
default: "Incorrect",
|
|
15
|
-
type: "none"
|
|
16
|
-
},
|
|
17
|
-
partial: {
|
|
18
|
-
default: "Nearly",
|
|
19
|
-
type: "none"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
feedbackEnabled: !1,
|
|
23
|
-
ignoreOrderDefault: !1,
|
|
24
|
-
partialScoring: !0,
|
|
25
|
-
prompt: "",
|
|
26
|
-
promptEnabled: !0,
|
|
27
|
-
rationale: "",
|
|
28
|
-
rationaleEnabled: !0,
|
|
29
|
-
responseType: e.advanced,
|
|
30
|
-
responses: [],
|
|
31
|
-
scoringType: "auto",
|
|
32
|
-
studentInstructionsEnabled: !0,
|
|
33
|
-
teacherInstructions: "",
|
|
34
|
-
teacherInstructionsEnabled: !0,
|
|
35
|
-
toolbarEditorPosition: "bottom",
|
|
36
|
-
validationDefault: "literal"
|
|
37
|
-
};
|
|
38
|
-
//#endregion
|
|
39
|
-
export { t as default };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/math-inline/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 function createDefaultModel(model?: {}): Promise<unknown>;
|
|
10
|
-
/**
|
|
11
|
-
* Generates detailed trace log for math-inline scoring evaluation
|
|
12
|
-
* @param {Object} question
|
|
13
|
-
* @param {Object} session
|
|
14
|
-
* @param {Object} env
|
|
15
|
-
* @returns {Array<string>} traceLog
|
|
16
|
-
*/
|
|
17
|
-
export declare const getLogTrace: (question: any, session: any, env: any) => string[];
|
|
18
|
-
export declare const outcome: (question: any, session: any, env: any) => Promise<unknown>;
|
|
19
|
-
export declare const normalize: (question: any) => any;
|
|
20
|
-
export declare const model: (question: any, session: any, env: any) => Promise<unknown>;
|
|
21
|
-
export declare const createCorrectResponseSession: (question: any, env: any) => Promise<unknown>;
|
|
22
|
-
export declare const validate: (model?: {}, config?: {}) => {};
|
package/dist/controller/index.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { ResponseTypes as e } from "./utils.js";
|
|
2
|
-
import t from "./defaults.js";
|
|
3
|
-
import n from "debug";
|
|
4
|
-
import { isEmpty as r } from "@pie-element/shared-lodash";
|
|
5
|
-
import i from "@pie-lib/translator";
|
|
6
|
-
import { getActualFeedbackForCorrectness as a } from "@pie-element/shared-feedback";
|
|
7
|
-
import * as o from "@pie-framework/math-validation";
|
|
8
|
-
//#region src/controller/index.ts
|
|
9
|
-
var { translator: s } = i, c = n("@pie-element:math-inline:controller"), l = (t, n, r) => {
|
|
10
|
-
let i = t.responses, a = t.responseType === e.advanced;
|
|
11
|
-
if (!n) return {
|
|
12
|
-
correctness: "unanswered",
|
|
13
|
-
score: r ? 0 : "0%",
|
|
14
|
-
correct: !1
|
|
15
|
-
};
|
|
16
|
-
let o = u(a ? i : i.slice(0, 1), n), s = {
|
|
17
|
-
correctness: "incorrect",
|
|
18
|
-
score: r ? 0 : "0%",
|
|
19
|
-
correct: !1
|
|
20
|
-
};
|
|
21
|
-
return o && (s.correctness = "correct", s.score = r ? 1 : "100%", s.correct = !0), s;
|
|
22
|
-
};
|
|
23
|
-
function u(e, n) {
|
|
24
|
-
let r = !1;
|
|
25
|
-
return (e || []).forEach((e) => {
|
|
26
|
-
if (r) return;
|
|
27
|
-
let i = { mode: e.validation || t.validationDefault };
|
|
28
|
-
i.mode === "literal" && (i.literal = {
|
|
29
|
-
allowTrailingZeros: e.allowTrailingZeros || !1,
|
|
30
|
-
ignoreOrder: e.ignoreOrder || !1
|
|
31
|
-
});
|
|
32
|
-
let a = [e.answer].concat(Object.keys(e.alternates || {}).map((t) => e.alternates[t]));
|
|
33
|
-
for (let e = 0; e < a.length; e++) try {
|
|
34
|
-
if (o.latexEqual(n, a[e], i)) {
|
|
35
|
-
r = !0;
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
} catch (t) {
|
|
39
|
-
c("Parse failure when evaluating math", a[e], n, t);
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
}), r;
|
|
43
|
-
}
|
|
44
|
-
var d = (t, n, r, i) => {
|
|
45
|
-
if (n.mode === "evaluate") return l(t, t.responseType === e.advanced ? r && r.completeAnswer || "" : r && r.response, i);
|
|
46
|
-
};
|
|
47
|
-
function f(e = {}) {
|
|
48
|
-
return new Promise((n) => {
|
|
49
|
-
n({ config: {
|
|
50
|
-
...t,
|
|
51
|
-
...e
|
|
52
|
-
} });
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
var p = (t, n, r) => {
|
|
56
|
-
let i = [];
|
|
57
|
-
if (!n || !n.response && !n.completeAnswer) return i.push("Student did not enter a response."), i;
|
|
58
|
-
let a = t?.responseType === e.advanced, o = a ? n.completeAnswer : n.response, s = o ? o.replace(/\\/g, "") : "";
|
|
59
|
-
if (!s) return i.push("Student entered a response, but then it was removed."), i;
|
|
60
|
-
i.push(`Student entered response: ${s}.`), i.push(`Response type: ${a ? "advanced" : "simple"}.`);
|
|
61
|
-
let c = t.responses || [];
|
|
62
|
-
(a ? c : c.slice(0, 1)).forEach((e, n) => {
|
|
63
|
-
let r = e.validation || t.validationDefault;
|
|
64
|
-
if (i.push(`Response ${n + 1} validation mode: ${r}.`), r === "literal") {
|
|
65
|
-
let t = e.allowTrailingZeros || !1, n = e.ignoreOrder || !1;
|
|
66
|
-
i.push(`Allow trailing zeros: ${t ? "enabled" : "disabled"}.`), i.push(`Ignore order: ${n ? "enabled" : "disabled"}.`);
|
|
67
|
-
}
|
|
68
|
-
let a = [e.answer].concat(Object.keys(e.alternates || {}).map((t) => e.alternates[t]));
|
|
69
|
-
a.length > 1 && i.push(`Accepted answers: ${a.length} (including alternates).`);
|
|
70
|
-
});
|
|
71
|
-
let l = d(t, r, n, !0);
|
|
72
|
-
return l.correctness === "correct" ? i.push("Student answer matches one of the accepted responses.") : l.correctness === "incorrect" ? i.push("Student answer does not match any of the accepted responses.") : i.push("Student answer could not be evaluated."), i.push(`Response evaluated as ${l.correctness}.`), i.push(`Final score: ${l.score}.`), i;
|
|
73
|
-
}, m = (e, t, n) => new Promise((i) => {
|
|
74
|
-
n.mode === "evaluate" ? !t || r(t) ? i({
|
|
75
|
-
score: 0,
|
|
76
|
-
empty: !0,
|
|
77
|
-
logTrace: ["Student did not enter a response."]
|
|
78
|
-
}) : i({
|
|
79
|
-
score: d(e, n, t, !0).score,
|
|
80
|
-
logTrace: p(e, t, n)
|
|
81
|
-
}) : i({
|
|
82
|
-
score: void 0,
|
|
83
|
-
completed: void 0,
|
|
84
|
-
logTrace: []
|
|
85
|
-
});
|
|
86
|
-
}), h = (e) => (r(e.responses) || (e.responses = e.responses.map((t) => ({
|
|
87
|
-
...t,
|
|
88
|
-
validation: t.validation || e.validationDefault,
|
|
89
|
-
allowTrailingZeros: t.allowTrailingZeros || e.allowTrailingZerosDefault,
|
|
90
|
-
ignoreOrder: t.ignoreOrder || e.ignoreOrderDefault
|
|
91
|
-
}))), {
|
|
92
|
-
...t,
|
|
93
|
-
...e
|
|
94
|
-
}), g = (t, n, r) => new Promise((i) => {
|
|
95
|
-
let o = h(t), l = d(o, r, n), { extraCSSRules: u, responses: f, language: p, ...m } = o;
|
|
96
|
-
m.responses = m.responseType === e.simple ? f.slice(0, 1) : f;
|
|
97
|
-
let g = {
|
|
98
|
-
extraCSSRules: u,
|
|
99
|
-
config: m,
|
|
100
|
-
correctness: l,
|
|
101
|
-
feedback: r.mode === "evaluate" && o.feedbackEnabled ? a(l?.correctness, o.feedback) : void 0,
|
|
102
|
-
disabled: r.mode !== "gather",
|
|
103
|
-
view: r.mode === "view"
|
|
104
|
-
}, _ = o.note || s.t("mathInline.primaryCorrectWithAlternates", { lng: p }), v = m?.responses?.length > 1 || (m?.responses || []).some((e) => e.validation === "symbolic" || Object.keys(e.alternates || {}).length > 0);
|
|
105
|
-
r.mode === "evaluate" ? (g.correctResponse = {}, g.config.showNote = v, g.config.note = _) : (g.config.responses = [], g.config.showNote = !1), r.role === "instructor" && (r.mode === "view" || r.mode === "evaluate") ? (g.rationale = o.rationaleEnabled ? o.rationale : null, g.teacherInstructions = o.teacherInstructionsEnabled ? o.teacherInstructions : null) : (g.rationale = null, g.teacherInstructions = null, g.config.rationale = null, g.config.teacherInstructions = null), g.config.env = r, g.config.prompt = o.promptEnabled ? o.prompt : null, g.language = p, c("out: ", g), i(g);
|
|
106
|
-
}), _ = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), v = (e) => new Promise((t) => {
|
|
107
|
-
let { responses: n, id: r } = e, { answer: i } = n && n.length ? n[0] : {};
|
|
108
|
-
t({
|
|
109
|
-
id: r,
|
|
110
|
-
response: i || "",
|
|
111
|
-
completeAnswer: i || ""
|
|
112
|
-
});
|
|
113
|
-
}), y = (e) => e.endsWith("\\") ? e.slice(0, -1) : e, b = (e) => new Promise((t) => {
|
|
114
|
-
let { responses: n, id: r } = e, { answer: i } = n && n.length ? n[0] : {};
|
|
115
|
-
if (!i) {
|
|
116
|
-
t({
|
|
117
|
-
id: r,
|
|
118
|
-
answers: {},
|
|
119
|
-
completeAnswer: ""
|
|
120
|
-
});
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
try {
|
|
124
|
-
let n = e.expression, o = _(n).split(/\\{\\{\s*response\s*\\}\\}/g), s = o.map((e) => e === "" ? e : e.replace(/\s+/g, () => "\\s*")).join("(.*)"), c = i.match(new RegExp(s)), l = o.length - 1;
|
|
125
|
-
if (!c) {
|
|
126
|
-
t({
|
|
127
|
-
id: r,
|
|
128
|
-
answers: {},
|
|
129
|
-
completeAnswer: i
|
|
130
|
-
}), console.log(`can not find match: ${o} in ${i}`);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
c.shift();
|
|
134
|
-
let u = {};
|
|
135
|
-
for (var a = 0; a < l; a++) u[`r${a + 1}`] = { value: y(c[a].trim()) };
|
|
136
|
-
t({
|
|
137
|
-
id: r,
|
|
138
|
-
answers: u,
|
|
139
|
-
completeAnswer: i
|
|
140
|
-
});
|
|
141
|
-
} catch (e) {
|
|
142
|
-
t({
|
|
143
|
-
id: r,
|
|
144
|
-
answers: {},
|
|
145
|
-
completeAnswer: i
|
|
146
|
-
}), console.error(e.toString());
|
|
147
|
-
}
|
|
148
|
-
}), x = (e, t) => t.mode === "evaluate" || t.role !== "instructor" ? (console.error("can not create correct response session if mode is evaluate or role is not instructor"), Promise.resolve(null)) : (e.responseType || "").toLowerCase() === "simple" ? v(e, t) : b(e, t), S = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), C = (e = {}, t = {}) => {
|
|
149
|
-
let { expression: n = "", responses: i, responseType: a } = e, { maxResponseAreas: o } = t, s = {}, c = {};
|
|
150
|
-
if ([
|
|
151
|
-
"teacherInstructions",
|
|
152
|
-
"prompt",
|
|
153
|
-
"rationale"
|
|
154
|
-
].forEach((n) => {
|
|
155
|
-
t[n]?.required && !S(e[n]) && (c[n] = "This field is required.");
|
|
156
|
-
}), (i || []).forEach((e, t) => {
|
|
157
|
-
let { answer: n } = e, i = [...Object.entries(e.alternates || {})].reverse(), a = {}, o = {};
|
|
158
|
-
n === "" && (o.answer = "Content should not be empty."), i.forEach(([e, t], r) => {
|
|
159
|
-
t === "" ? a[e] = "Content should not be empty." : (n === t || i.slice(r + 1).some(([, e]) => e === t)) && (a[e] = "Content should be unique.");
|
|
160
|
-
}), (!r(o) || !r(a)) && (s[t] = {
|
|
161
|
-
...o,
|
|
162
|
-
...a
|
|
163
|
-
});
|
|
164
|
-
}), a === "Advanced Multi") {
|
|
165
|
-
let e = (n.match(/\{\{response\}\}/g) || []).length;
|
|
166
|
-
e > o ? c.responseAreasError = `No more than ${o} response areas should be defined.` : e < 1 && (c.responseAreasError = "There should be at least 1 response area defined.");
|
|
167
|
-
}
|
|
168
|
-
return r(s) || (c.responsesErrors = s), c;
|
|
169
|
-
};
|
|
170
|
-
//#endregion
|
|
171
|
-
export { x as createCorrectResponseSession, f as createDefaultModel, p as getLogTrace, g as model, h as normalize, m as outcome, C as validate };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/math-inline/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 ResponseTypes: {
|
|
10
|
-
advanced: string;
|
|
11
|
-
simple: string;
|
|
12
|
-
};
|
package/dist/controller/utils.js
DELETED
package/dist/delivery/index.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/math-inline/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
|
-
import Main from './main.js';
|
|
10
|
-
export { Main as Component };
|
|
11
|
-
export default class MathInline extends HTMLElement {
|
|
12
|
-
constructor();
|
|
13
|
-
setLangAttribute(): void;
|
|
14
|
-
set model(m: any);
|
|
15
|
-
set session(s: any);
|
|
16
|
-
get session(): any;
|
|
17
|
-
set configuration(c: any);
|
|
18
|
-
sessionChanged(s: any): void;
|
|
19
|
-
connectedCallback(): void;
|
|
20
|
-
_render(): void;
|
|
21
|
-
disconnectedCallback(): void;
|
|
22
|
-
}
|
package/dist/delivery/index.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Main as e } from "./main.js";
|
|
2
|
-
import t from "react";
|
|
3
|
-
import { createRoot as n } from "react-dom/client";
|
|
4
|
-
import r from "debug";
|
|
5
|
-
import { debounce as i } from "@pie-element/shared-lodash";
|
|
6
|
-
import { ModelSetEvent as a, SessionChangedEvent as o } from "@pie-element/shared-player-events";
|
|
7
|
-
//#region src/delivery/index.ts
|
|
8
|
-
var s = { configuration: {} }, c = r("pie-ui:math-inline"), l = class extends HTMLElement {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(), this._root = null, this._configuration = s.configuration, this.sessionChangedEventCaller = i(() => {
|
|
11
|
-
this.dispatchEvent(new o(this.tagName.toLowerCase(), !0));
|
|
12
|
-
}, 1e3);
|
|
13
|
-
}
|
|
14
|
-
setLangAttribute() {
|
|
15
|
-
let e = this._model && typeof this._model.language ? this._model.language : "", t = e ? e.slice(0, 2) : "en";
|
|
16
|
-
this.setAttribute("lang", t);
|
|
17
|
-
let n = this.closest(".player-container");
|
|
18
|
-
n && n.setAttribute("lang", t);
|
|
19
|
-
}
|
|
20
|
-
set model(e) {
|
|
21
|
-
this._model = e, this.dispatchEvent(new a(this._model, !0, !!this._model)), this.setLangAttribute(), this._render();
|
|
22
|
-
}
|
|
23
|
-
set session(e) {
|
|
24
|
-
this._session = e, this._render();
|
|
25
|
-
}
|
|
26
|
-
get session() {
|
|
27
|
-
return this._session;
|
|
28
|
-
}
|
|
29
|
-
set configuration(e) {
|
|
30
|
-
this._configuration = e, this._render();
|
|
31
|
-
}
|
|
32
|
-
sessionChanged(e) {
|
|
33
|
-
Object.keys(e).map((t) => {
|
|
34
|
-
this._session[t] = e[t];
|
|
35
|
-
}), this.sessionChangedEventCaller(), c("session: ", this._session);
|
|
36
|
-
}
|
|
37
|
-
connectedCallback() {
|
|
38
|
-
this.setAttribute("aria-label", "Math Response Question"), this.setAttribute("role", "region"), this._render();
|
|
39
|
-
}
|
|
40
|
-
_render() {
|
|
41
|
-
if (!this._model || !this._session) return;
|
|
42
|
-
let r = t.createElement(e, {
|
|
43
|
-
model: this._model,
|
|
44
|
-
session: this._session,
|
|
45
|
-
configuration: this._configuration,
|
|
46
|
-
onSessionChange: this.sessionChanged.bind(this)
|
|
47
|
-
});
|
|
48
|
-
this._root ||= n(this), this._root.render(r);
|
|
49
|
-
}
|
|
50
|
-
disconnectedCallback() {
|
|
51
|
-
this._root &&= (this._root.unmount(), null);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
//#endregion
|
|
55
|
-
export { e as Component, l as default };
|
package/dist/delivery/main.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/math-inline/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 propTypes: {
|
|
13
|
-
session: PropTypes.Validator<object>;
|
|
14
|
-
onSessionChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
15
|
-
model: PropTypes.Validator<object>;
|
|
16
|
-
};
|
|
17
|
-
constructor(props: any);
|
|
18
|
-
UNSAFE_componentWillMount(): void;
|
|
19
|
-
handleAnswerBlockDomUpdate: any;
|
|
20
|
-
countResponseOccurrences(expression: any): any;
|
|
21
|
-
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
22
|
-
shouldComponentUpdate(nextProps: any, nextState: any): boolean;
|
|
23
|
-
componentDidMount(): void;
|
|
24
|
-
componentDidUpdate(prevProps: any, prevState: any): void;
|
|
25
|
-
updateAria: any;
|
|
26
|
-
focusFirstKeypadElement: any;
|
|
27
|
-
handleKeyDown: any;
|
|
28
|
-
onSubFieldFocus: any;
|
|
29
|
-
cleanupKeyDownListener: any;
|
|
30
|
-
componentWillUnmount(): void;
|
|
31
|
-
onDone: any;
|
|
32
|
-
onSimpleResponseChange: any;
|
|
33
|
-
toNodeData: any;
|
|
34
|
-
setInput: any;
|
|
35
|
-
onClick: any;
|
|
36
|
-
callOnSessionChange: any;
|
|
37
|
-
toggleShowCorrect: any;
|
|
38
|
-
subFieldChanged: any;
|
|
39
|
-
getFieldName: any;
|
|
40
|
-
onBlur: any;
|
|
41
|
-
setTooltipRef(ref: any): void;
|
|
42
|
-
render(): React.JSX.Element | null;
|
|
43
|
-
}
|
|
44
|
-
export default Main;
|