@pie-element/fraction-model 6.1.2-next.1 → 6.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 +594 -0
- package/LICENSE.md +5 -0
- package/README.md +18 -0
- package/configure/CHANGELOG.json +1 -0
- package/configure/CHANGELOG.md +559 -0
- package/configure/lib/card-bar.js +57 -0
- package/configure/lib/card-bar.js.map +1 -0
- package/configure/lib/defaults.js +114 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +163 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/main.js +253 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/lib/model-options.js +144 -0
- package/configure/lib/model-options.js.map +1 -0
- package/configure/lib/number-text-field.js +47 -0
- package/configure/lib/number-text-field.js.map +1 -0
- package/configure/package.json +24 -0
- package/controller/CHANGELOG.json +1 -0
- package/controller/CHANGELOG.md +484 -0
- package/controller/lib/defaults.js +20 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +215 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/package.json +15 -0
- package/docs/config-schema.json +1796 -0
- package/docs/config-schema.json.md +1318 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +6 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +6 -0
- package/docs/pie-schema.json +873 -0
- package/docs/pie-schema.json.md +639 -0
- package/lib/answer-fraction.js +109 -0
- package/lib/answer-fraction.js.map +1 -0
- package/lib/fraction-model-chart.js +279 -0
- package/lib/fraction-model-chart.js.map +1 -0
- package/lib/index.js +91 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +203 -0
- package/lib/main.js.map +1 -0
- package/package.json +19 -83
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/card-bar.d.ts +0 -20
- package/dist/author/card-bar.js +0 -40
- package/dist/author/defaults.d.ts +0 -113
- package/dist/author/defaults.js +0 -84
- package/dist/author/index.d.ts +0 -44
- package/dist/author/index.js +0 -88
- package/dist/author/main.d.ts +0 -25
- package/dist/author/main.js +0 -156
- package/dist/author/model-options.d.ts +0 -32
- package/dist/author/model-options.js +0 -85
- package/dist/author/number-text-field.d.ts +0 -15
- package/dist/author/number-text-field.js +0 -24
- package/dist/browser/author/index.js +0 -36733
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/controller/index.js +0 -78
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -2
- package/dist/browser/delivery-BwB7hVA6.js +0 -27725
- package/dist/browser/delivery-BwB7hVA6.js.map +0 -1
- package/dist/browser/dist-DSzihwLW.js +0 -85
- package/dist/browser/dist-DSzihwLW.js.map +0 -1
- package/dist/browser/fraction-model.css +0 -2
- package/dist/controller/defaults.d.ts +0 -21
- package/dist/controller/defaults.js +0 -13
- package/dist/controller/index.d.ts +0 -23
- package/dist/controller/index.js +0 -68
- package/dist/delivery/answer-fraction.d.ts +0 -27
- package/dist/delivery/answer-fraction.js +0 -69
- package/dist/delivery/fraction-model-chart.d.ts +0 -11
- package/dist/delivery/fraction-model-chart.js +0 -154
- package/dist/delivery/index.d.ts +0 -22
- package/dist/delivery/index.js +0 -54
- package/dist/delivery/main.d.ts +0 -38
- package/dist/delivery/main.js +0 -136
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -179
- package/dist/index.js +0 -2
- package/dist/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/fraction-model/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
|
-
correctResponse: never[];
|
|
12
|
-
title: string;
|
|
13
|
-
prompt: string;
|
|
14
|
-
modelTypeSelected: string;
|
|
15
|
-
maxModelSelected: number;
|
|
16
|
-
partsPerModel: number;
|
|
17
|
-
allowedStudentConfig: boolean;
|
|
18
|
-
showGraphLabels: boolean;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export default _default;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region src/controller/defaults.ts
|
|
2
|
-
var e = { model: {
|
|
3
|
-
correctResponse: [],
|
|
4
|
-
title: "",
|
|
5
|
-
prompt: "",
|
|
6
|
-
modelTypeSelected: "bar",
|
|
7
|
-
maxModelSelected: 1,
|
|
8
|
-
partsPerModel: 5,
|
|
9
|
-
allowedStudentConfig: !1,
|
|
10
|
-
showGraphLabels: !1
|
|
11
|
-
} };
|
|
12
|
-
//#endregion
|
|
13
|
-
export { e as default };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/fraction-model/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 getResponseCorrectness: (model: any, answers: any, env?: {}) => "correct" | "incorrect";
|
|
10
|
-
export declare const outcome: (model: any, session: any, env: any) => Promise<unknown>;
|
|
11
|
-
export declare const createDefaultModel: (model?: {}) => {
|
|
12
|
-
correctResponse: never[];
|
|
13
|
-
title: string;
|
|
14
|
-
prompt: string;
|
|
15
|
-
modelTypeSelected: string;
|
|
16
|
-
maxModelSelected: number;
|
|
17
|
-
partsPerModel: number;
|
|
18
|
-
allowedStudentConfig: boolean;
|
|
19
|
-
showGraphLabels: boolean;
|
|
20
|
-
};
|
|
21
|
-
export declare const model: (question: any, session: any, env: any) => Promise<unknown>;
|
|
22
|
-
export declare const createCorrectResponseSession: (model: any, env: any) => Promise<unknown>;
|
|
23
|
-
export declare const validate: (model?: {}, config?: {}) => {};
|
package/dist/controller/index.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import e from "./defaults.js";
|
|
2
|
-
import { isEmpty as t } from "@pie-element/shared-lodash";
|
|
3
|
-
//#region src/controller/index.ts
|
|
4
|
-
var n = (e, t, n = {}) => {
|
|
5
|
-
let r;
|
|
6
|
-
return r = e.allowedStudentConfig ? !!(t.partsPerModel === e.partsPerModel && s(t.response, e.partsPerModel) && o(e.correctResponse, t.response)) : !!(s(t.response, e.partsPerModel) && o(e.correctResponse, t.response)), r ? "correct" : "incorrect";
|
|
7
|
-
}, r = (e, t, r = {}) => {
|
|
8
|
-
if (t.mode === "evaluate") return n(e, r, t);
|
|
9
|
-
}, i = (e, t, n = {}) => +(r(e, t, n) === "correct"), a = (e, n, r) => new Promise((a) => {
|
|
10
|
-
!n || t(n) ? a({
|
|
11
|
-
score: 0,
|
|
12
|
-
empty: !0
|
|
13
|
-
}) : r.mode === "evaluate" ? a({ score: i(e, r, n.answers) }) : a({
|
|
14
|
-
score: void 0,
|
|
15
|
-
completed: void 0
|
|
16
|
-
});
|
|
17
|
-
}), o = (e, t) => {
|
|
18
|
-
let n = 0, r = 0;
|
|
19
|
-
for (let t = 0; t < e.length; t++) n += e[t].value;
|
|
20
|
-
for (let e = 0; e < t.length; e++) r += t[e].value;
|
|
21
|
-
return n === r;
|
|
22
|
-
}, s = (e, t) => {
|
|
23
|
-
if (e.length > 0) {
|
|
24
|
-
let n = 0;
|
|
25
|
-
return e.forEach((e) => {
|
|
26
|
-
e.value !== t && n++;
|
|
27
|
-
}), n <= 1;
|
|
28
|
-
} else return !1;
|
|
29
|
-
}, c = (t = {}) => ({
|
|
30
|
-
...e.model,
|
|
31
|
-
...t
|
|
32
|
-
}), l = (e, n, a) => new Promise((o) => {
|
|
33
|
-
n ||= {};
|
|
34
|
-
let s = c(e), l, u;
|
|
35
|
-
(!n || t(n)) && a.mode === "evaluate" ? (l = "unanswered", u = "0%") : (l = r(s, a, n && n.answers), u = `${i(s, a, n && n.answers) * 100}%`);
|
|
36
|
-
let d = {
|
|
37
|
-
score: u,
|
|
38
|
-
correctness: l
|
|
39
|
-
}, f = {
|
|
40
|
-
env: a,
|
|
41
|
-
...s,
|
|
42
|
-
view: a.mode === "view" || a.mode === "evaluate"
|
|
43
|
-
};
|
|
44
|
-
a.mode === "evaluate" && Object.assign(f, { correctness: d }), o(f);
|
|
45
|
-
}), u = (e, t) => new Promise((n) => {
|
|
46
|
-
if (t.mode !== "evaluate" && t.role === "instructor") {
|
|
47
|
-
let { correctResponse: t, maxModelSelected: r, partsPerModel: i } = e;
|
|
48
|
-
n({
|
|
49
|
-
answers: {
|
|
50
|
-
response: t,
|
|
51
|
-
noOfModel: r,
|
|
52
|
-
partsPerModel: i
|
|
53
|
-
},
|
|
54
|
-
id: "1"
|
|
55
|
-
});
|
|
56
|
-
} else n(null);
|
|
57
|
-
}), d = (e = {}, t = {}) => {
|
|
58
|
-
let n = {};
|
|
59
|
-
if (e.correctResponse.length === 0 && (n.correctResponse = "To save the item, at least one section must be marked as correct."), e.correctResponse.length > 0) {
|
|
60
|
-
let t = 0;
|
|
61
|
-
e.correctResponse.forEach((n) => {
|
|
62
|
-
n.value !== e.partsPerModel && t++;
|
|
63
|
-
}), t > 1 && (n.correctResponse = "The correct answer should include no more than one partially-filled model");
|
|
64
|
-
}
|
|
65
|
-
return n;
|
|
66
|
-
};
|
|
67
|
-
//#endregion
|
|
68
|
-
export { u as createCorrectResponseSession, c as createDefaultModel, n as getResponseCorrectness, l as model, a as outcome, d as validate };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/fraction-model/src/answer-fraction.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 AnswerFraction extends React.Component {
|
|
12
|
-
static propTypes: {
|
|
13
|
-
model: PropTypes.Validator<object>;
|
|
14
|
-
disabled: PropTypes.Validator<boolean>;
|
|
15
|
-
showCorrect: PropTypes.Validator<boolean>;
|
|
16
|
-
onAnswerChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
17
|
-
answers: PropTypes.Validator<object>;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Function to trigger when value change from number selection
|
|
21
|
-
* @param {string} key contains event change object
|
|
22
|
-
* @returns updated answer change object
|
|
23
|
-
*/
|
|
24
|
-
onValueChange: (key: any) => (event: any) => void;
|
|
25
|
-
render(): React.JSX.Element;
|
|
26
|
-
}
|
|
27
|
-
export default AnswerFraction;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import e from "react";
|
|
2
|
-
import t from "prop-types";
|
|
3
|
-
import { styled as n } from "@mui/material/styles";
|
|
4
|
-
import { TextField as r } from "@mui/material";
|
|
5
|
-
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
-
//#region src/delivery/answer-fraction.tsx
|
|
7
|
-
var o = n("div")({
|
|
8
|
-
alignItems: "center",
|
|
9
|
-
display: "flex",
|
|
10
|
-
gap: "20px"
|
|
11
|
-
}), s = n("div")({ margin: "12px 0" }), c = n("label")({
|
|
12
|
-
display: "block",
|
|
13
|
-
marginBottom: "4px"
|
|
14
|
-
}), l = n(r)({
|
|
15
|
-
width: "120px",
|
|
16
|
-
maxHeight: "40px",
|
|
17
|
-
"& [class^=\"MuiInputBase-root\"]": {
|
|
18
|
-
height: 40,
|
|
19
|
-
fontSize: "14px"
|
|
20
|
-
}
|
|
21
|
-
}), u = class extends e.Component {
|
|
22
|
-
static propTypes = {
|
|
23
|
-
model: t.object.isRequired,
|
|
24
|
-
disabled: t.bool.isRequired,
|
|
25
|
-
showCorrect: t.bool.isRequired,
|
|
26
|
-
onAnswerChange: t.func.isRequired,
|
|
27
|
-
answers: t.object.isRequired
|
|
28
|
-
};
|
|
29
|
-
onValueChange = (e) => (t) => {
|
|
30
|
-
let n = parseInt(t?.target?.value), { model: r, onAnswerChange: i, answers: a } = this.props, o = { ...a }, s = e === "noOfModel" ? r.maxModelSelected : 9;
|
|
31
|
-
n > s ? n = s : n < 1 && (n = 1), o[e] = n, i(o);
|
|
32
|
-
};
|
|
33
|
-
render() {
|
|
34
|
-
let { model: e, showCorrect: t, answers: n, disabled: r } = this.props;
|
|
35
|
-
return /* @__PURE__ */ i("div", { children: e.allowedStudentConfig && /* @__PURE__ */ a(o, { children: [/* @__PURE__ */ a(s, { children: [/* @__PURE__ */ i(c, {
|
|
36
|
-
htmlFor: "preview_number-of-models",
|
|
37
|
-
children: "Number of Models"
|
|
38
|
-
}), /* @__PURE__ */ i(l, {
|
|
39
|
-
id: "preview_number-of-models",
|
|
40
|
-
inputProps: {
|
|
41
|
-
min: 1,
|
|
42
|
-
max: e.maxModelSelected
|
|
43
|
-
},
|
|
44
|
-
name: "preview_number-of-models",
|
|
45
|
-
onChange: this.onValueChange("noOfModel"),
|
|
46
|
-
type: "number",
|
|
47
|
-
variant: "outlined",
|
|
48
|
-
disabled: r,
|
|
49
|
-
value: t ? e.maxModelSelected : n.noOfModel
|
|
50
|
-
})] }), /* @__PURE__ */ a(s, { children: [/* @__PURE__ */ i(c, {
|
|
51
|
-
htmlFor: "preview_parts-per-model",
|
|
52
|
-
children: "Parts per Model"
|
|
53
|
-
}), /* @__PURE__ */ i(l, {
|
|
54
|
-
id: "preview_parts-per-model",
|
|
55
|
-
inputProps: {
|
|
56
|
-
min: 1,
|
|
57
|
-
max: 9
|
|
58
|
-
},
|
|
59
|
-
name: "preview_parts-per-model",
|
|
60
|
-
onChange: this.onValueChange("partsPerModel"),
|
|
61
|
-
type: "number",
|
|
62
|
-
variant: "outlined",
|
|
63
|
-
disabled: r,
|
|
64
|
-
value: t ? e.partsPerModel : n.partsPerModel
|
|
65
|
-
})] })] }) });
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
//#endregion
|
|
69
|
-
export { u as default };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/fraction-model/src/fraction-model-chart.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
|
-
declare const FractionModelChart: (props: any) => React.JSX.Element | undefined;
|
|
11
|
-
export default FractionModelChart;
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { useEffect as e, useRef as t, useState as n } from "react";
|
|
2
|
-
import { styled as r } from "@mui/material/styles";
|
|
3
|
-
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
4
|
-
import { Bar as o, BarChart as s, Cell as c, LabelList as l, Pie as u, PieChart as d, YAxis as f } from "recharts";
|
|
5
|
-
//#region src/delivery/fraction-model-chart.tsx
|
|
6
|
-
var p = r("div")({
|
|
7
|
-
display: "grid",
|
|
8
|
-
gridTemplateColumns: "200px 200px 200px",
|
|
9
|
-
gap: "10px",
|
|
10
|
-
padding: "5px 0"
|
|
11
|
-
}), m = r("div")({
|
|
12
|
-
display: "grid",
|
|
13
|
-
gridTemplateColumns: "200px 200px 200px",
|
|
14
|
-
gap: "20px",
|
|
15
|
-
padding: "10px 0"
|
|
16
|
-
}), h = r(d)({ "& .recharts-pie-sector": {
|
|
17
|
-
outline: "none !important",
|
|
18
|
-
"&:focus": { outline: "none !important" }
|
|
19
|
-
} }), g = (r) => {
|
|
20
|
-
let d = (e, t) => {
|
|
21
|
-
typeof t == "string" && (t = parseInt(t));
|
|
22
|
-
let n = A.findIndex((t) => t.id === e), r;
|
|
23
|
-
r = n >= 0 ? A[n].value === t ? A.filter((e, t) => t !== n) : [
|
|
24
|
-
...A.slice(0, n),
|
|
25
|
-
{
|
|
26
|
-
id: e,
|
|
27
|
-
value: t
|
|
28
|
-
},
|
|
29
|
-
...A.slice(n + 1)
|
|
30
|
-
] : [...A, {
|
|
31
|
-
id: e,
|
|
32
|
-
value: t
|
|
33
|
-
}], D(r), j(r);
|
|
34
|
-
}, g = (e, t) => {
|
|
35
|
-
k(e + "-" + t);
|
|
36
|
-
}, _ = () => {
|
|
37
|
-
k(null);
|
|
38
|
-
}, v = (e, t) => {
|
|
39
|
-
let [n, r] = t.split("-").map(Number), i = A.find((e) => e.id === n);
|
|
40
|
-
if (i && r <= i.value) return "rgb(60, 73, 150, 0.6)";
|
|
41
|
-
if (e) {
|
|
42
|
-
let [t, i] = e.split("-").map(Number);
|
|
43
|
-
if (t === n && i >= r) return "rgb(0, 0, 0, 0.25)";
|
|
44
|
-
}
|
|
45
|
-
return "#FFFFFF";
|
|
46
|
-
}, y = (e) => {
|
|
47
|
-
let { cx: t, cy: n, midAngle: r, outerRadius: a, index: o } = e, s = Math.PI / 180, c = a * 1.13, l = t + c * Math.cos(-r * s);
|
|
48
|
-
return /* @__PURE__ */ i("text", {
|
|
49
|
-
x: l,
|
|
50
|
-
y: n + c * Math.sin(-r * s),
|
|
51
|
-
fill: "#000000",
|
|
52
|
-
textAnchor: l > t ? "start" : "end",
|
|
53
|
-
dominantBaseline: "central",
|
|
54
|
-
children: `${(o + 1).toFixed(0)}`
|
|
55
|
-
});
|
|
56
|
-
}, b = () => (e) => {
|
|
57
|
-
let { fill: t, x: n, y: r, width: a, height: o } = e;
|
|
58
|
-
return /* @__PURE__ */ i("g", { children: /* @__PURE__ */ i("rect", {
|
|
59
|
-
x: n,
|
|
60
|
-
y: r,
|
|
61
|
-
width: a,
|
|
62
|
-
height: o,
|
|
63
|
-
stroke: "#000000",
|
|
64
|
-
fill: t
|
|
65
|
-
}) });
|
|
66
|
-
}, { value: x = [], modelType: S = "bar", noOfModels: C = 0, partsPerModel: w = 0, showLabel: T = !1, disabled: E = !1, onChange: D } = r, [O, k] = n(null), [A, j] = n(x), M = () => {
|
|
67
|
-
let e = [];
|
|
68
|
-
for (let t = 1; t < C + 1; t++) {
|
|
69
|
-
let n = [{ name: t }];
|
|
70
|
-
for (let e = 1; e < w + 1; e++) n[0][`${e}`] = 1;
|
|
71
|
-
e.push(n);
|
|
72
|
-
}
|
|
73
|
-
let t = [];
|
|
74
|
-
return e.forEach((e, n) => {
|
|
75
|
-
t.push(/* @__PURE__ */ a(s, {
|
|
76
|
-
width: 200,
|
|
77
|
-
height: 30 * w,
|
|
78
|
-
data: e,
|
|
79
|
-
children: [/* @__PURE__ */ i(f, {
|
|
80
|
-
hide: !0,
|
|
81
|
-
type: "number",
|
|
82
|
-
domain: [0, w]
|
|
83
|
-
}), Object.keys(e[0]).map((e, t) => {
|
|
84
|
-
if (e !== "name") return /* @__PURE__ */ i(o, {
|
|
85
|
-
dataKey: e,
|
|
86
|
-
stackId: "a",
|
|
87
|
-
onClick: E ? null : () => d(n + 1, e),
|
|
88
|
-
onMouseEnter: E ? null : () => g(n + 1, e),
|
|
89
|
-
onMouseLeave: E ? null : () => _(n + 1, e),
|
|
90
|
-
shape: b(),
|
|
91
|
-
isAnimationActive: !1,
|
|
92
|
-
fill: v(O, `${n + 1}-${e}`),
|
|
93
|
-
children: T && /* @__PURE__ */ i(l, {
|
|
94
|
-
position: "left",
|
|
95
|
-
fill: "#000000"
|
|
96
|
-
})
|
|
97
|
-
}, `bar-${n + 1}-${t + 1}`);
|
|
98
|
-
})]
|
|
99
|
-
}, `bar-chart-${n + 1}`));
|
|
100
|
-
}), /* @__PURE__ */ i(m, { children: t });
|
|
101
|
-
}, N = t(null), P = () => {
|
|
102
|
-
let e = [];
|
|
103
|
-
for (let t = 1; t < C + 1; t++) {
|
|
104
|
-
let t = Array.from({ length: w }, (e, t) => ({
|
|
105
|
-
name: `${t + 1}`,
|
|
106
|
-
value: 1
|
|
107
|
-
}));
|
|
108
|
-
e.push(t);
|
|
109
|
-
}
|
|
110
|
-
let t = [];
|
|
111
|
-
return e.forEach((e, n) => {
|
|
112
|
-
t.push(/* @__PURE__ */ i(h, {
|
|
113
|
-
width: 200,
|
|
114
|
-
height: 200,
|
|
115
|
-
children: /* @__PURE__ */ i(u, {
|
|
116
|
-
data: e,
|
|
117
|
-
fill: "#FFFFFF",
|
|
118
|
-
stroke: "#000000",
|
|
119
|
-
dataKey: "value",
|
|
120
|
-
startAngle: 90,
|
|
121
|
-
endAngle: -270,
|
|
122
|
-
isAnimationActive: !1,
|
|
123
|
-
labelLine: !1,
|
|
124
|
-
label: T && y,
|
|
125
|
-
children: e.map((e, t) => /* @__PURE__ */ i(c, {
|
|
126
|
-
onClick: E ? null : () => d(n + 1, t + 1),
|
|
127
|
-
onMouseEnter: E ? null : () => g(n + 1, t + 1),
|
|
128
|
-
onMouseLeave: E ? null : () => _(n + 1, t + 1),
|
|
129
|
-
fill: v(O, `${n + 1}-${t + 1}`),
|
|
130
|
-
style: {
|
|
131
|
-
outline: "none",
|
|
132
|
-
cursor: E ? "default" : "pointer"
|
|
133
|
-
}
|
|
134
|
-
}, `${n + 1}-${t + 1}`))
|
|
135
|
-
}, `pie-${n + 1}`)
|
|
136
|
-
}, `pie-chart-${n}`));
|
|
137
|
-
}), /* @__PURE__ */ i(p, {
|
|
138
|
-
ref: N,
|
|
139
|
-
children: t
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
|
-
if (S === "bar") return M();
|
|
143
|
-
if (S === "pie") return e(() => {
|
|
144
|
-
if (N?.current && w === 1) {
|
|
145
|
-
let e = N.current.querySelectorAll("path");
|
|
146
|
-
e.length > 0 && e.forEach((e) => {
|
|
147
|
-
let t = e.getAttribute("d");
|
|
148
|
-
e.setAttribute("d", t.replaceAll("L 100,100", ""));
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}, []), P();
|
|
152
|
-
};
|
|
153
|
-
//#endregion
|
|
154
|
-
export { g as default };
|
package/dist/delivery/index.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/fraction-model/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 FractionModelChart from './fraction-model-chart.js';
|
|
10
|
-
export { FractionModelChart };
|
|
11
|
-
export default class FractionModel extends HTMLElement {
|
|
12
|
-
constructor();
|
|
13
|
-
set model(m: any);
|
|
14
|
-
get model(): any;
|
|
15
|
-
set session(s: any);
|
|
16
|
-
get session(): any;
|
|
17
|
-
isSessionComplete(session: any, model: any): boolean;
|
|
18
|
-
onSessionChange(session: any): void;
|
|
19
|
-
connectedCallback(): void;
|
|
20
|
-
_render(): void;
|
|
21
|
-
disconnectedCallback(): void;
|
|
22
|
-
}
|
package/dist/delivery/index.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import e from "./fraction-model-chart.js";
|
|
2
|
-
import t from "./main.js";
|
|
3
|
-
import n from "react";
|
|
4
|
-
import { createRoot as r } from "react-dom/client";
|
|
5
|
-
import { SessionChangedEvent as i } from "@pie-element/shared-player-events";
|
|
6
|
-
import { cloneDeep as a } from "@pie-element/shared-lodash";
|
|
7
|
-
import { renderMath as o } from "@pie-element/shared-math-rendering-mathjax";
|
|
8
|
-
//#region src/delivery/index.ts
|
|
9
|
-
var s = class extends HTMLElement {
|
|
10
|
-
constructor() {
|
|
11
|
-
super(), this._root = null;
|
|
12
|
-
}
|
|
13
|
-
set model(e) {
|
|
14
|
-
this._model = e, this._render();
|
|
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(e, t) {
|
|
26
|
-
let n = e && e.answers, r = t.allowedStudentConfig ? n.noOfModel > 0 && n.partsPerModel > 0 : !0, i = Array.isArray(n.response) && n.response.length > 0;
|
|
27
|
-
return r && i;
|
|
28
|
-
}
|
|
29
|
-
onSessionChange(e) {
|
|
30
|
-
this._session.answers = e && e.answers;
|
|
31
|
-
let t = this.isSessionComplete(this._session, this._model);
|
|
32
|
-
this.dispatchEvent(new i(this.tagName.toLowerCase(), t));
|
|
33
|
-
}
|
|
34
|
-
connectedCallback() {
|
|
35
|
-
this._render();
|
|
36
|
-
}
|
|
37
|
-
_render() {
|
|
38
|
-
if (this._model && this._session) {
|
|
39
|
-
let e = a(this._model), i = n.createElement(t, {
|
|
40
|
-
model: e,
|
|
41
|
-
session: this._session,
|
|
42
|
-
onSessionChange: this.onSessionChange.bind(this)
|
|
43
|
-
});
|
|
44
|
-
this._root ||= r(this), this._root.render(i), queueMicrotask(() => {
|
|
45
|
-
o(this);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
disconnectedCallback() {
|
|
50
|
-
this._root && this._root.unmount();
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
//#endregion
|
|
54
|
-
export { e as FractionModelChart, s as default };
|
package/dist/delivery/main.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/fraction-model/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
|
-
model: PropTypes.Requireable<object>;
|
|
14
|
-
session: PropTypes.Requireable<object>;
|
|
15
|
-
onSessionChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
16
|
-
};
|
|
17
|
-
constructor(props: any);
|
|
18
|
-
/**
|
|
19
|
-
* Function to trigger when session value change for fraction model
|
|
20
|
-
*/
|
|
21
|
-
callOnSessionChange: any;
|
|
22
|
-
/**
|
|
23
|
-
* Function to generate answers for preview selection
|
|
24
|
-
* @param {object} model contains model object for fraction model
|
|
25
|
-
* @returns answer model
|
|
26
|
-
*/
|
|
27
|
-
generateAnswers: any;
|
|
28
|
-
/**
|
|
29
|
-
* Function to trigger when answer change from preview
|
|
30
|
-
* @param {object} newAnswers contains updated answer model
|
|
31
|
-
*/
|
|
32
|
-
onAnswerChange: any;
|
|
33
|
-
toggleShowCorrect: any;
|
|
34
|
-
onResponseChange: any;
|
|
35
|
-
generateRandomKey: any;
|
|
36
|
-
render(): React.JSX.Element;
|
|
37
|
-
}
|
|
38
|
-
export default Main;
|
package/dist/delivery/main.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import e from "./answer-fraction.js";
|
|
2
|
-
import t from "./fraction-model-chart.js";
|
|
3
|
-
import n from "react";
|
|
4
|
-
import r from "prop-types";
|
|
5
|
-
import { styled as i } from "@mui/material/styles";
|
|
6
|
-
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
|
-
import s from "@pie-lib/correct-answer-toggle";
|
|
8
|
-
import { AlertDialog as c } from "@pie-lib/config-ui";
|
|
9
|
-
import * as l from "@pie-lib/render-ui";
|
|
10
|
-
import { PreviewPrompt as u, UiLayout as d } from "@pie-lib/render-ui";
|
|
11
|
-
import { cloneDeep as f } from "@pie-element/shared-lodash";
|
|
12
|
-
//#region src/delivery/main.tsx
|
|
13
|
-
function p(e) {
|
|
14
|
-
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
15
|
-
}
|
|
16
|
-
function m(e, t) {
|
|
17
|
-
return !e || p(e) ? e : p(e.default) ? e.default : t && p(e[t]) ? e[t] : t && p(e[t]?.default) ? e[t].default : e;
|
|
18
|
-
}
|
|
19
|
-
var h = m(d, "UiLayout") || m(y.UiLayout, "UiLayout"), g = m(u, "PreviewPrompt") || m(y.PreviewPrompt, "PreviewPrompt"), _ = l, v = _.default, y = v && typeof v == "object" ? v : _, b = i("div")({ padding: "16px" }), x = i("div")({
|
|
20
|
-
textAlign: "center",
|
|
21
|
-
fontSize: "20px"
|
|
22
|
-
}), S = class extends n.Component {
|
|
23
|
-
static propTypes = {
|
|
24
|
-
model: r.object,
|
|
25
|
-
session: r.object,
|
|
26
|
-
onSessionChange: r.func.isRequired
|
|
27
|
-
};
|
|
28
|
-
constructor(e) {
|
|
29
|
-
super(e), this.state = {
|
|
30
|
-
session: {
|
|
31
|
-
...e.session,
|
|
32
|
-
answers: e.session && e.session.answers || this.generateAnswers(e.model)
|
|
33
|
-
},
|
|
34
|
-
showCorrect: !1,
|
|
35
|
-
answerChangeDialog: {
|
|
36
|
-
open: !1,
|
|
37
|
-
text: ""
|
|
38
|
-
}
|
|
39
|
-
}, this.callOnSessionChange();
|
|
40
|
-
}
|
|
41
|
-
callOnSessionChange = () => {
|
|
42
|
-
let { onSessionChange: e } = this.props;
|
|
43
|
-
e && e(this.state.session);
|
|
44
|
-
};
|
|
45
|
-
generateAnswers = (e) => {
|
|
46
|
-
let t = { response: [] };
|
|
47
|
-
return e.allowedStudentConfig && (t.noOfModel = "", t.partsPerModel = ""), t;
|
|
48
|
-
};
|
|
49
|
-
onAnswerChange = (e) => {
|
|
50
|
-
let t = f(this.state.session), n = {
|
|
51
|
-
...this.state.session,
|
|
52
|
-
answers: e
|
|
53
|
-
};
|
|
54
|
-
e.response.length > 0 ? this.setState({ answerChangeDialog: {
|
|
55
|
-
open: !0,
|
|
56
|
-
oldSession: t,
|
|
57
|
-
newSession: n,
|
|
58
|
-
text: "Changing either the Number of Models or Parts per Model will remove added answer. Are you sure you want to continue?"
|
|
59
|
-
} }) : this.setState((e) => ({ session: n }), this.callOnSessionChange);
|
|
60
|
-
};
|
|
61
|
-
toggleShowCorrect = (e) => {
|
|
62
|
-
this.setState({ showCorrect: e });
|
|
63
|
-
};
|
|
64
|
-
onResponseChange = (e) => {
|
|
65
|
-
this.setState((t) => ({ session: {
|
|
66
|
-
...t.session,
|
|
67
|
-
answers: {
|
|
68
|
-
...t.session.answers,
|
|
69
|
-
response: e
|
|
70
|
-
}
|
|
71
|
-
} }), this.callOnSessionChange);
|
|
72
|
-
};
|
|
73
|
-
generateRandomKey = () => Math.floor(Math.random() * 1e4);
|
|
74
|
-
render() {
|
|
75
|
-
let { model: n } = this.props, { showCorrect: r, session: i, answerChangeDialog: l } = this.state, { prompt: u, title: d, correctness: f = {}, extraCSSRules: p, language: m } = n, _ = f.correctness && f.correctness !== "correct", v = this.generateRandomKey();
|
|
76
|
-
return /* @__PURE__ */ a(h, {
|
|
77
|
-
extraCSSRules: p,
|
|
78
|
-
children: /* @__PURE__ */ o(b, { children: [
|
|
79
|
-
/* @__PURE__ */ a(x, { children: /* @__PURE__ */ a(g, {
|
|
80
|
-
className: "prompt",
|
|
81
|
-
prompt: d,
|
|
82
|
-
tagName: "h3"
|
|
83
|
-
}) }),
|
|
84
|
-
/* @__PURE__ */ a(g, {
|
|
85
|
-
className: "prompt",
|
|
86
|
-
prompt: u,
|
|
87
|
-
tagName: "p"
|
|
88
|
-
}),
|
|
89
|
-
/* @__PURE__ */ a(s, {
|
|
90
|
-
language: m,
|
|
91
|
-
show: _,
|
|
92
|
-
toggled: r,
|
|
93
|
-
onToggle: this.toggleShowCorrect
|
|
94
|
-
}),
|
|
95
|
-
/* @__PURE__ */ a(e, {
|
|
96
|
-
model: n,
|
|
97
|
-
showCorrect: r,
|
|
98
|
-
disabled: n.view,
|
|
99
|
-
onAnswerChange: this.onAnswerChange,
|
|
100
|
-
answers: i.answers
|
|
101
|
-
}),
|
|
102
|
-
/* @__PURE__ */ a(t, {
|
|
103
|
-
disabled: n.view,
|
|
104
|
-
value: r ? n.correctResponse : i.answers.response,
|
|
105
|
-
modelType: n.modelTypeSelected,
|
|
106
|
-
noOfModels: r ? n.maxModelSelected : n.allowedStudentConfig ? i.answers.noOfModel : n.maxModelSelected,
|
|
107
|
-
partsPerModel: r ? n.partsPerModel : n.allowedStudentConfig ? i.answers.partsPerModel : n.partsPerModel,
|
|
108
|
-
showLabel: n.showGraphLabels,
|
|
109
|
-
onChange: this.onResponseChange
|
|
110
|
-
}, v),
|
|
111
|
-
/* @__PURE__ */ a(c, {
|
|
112
|
-
open: l.open,
|
|
113
|
-
title: "Warning",
|
|
114
|
-
text: l.text,
|
|
115
|
-
onConfirm: () => {
|
|
116
|
-
let e = this.state.answerChangeDialog.newSession;
|
|
117
|
-
e.answers.response = [], this.setState(() => ({
|
|
118
|
-
session: e,
|
|
119
|
-
answerChangeDialog: { open: !1 }
|
|
120
|
-
}), this.callOnSessionChange);
|
|
121
|
-
},
|
|
122
|
-
onClose: () => {
|
|
123
|
-
this.setState((e) => ({
|
|
124
|
-
session: e.answerChangeDialog.oldSession,
|
|
125
|
-
answerChangeDialog: { open: !1 }
|
|
126
|
-
}), this.callOnSessionChange);
|
|
127
|
-
},
|
|
128
|
-
onConfirmText: "OK",
|
|
129
|
-
onCloseText: "Cancel"
|
|
130
|
-
})
|
|
131
|
-
] })
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
//#endregion
|
|
136
|
-
export { S as default };
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './delivery/index.js';
|
package/dist/index.iife.d.ts
DELETED