@pie-element/math-templated 7.1.0-next.2 → 7.1.1-next.0
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/configure.js +2 -0
- package/controller.js +1 -0
- package/dist/author/defaults.d.ts +173 -0
- package/dist/author/defaults.js +123 -0
- package/dist/author/design.d.ts +35 -0
- package/dist/author/design.js +360 -0
- package/dist/author/index.d.ts +42 -0
- package/dist/author/index.js +97 -0
- package/dist/author/markupUtils.d.ts +11 -0
- package/dist/author/markupUtils.js +10 -0
- package/dist/author/response.d.ts +41 -0
- package/dist/author/response.js +238 -0
- package/dist/author/utils.d.ts +9 -0
- package/dist/author/utils.js +7 -0
- package/dist/browser/author/index.js +31954 -0
- package/dist/browser/author/index.js.map +1 -0
- package/dist/browser/browser-DJA4OL8j.js +331 -0
- package/dist/browser/browser-DJA4OL8j.js.map +1 -0
- package/dist/browser/controller/index.js +37731 -0
- package/dist/browser/controller/index.js.map +1 -0
- package/dist/browser/delivery/index.js +81 -0
- package/dist/browser/delivery/index.js.map +1 -0
- package/dist/browser/dist-CGHr_3dl.js +17039 -0
- package/dist/browser/dist-CGHr_3dl.js.map +1 -0
- package/dist/browser/dist-D9ARZhQk.js +1426 -0
- package/dist/browser/dist-D9ARZhQk.js.map +1 -0
- package/dist/browser/main-DjRQVdyL.js +1274 -0
- package/dist/browser/main-DjRQVdyL.js.map +1 -0
- package/dist/browser/math-templated.css +2 -0
- package/dist/browser/print/index.js +47 -0
- package/dist/browser/print/index.js.map +1 -0
- package/dist/controller/defaults.d.ts +29 -0
- package/dist/controller/defaults.js +23 -0
- package/dist/controller/index.d.ts +45 -0
- package/dist/controller/index.js +154 -0
- package/dist/delivery/index.d.ts +20 -0
- package/dist/delivery/index.js +51 -0
- package/dist/delivery/main.d.ts +40 -0
- package/dist/delivery/main.js +492 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.iife.d.ts +8 -0
- package/dist/index.iife.js +205 -0
- package/dist/index.js +2 -0
- package/dist/math-templated.css +2 -0
- package/dist/print/index.d.ts +15 -0
- package/dist/print/index.js +47 -0
- package/dist/runtime-support.d.ts +12 -0
- package/dist/runtime-support.js +12 -0
- package/package.json +94 -22
- package/CHANGELOG.json +0 -1
- package/CHANGELOG.md +0 -1125
- package/LICENSE.md +0 -5
- package/README.md +0 -0
- package/configure/CHANGELOG.json +0 -1
- package/configure/CHANGELOG.md +0 -1002
- package/configure/lib/defaults.js +0 -172
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/design.js +0 -546
- package/configure/lib/design.js.map +0 -1
- package/configure/lib/index.js +0 -169
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/markupUtils.js +0 -39
- package/configure/lib/markupUtils.js.map +0 -1
- package/configure/lib/response.js +0 -394
- package/configure/lib/response.js.map +0 -1
- package/configure/lib/utils.js +0 -15
- package/configure/lib/utils.js.map +0 -1
- package/configure/package.json +0 -26
- package/controller/CHANGELOG.json +0 -1
- package/controller/CHANGELOG.md +0 -863
- package/controller/lib/defaults.js +0 -28
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -360
- package/controller/lib/index.js.map +0 -1
- package/controller/package.json +0 -17
- package/docs/config-schema.json +0 -2251
- package/docs/config-schema.json.md +0 -1658
- package/docs/demo/config.js +0 -8
- package/docs/demo/generate.js +0 -42
- package/docs/demo/index.html +0 -1
- package/docs/demo/session.js +0 -14
- package/docs/pie-schema.json +0 -1231
- package/docs/pie-schema.json.md +0 -894
- package/lib/index.js +0 -76
- package/lib/index.js.map +0 -1
- package/lib/main.js +0 -877
- package/lib/main.js.map +0 -1
- package/lib/print.js +0 -88
- package/lib/print.js.map +0 -1
- package/module/configure.js +0 -1
- package/module/controller.js +0 -3711
- package/module/demo.js +0 -67
- package/module/element.js +0 -1
- package/module/index.html +0 -21
- package/module/manifest.json +0 -22
- package/module/print-demo.js +0 -105
- package/module/print.html +0 -18
- package/module/print.js +0 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/math-templated/configure/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 MathTemplateConfigure extends HTMLElement {
|
|
10
|
+
static prepareModel: (model?: {}) => {
|
|
11
|
+
slateMarkup: any;
|
|
12
|
+
markup: string;
|
|
13
|
+
responses: {};
|
|
14
|
+
allowTrailingZerosDefault: boolean;
|
|
15
|
+
equationEditor: string;
|
|
16
|
+
ignoreOrderDefault: boolean;
|
|
17
|
+
playerSpellCheckEnabled: boolean;
|
|
18
|
+
prompt: string;
|
|
19
|
+
promptEnabled: boolean;
|
|
20
|
+
rationale: string;
|
|
21
|
+
rationaleEnabled: boolean;
|
|
22
|
+
spellCheckEnabled: boolean;
|
|
23
|
+
teacherInstructions: string;
|
|
24
|
+
teacherInstructionsEnabled: boolean;
|
|
25
|
+
toolbarEditorPosition: string;
|
|
26
|
+
validationDefault: string;
|
|
27
|
+
};
|
|
28
|
+
constructor();
|
|
29
|
+
set model(s: any);
|
|
30
|
+
set configuration(c: any);
|
|
31
|
+
set disableSidePanel(s: any);
|
|
32
|
+
dispatchModelUpdated(reset: any): void;
|
|
33
|
+
onModelChanged(m: any, reset: any): void;
|
|
34
|
+
onConfigurationChanged(c: any): void;
|
|
35
|
+
/** @param {done, progress, file} handler */
|
|
36
|
+
insertImage(handler: any): void;
|
|
37
|
+
onDeleteImage(src: any, done: any): void;
|
|
38
|
+
insertSound(handler: any): void;
|
|
39
|
+
onDeleteSound(src: any, done: any): void;
|
|
40
|
+
_render(): void;
|
|
41
|
+
disconnectedCallback(): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createSlateMarkup as e, processMarkup as t } from "./markupUtils.js";
|
|
2
|
+
import n from "./design.js";
|
|
3
|
+
import r from "./defaults.js";
|
|
4
|
+
import i from "react";
|
|
5
|
+
import { createRoot as a } from "react-dom/client";
|
|
6
|
+
import { defaults as o, isArray as s } from "@pie-element/shared-lodash";
|
|
7
|
+
import c from "debug";
|
|
8
|
+
import { DeleteImageEvent as l, DeleteSoundEvent as u, InsertImageEvent as d, InsertSoundEvent as f, ModelUpdatedEvent as p } from "@pie-element/shared-configure-events";
|
|
9
|
+
//#region src/author/index.ts
|
|
10
|
+
var m = c("math-templated:configure"), h = class c extends HTMLElement {
|
|
11
|
+
static prepareModel = (n = {}) => {
|
|
12
|
+
let { validationDefault: i, allowTrailingZerosDefault: a, ignoreOrderDefault: o, responses: c = {} } = n, l = Object.keys(c).reduce((e, t) => {
|
|
13
|
+
let n = c[t];
|
|
14
|
+
return e[t] = {
|
|
15
|
+
...n,
|
|
16
|
+
validation: n.validation || i,
|
|
17
|
+
allowTrailingZeros: n.allowTrailingZeros || a,
|
|
18
|
+
ignoreOrder: n.ignoreOrder || o
|
|
19
|
+
}, e;
|
|
20
|
+
}, {}), u = {
|
|
21
|
+
...r.model,
|
|
22
|
+
...n,
|
|
23
|
+
responses: l
|
|
24
|
+
}, d = u.slateMarkup || e(u.markup, u.responses), f = t(d);
|
|
25
|
+
return u.responses && Object.keys(u.responses).forEach((e) => {
|
|
26
|
+
s(u.responses[e]) && (u.responses[e] = (u.responses[e] || []).map((e, t) => e.answer ? e : (m("Choice does not contain \"answer\" property, which is required.", e), {
|
|
27
|
+
answer: `${t}`,
|
|
28
|
+
...e
|
|
29
|
+
})));
|
|
30
|
+
}), {
|
|
31
|
+
...u,
|
|
32
|
+
slateMarkup: d,
|
|
33
|
+
markup: f
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
constructor() {
|
|
37
|
+
super(), this._root = null, this._model = c.prepareModel(), this._configuration = r.configuration, this.onModelChanged = this.onModelChanged.bind(this), this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
|
|
38
|
+
}
|
|
39
|
+
set model(e) {
|
|
40
|
+
this._model = c.prepareModel(e), this._render();
|
|
41
|
+
}
|
|
42
|
+
set configuration(e) {
|
|
43
|
+
this._configuration = o(e, r.configuration), e.language?.enabled ? e.languageChoices?.options?.length && (this._model.language = e.languageChoices.options[0].value) : e.language.settings && this._model.language ? (this._configuration.language.enabled = !0, (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) && (this._configuration.languageChoices.options = []), this._configuration.languageChoices.options.find((e) => e.value === this._model.language) || this._configuration.languageChoices.options.push({
|
|
44
|
+
value: this._model.language,
|
|
45
|
+
label: this._model.language
|
|
46
|
+
})) : delete this._model.language, this._render();
|
|
47
|
+
}
|
|
48
|
+
set disableSidePanel(e) {
|
|
49
|
+
this._disableSidePanel = e, this._render();
|
|
50
|
+
}
|
|
51
|
+
dispatchModelUpdated(e) {
|
|
52
|
+
let t = !!e;
|
|
53
|
+
this.dispatchEvent(new p(this._model, t));
|
|
54
|
+
}
|
|
55
|
+
onModelChanged(e, t) {
|
|
56
|
+
this._model = c.prepareModel(e), this._render(), this.dispatchModelUpdated(t);
|
|
57
|
+
}
|
|
58
|
+
onConfigurationChanged(e) {
|
|
59
|
+
this._configuration = e, this._render();
|
|
60
|
+
}
|
|
61
|
+
insertImage(e) {
|
|
62
|
+
this.dispatchEvent(new d(e));
|
|
63
|
+
}
|
|
64
|
+
onDeleteImage(e, t) {
|
|
65
|
+
this.dispatchEvent(new l(e, t));
|
|
66
|
+
}
|
|
67
|
+
insertSound(e) {
|
|
68
|
+
this.dispatchEvent(new f(e));
|
|
69
|
+
}
|
|
70
|
+
onDeleteSound(e, t) {
|
|
71
|
+
this.dispatchEvent(new u(e, t));
|
|
72
|
+
}
|
|
73
|
+
_render() {
|
|
74
|
+
m("_render");
|
|
75
|
+
let e = i.createElement(n, {
|
|
76
|
+
model: this._model,
|
|
77
|
+
configuration: this._configuration,
|
|
78
|
+
onModelChanged: this.onModelChanged,
|
|
79
|
+
onConfigurationChanged: this.onConfigurationChanged,
|
|
80
|
+
disableSidePanel: this._disableSidePanel,
|
|
81
|
+
imageSupport: {
|
|
82
|
+
add: this.insertImage.bind(this),
|
|
83
|
+
delete: this.onDeleteImage.bind(this)
|
|
84
|
+
},
|
|
85
|
+
uploadSoundSupport: {
|
|
86
|
+
add: this.insertSound.bind(this),
|
|
87
|
+
delete: this.onDeleteSound.bind(this)
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
this._root ||= a(this), this._root.render(e);
|
|
91
|
+
}
|
|
92
|
+
disconnectedCallback() {
|
|
93
|
+
this._root && this._root.unmount();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
export { h as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/math-templated/configure/src/markupUtils.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 removeUnwantedCharacters: (markup: any) => any;
|
|
10
|
+
export declare const processMarkup: (markup: any) => string;
|
|
11
|
+
export declare const createSlateMarkup: (markup: any, responses: any) => any;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/author/markupUtils.tsx
|
|
2
|
+
var e = "imes|riangle|an|heta|herefore", t = "throot|parallel|cong|approx|eq|e|sim", n = RegExp(`(\\t(?!${e}))|(\\n(?!${t}))|(\\\\t(?!${e}))|(\\\\n(?!${t}))`, "g"), r = (e) => e.replace(n, "").replace(/\\"/g, "\"").replace(/\\\//g, "/"), i = (e = "") => {
|
|
3
|
+
let t = document.createElement("div");
|
|
4
|
+
return t.innerHTML = e.trim(), t;
|
|
5
|
+
}, a = (e) => {
|
|
6
|
+
let t = i(r(e || "") || "");
|
|
7
|
+
return t.querySelectorAll("[data-type=\"math_templated\"]").forEach((e) => e.replaceWith(`{{${e.dataset.index}}}`)), t.innerHTML;
|
|
8
|
+
}, o = /\{\{(\d+)\}\}/g, s = (e, t) => e ? r(e).replace(o, (e, n) => `<span data-type="math_templated" data-index="${n}" data-value="${t[n]?.answer || ""}"></span>`) : "";
|
|
9
|
+
//#endregion
|
|
10
|
+
export { s as createSlateMarkup, a as processMarkup };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/math-templated/configure/src/response.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 * as React from 'react';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
export declare class Response extends React.Component {
|
|
12
|
+
static propTypes: {
|
|
13
|
+
defaultResponse: PropTypes.Requireable<boolean>;
|
|
14
|
+
error: PropTypes.Requireable<object>;
|
|
15
|
+
mode: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
16
|
+
onResponseChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
17
|
+
onResponseDone: PropTypes.Validator<(...args: any[]) => any>;
|
|
18
|
+
response: PropTypes.Validator<object>;
|
|
19
|
+
cIgnoreOrder: PropTypes.Validator<object>;
|
|
20
|
+
cAllowTrailingZeros: PropTypes.Validator<object>;
|
|
21
|
+
responseKey: PropTypes.Validator<number>;
|
|
22
|
+
};
|
|
23
|
+
static defaultProps: {
|
|
24
|
+
defaultResponse: boolean;
|
|
25
|
+
mode: string;
|
|
26
|
+
};
|
|
27
|
+
constructor(props: any);
|
|
28
|
+
onChange: (name: any) => (evt: any) => void;
|
|
29
|
+
onConfigChanged: (name: any) => (evt: any) => void;
|
|
30
|
+
onLiteralOptionsChange: (name: any) => () => void;
|
|
31
|
+
onAnswerChange: any;
|
|
32
|
+
onAlternateAnswerChange: (alternateId: any) => (answer: any) => void;
|
|
33
|
+
onAddAlternate: any;
|
|
34
|
+
onRemoveAlternate: (alternateId: any) => () => void;
|
|
35
|
+
onDone: any;
|
|
36
|
+
onFocus: any;
|
|
37
|
+
onAlternateFocus: (alternateId: any) => () => void;
|
|
38
|
+
onAlternateDone: (alternateId: any) => () => void;
|
|
39
|
+
render(): React.JSX.Element;
|
|
40
|
+
}
|
|
41
|
+
export default Response;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
import t from "prop-types";
|
|
3
|
+
import { styled as n } from "@mui/material/styles";
|
|
4
|
+
import { color as r } from "@pie-lib/render-ui";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
import o from "@mui/material/Typography";
|
|
7
|
+
import s from "@mui/material/Select";
|
|
8
|
+
import c from "@mui/material/MenuItem";
|
|
9
|
+
import { InputContainer as l } from "@pie-lib/config-ui";
|
|
10
|
+
import { MathToolbar as u } from "@pie-lib/math-toolbar";
|
|
11
|
+
import d from "@mui/material/Card";
|
|
12
|
+
import f from "@mui/material/CardContent";
|
|
13
|
+
import p from "@mui/material/Button";
|
|
14
|
+
import m from "@mui/material/FormControlLabel";
|
|
15
|
+
import h from "@mui/material/InputLabel";
|
|
16
|
+
import g from "@mui/material/Checkbox";
|
|
17
|
+
import _ from "@mui/material/IconButton";
|
|
18
|
+
import v from "@mui/icons-material/Delete";
|
|
19
|
+
//#region src/author/response.tsx
|
|
20
|
+
var y = n(d)(({ theme: e }) => ({
|
|
21
|
+
marginBottom: e.spacing(2.5),
|
|
22
|
+
width: "100%",
|
|
23
|
+
minWidth: "548px",
|
|
24
|
+
border: `1px solid ${e.palette.grey[700]}`,
|
|
25
|
+
display: "flex",
|
|
26
|
+
flexDirection: "column",
|
|
27
|
+
justifyContent: "space-between"
|
|
28
|
+
})), b = n(f)(({ theme: e }) => ({ paddingBottom: `${e.spacing(2)} !important` })), x = n(o)({
|
|
29
|
+
fontWeight: 700,
|
|
30
|
+
fontSize: "1.2rem",
|
|
31
|
+
flex: 3
|
|
32
|
+
}), S = n(l)(({ theme: e }) => ({
|
|
33
|
+
flex: 2,
|
|
34
|
+
"& > *:not(label)": { marginTop: e.spacing(1) }
|
|
35
|
+
})), C = n("div")(({ theme: e }) => ({ marginBottom: e.spacing(2) })), w = n("div")({
|
|
36
|
+
display: "flex",
|
|
37
|
+
alignItems: "center",
|
|
38
|
+
justifyContent: "space-between"
|
|
39
|
+
}), T = n("div")({ display: "flex" }), E = n(p)(({ theme: e }) => ({
|
|
40
|
+
border: `1px solid ${e.palette.grey.A400}`,
|
|
41
|
+
color: r.text()
|
|
42
|
+
})), D = n(_)(({ theme: e }) => ({ marginLeft: e.spacing(1) })), O = n("div")(({ theme: e }) => ({
|
|
43
|
+
fontSize: e.typography.fontSize - 2,
|
|
44
|
+
color: e.palette.error.main,
|
|
45
|
+
paddingTop: e.spacing(1)
|
|
46
|
+
})), k = n("div")(({ theme: e }) => ({
|
|
47
|
+
background: e.palette.grey.A100,
|
|
48
|
+
color: e.palette.grey.A700,
|
|
49
|
+
display: "inline",
|
|
50
|
+
minWidth: "50px",
|
|
51
|
+
padding: "8px",
|
|
52
|
+
border: "1px solid #C0C3CF"
|
|
53
|
+
})), A = n("div")({
|
|
54
|
+
display: "flex",
|
|
55
|
+
justifyContent: "space-between",
|
|
56
|
+
alignItems: "center"
|
|
57
|
+
}), j = n(g)({ color: `${r.tertiary()} !important` });
|
|
58
|
+
if (typeof document < "u") {
|
|
59
|
+
let e = "math-templated-response-styles";
|
|
60
|
+
if (!document.getElementById(e)) {
|
|
61
|
+
let t = document.createElement("style");
|
|
62
|
+
t.id = e, t.textContent = "\n .response-editor {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n min-width: 500px;\n max-width: 900px;\n height: auto;\n min-height: 40px;\n }\n .math-toolbar {\n width: 100%;\n }\n ", document.head.appendChild(t);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
var M = class extends e.Component {
|
|
66
|
+
static propTypes = {
|
|
67
|
+
defaultResponse: t.bool,
|
|
68
|
+
error: t.object,
|
|
69
|
+
mode: t.oneOfType([t.string, t.number]),
|
|
70
|
+
onResponseChange: t.func.isRequired,
|
|
71
|
+
onResponseDone: t.func.isRequired,
|
|
72
|
+
response: t.object.isRequired,
|
|
73
|
+
cIgnoreOrder: t.object.isRequired,
|
|
74
|
+
cAllowTrailingZeros: t.object.isRequired,
|
|
75
|
+
responseKey: t.number.isRequired
|
|
76
|
+
};
|
|
77
|
+
static defaultProps = {
|
|
78
|
+
defaultResponse: !1,
|
|
79
|
+
mode: "8"
|
|
80
|
+
};
|
|
81
|
+
constructor(e) {
|
|
82
|
+
super(e);
|
|
83
|
+
let { response: { alternates: t } = {} } = e || {}, n = Object.keys(t || {}).length;
|
|
84
|
+
this.state = {
|
|
85
|
+
alternateIdCounter: n + 1,
|
|
86
|
+
showKeypad: {
|
|
87
|
+
openCount: 0,
|
|
88
|
+
main: !1
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
onChange = (e) => (t) => {
|
|
93
|
+
let { response: n, onResponseChange: r, responseKey: i } = this.props, a = { ...n };
|
|
94
|
+
a[e] = t.target.value, r(a, i);
|
|
95
|
+
};
|
|
96
|
+
onConfigChanged = (e) => (t) => {
|
|
97
|
+
let { response: n, onResponseChange: r, responseKey: i } = this.props, a = { ...n };
|
|
98
|
+
a[e] = t.target.checked, r(a, i);
|
|
99
|
+
};
|
|
100
|
+
onLiteralOptionsChange = (e) => () => {
|
|
101
|
+
let { response: t, onResponseChange: n, responseKey: r } = this.props, i = { ...t };
|
|
102
|
+
i[e] = !t[e], n(i, r);
|
|
103
|
+
};
|
|
104
|
+
onAnswerChange = (e) => {
|
|
105
|
+
let { response: t, onResponseChange: n, responseKey: r } = this.props, i = { ...t };
|
|
106
|
+
i.answer = e, n(i, r);
|
|
107
|
+
};
|
|
108
|
+
onAlternateAnswerChange = (e) => (t) => {
|
|
109
|
+
let { response: n, onResponseChange: r, responseKey: i } = this.props, a = { ...n };
|
|
110
|
+
a.alternates[e] = t, r(a, i);
|
|
111
|
+
};
|
|
112
|
+
onAddAlternate = () => {
|
|
113
|
+
let { response: e, onResponseChange: t, responseKey: n } = this.props, { alternateIdCounter: r } = this.state, i = { ...e };
|
|
114
|
+
i.alternates ||= {}, i.alternates[r] = "", t(i, n), this.setState({ alternateIdCounter: r + 1 });
|
|
115
|
+
};
|
|
116
|
+
onRemoveAlternate = (e) => () => {
|
|
117
|
+
let { response: t, onResponseChange: n, responseKey: r } = this.props, i = { ...t };
|
|
118
|
+
delete i.alternates[e], n(i, r), this.setState((t) => ({ showKeypad: {
|
|
119
|
+
...t.showKeypad,
|
|
120
|
+
openCount: t.showKeypad[e] ? t.showKeypad.openCount - 1 : t.showKeypad.openCount
|
|
121
|
+
} }));
|
|
122
|
+
};
|
|
123
|
+
onDone = () => {
|
|
124
|
+
let { onResponseDone: e } = this.props;
|
|
125
|
+
this.setState((e) => ({ showKeypad: {
|
|
126
|
+
...e.showKeypad,
|
|
127
|
+
openCount: e.showKeypad.openCount - 1,
|
|
128
|
+
main: !1
|
|
129
|
+
} })), e();
|
|
130
|
+
};
|
|
131
|
+
onFocus = () => {
|
|
132
|
+
this.setState((e) => ({ showKeypad: {
|
|
133
|
+
...e.showKeypad,
|
|
134
|
+
openCount: e.showKeypad.main ? e.showKeypad.openCount : e.showKeypad.openCount + 1,
|
|
135
|
+
main: !0
|
|
136
|
+
} }));
|
|
137
|
+
};
|
|
138
|
+
onAlternateFocus = (e) => () => {
|
|
139
|
+
this.setState((t) => ({ showKeypad: {
|
|
140
|
+
...t.showKeypad,
|
|
141
|
+
openCount: t.showKeypad[e] ? t.showKeypad.openCount : t.showKeypad.openCount + 1,
|
|
142
|
+
[e]: !0
|
|
143
|
+
} }));
|
|
144
|
+
};
|
|
145
|
+
onAlternateDone = (e) => () => {
|
|
146
|
+
this.setState((t) => ({ showKeypad: {
|
|
147
|
+
...t.showKeypad,
|
|
148
|
+
openCount: t.showKeypad.openCount - 1,
|
|
149
|
+
[e]: !1
|
|
150
|
+
} }));
|
|
151
|
+
};
|
|
152
|
+
render() {
|
|
153
|
+
let { mode: e, responseKey: t, response: n, cAllowTrailingZeros: r, cIgnoreOrder: o, error: l } = this.props, { showKeypad: d } = this.state, { validation: f, answer: p, alternates: g, ignoreOrder: _, allowTrailingZeros: M } = n, N = Object.keys(g || {}).length > 0, P = {
|
|
154
|
+
editor: "response-editor",
|
|
155
|
+
mathToolbar: "math-toolbar"
|
|
156
|
+
};
|
|
157
|
+
return /* @__PURE__ */ i(y, {
|
|
158
|
+
style: { minHeight: `${d.openCount > 0 ? 430 : 230}px` },
|
|
159
|
+
children: /* @__PURE__ */ a(b, { children: [
|
|
160
|
+
/* @__PURE__ */ a(w, { children: [/* @__PURE__ */ a(x, {
|
|
161
|
+
component: "div",
|
|
162
|
+
children: ["Response for ", /* @__PURE__ */ i(k, { children: `R ${parseInt(t) + 1}` })]
|
|
163
|
+
}), /* @__PURE__ */ i(S, {
|
|
164
|
+
label: "Validation",
|
|
165
|
+
children: /* @__PURE__ */ a(s, {
|
|
166
|
+
onChange: this.onChange("validation"),
|
|
167
|
+
value: f || "literal",
|
|
168
|
+
MenuProps: { transitionDuration: {
|
|
169
|
+
enter: 225,
|
|
170
|
+
exit: 195
|
|
171
|
+
} },
|
|
172
|
+
children: [/* @__PURE__ */ i(c, {
|
|
173
|
+
value: "literal",
|
|
174
|
+
children: "Literal Validation"
|
|
175
|
+
}), /* @__PURE__ */ i(c, {
|
|
176
|
+
value: "symbolic",
|
|
177
|
+
children: "Symbolic Validation"
|
|
178
|
+
})]
|
|
179
|
+
})
|
|
180
|
+
})] }),
|
|
181
|
+
f === "literal" && /* @__PURE__ */ a(T, { children: [r.enabled && /* @__PURE__ */ i(m, {
|
|
182
|
+
label: r.label,
|
|
183
|
+
control: /* @__PURE__ */ i(j, {
|
|
184
|
+
checked: M,
|
|
185
|
+
onChange: this.onLiteralOptionsChange("allowTrailingZeros")
|
|
186
|
+
})
|
|
187
|
+
}), o.enabled && /* @__PURE__ */ i(m, {
|
|
188
|
+
label: o.label,
|
|
189
|
+
control: /* @__PURE__ */ i(j, {
|
|
190
|
+
checked: _,
|
|
191
|
+
onChange: this.onLiteralOptionsChange("ignoreOrder")
|
|
192
|
+
})
|
|
193
|
+
})] }),
|
|
194
|
+
/* @__PURE__ */ a(C, { children: [
|
|
195
|
+
/* @__PURE__ */ i(h, { children: "Correct Answer" }),
|
|
196
|
+
/* @__PURE__ */ i(u, {
|
|
197
|
+
keypadMode: e,
|
|
198
|
+
classNames: P,
|
|
199
|
+
controlledKeypad: !0,
|
|
200
|
+
showKeypad: d.main,
|
|
201
|
+
latex: p || "",
|
|
202
|
+
onChange: this.onAnswerChange,
|
|
203
|
+
onFocus: this.onFocus,
|
|
204
|
+
onDone: this.onDone,
|
|
205
|
+
error: l && l.answer
|
|
206
|
+
}),
|
|
207
|
+
l && l.answer ? /* @__PURE__ */ i(O, { children: l.answer }) : null
|
|
208
|
+
] }),
|
|
209
|
+
N && Object.keys(g).map((t, n) => /* @__PURE__ */ a(C, { children: [
|
|
210
|
+
/* @__PURE__ */ a(h, { children: ["Alternate", Object.keys(g).length > 1 ? ` ${n + 1}` : ""] }),
|
|
211
|
+
/* @__PURE__ */ a(A, { children: [/* @__PURE__ */ i(u, {
|
|
212
|
+
classNames: P,
|
|
213
|
+
controlledKeypad: !0,
|
|
214
|
+
keypadMode: e,
|
|
215
|
+
showKeypad: d[t] || !1,
|
|
216
|
+
latex: g[t] || "",
|
|
217
|
+
onChange: this.onAlternateAnswerChange(t),
|
|
218
|
+
onFocus: this.onAlternateFocus(t),
|
|
219
|
+
onDone: this.onAlternateDone(t),
|
|
220
|
+
error: l && l[t]
|
|
221
|
+
}), /* @__PURE__ */ i(D, {
|
|
222
|
+
onClick: this.onRemoveAlternate(t),
|
|
223
|
+
size: "large",
|
|
224
|
+
children: /* @__PURE__ */ i(v, {})
|
|
225
|
+
})] }),
|
|
226
|
+
l && l[t] ? /* @__PURE__ */ i(O, { children: l[t] }) : null
|
|
227
|
+
] }, t)),
|
|
228
|
+
/* @__PURE__ */ i(E, {
|
|
229
|
+
type: "primary",
|
|
230
|
+
onClick: this.onAddAlternate,
|
|
231
|
+
children: "ADD ALTERNATE"
|
|
232
|
+
})
|
|
233
|
+
] })
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
//#endregion
|
|
238
|
+
export { M as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/math-templated/configure/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 generateValidationMessage: (config: any) => string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/author/utils.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
let { maxResponseAreas: t } = e;
|
|
4
|
+
return "Validation requirements:" + ("\nCorrect answers should not be blank.\nEach answer defined for a response area should be unique.\nThere should be at least 1 " + (t ? `and at most ${t} ` : "") + "response area" + (t ? "s" : "") + " defined.");
|
|
5
|
+
};
|
|
6
|
+
//#endregion
|
|
7
|
+
export { e as generateValidationMessage };
|