@pie-element/graphing 10.1.1 → 10.1.2-next.1
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/configure.d.ts +26 -0
- package/dist/author/configure.js +208 -0
- package/dist/author/correct-response.d.ts +54 -0
- package/dist/author/correct-response.js +303 -0
- package/dist/author/defaults.d.ts +294 -0
- package/dist/author/defaults.js +415 -0
- package/dist/author/graphing-config.d.ts +34 -0
- package/dist/author/graphing-config.js +244 -0
- package/dist/author/index.d.ts +59 -0
- package/dist/author/index.js +96 -0
- package/dist/author/utils.d.ts +43 -0
- package/dist/author/utils.js +260 -0
- package/dist/browser/author/index.js +4480 -0
- package/dist/browser/author/index.js.map +1 -0
- package/dist/browser/container-DaIvr1Vu.js +57966 -0
- package/dist/browser/container-DaIvr1Vu.js.map +1 -0
- package/dist/browser/controller/index.js +353 -0
- package/dist/browser/controller/index.js.map +1 -0
- package/dist/browser/delivery/index.js +683 -0
- package/dist/browser/delivery/index.js.map +1 -0
- package/dist/browser/dist-BrN2xZtM.js +547 -0
- package/dist/browser/dist-BrN2xZtM.js.map +1 -0
- package/dist/browser/graphing.css +2 -0
- package/dist/controller/defaults.d.ts +59 -0
- package/dist/controller/defaults.js +61 -0
- package/dist/controller/index.d.ts +34 -0
- package/dist/controller/index.js +179 -0
- package/dist/controller/utils.d.ts +37 -0
- package/dist/controller/utils.js +111 -0
- package/dist/delivery/index.d.ts +21 -0
- package/dist/delivery/index.js +43 -0
- package/dist/delivery/main.d.ts +23 -0
- package/dist/delivery/main.js +107 -0
- package/dist/delivery/utils.d.ts +22 -0
- package/dist/graphing.css +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.iife.d.ts +8 -0
- package/dist/index.iife.js +406 -0
- package/dist/index.js +2 -0
- package/dist/runtime-support.d.ts +12 -0
- package/dist/runtime-support.js +12 -0
- package/package.json +88 -21
- package/CHANGELOG.json +0 -652
- package/CHANGELOG.md +0 -2043
- package/LICENSE.md +0 -5
- package/README.md +0 -1
- package/configure/CHANGELOG.json +0 -382
- package/configure/CHANGELOG.md +0 -1834
- package/configure/lib/configure.js +0 -328
- package/configure/lib/configure.js.map +0 -1
- package/configure/lib/correct-response.js +0 -484
- package/configure/lib/correct-response.js.map +0 -1
- package/configure/lib/defaults.js +0 -448
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/graphing-config.js +0 -388
- package/configure/lib/graphing-config.js.map +0 -1
- package/configure/lib/index.js +0 -173
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/utils.js +0 -122
- package/configure/lib/utils.js.map +0 -1
- package/configure/package.json +0 -30
- package/controller/CHANGELOG.json +0 -412
- package/controller/CHANGELOG.md +0 -1267
- package/controller/lib/defaults.js +0 -64
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -459
- package/controller/lib/index.js.map +0 -1
- package/controller/lib/utils.js +0 -451
- package/controller/lib/utils.js.map +0 -1
- package/controller/package.json +0 -24
- package/docs/config-schema.json +0 -3164
- package/docs/config-schema.json.md +0 -2293
- package/docs/demo/config.js +0 -8
- package/docs/demo/generate.js +0 -200
- package/docs/demo/index.html +0 -1
- package/docs/demo/session.js +0 -20
- package/docs/pie-schema.json +0 -3495
- package/docs/pie-schema.json.md +0 -1345
- package/lib/index.js +0 -69
- package/lib/index.js.map +0 -1
- package/lib/main.js +0 -161
- package/lib/main.js.map +0 -1
- package/lib/utils.js +0 -24
- package/lib/utils.js.map +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/graphing/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
|
+
answers: {
|
|
11
|
+
correctAnswer: {
|
|
12
|
+
name: string;
|
|
13
|
+
marks: never[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
arrows: {
|
|
17
|
+
left: boolean;
|
|
18
|
+
right: boolean;
|
|
19
|
+
up: boolean;
|
|
20
|
+
down: boolean;
|
|
21
|
+
};
|
|
22
|
+
backgroundMarks: never[];
|
|
23
|
+
coordinatesOnHover: boolean;
|
|
24
|
+
defaultGridConfiguration: number;
|
|
25
|
+
domain: {
|
|
26
|
+
min: number;
|
|
27
|
+
max: number;
|
|
28
|
+
step: number;
|
|
29
|
+
labelStep: number;
|
|
30
|
+
axisLabel: string;
|
|
31
|
+
};
|
|
32
|
+
graph: {
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
};
|
|
36
|
+
includeAxes: boolean;
|
|
37
|
+
labels: {};
|
|
38
|
+
labelsEnabled: boolean;
|
|
39
|
+
padding: boolean;
|
|
40
|
+
prompt: string;
|
|
41
|
+
promptEnabled: boolean;
|
|
42
|
+
range: {
|
|
43
|
+
min: number;
|
|
44
|
+
max: number;
|
|
45
|
+
step: number;
|
|
46
|
+
labelStep: number;
|
|
47
|
+
axisLabel: string;
|
|
48
|
+
};
|
|
49
|
+
rationale: string;
|
|
50
|
+
rationaleEnabled: boolean;
|
|
51
|
+
standardGrid: boolean;
|
|
52
|
+
studentInstructionsEnabled: boolean;
|
|
53
|
+
teacherInstructions: string;
|
|
54
|
+
teacherInstructionsEnabled: boolean;
|
|
55
|
+
title: string;
|
|
56
|
+
titleEnabled: boolean;
|
|
57
|
+
toolbarTools: string[];
|
|
58
|
+
};
|
|
59
|
+
export default _default;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var e = {
|
|
2
|
+
answers: { correctAnswer: {
|
|
3
|
+
name: "Correct Answer",
|
|
4
|
+
marks: []
|
|
5
|
+
} },
|
|
6
|
+
arrows: {
|
|
7
|
+
left: !0,
|
|
8
|
+
right: !0,
|
|
9
|
+
up: !0,
|
|
10
|
+
down: !0
|
|
11
|
+
},
|
|
12
|
+
backgroundMarks: [],
|
|
13
|
+
coordinatesOnHover: !1,
|
|
14
|
+
defaultGridConfiguration: 0,
|
|
15
|
+
domain: {
|
|
16
|
+
min: -5,
|
|
17
|
+
max: 5,
|
|
18
|
+
step: 1,
|
|
19
|
+
labelStep: 1,
|
|
20
|
+
axisLabel: "x"
|
|
21
|
+
},
|
|
22
|
+
graph: {
|
|
23
|
+
width: 500,
|
|
24
|
+
height: 500
|
|
25
|
+
},
|
|
26
|
+
includeAxes: !0,
|
|
27
|
+
labels: {},
|
|
28
|
+
labelsEnabled: !0,
|
|
29
|
+
padding: !0,
|
|
30
|
+
prompt: "",
|
|
31
|
+
promptEnabled: !0,
|
|
32
|
+
range: {
|
|
33
|
+
min: -5,
|
|
34
|
+
max: 5,
|
|
35
|
+
step: 1,
|
|
36
|
+
labelStep: 1,
|
|
37
|
+
axisLabel: "y"
|
|
38
|
+
},
|
|
39
|
+
rationale: "",
|
|
40
|
+
rationaleEnabled: !0,
|
|
41
|
+
standardGrid: !1,
|
|
42
|
+
studentInstructionsEnabled: !0,
|
|
43
|
+
teacherInstructions: "",
|
|
44
|
+
teacherInstructionsEnabled: !0,
|
|
45
|
+
title: "",
|
|
46
|
+
titleEnabled: !0,
|
|
47
|
+
toolbarTools: [
|
|
48
|
+
"circle",
|
|
49
|
+
"line",
|
|
50
|
+
"label",
|
|
51
|
+
"parabola",
|
|
52
|
+
"point",
|
|
53
|
+
"polygon",
|
|
54
|
+
"ray",
|
|
55
|
+
"segment",
|
|
56
|
+
"sine",
|
|
57
|
+
"vector"
|
|
58
|
+
]
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
export { e as default };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/graphing/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 compareMarks: (mark1: any, mark2: any) => boolean;
|
|
10
|
+
export declare const comparLabelMarks: (mark1: any, mark2: any) => "correct" | "incorrect";
|
|
11
|
+
export declare const getAnswerCorrected: ({ sessionAnswers, marks: correctAnswers, withPointLabel }: {
|
|
12
|
+
sessionAnswers: any;
|
|
13
|
+
marks: any;
|
|
14
|
+
withPointLabel?: boolean | undefined;
|
|
15
|
+
}) => any[];
|
|
16
|
+
export declare const getBestAnswer: (question: any, session: any, env?: {}) => {
|
|
17
|
+
bestScore: number;
|
|
18
|
+
bestScoreAnswerKey: null;
|
|
19
|
+
answersCorrected: any[];
|
|
20
|
+
foundOneSolution: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare const normalize: (question: any) => any;
|
|
23
|
+
export declare function model(question: any, session: any, env: any): Promise<unknown>;
|
|
24
|
+
/**
|
|
25
|
+
* Generates detailed trace log for scoring evaluation
|
|
26
|
+
* @param {Object} model - the question model
|
|
27
|
+
* @param {Object} session - the student session
|
|
28
|
+
* @param {Object} env - the environment
|
|
29
|
+
* @returns {Array} traceLog - array of trace messages
|
|
30
|
+
*/
|
|
31
|
+
export declare const getLogTrace: (question: any, session: any, env: any) => string[];
|
|
32
|
+
export declare function outcome(question: any, session: any, env?: {}): Promise<unknown>;
|
|
33
|
+
export declare const createCorrectResponseSession: (question: any, env: any) => Promise<unknown>;
|
|
34
|
+
export declare const validate: (model?: {}, config?: {}) => {};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import e from "./defaults.js";
|
|
2
|
+
import { equalMarks as t, equalPointWithLabel as n, sortedAnswers as r } from "./utils.js";
|
|
3
|
+
import i from "debug";
|
|
4
|
+
import { cloneDeep as a, isEmpty as o, uniqWith as s } from "@pie-element/shared-lodash";
|
|
5
|
+
import { partialScoring as c } from "@pie-element/shared-controller-utils";
|
|
6
|
+
//#region src/controller/index.ts
|
|
7
|
+
var l = i("@pie-element:graphing:controller"), u = () => ({
|
|
8
|
+
point: [],
|
|
9
|
+
segment: [],
|
|
10
|
+
line: [],
|
|
11
|
+
ray: [],
|
|
12
|
+
vector: [],
|
|
13
|
+
polygon: [],
|
|
14
|
+
circle: [],
|
|
15
|
+
sine: [],
|
|
16
|
+
parabola: [],
|
|
17
|
+
absolute: [],
|
|
18
|
+
exponential: []
|
|
19
|
+
}), d = {
|
|
20
|
+
incorrect: 0,
|
|
21
|
+
correct: 1,
|
|
22
|
+
missing: 2
|
|
23
|
+
}, f = (e, n) => !!(e && n && e.type === n.type && t[e.type] && t[e.type](e, n)), p = (e, t) => e.label === t.label ? "correct" : "incorrect", m = ({ sessionAnswers: e, marks: t, withPointLabel: r = !1 }) => {
|
|
24
|
+
e ||= [], t ||= [];
|
|
25
|
+
let i = a(e).reduce((e, i) => {
|
|
26
|
+
let a = t.find((e) => f(i, e));
|
|
27
|
+
return i.correctness = (a && i.type === "point" && r ? n(i, a) : a) ? "correct" : "incorrect", a && (i.correctnesslabel = p(i, a), i.correctlabel = a.label ? a.label : "", i.label = i.label ? i.label : ""), [...e, i];
|
|
28
|
+
}, []), o = a(t).reduce((t, n) => e.find((e) => f(n, e)) ? t : [...t, {
|
|
29
|
+
...n,
|
|
30
|
+
correctness: "missing"
|
|
31
|
+
}], []);
|
|
32
|
+
return [...i, ...o];
|
|
33
|
+
}, h = ({ scoringType: e, env: t }) => {
|
|
34
|
+
let n = e;
|
|
35
|
+
return e && (n = e === "partial scoring"), c.enabled({ partialScoring: n }, t);
|
|
36
|
+
}, g = (e, t, n = {}) => {
|
|
37
|
+
let { answers: i = {}, scoringType: c } = e || {}, { answer: l } = t || {};
|
|
38
|
+
Object.entries(i || {}).forEach(([e, t]) => i[e] = {
|
|
39
|
+
...t,
|
|
40
|
+
marks: t?.marks.filter((e) => !e.building)
|
|
41
|
+
}), l ||= [], l = l.filter((e) => !e.building), i = o(i) ? { correctAnswer: u() } : {
|
|
42
|
+
correctAnswer: i.correctAnswer,
|
|
43
|
+
...r(i)
|
|
44
|
+
};
|
|
45
|
+
let d = h({
|
|
46
|
+
scoringType: c,
|
|
47
|
+
env: n
|
|
48
|
+
}), p = s(l, f);
|
|
49
|
+
return Object.entries(i).reduce((e, t) => {
|
|
50
|
+
let n = t[0], { marks: r } = t[1] || {};
|
|
51
|
+
if (!r || !r.length) return e;
|
|
52
|
+
let i = m({
|
|
53
|
+
sessionAnswers: p,
|
|
54
|
+
marks: r
|
|
55
|
+
}), a = m({
|
|
56
|
+
sessionAnswers: p,
|
|
57
|
+
marks: r,
|
|
58
|
+
withPointLabel: !0
|
|
59
|
+
}), o = a.filter((e) => e.correctness === "correct"), s = a.filter((e) => e.correctness !== "missing"), c = r.length, l = o.length;
|
|
60
|
+
return s.length > c && (l -= s.length - c), l < 0 && (l = 0), (l / c > e.bestScore || !e.foundOneSolution) && (d ? e.bestScore = parseFloat((l / c).toFixed(2)) : e.bestScore = Math.floor(l / c), e.bestScoreAnswerKey = n, e.answersCorrected = i, e.foundOneSolution = !0), e;
|
|
61
|
+
}, {
|
|
62
|
+
bestScore: 0,
|
|
63
|
+
bestScoreAnswerKey: null,
|
|
64
|
+
answersCorrected: a(p).map((e) => ({
|
|
65
|
+
...e,
|
|
66
|
+
correctness: "incorrect"
|
|
67
|
+
})),
|
|
68
|
+
foundOneSolution: !1
|
|
69
|
+
});
|
|
70
|
+
}, _ = (t) => ({
|
|
71
|
+
...e,
|
|
72
|
+
...t
|
|
73
|
+
});
|
|
74
|
+
function v(e, t, n) {
|
|
75
|
+
return new Promise((r) => {
|
|
76
|
+
let i = _(e);
|
|
77
|
+
t ??= {};
|
|
78
|
+
let { defaultTool: a, extraCSSRules: s, prompt: c, promptEnabled: u, graph: f, answers: p, toolbarTools: m, ...h } = i || {}, { arrows: v } = i, { mode: y, role: b } = n || {};
|
|
79
|
+
typeof v == "boolean" && (v = v ? {
|
|
80
|
+
left: !0,
|
|
81
|
+
right: !0,
|
|
82
|
+
up: !0,
|
|
83
|
+
down: !0
|
|
84
|
+
} : {
|
|
85
|
+
left: !1,
|
|
86
|
+
right: !1,
|
|
87
|
+
up: !1,
|
|
88
|
+
down: !1
|
|
89
|
+
});
|
|
90
|
+
let x = (m || []).filter((e) => e !== "label"), S = a || x.length && x[0] || "", C = {
|
|
91
|
+
...h,
|
|
92
|
+
answers: p,
|
|
93
|
+
arrows: v,
|
|
94
|
+
defaultTool: S,
|
|
95
|
+
disabled: n.mode !== "gather",
|
|
96
|
+
prompt: u ? c : null,
|
|
97
|
+
rationale: null,
|
|
98
|
+
size: f,
|
|
99
|
+
showKeyLegend: n.mode === "evaluate",
|
|
100
|
+
showToggle: n.mode === "evaluate" && !o(p) && p.correctAnswer && p.correctAnswer.marks && !o(p.correctAnswer.marks),
|
|
101
|
+
teacherInstructions: null,
|
|
102
|
+
toolbarTools: m,
|
|
103
|
+
extraCSSRules: s
|
|
104
|
+
};
|
|
105
|
+
if (b === "instructor" && (y === "view" || y === "evaluate")) {
|
|
106
|
+
let { rationale: e, rationaleEnabled: t, teacherInstructions: n, teacherInstructionsEnabled: r } = i || {};
|
|
107
|
+
C.rationale = t ? e : null, C.teacherInstructions = r ? n : null;
|
|
108
|
+
}
|
|
109
|
+
if (y === "evaluate") if (!o(p) && p.correctAnswer && p.correctAnswer.marks && !o(p.correctAnswer.marks)) {
|
|
110
|
+
let { answersCorrected: e, bestScoreAnswerKey: r, bestScore: a } = g(i, t, n);
|
|
111
|
+
C.answersCorrected = e.sort((e, t) => d[e.correctness] - d[t.correctness]), C.correctResponse = r ? (p[r] || {}).marks : [], C.showToggle = C.showToggle && a !== 1;
|
|
112
|
+
} else C.answersCorrected = t && t.answer || [], C.correctResponse = [];
|
|
113
|
+
l("base: ", C), r(C);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
var y = (e, t, n) => {
|
|
117
|
+
let r = [], { answers: i = {}, scoringType: a } = e || {}, o = t && t.answer || [];
|
|
118
|
+
if (!o.length) return ["Student did not interact with the graph."];
|
|
119
|
+
r.push(`Student added ${o.length} object(s) to the graph.`);
|
|
120
|
+
let s = h({
|
|
121
|
+
scoringType: a,
|
|
122
|
+
env: n
|
|
123
|
+
}), { answersCorrected: c, bestScore: l, bestScoreAnswerKey: u } = g(e, t, n), d = u && i[u] && i[u].marks || [], f = 0, p = 0, m = 0;
|
|
124
|
+
for (let e = 0; e < c.length; e++) {
|
|
125
|
+
let t = c[e].correctness;
|
|
126
|
+
t === "correct" ? f++ : t === "incorrect" ? p++ : t === "missing" && m++;
|
|
127
|
+
}
|
|
128
|
+
if (f > 0 && r.push(`Correct objects: ${f}.`), p > 0 && r.push(`Incorrect objects: ${p}.`), m > 0 && r.push(`Missing required objects: ${m}.`), c.forEach((e, t) => {
|
|
129
|
+
let n = e.type || "graph object", i = e.label ? `'${e.label}'` : "", a = `with index ${t + 1}`;
|
|
130
|
+
e.correctness === "correct" && r.push(`${n.charAt(0).toUpperCase() + n.slice(1)} ${i || a} is correct.`), e.correctness === "incorrect" && r.push(`${n.charAt(0).toUpperCase() + n.slice(1)} ${i || a} does not match the expected ${n}.`), e.correctness === "missing" && r.push(`Expected ${n} ${i || a} was not plotted by the student.`);
|
|
131
|
+
}), o.length > d.length) {
|
|
132
|
+
let e = o.length - d.length;
|
|
133
|
+
r.push(`${e} extra object(s) were plotted and are penalized in scoring.`);
|
|
134
|
+
}
|
|
135
|
+
return s ? r.push("Score calculated using partial scoring.") : r.push("Score calculated using all-or-nothing scoring."), r.push(`Final score: ${l}.`), r;
|
|
136
|
+
};
|
|
137
|
+
function b(e, t, n = {}) {
|
|
138
|
+
return new Promise((r) => {
|
|
139
|
+
(!t || o(t)) && r({
|
|
140
|
+
score: 0,
|
|
141
|
+
empty: !0,
|
|
142
|
+
logTrace: ["Student did not interact with the graph."]
|
|
143
|
+
}), (n.mode !== "evaluate" || o(e.answers) || e.answers && e.answers.correctAnswer && o(e.answers.correctAnswer.marks)) && r({
|
|
144
|
+
score: 0,
|
|
145
|
+
empty: !0,
|
|
146
|
+
logTrace: ["Student did not interact with the graph."]
|
|
147
|
+
});
|
|
148
|
+
let { bestScore: i } = g(e, t, n);
|
|
149
|
+
r({
|
|
150
|
+
score: i,
|
|
151
|
+
empty: !1,
|
|
152
|
+
logTrace: y(e, t, n)
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
var x = (e, t) => new Promise((n) => {
|
|
157
|
+
if (t.mode !== "evaluate" && t.role === "instructor") {
|
|
158
|
+
let { answers: t } = e || {}, r = [];
|
|
159
|
+
t && Object.values(t) && (r = (t.correctAnswer || Object.values(t)[0] || {}).marks || []), n({
|
|
160
|
+
answer: r,
|
|
161
|
+
id: "1"
|
|
162
|
+
});
|
|
163
|
+
} else n(null);
|
|
164
|
+
}), S = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), C = (e = {}, t = {}) => {
|
|
165
|
+
let { answers: n, toolbarTools: r } = e, i = {}, a = {};
|
|
166
|
+
return (r || []).filter((e) => e !== "label").length || (i.toolbarToolsError = "There should be at least 1 tool defined."), [
|
|
167
|
+
"teacherInstructions",
|
|
168
|
+
"prompt",
|
|
169
|
+
"rationale"
|
|
170
|
+
].forEach((n) => {
|
|
171
|
+
t[n]?.required && !S(e[n]) && (i[n] = "This field is required.");
|
|
172
|
+
}), Object.entries(n || {}).forEach(([e, t]) => {
|
|
173
|
+
t.marks.length || (a[e] = "At least 1 graph object should be defined."), t.marks.length > 0 && t.marks.forEach((t) => {
|
|
174
|
+
t.building && (a[e] = "At least 1 graph object is not correctly defined.");
|
|
175
|
+
});
|
|
176
|
+
}), o(a) || (i.correctAnswerErrors = a), i;
|
|
177
|
+
};
|
|
178
|
+
//#endregion
|
|
179
|
+
export { p as comparLabelMarks, f as compareMarks, x as createCorrectResponseSession, m as getAnswerCorrected, g as getBestAnswer, y as getLogTrace, v as model, _ as normalize, b as outcome, C as validate };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/graphing/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 equalPoint: (A: any, B: any) => boolean;
|
|
10
|
+
export declare const equalPointWithLabel: (A: any, B: any) => boolean;
|
|
11
|
+
export declare const equalSegment: (segment1: any, segment2: any) => boolean;
|
|
12
|
+
export declare const equalVector: (vector1: any, vector2: any) => boolean;
|
|
13
|
+
export declare const sortedAnswers: (answers: any) => {};
|
|
14
|
+
export declare const equalLine: (line1: any, line2: any) => boolean;
|
|
15
|
+
export declare const equalRay: (ray1: any, ray2: any) => boolean;
|
|
16
|
+
export declare const constructSegmentsFromPoints: (points: any) => any;
|
|
17
|
+
export declare const removeDuplicateSegments: (segments: any) => unknown[];
|
|
18
|
+
export declare const removeInvalidSegments: (segments: any) => any;
|
|
19
|
+
export declare const equalPolygon: (poly1: any, poly2: any) => boolean;
|
|
20
|
+
export declare const equalCircle: (c1: any, c2: any) => boolean;
|
|
21
|
+
export declare const equalSine: (sine1: any, sine2: any) => boolean;
|
|
22
|
+
export declare const equalParabola: (p1: any, p2: any) => boolean;
|
|
23
|
+
export declare const equalAbsolute: (p1: any, p2: any) => boolean;
|
|
24
|
+
export declare const equalExponential: (p1: any, p2: any) => boolean;
|
|
25
|
+
export declare const equalMarks: {
|
|
26
|
+
circle: (sessAnswer: any, mark: any) => boolean;
|
|
27
|
+
line: (sessAnswer: any, mark: any) => boolean;
|
|
28
|
+
parabola: (sessAnswer: any, mark: any) => boolean;
|
|
29
|
+
absolute: (sessAnswer: any, mark: any) => boolean;
|
|
30
|
+
exponential: (sessAnswer: any, mark: any) => boolean;
|
|
31
|
+
point: (sessAnswer: any, mark: any) => boolean;
|
|
32
|
+
polygon: (sessAnswer: any, poly: any) => boolean;
|
|
33
|
+
ray: (sessAnswer: any, mark: any) => boolean;
|
|
34
|
+
segment: (sessAnswer: any, mark: any) => boolean;
|
|
35
|
+
sine: (sessAnswer: any, mark: any) => boolean;
|
|
36
|
+
vector: (sessAnswer: any, mark: any) => boolean;
|
|
37
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { differenceWith as e, isEqual as t, uniq as n, uniqWith as r } from "@pie-element/shared-lodash";
|
|
2
|
+
import { getAmplitudeAndFreq as i, pointsToABC as a, pointsToABForExponential as o, pointsToAForAbsolute as s } from "@pie-lib/graphing-utils";
|
|
3
|
+
//#region src/controller/utils.ts
|
|
4
|
+
var c = (e, n) => (e = { ...e }, n = { ...n }, t(e.x, n.x) && t(e.y, n.y)), l = (e, n) => {
|
|
5
|
+
let r = !0;
|
|
6
|
+
return e = { ...e }, n = { ...n }, (e.label || n.label) && (r = t(e.label, n.label)), t(e.x, n.x) && t(e.y, n.y) && r;
|
|
7
|
+
}, u = (e, n) => t(e.from, n.from) && t(e.to, n.to) || t(e.to, n.from) && t(e.from, n.to), d = (e, n) => t(e.from, n.from) && t(e.to, n.to), f = (e) => Object.keys(e || {}).sort().reduce((t, n) => (n !== "correctAnswer" && (t[n] = e[n]), t), {}), p = (e) => {
|
|
8
|
+
e = {
|
|
9
|
+
...e,
|
|
10
|
+
to: { ...e.to },
|
|
11
|
+
from: { ...e.from }
|
|
12
|
+
};
|
|
13
|
+
let t = e.from.x, n = e.from.y, r = e.to.x, i = e.to.y;
|
|
14
|
+
return {
|
|
15
|
+
a: i - n,
|
|
16
|
+
b: t - r,
|
|
17
|
+
c: r * n - t * i
|
|
18
|
+
};
|
|
19
|
+
}, m = (e) => Math.round(e * 1e4) / 1e4, h = (e, t) => {
|
|
20
|
+
let { a: r, b: i, c: a } = p(e), { a: o, b: s, c } = p(t), l = [];
|
|
21
|
+
if (o !== 0) l.push(m(r / o));
|
|
22
|
+
else if (r !== o) return !1;
|
|
23
|
+
if (s !== 0) l.push(m(i / s));
|
|
24
|
+
else if (i !== s) return !1;
|
|
25
|
+
if (c !== 0) l.push(m(a / c));
|
|
26
|
+
else if (a !== c) return !1;
|
|
27
|
+
return n(l).length === 1;
|
|
28
|
+
}, g = (e, t) => {
|
|
29
|
+
e = {
|
|
30
|
+
...e,
|
|
31
|
+
to: { ...e.to },
|
|
32
|
+
from: { ...e.from }
|
|
33
|
+
}, t = {
|
|
34
|
+
...t,
|
|
35
|
+
to: { ...t.to },
|
|
36
|
+
from: { ...t.from }
|
|
37
|
+
};
|
|
38
|
+
let n = (e.to.y - e.from.y) / (e.to.x - e.from.x), r = (t.to.y - t.from.y) / (t.to.x - t.from.x), i = Math.atan2(e.to.y - e.from.y, e.to.x - e.from.x) * 180 / Math.PI, a = Math.atan2(t.to.y - t.from.y, t.to.x - t.from.x) * 180 / Math.PI;
|
|
39
|
+
return n === r && e.from.x === t.from.x && e.from.y === t.from.y && i === a;
|
|
40
|
+
}, _ = (e) => (e || []).map((t, n) => ({
|
|
41
|
+
from: t,
|
|
42
|
+
to: e[(n + 1) % e.length]
|
|
43
|
+
})), v = (e) => (e ||= [], r(e, (e, t) => u(e, t))), y = (e) => (e ||= [], e.filter((e) => !t(e.from, e.to))), b = (t, n) => {
|
|
44
|
+
let { points: r } = t, { points: i } = n, a = _(r), o = _(i), s = v(y(a)), c = v(y(o)), l = e(s, c, u), d = e(c, s, u);
|
|
45
|
+
return (!l || !l.length) && (!d || !d.length);
|
|
46
|
+
}, x = (e, n) => {
|
|
47
|
+
if (e = {
|
|
48
|
+
...e,
|
|
49
|
+
root: { ...e.root },
|
|
50
|
+
edge: { ...e.edge }
|
|
51
|
+
}, n = {
|
|
52
|
+
...n,
|
|
53
|
+
root: { ...n.root },
|
|
54
|
+
edge: { ...n.edge }
|
|
55
|
+
}, t(n.edge, e.edge) && t(n.root, e.root)) return !0;
|
|
56
|
+
let r = Math.sqrt((e.edge.x - e.root.x) ** 2 + (e.edge.y - e.root.y) ** 2), i = Math.sqrt((n.edge.x - n.root.x) ** 2 + (n.edge.y - n.root.y) ** 2);
|
|
57
|
+
return t(n.root, e.root) && t(r, i);
|
|
58
|
+
}, S = (e, t) => {
|
|
59
|
+
let n = ({ root: e, edge: t }) => {
|
|
60
|
+
e = { ...e }, t = { ...t };
|
|
61
|
+
let { amplitude: n, freq: r } = i(e, t), a = Math.abs(e.y - t.y) * 2, o = Math.abs(e.x - t.x) * 2, s = t.x, c = t.y;
|
|
62
|
+
for (; s < 0 && o !== 0;) s += o, c = c < e.y ? c + a : c - a;
|
|
63
|
+
for (; s - o > 0 && o !== 0;) s -= o, c = c < e.y ? c + a : c - a;
|
|
64
|
+
return {
|
|
65
|
+
amplitude: m(n),
|
|
66
|
+
freq: m(r),
|
|
67
|
+
min: m(t.y < e.y ? t.y : t.y - a),
|
|
68
|
+
max: m(t.y < e.y ? t.y + a : t.y),
|
|
69
|
+
edgeAboveZeroX: m(s),
|
|
70
|
+
edgeAboveZeroY: m(c)
|
|
71
|
+
};
|
|
72
|
+
}, r = n(e), a = n(t), { amplitude: o, freq: s, min: c, max: l, edgeAboveZeroX: u, edgeAboveZeroY: d } = r, { amplitude: f, freq: p, min: h, max: g, edgeAboveZeroX: _, edgeAboveZeroY: v } = a;
|
|
73
|
+
return Math.abs(o) === Math.abs(f) && Math.abs(s) === Math.abs(p) && c === h && l === g && u === _ && d === v;
|
|
74
|
+
}, C = (e, t) => {
|
|
75
|
+
let { edge: n } = e, { edge: r } = t, { root: i } = e, { root: o } = t;
|
|
76
|
+
i = { ...i }, o = { ...o };
|
|
77
|
+
let s = n || { ...i }, c = r || { ...o }, l = {
|
|
78
|
+
x: i.x - (s.x - i.x),
|
|
79
|
+
y: s.y
|
|
80
|
+
}, u = {
|
|
81
|
+
x: o.x - (c.x - o.x),
|
|
82
|
+
y: c.y
|
|
83
|
+
};
|
|
84
|
+
if (!n || !r) return !1;
|
|
85
|
+
let { a: d, b: f, c: p } = a(i, n, l), { a: m, b: h, c: g } = a(o, r, u), _ = (e) => Math.round(e * 1e4) / 1e4;
|
|
86
|
+
return _(d) === _(m) && _(f) === _(h) && _(p) === _(g);
|
|
87
|
+
}, w = (e, n) => {
|
|
88
|
+
let { edge: r } = e, { edge: i } = n, { root: a } = e, { root: o } = n;
|
|
89
|
+
a = { ...a }, o = { ...o };
|
|
90
|
+
let c = r || { ...a }, l = i || { ...o }, u = s(a, c), d = s(o, l);
|
|
91
|
+
return t(o, a) && t(d, u);
|
|
92
|
+
}, T = (e, n) => {
|
|
93
|
+
let { edge: r } = e, { edge: i } = n, { root: a } = e, { root: s } = n;
|
|
94
|
+
a = { ...a }, s = { ...s };
|
|
95
|
+
let c = r || { ...a }, l = i || { ...s }, { a1: u, b1: d } = o(a, c), { a2: f, b2: p } = o(s, l);
|
|
96
|
+
return t(f, u) && t(p, d);
|
|
97
|
+
}, E = {
|
|
98
|
+
circle: (e, t) => x(e, t),
|
|
99
|
+
line: (e, t) => h(e, t),
|
|
100
|
+
parabola: (e, t) => C(e, t),
|
|
101
|
+
absolute: (e, t) => w(e, t),
|
|
102
|
+
exponential: (e, t) => T(e, t),
|
|
103
|
+
point: (e, t) => c(e, t),
|
|
104
|
+
polygon: (e, t) => b(e, t),
|
|
105
|
+
ray: (e, t) => g(e, t),
|
|
106
|
+
segment: (e, t) => u(e, t),
|
|
107
|
+
sine: (e, t) => S(e, t),
|
|
108
|
+
vector: (e, t) => d(e, t)
|
|
109
|
+
};
|
|
110
|
+
//#endregion
|
|
111
|
+
export { E as equalMarks, l as equalPointWithLabel, f as sortedAnswers };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/graphing/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 Graphing extends HTMLElement {
|
|
12
|
+
constructor();
|
|
13
|
+
set model(m: any);
|
|
14
|
+
set session(s: any);
|
|
15
|
+
get session(): any;
|
|
16
|
+
connectedCallback(): void;
|
|
17
|
+
isComplete: (answer: any) => boolean;
|
|
18
|
+
changeAnswers: any;
|
|
19
|
+
_render(): void;
|
|
20
|
+
disconnectedCallback(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import e from "./main.js";
|
|
2
|
+
import t from "react";
|
|
3
|
+
import { createRoot as n } from "react-dom/client";
|
|
4
|
+
import { SessionChangedEvent as r } from "@pie-element/shared-player-events";
|
|
5
|
+
import { renderMath as i } from "@pie-element/shared-math-rendering-mathjax";
|
|
6
|
+
//#region src/delivery/index.ts
|
|
7
|
+
var a = class extends HTMLElement {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(), this._root = null;
|
|
10
|
+
}
|
|
11
|
+
set model(e) {
|
|
12
|
+
this._model = e, this._render();
|
|
13
|
+
}
|
|
14
|
+
set session(e) {
|
|
15
|
+
this._session = e, this._render();
|
|
16
|
+
}
|
|
17
|
+
get session() {
|
|
18
|
+
return this._session;
|
|
19
|
+
}
|
|
20
|
+
connectedCallback() {
|
|
21
|
+
this._render();
|
|
22
|
+
}
|
|
23
|
+
isComplete = (e) => Array.isArray(e) && e.length > 0;
|
|
24
|
+
changeAnswers = (e) => {
|
|
25
|
+
this._session.answer = e, this.dispatchEvent(new r(this.tagName.toLowerCase(), this.isComplete(this._session.answer))), this._render();
|
|
26
|
+
};
|
|
27
|
+
_render() {
|
|
28
|
+
if (!this._model || !this._session) return;
|
|
29
|
+
let r = t.createElement(e, {
|
|
30
|
+
model: this._model,
|
|
31
|
+
session: this._session,
|
|
32
|
+
onAnswersChange: this.changeAnswers
|
|
33
|
+
});
|
|
34
|
+
this._root ||= n(this), this._root.render(r), queueMicrotask(() => {
|
|
35
|
+
i(this);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
disconnectedCallback() {
|
|
39
|
+
this._root && this._root.unmount();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { e as Component, a as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/graphing/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.Validator<object>;
|
|
14
|
+
session: PropTypes.Validator<object>;
|
|
15
|
+
onAnswersChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
16
|
+
};
|
|
17
|
+
state: {
|
|
18
|
+
showingCorrect: boolean;
|
|
19
|
+
};
|
|
20
|
+
toggleCorrect: (showingCorrect: any) => void;
|
|
21
|
+
render(): React.JSX.Element;
|
|
22
|
+
}
|
|
23
|
+
export default Main;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import e from "react";
|
|
2
|
+
import t from "prop-types";
|
|
3
|
+
import { styled as n } from "@mui/material/styles";
|
|
4
|
+
import { GraphContainer as r, KeyLegend as i } from "@pie-lib/graphing";
|
|
5
|
+
import * as a from "@pie-lib/render-ui";
|
|
6
|
+
import { Collapsible as o, PreviewPrompt as s, UiLayout as c, color as l, hasMedia as u, hasText as d } from "@pie-lib/render-ui";
|
|
7
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
8
|
+
import m from "@pie-lib/correct-answer-toggle";
|
|
9
|
+
//#region src/delivery/main.tsx
|
|
10
|
+
function h(e) {
|
|
11
|
+
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
12
|
+
}
|
|
13
|
+
function g(e, t) {
|
|
14
|
+
return !e || h(e) ? e : h(e.default) ? e.default : t && h(e[t]) ? e[t] : t && h(e[t]?.default) ? e[t].default : e;
|
|
15
|
+
}
|
|
16
|
+
var _ = g(c, "UiLayout") || g(S.UiLayout, "UiLayout"), v = g(s, "PreviewPrompt") || g(S.PreviewPrompt, "PreviewPrompt"), y = g(o, "Collapsible") || g(S.Collapsible, "Collapsible"), b = a, x = b.default, S = x && typeof x == "object" ? x : b, C = n(_)({
|
|
17
|
+
color: l.text(),
|
|
18
|
+
backgroundColor: l.background()
|
|
19
|
+
}), w = n(y)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), T = n(r)(({ theme: e }) => ({
|
|
20
|
+
marginTop: e.spacing(2),
|
|
21
|
+
marginBottom: e.spacing(2)
|
|
22
|
+
})), E = class extends e.Component {
|
|
23
|
+
static propTypes = {
|
|
24
|
+
model: t.object.isRequired,
|
|
25
|
+
session: t.object.isRequired,
|
|
26
|
+
onAnswersChange: t.func
|
|
27
|
+
};
|
|
28
|
+
state = { showingCorrect: !1 };
|
|
29
|
+
toggleCorrect = (e) => this.setState({ showingCorrect: e });
|
|
30
|
+
render() {
|
|
31
|
+
let { model: e, onAnswersChange: t, session: n } = this.props, { showingCorrect: r } = this.state, { answer: a } = n || {}, { answersCorrected: o, arrows: s, backgroundMarks: c, coordinatesOnHover: l, correctResponse: h, defaultTool: g, disabled: _, domain: b, extraCSSRules: x, labels: S, labelsEnabled: E, prompt: D, range: O, rationale: k, showKeyLegend: A, showToggle: j, title: M, titleEnabled: N, teacherInstructions: P, toolbarTools: F, language: I } = e || {}, L = e?.size || e?.graph || {}, R = o || a || [], z = F?.includes("label") || !1, B = e.rationale && (d(e.rationale) || u(e.rationale));
|
|
32
|
+
return /* @__PURE__ */ p(C, {
|
|
33
|
+
extraCSSRules: x,
|
|
34
|
+
children: [
|
|
35
|
+
e.teacherInstructions && (d(e.teacherInstructions) || u(e.teacherInstructions)) && /* @__PURE__ */ f(w, {
|
|
36
|
+
labels: {
|
|
37
|
+
hidden: "Show Teacher Instructions",
|
|
38
|
+
visible: "Hide Teacher Instructions"
|
|
39
|
+
},
|
|
40
|
+
children: /* @__PURE__ */ f(v, { prompt: P })
|
|
41
|
+
}),
|
|
42
|
+
D && /* @__PURE__ */ f(v, {
|
|
43
|
+
className: "prompt",
|
|
44
|
+
prompt: D
|
|
45
|
+
}),
|
|
46
|
+
/* @__PURE__ */ f(m, {
|
|
47
|
+
show: j,
|
|
48
|
+
toggled: r,
|
|
49
|
+
onToggle: this.toggleCorrect,
|
|
50
|
+
language: I
|
|
51
|
+
}),
|
|
52
|
+
r && j ? /* @__PURE__ */ f(T, {
|
|
53
|
+
axesSettings: { includeArrows: s },
|
|
54
|
+
backgroundMarks: c.filter((e) => !e.building),
|
|
55
|
+
coordinatesOnHover: l,
|
|
56
|
+
disabled: !0,
|
|
57
|
+
disabledLabels: !0,
|
|
58
|
+
disabledTitle: !0,
|
|
59
|
+
domain: b,
|
|
60
|
+
labels: S,
|
|
61
|
+
marks: h.map((e) => ({
|
|
62
|
+
...e,
|
|
63
|
+
correctness: "correct"
|
|
64
|
+
})),
|
|
65
|
+
onChangeMarks: t,
|
|
66
|
+
range: O,
|
|
67
|
+
showLabels: E,
|
|
68
|
+
showTitle: N,
|
|
69
|
+
size: L,
|
|
70
|
+
title: M,
|
|
71
|
+
toolbarTools: F,
|
|
72
|
+
language: I
|
|
73
|
+
}) : /* @__PURE__ */ f(T, {
|
|
74
|
+
axesSettings: { includeArrows: s },
|
|
75
|
+
backgroundMarks: c.filter((e) => !e.building),
|
|
76
|
+
coordinatesOnHover: l,
|
|
77
|
+
defaultTool: g,
|
|
78
|
+
disabled: _,
|
|
79
|
+
disabledLabels: !0,
|
|
80
|
+
disabledTitle: !0,
|
|
81
|
+
domain: b,
|
|
82
|
+
labels: S,
|
|
83
|
+
marks: R,
|
|
84
|
+
onChangeMarks: t,
|
|
85
|
+
range: O,
|
|
86
|
+
showLabels: E,
|
|
87
|
+
showTitle: N,
|
|
88
|
+
size: L,
|
|
89
|
+
title: M,
|
|
90
|
+
toolbarTools: F,
|
|
91
|
+
language: I,
|
|
92
|
+
limitLabeling: !0
|
|
93
|
+
}),
|
|
94
|
+
A && !r && /* @__PURE__ */ f(i, { isLabelAvailable: z }),
|
|
95
|
+
B && /* @__PURE__ */ f(y, {
|
|
96
|
+
labels: {
|
|
97
|
+
hidden: "Show Rationale",
|
|
98
|
+
visible: "Hide Rationale"
|
|
99
|
+
},
|
|
100
|
+
children: /* @__PURE__ */ f(v, { prompt: k })
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
//#endregion
|
|
107
|
+
export { E as default };
|