@pie-element/graphing 10.1.2-next.2 → 10.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.
Files changed (86) hide show
  1. package/CHANGELOG.json +652 -0
  2. package/CHANGELOG.md +2049 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +1 -0
  5. package/configure/CHANGELOG.json +382 -0
  6. package/configure/CHANGELOG.md +1840 -0
  7. package/configure/lib/configure.js +328 -0
  8. package/configure/lib/configure.js.map +1 -0
  9. package/configure/lib/correct-response.js +484 -0
  10. package/configure/lib/correct-response.js.map +1 -0
  11. package/configure/lib/defaults.js +448 -0
  12. package/configure/lib/defaults.js.map +1 -0
  13. package/configure/lib/graphing-config.js +388 -0
  14. package/configure/lib/graphing-config.js.map +1 -0
  15. package/configure/lib/index.js +173 -0
  16. package/configure/lib/index.js.map +1 -0
  17. package/configure/lib/utils.js +122 -0
  18. package/configure/lib/utils.js.map +1 -0
  19. package/configure/package.json +30 -0
  20. package/controller/CHANGELOG.json +412 -0
  21. package/controller/CHANGELOG.md +1267 -0
  22. package/controller/lib/defaults.js +64 -0
  23. package/controller/lib/defaults.js.map +1 -0
  24. package/controller/lib/index.js +459 -0
  25. package/controller/lib/index.js.map +1 -0
  26. package/controller/lib/utils.js +451 -0
  27. package/controller/lib/utils.js.map +1 -0
  28. package/controller/package.json +24 -0
  29. package/docs/config-schema.json +3164 -0
  30. package/docs/config-schema.json.md +2293 -0
  31. package/docs/demo/config.js +8 -0
  32. package/docs/demo/generate.js +200 -0
  33. package/docs/demo/index.html +1 -0
  34. package/docs/demo/session.js +20 -0
  35. package/docs/pie-schema.json +3495 -0
  36. package/docs/pie-schema.json.md +1345 -0
  37. package/lib/index.js +69 -0
  38. package/lib/index.js.map +1 -0
  39. package/lib/main.js +161 -0
  40. package/lib/main.js.map +1 -0
  41. package/lib/utils.js +24 -0
  42. package/lib/utils.js.map +1 -0
  43. package/package.json +21 -87
  44. package/configure.js +0 -2
  45. package/controller.js +0 -1
  46. package/dist/author/configure.d.ts +0 -26
  47. package/dist/author/configure.js +0 -208
  48. package/dist/author/correct-response.d.ts +0 -54
  49. package/dist/author/correct-response.js +0 -303
  50. package/dist/author/defaults.d.ts +0 -294
  51. package/dist/author/defaults.js +0 -415
  52. package/dist/author/graphing-config.d.ts +0 -34
  53. package/dist/author/graphing-config.js +0 -244
  54. package/dist/author/index.d.ts +0 -59
  55. package/dist/author/index.js +0 -96
  56. package/dist/author/utils.d.ts +0 -43
  57. package/dist/author/utils.js +0 -260
  58. package/dist/browser/author/index.js +0 -4480
  59. package/dist/browser/author/index.js.map +0 -1
  60. package/dist/browser/container-DwOO2mgz.js +0 -57973
  61. package/dist/browser/container-DwOO2mgz.js.map +0 -1
  62. package/dist/browser/controller/index.js +0 -353
  63. package/dist/browser/controller/index.js.map +0 -1
  64. package/dist/browser/delivery/index.js +0 -683
  65. package/dist/browser/delivery/index.js.map +0 -1
  66. package/dist/browser/dist-BrN2xZtM.js +0 -547
  67. package/dist/browser/dist-BrN2xZtM.js.map +0 -1
  68. package/dist/browser/graphing.css +0 -2
  69. package/dist/controller/defaults.d.ts +0 -59
  70. package/dist/controller/defaults.js +0 -61
  71. package/dist/controller/index.d.ts +0 -34
  72. package/dist/controller/index.js +0 -179
  73. package/dist/controller/utils.d.ts +0 -37
  74. package/dist/controller/utils.js +0 -111
  75. package/dist/delivery/index.d.ts +0 -21
  76. package/dist/delivery/index.js +0 -43
  77. package/dist/delivery/main.d.ts +0 -23
  78. package/dist/delivery/main.js +0 -107
  79. package/dist/delivery/utils.d.ts +0 -22
  80. package/dist/graphing.css +0 -2
  81. package/dist/index.d.ts +0 -1
  82. package/dist/index.iife.d.ts +0 -8
  83. package/dist/index.iife.js +0 -406
  84. package/dist/index.js +0 -2
  85. package/dist/runtime-support.d.ts +0 -12
  86. package/dist/runtime-support.js +0 -12
@@ -1,353 +0,0 @@
1
- import { D as e, E as t, R as n, b as r, f as i, i as a, l as o, p as s, r as c, s as l, u, w as d } from "../dist-BrN2xZtM.js";
2
- //#region src/controller/defaults.ts
3
- var f = /* @__PURE__ */ n(u(), 1), p = {
4
- answers: { correctAnswer: {
5
- name: "Correct Answer",
6
- marks: []
7
- } },
8
- arrows: {
9
- left: !0,
10
- right: !0,
11
- up: !0,
12
- down: !0
13
- },
14
- backgroundMarks: [],
15
- coordinatesOnHover: !1,
16
- defaultGridConfiguration: 0,
17
- domain: {
18
- min: -5,
19
- max: 5,
20
- step: 1,
21
- labelStep: 1,
22
- axisLabel: "x"
23
- },
24
- graph: {
25
- width: 500,
26
- height: 500
27
- },
28
- includeAxes: !0,
29
- labels: {},
30
- labelsEnabled: !0,
31
- padding: !0,
32
- prompt: "",
33
- promptEnabled: !0,
34
- range: {
35
- min: -5,
36
- max: 5,
37
- step: 1,
38
- labelStep: 1,
39
- axisLabel: "y"
40
- },
41
- rationale: "",
42
- rationaleEnabled: !0,
43
- standardGrid: !1,
44
- studentInstructionsEnabled: !0,
45
- teacherInstructions: "",
46
- teacherInstructionsEnabled: !0,
47
- title: "",
48
- titleEnabled: !0,
49
- toolbarTools: [
50
- "circle",
51
- "line",
52
- "label",
53
- "parabola",
54
- "point",
55
- "polygon",
56
- "ray",
57
- "segment",
58
- "sine",
59
- "vector"
60
- ]
61
- }, m = (e, t) => (e = { ...e }, t = { ...t }, s(e.x, t.x) && s(e.y, t.y)), h = (e, t) => {
62
- let n = !0;
63
- return e = { ...e }, t = { ...t }, (e.label || t.label) && (n = s(e.label, t.label)), s(e.x, t.x) && s(e.y, t.y) && n;
64
- }, g = (e, t) => s(e.from, t.from) && s(e.to, t.to) || s(e.to, t.from) && s(e.from, t.to), _ = (e, t) => s(e.from, t.from) && s(e.to, t.to), v = (e) => Object.keys(e || {}).sort().reduce((t, n) => (n !== "correctAnswer" && (t[n] = e[n]), t), {}), y = (e) => {
65
- e = {
66
- ...e,
67
- to: { ...e.to },
68
- from: { ...e.from }
69
- };
70
- let t = e.from.x, n = e.from.y, r = e.to.x, i = e.to.y;
71
- return {
72
- a: i - n,
73
- b: t - r,
74
- c: r * n - t * i
75
- };
76
- }, b = (e) => Math.round(e * 1e4) / 1e4, x = (e, t) => {
77
- let { a: n, b: r, c: a } = y(e), { a: o, b: s, c } = y(t), l = [];
78
- if (o !== 0) l.push(b(n / o));
79
- else if (n !== o) return !1;
80
- if (s !== 0) l.push(b(r / s));
81
- else if (r !== s) return !1;
82
- if (c !== 0) l.push(b(a / c));
83
- else if (a !== c) return !1;
84
- return i(l).length === 1;
85
- }, S = (e, t) => {
86
- e = {
87
- ...e,
88
- to: { ...e.to },
89
- from: { ...e.from }
90
- }, t = {
91
- ...t,
92
- to: { ...t.to },
93
- from: { ...t.from }
94
- };
95
- 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;
96
- return n === r && e.from.x === t.from.x && e.from.y === t.from.y && i === a;
97
- }, C = (e) => (e || []).map((t, n) => ({
98
- from: t,
99
- to: e[(n + 1) % e.length]
100
- })), w = (e) => (e ||= [], d(e, (e, t) => g(e, t))), T = (e) => (e ||= [], e.filter((e) => !s(e.from, e.to))), E = (e, n) => {
101
- let { points: r } = e, { points: i } = n, a = C(r), o = C(i), s = w(T(a)), c = w(T(o)), l = t(s, c, g), u = t(c, s, g);
102
- return (!l || !l.length) && (!u || !u.length);
103
- }, D = (e, t) => {
104
- if (e = {
105
- ...e,
106
- root: { ...e.root },
107
- edge: { ...e.edge }
108
- }, t = {
109
- ...t,
110
- root: { ...t.root },
111
- edge: { ...t.edge }
112
- }, s(t.edge, e.edge) && s(t.root, e.root)) return !0;
113
- let n = Math.sqrt((e.edge.x - e.root.x) ** 2 + (e.edge.y - e.root.y) ** 2), r = Math.sqrt((t.edge.x - t.root.x) ** 2 + (t.edge.y - t.root.y) ** 2);
114
- return s(t.root, e.root) && s(n, r);
115
- }, O = (e, t) => {
116
- let n = ({ root: e, edge: t }) => {
117
- e = { ...e }, t = { ...t };
118
- let { amplitude: n, freq: r } = l(e, t), i = Math.abs(e.y - t.y) * 2, a = Math.abs(e.x - t.x) * 2, o = t.x, s = t.y;
119
- for (; o < 0 && a !== 0;) o += a, s = s < e.y ? s + i : s - i;
120
- for (; o - a > 0 && a !== 0;) o -= a, s = s < e.y ? s + i : s - i;
121
- return {
122
- amplitude: b(n),
123
- freq: b(r),
124
- min: b(t.y < e.y ? t.y : t.y - i),
125
- max: b(t.y < e.y ? t.y + i : t.y),
126
- edgeAboveZeroX: b(o),
127
- edgeAboveZeroY: b(s)
128
- };
129
- }, r = n(e), i = n(t), { amplitude: a, freq: o, min: s, max: c, edgeAboveZeroX: u, edgeAboveZeroY: d } = r, { amplitude: f, freq: p, min: m, max: h, edgeAboveZeroX: g, edgeAboveZeroY: _ } = i;
130
- return Math.abs(a) === Math.abs(f) && Math.abs(o) === Math.abs(p) && s === m && c === h && u === g && d === _;
131
- }, k = (e, t) => {
132
- let { edge: n } = e, { edge: r } = t, { root: i } = e, { root: a } = t;
133
- i = { ...i }, a = { ...a };
134
- let o = n || { ...i }, s = r || { ...a }, l = {
135
- x: i.x - (o.x - i.x),
136
- y: o.y
137
- }, u = {
138
- x: a.x - (s.x - a.x),
139
- y: s.y
140
- };
141
- if (!n || !r) return !1;
142
- let { a: d, b: f, c: p } = c(i, n, l), { a: m, b: h, c: g } = c(a, r, u), _ = (e) => Math.round(e * 1e4) / 1e4;
143
- return _(d) === _(m) && _(f) === _(h) && _(p) === _(g);
144
- }, A = (e, t) => {
145
- let { edge: n } = e, { edge: r } = t, { root: i } = e, { root: o } = t;
146
- i = { ...i }, o = { ...o };
147
- let c = n || { ...i }, l = r || { ...o }, u = a(i, c), d = a(o, l);
148
- return s(o, i) && s(d, u);
149
- }, j = (e, t) => {
150
- let { edge: n } = e, { edge: r } = t, { root: i } = e, { root: a } = t;
151
- i = { ...i }, a = { ...a };
152
- let c = n || { ...i }, l = r || { ...a }, { a1: u, b1: d } = o(i, c), { a2: f, b2: p } = o(a, l);
153
- return s(f, u) && s(p, d);
154
- }, M = {
155
- circle: (e, t) => D(e, t),
156
- line: (e, t) => x(e, t),
157
- parabola: (e, t) => k(e, t),
158
- absolute: (e, t) => A(e, t),
159
- exponential: (e, t) => j(e, t),
160
- point: (e, t) => m(e, t),
161
- polygon: (e, t) => E(e, t),
162
- ray: (e, t) => S(e, t),
163
- segment: (e, t) => g(e, t),
164
- sine: (e, t) => O(e, t),
165
- vector: (e, t) => _(e, t)
166
- }, N = Object.defineProperty, P = /* @__PURE__ */ ((e, t) => {
167
- let n = {};
168
- for (var r in e) N(n, r, {
169
- get: e[r],
170
- enumerable: !0
171
- });
172
- return t || N(n, Symbol.toStringTag, { value: "Module" }), n;
173
- })({ enabled: () => F });
174
- function F(e, t, n) {
175
- return e?.partialScoring === !1 || t?.partialScoring === !1 ? !1 : typeof n == "boolean" ? n : !0;
176
- }
177
- //#endregion
178
- //#region src/controller/index.ts
179
- var I = (0, f.default)("@pie-element:graphing:controller"), L = () => ({
180
- point: [],
181
- segment: [],
182
- line: [],
183
- ray: [],
184
- vector: [],
185
- polygon: [],
186
- circle: [],
187
- sine: [],
188
- parabola: [],
189
- absolute: [],
190
- exponential: []
191
- }), R = {
192
- incorrect: 0,
193
- correct: 1,
194
- missing: 2
195
- }, z = (e, t) => !!(e && t && e.type === t.type && M[e.type] && M[e.type](e, t)), B = (e, t) => e.label === t.label ? "correct" : "incorrect", V = ({ sessionAnswers: t, marks: n, withPointLabel: r = !1 }) => {
196
- t ||= [], n ||= [];
197
- let i = e(t).reduce((e, t) => {
198
- let i = n.find((e) => z(t, e));
199
- return t.correctness = (i && t.type === "point" && r ? h(t, i) : i) ? "correct" : "incorrect", i && (t.correctnesslabel = B(t, i), t.correctlabel = i.label ? i.label : "", t.label = t.label ? t.label : ""), [...e, t];
200
- }, []), a = e(n).reduce((e, n) => t.find((e) => z(n, e)) ? e : [...e, {
201
- ...n,
202
- correctness: "missing"
203
- }], []);
204
- return [...i, ...a];
205
- }, H = ({ scoringType: e, env: t }) => {
206
- let n = e;
207
- return e && (n = e === "partial scoring"), P.enabled({ partialScoring: n }, t);
208
- }, U = (t, n, i = {}) => {
209
- let { answers: a = {}, scoringType: o } = t || {}, { answer: s } = n || {};
210
- Object.entries(a || {}).forEach(([e, t]) => a[e] = {
211
- ...t,
212
- marks: t?.marks.filter((e) => !e.building)
213
- }), s ||= [], s = s.filter((e) => !e.building), a = r(a) ? { correctAnswer: L() } : {
214
- correctAnswer: a.correctAnswer,
215
- ...v(a)
216
- };
217
- let c = H({
218
- scoringType: o,
219
- env: i
220
- }), l = d(s, z);
221
- return Object.entries(a).reduce((e, t) => {
222
- let n = t[0], { marks: r } = t[1] || {};
223
- if (!r || !r.length) return e;
224
- let i = V({
225
- sessionAnswers: l,
226
- marks: r
227
- }), a = V({
228
- sessionAnswers: l,
229
- marks: r,
230
- withPointLabel: !0
231
- }), o = a.filter((e) => e.correctness === "correct"), s = a.filter((e) => e.correctness !== "missing"), u = r.length, d = o.length;
232
- return s.length > u && (d -= s.length - u), d < 0 && (d = 0), (d / u > e.bestScore || !e.foundOneSolution) && (c ? e.bestScore = parseFloat((d / u).toFixed(2)) : e.bestScore = Math.floor(d / u), e.bestScoreAnswerKey = n, e.answersCorrected = i, e.foundOneSolution = !0), e;
233
- }, {
234
- bestScore: 0,
235
- bestScoreAnswerKey: null,
236
- answersCorrected: e(l).map((e) => ({
237
- ...e,
238
- correctness: "incorrect"
239
- })),
240
- foundOneSolution: !1
241
- });
242
- }, W = (e) => ({
243
- ...p,
244
- ...e
245
- });
246
- function G(e, t, n) {
247
- return new Promise((i) => {
248
- let a = W(e);
249
- t ??= {};
250
- let { defaultTool: o, extraCSSRules: s, prompt: c, promptEnabled: l, graph: u, answers: d, toolbarTools: f, ...p } = a || {}, { arrows: m } = a, { mode: h, role: g } = n || {};
251
- typeof m == "boolean" && (m = m ? {
252
- left: !0,
253
- right: !0,
254
- up: !0,
255
- down: !0
256
- } : {
257
- left: !1,
258
- right: !1,
259
- up: !1,
260
- down: !1
261
- });
262
- let _ = (f || []).filter((e) => e !== "label"), v = o || _.length && _[0] || "", y = {
263
- ...p,
264
- answers: d,
265
- arrows: m,
266
- defaultTool: v,
267
- disabled: n.mode !== "gather",
268
- prompt: l ? c : null,
269
- rationale: null,
270
- size: u,
271
- showKeyLegend: n.mode === "evaluate",
272
- showToggle: n.mode === "evaluate" && !r(d) && d.correctAnswer && d.correctAnswer.marks && !r(d.correctAnswer.marks),
273
- teacherInstructions: null,
274
- toolbarTools: f,
275
- extraCSSRules: s
276
- };
277
- if (g === "instructor" && (h === "view" || h === "evaluate")) {
278
- let { rationale: e, rationaleEnabled: t, teacherInstructions: n, teacherInstructionsEnabled: r } = a || {};
279
- y.rationale = t ? e : null, y.teacherInstructions = r ? n : null;
280
- }
281
- if (h === "evaluate") if (!r(d) && d.correctAnswer && d.correctAnswer.marks && !r(d.correctAnswer.marks)) {
282
- let { answersCorrected: e, bestScoreAnswerKey: r, bestScore: i } = U(a, t, n);
283
- y.answersCorrected = e.sort((e, t) => R[e.correctness] - R[t.correctness]), y.correctResponse = r ? (d[r] || {}).marks : [], y.showToggle = y.showToggle && i !== 1;
284
- } else y.answersCorrected = t && t.answer || [], y.correctResponse = [];
285
- I("base: ", y), i(y);
286
- });
287
- }
288
- var K = (e, t, n) => {
289
- let r = [], { answers: i = {}, scoringType: a } = e || {}, o = t && t.answer || [];
290
- if (!o.length) return ["Student did not interact with the graph."];
291
- r.push(`Student added ${o.length} object(s) to the graph.`);
292
- let s = H({
293
- scoringType: a,
294
- env: n
295
- }), { answersCorrected: c, bestScore: l, bestScoreAnswerKey: u } = U(e, t, n), d = u && i[u] && i[u].marks || [], f = 0, p = 0, m = 0;
296
- for (let e = 0; e < c.length; e++) {
297
- let t = c[e].correctness;
298
- t === "correct" ? f++ : t === "incorrect" ? p++ : t === "missing" && m++;
299
- }
300
- 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) => {
301
- let n = e.type || "graph object", i = e.label ? `'${e.label}'` : "", a = `with index ${t + 1}`;
302
- 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.`);
303
- }), o.length > d.length) {
304
- let e = o.length - d.length;
305
- r.push(`${e} extra object(s) were plotted and are penalized in scoring.`);
306
- }
307
- return s ? r.push("Score calculated using partial scoring.") : r.push("Score calculated using all-or-nothing scoring."), r.push(`Final score: ${l}.`), r;
308
- };
309
- function q(e, t, n = {}) {
310
- return new Promise((i) => {
311
- (!t || r(t)) && i({
312
- score: 0,
313
- empty: !0,
314
- logTrace: ["Student did not interact with the graph."]
315
- }), (n.mode !== "evaluate" || r(e.answers) || e.answers && e.answers.correctAnswer && r(e.answers.correctAnswer.marks)) && i({
316
- score: 0,
317
- empty: !0,
318
- logTrace: ["Student did not interact with the graph."]
319
- });
320
- let { bestScore: a } = U(e, t, n);
321
- i({
322
- score: a,
323
- empty: !1,
324
- logTrace: K(e, t, n)
325
- });
326
- });
327
- }
328
- var J = (e, t) => new Promise((n) => {
329
- if (t.mode !== "evaluate" && t.role === "instructor") {
330
- let { answers: t } = e || {}, r = [];
331
- t && Object.values(t) && (r = (t.correctAnswer || Object.values(t)[0] || {}).marks || []), n({
332
- answer: r,
333
- id: "1"
334
- });
335
- } else n(null);
336
- }), Y = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), X = (e = {}, t = {}) => {
337
- let { answers: n, toolbarTools: i } = e, a = {}, o = {};
338
- return (i || []).filter((e) => e !== "label").length || (a.toolbarToolsError = "There should be at least 1 tool defined."), [
339
- "teacherInstructions",
340
- "prompt",
341
- "rationale"
342
- ].forEach((n) => {
343
- t[n]?.required && !Y(e[n]) && (a[n] = "This field is required.");
344
- }), Object.entries(n || {}).forEach(([e, t]) => {
345
- t.marks.length || (o[e] = "At least 1 graph object should be defined."), t.marks.length > 0 && t.marks.forEach((t) => {
346
- t.building && (o[e] = "At least 1 graph object is not correctly defined.");
347
- });
348
- }), r(o) || (a.correctAnswerErrors = o), a;
349
- };
350
- //#endregion
351
- export { B as comparLabelMarks, z as compareMarks, J as createCorrectResponseSession, V as getAnswerCorrected, U as getBestAnswer, K as getLogTrace, G as model, W as normalize, q as outcome, X as validate };
352
-
353
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/controller/defaults.ts","../../../src/controller/utils.ts","../../../../../shared/controller-utils/dist/index.js","../../../src/controller/index.ts"],"sourcesContent":["// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/graphing/controller/src/defaults.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\n// TODO: This is lifted from @pie-lib/graphing, however importing this will break a controller build because it has jsx source in that package.\nconst allTools = [\n 'circle',\n 'line',\n 'label',\n 'parabola',\n 'point',\n 'polygon',\n 'ray',\n 'segment',\n 'sine',\n 'vector',\n // 'absolute', // - not available as default\n // 'exponential', // - not available as default\n];\n\n/* model defaults */\nexport default {\n answers: {\n correctAnswer: {\n name: 'Correct Answer',\n marks: [],\n },\n },\n arrows: {\n left: true,\n right: true,\n up: true,\n down: true,\n },\n backgroundMarks: [],\n coordinatesOnHover: false,\n defaultGridConfiguration: 0,\n domain: {\n min: -5,\n max: 5,\n step: 1,\n labelStep: 1,\n axisLabel: 'x',\n },\n graph: { width: 500, height: 500 },\n includeAxes: true,\n labels: {},\n labelsEnabled: true,\n padding: true,\n prompt: '',\n promptEnabled: true,\n range: {\n min: -5,\n max: 5,\n step: 1,\n labelStep: 1,\n axisLabel: 'y',\n },\n rationale: '',\n rationaleEnabled: true,\n standardGrid: false,\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n title: '',\n titleEnabled: true,\n toolbarTools: allTools,\n};\n","// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/graphing/controller/src/utils.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 { differenceWith, isEqual, uniq, uniqWith } from '@pie-element/shared-lodash';\nimport {\n getAmplitudeAndFreq,\n pointsToABC,\n pointsToAForAbsolute,\n pointsToABForExponential,\n} from '@pie-lib/graphing-utils';\n\nexport const equalPoint = (A, B) => {\n A = { ...A };\n B = { ...B };\n\n return isEqual(A.x, B.x) && isEqual(A.y, B.y);\n};\n\nexport const equalPointWithLabel = (A, B) => {\n // x1 = x2 & y1 = y2\n // A point is only correct if both its position AND its label match.\n // Labels are not scored independently; a point in the correct position\n // with the wrong label is considered incorrect as a whole.\n let equalLabel = true;\n\n A = { ...A };\n B = { ...B };\n\n if (A.label || B.label) {\n equalLabel = isEqual(A.label, B.label);\n }\n\n return isEqual(A.x, B.x) && isEqual(A.y, B.y) && equalLabel;\n};\n\nexport const equalSegment = (segment1, segment2) => {\n // A.from = B.from, A.to = B.to OR A.from = B.to, A.to = B.from\n // x1 = x3 & y1 = y3 & x2 = x4 & y2 = y4\n return (\n (isEqual(segment1.from, segment2.from) && isEqual(segment1.to, segment2.to)) ||\n (isEqual(segment1.to, segment2.from) && isEqual(segment1.from, segment2.to))\n );\n};\n\nexport const equalVector = (vector1, vector2) => {\n // A.from = B.from, A.to = B.to;\n // x1 = x3 & y1 = y3 & x2 = x4 & y2 = y4\n return isEqual(vector1.from, vector2.from) && isEqual(vector1.to, vector2.to);\n};\n\n// this function is implemented in configure as well\nexport const sortedAnswers = (answers) =>\n Object.keys(answers || {})\n .sort()\n .reduce((result, key) => {\n if (key !== 'correctAnswer') {\n result[key] = answers[key];\n }\n\n return result;\n }, {});\n\nconst returnLineEquationCoefficients = (line) => {\n line = { ...line, to: { ...line.to }, from: { ...line.from } };\n\n const xA = line.from.x;\n const yA = line.from.y;\n const xB = line.to.x;\n const yB = line.to.y;\n\n return {\n a: yB - yA,\n b: xA - xB,\n c: xB * yA - xA * yB,\n };\n};\n\nconst getSignificantDecimals = (number) => Math.round(number * 10000) / 10000;\n\nexport const equalLine = (line1, line2) => {\n // line equation: ax + by + c = 0\n // 2 lines are equal if a1/a2 = b1/b2 = c1/c2, where a, b, c are the coefficients in line equation\n\n // line equation knowing 2 points: (y - yA) / (yB - yA) = (x - xA) / (xB - xA)\n // extending this equation, we get: x * (yB - yA) + y * (xA - xB) + (xB * yA - xA * yB) = 0\n // where a = yB - yA; b = xA - xB; c = xB * yA - xA * yB\n\n const { a: a1, b: b1, c: c1 } = returnLineEquationCoefficients(line1);\n const { a: a2, b: b2, c: c2 } = returnLineEquationCoefficients(line2);\n\n const proportions = [];\n\n if (a2 !== 0) {\n proportions.push(getSignificantDecimals(a1 / a2));\n } else if (a1 !== a2) {\n return false;\n }\n\n if (b2 !== 0) {\n proportions.push(getSignificantDecimals(b1 / b2));\n } else if (b1 !== b2) {\n return false;\n }\n\n if (c2 !== 0) {\n proportions.push(getSignificantDecimals(c1 / c2));\n } else if (c1 !== c2) {\n return false;\n }\n\n return uniq(proportions).length === 1;\n\n // (y2 - y1)/(x2 - x1) = (y4 - y3)/(x4 - x3);\n // return ((Math.abs((line1.to.y - line1.from.y) / (line1.to.x - line1.from.x))) === (Math.abs((line2.to.y - line2.from.y) / (line2.to.x - line2.from.x))));\n};\n\nexport const equalRay = (ray1, ray2) => {\n ray1 = { ...ray1, to: { ...ray1.to }, from: { ...ray1.from } };\n ray2 = { ...ray2, to: { ...ray2.to }, from: { ...ray2.from } };\n\n // slope: m = (y2-y1)/(x2-x1)\n // slope & x1 = x3 & y1 = y3 & angle between (x1, y1) (x2, y2) is same as angle between (x3, y3) (x4, y4)\n const mRay1 = (ray1.to.y - ray1.from.y) / (ray1.to.x - ray1.from.x);\n const mRay2 = (ray2.to.y - ray2.from.y) / (ray2.to.x - ray2.from.x);\n const angleRay1 = (Math.atan2(ray1.to.y - ray1.from.y, ray1.to.x - ray1.from.x) * 180) / Math.PI;\n const angleRay2 = (Math.atan2(ray2.to.y - ray2.from.y, ray2.to.x - ray2.from.x) * 180) / Math.PI;\n\n return mRay1 === mRay2 && ray1.from.x === ray2.from.x && ray1.from.y === ray2.from.y && angleRay1 === angleRay2;\n};\n\nexport const constructSegmentsFromPoints = (points) => {\n // takes the list of points that represent a polygon and transforms it into a list of segments; eg.:\n // points: A, B, C, D => segments: AB, BC, CD, DA\n return (points || []).map((point, index) => ({ from: point, to: points[(index + 1) % points.length] }));\n};\n\nexport const removeDuplicateSegments = (segments) => {\n segments = segments || [];\n // removes segments that are duplicates; eg. These segments are the same, so one will be removed:\n // segment1: from: { x: 1, y: 1 }, to: { x: 2, y: 1 }\n // segment2: from: { x: 2, y: 1 }, to: { x: 1, y: 1 }\n return uniqWith(segments, (s1, s2) => equalSegment(s1, s2));\n};\n\nexport const removeInvalidSegments = (segments) => {\n segments = segments || [];\n // removes segments that start in a point and end in the same point (eg.: from: { x: 1, y: 1 }, to: { x: 1, y: 1 })\n\n return segments.filter((segment) => !isEqual(segment.from, segment.to));\n};\n\nexport const equalPolygon = (poly1, poly2) => {\n const { points: points1 } = poly1;\n const { points: points2 } = poly2;\n\n // generate segments\n const segments1 = constructSegmentsFromPoints(points1);\n const segments2 = constructSegmentsFromPoints(points2);\n\n const segments1NoDuplicates = removeDuplicateSegments(removeInvalidSegments(segments1));\n const segments2NoDuplicates = removeDuplicateSegments(removeInvalidSegments(segments2));\n\n const differentSegments1 = differenceWith(segments1NoDuplicates, segments2NoDuplicates, equalSegment);\n const differentSegments2 = differenceWith(segments2NoDuplicates, segments1NoDuplicates, equalSegment);\n\n return (!differentSegments1 || !differentSegments1.length) && (!differentSegments2 || !differentSegments2.length);\n};\n\nexport const equalCircle = (c1, c2) => {\n c1 = { ...c1, root: { ...c1.root }, edge: { ...c1.edge } };\n c2 = { ...c2, root: { ...c2.root }, edge: { ...c2.edge } };\n const equalRootAndEdge = isEqual(c2.edge, c1.edge) && isEqual(c2.root, c1.root);\n\n // if both edge and root are the same, it means the shapes are exactly the same\n if (equalRootAndEdge) return true;\n\n const rC1 = Math.sqrt((c1.edge.x - c1.root.x) ** 2 + (c1.edge.y - c1.root.y) ** 2);\n const rC2 = Math.sqrt((c2.edge.x - c2.root.x) ** 2 + (c2.edge.y - c2.root.y) ** 2);\n\n // if both root and radius are the same, it means the shapes are equal\n return isEqual(c2.root, c1.root) && isEqual(rC1, rC2);\n};\n\nexport const equalSine = (sine1, sine2) => {\n const getPoints = ({ root, edge }) => {\n root = { ...root };\n edge = { ...edge };\n\n const { amplitude, freq } = getAmplitudeAndFreq(root, edge);\n // the height of the sine wave\n const tY = Math.abs(root.y - edge.y) * 2;\n // the distance on x axis between edge and root\n const tXRoot = Math.abs(root.x - edge.x);\n // the distance on x axis between 2 edges for sine wave (min & max)\n const tX = tXRoot * 2;\n // the first edge placed east side of root\n let edgeAboveZeroX = edge.x;\n let edgeAboveZeroY = edge.y;\n\n // if edge less then 0, find out the appropriate edge placed east side of zero (0)\n while (edgeAboveZeroX < 0 && tX !== 0) {\n edgeAboveZeroX = edgeAboveZeroX + tX;\n edgeAboveZeroY = edgeAboveZeroY < root.y ? edgeAboveZeroY + tY : edgeAboveZeroY - tY;\n }\n\n // if edge more then 0, find out the appropriate edge placed east side of zero (0)\n while (edgeAboveZeroX - tX > 0 && tX !== 0) {\n edgeAboveZeroX = edgeAboveZeroX - tX;\n edgeAboveZeroY = edgeAboveZeroY < root.y ? edgeAboveZeroY + tY : edgeAboveZeroY - tY;\n }\n\n return {\n amplitude: getSignificantDecimals(amplitude),\n freq: getSignificantDecimals(freq),\n min: getSignificantDecimals(edge.y < root.y ? edge.y : edge.y - tY),\n max: getSignificantDecimals(edge.y < root.y ? edge.y + tY : edge.y),\n edgeAboveZeroX: getSignificantDecimals(edgeAboveZeroX),\n edgeAboveZeroY: getSignificantDecimals(edgeAboveZeroY),\n };\n };\n\n const studentAnswerBpY = getPoints(sine1);\n const correctAnswerBpY = getPoints(sine2);\n\n const {\n amplitude: amplitude1,\n freq: freq1,\n min: min1,\n max: max1,\n edgeAboveZeroX: edgeAboveZeroX1,\n edgeAboveZeroY: edgeAboveZeroY1,\n } = studentAnswerBpY;\n const {\n amplitude: amplitude2,\n freq: freq2,\n min: min2,\n max: max2,\n edgeAboveZeroX: edgeAboveZeroX2,\n edgeAboveZeroY: edgeAboveZeroY2,\n } = correctAnswerBpY;\n\n return (\n Math.abs(amplitude1) === Math.abs(amplitude2) &&\n Math.abs(freq1) === Math.abs(freq2) &&\n min1 === min2 &&\n max1 === max2 &&\n edgeAboveZeroX1 === edgeAboveZeroX2 &&\n edgeAboveZeroY1 === edgeAboveZeroY2\n );\n // rootDiff1 === rootDiff2);\n};\n\nexport const equalParabola = (p1, p2) => {\n const { edge: edgeP1 } = p1;\n const { edge: edgeP2 } = p2;\n let { root: rootP1 } = p1;\n let { root: rootP2 } = p2;\n\n rootP1 = { ...rootP1 };\n rootP2 = { ...rootP2 };\n\n const p1edge = edgeP1 || { ...rootP1 };\n const p2edge = edgeP2 || { ...rootP2 };\n\n const p1mirrorEdge = { x: rootP1.x - (p1edge.x - rootP1.x), y: p1edge.y };\n const p2mirrorEdge = { x: rootP2.x - (p2edge.x - rootP2.x), y: p2edge.y };\n\n if (!edgeP1 || !edgeP2) return false;\n\n const { a: a1, b: b1, c: c1 } = pointsToABC(rootP1, edgeP1, p1mirrorEdge);\n const { a: a2, b: b2, c: c2 } = pointsToABC(rootP2, edgeP2, p2mirrorEdge);\n\n // sometimes numbers have this form: 1.00000000002 because of calculations, we have to round them\n const round = (number) => Math.round(number * 10000) / 10000;\n\n return round(a1) === round(a2) && round(b1) === round(b2) && round(c1) === round(c2);\n};\n\n/*\n * Function to check if given two points for absolute function\n * for correct answer and student answer are equal or not.\n * @param p1 - student answer\n * @param p2 - correct answer\n * */\nexport const equalAbsolute = (p1, p2) => {\n const { edge: edgeP1 } = p1;\n const { edge: edgeP2 } = p2;\n let { root: rootP1 } = p1;\n let { root: rootP2 } = p2;\n\n rootP1 = { ...rootP1 };\n rootP2 = { ...rootP2 };\n\n const p1edge = edgeP1 || { ...rootP1 };\n const p2edge = edgeP2 || { ...rootP2 };\n\n const p1a1 = pointsToAForAbsolute(rootP1, p1edge);\n const p2a2 = pointsToAForAbsolute(rootP2, p2edge);\n\n // if both root and a value are equal\n return isEqual(rootP2, rootP1) && isEqual(p2a2, p1a1);\n};\n\n/*\n * Function to check if given two points for exponential function\n * for correct answer and student answer are equal or not.\n * @param p1 - student answer\n * @param p2 - correct answer\n * */\nexport const equalExponential = (p1, p2) => {\n const { edge: edgeP1 } = p1;\n const { edge: edgeP2 } = p2;\n let { root: rootP1 } = p1;\n let { root: rootP2 } = p2;\n\n rootP1 = { ...rootP1 };\n rootP2 = { ...rootP2 };\n\n const p1edge = edgeP1 || { ...rootP1 };\n const p2edge = edgeP2 || { ...rootP2 };\n\n const { a1, b1 } = pointsToABForExponential(rootP1, p1edge);\n const { a2, b2 } = pointsToABForExponential(rootP2, p2edge);\n\n // if both a and b value are equal\n return isEqual(a2, a1) && isEqual(b2, b1);\n};\n\nexport const equalMarks = {\n circle: (sessAnswer, mark) => equalCircle(sessAnswer, mark),\n line: (sessAnswer, mark) => equalLine(sessAnswer, mark),\n parabola: (sessAnswer, mark) => equalParabola(sessAnswer, mark),\n absolute: (sessAnswer, mark) => equalAbsolute(sessAnswer, mark),\n exponential: (sessAnswer, mark) => equalExponential(sessAnswer, mark),\n point: (sessAnswer, mark) => equalPoint(sessAnswer, mark),\n polygon: (sessAnswer, poly) => equalPolygon(sessAnswer, poly),\n ray: (sessAnswer, mark) => equalRay(sessAnswer, mark),\n segment: (sessAnswer, mark) => equalSegment(sessAnswer, mark),\n sine: (sessAnswer, mark) => equalSine(sessAnswer, mark),\n vector: (sessAnswer, mark) => equalVector(sessAnswer, mark),\n};\n\nconst completePoint = (point) => point && Number.isFinite(point.x) && Number.isFinite(point.y);\nconst completeFromTo = (item) => item && completeMark.point(item.from) && completeMark.point(item.to);\nconst completeRootEdge = (item) => item && completeMark.point(item.edge) && completeMark.point(item.root);\nconst completePoints = (item) =>\n item &&\n item.points &&\n item.points.length &&\n (item.points.filter((point) => completePoint(point)) || []).length === item.points.length;\n\nconst completeMark = {\n point: completePoint,\n line: completeFromTo,\n ray: completeFromTo,\n segment: completeFromTo,\n vector: completeFromTo,\n circle: completeRootEdge,\n parabola: completeRootEdge,\n absolute: completeRootEdge,\n exponential: completeRootEdge,\n sine: completeRootEdge,\n polygon: completePoints,\n};\n","//#region \\0rolldown/runtime.js\nvar e = Object.defineProperty, t = (t, n) => {\n\tlet r = {};\n\tfor (var i in t) e(r, i, {\n\t\tget: t[i],\n\t\tenumerable: !0\n\t});\n\treturn n || e(r, Symbol.toStringTag, { value: \"Module\" }), r;\n};\n//#endregion\n//#region src/persistence.ts\nfunction n(e) {\n\treturn Array.isArray(e) ? e.filter((e) => e != null) : [];\n}\nfunction r(e) {\n\tlet t = [...e];\n\tfor (let e = t.length - 1; e > 0; e--) {\n\t\tlet n = Math.floor(Math.random() * (e + 1));\n\t\t[t[e], t[n]] = [t[n], t[e]];\n\t}\n\treturn t;\n}\nfunction i(e) {\n\treturn e == null ? !0 : Array.isArray(e) ? e.length === 0 : typeof e == \"object\" ? Object.keys(e).length === 0 : !1;\n}\nasync function a(e, t, a, o = \"value\") {\n\tlet s = n(t?.data?.shuffledValues ?? t?.shuffledValues ?? []);\n\tif (!t) {\n\t\tconsole.warn(\"Unable to save shuffled choices because there's no session.\");\n\t\treturn;\n\t}\n\tif (!i(s)) return n(s.map((t) => e.find((e) => e[o] === t)));\n\tlet c = r(e);\n\tif (a && typeof a == \"function\") try {\n\t\tlet e = n(c.map((e) => e[o]));\n\t\ti(e) ? console.error(`shuffledValues is an empty array - refusing to call updateSession. shuffledChoices: ${JSON.stringify(c)}, key: ${o}`) : t.id && t.element && await a(t.id, t.element, { shuffledValues: e });\n\t} catch (e) {\n\t\tconsole.warn(\"Unable to save shuffled order for choices\"), console.error(e);\n\t}\n\telse console.warn(\"Unable to save shuffled choices, shuffle will happen every time.\");\n\treturn c;\n}\nfunction o(e, t, n) {\n\treturn !!(e.lockChoiceOrder || n[\"@pie-element\"]?.lockChoiceOrder || (n.role ?? \"student\") === \"instructor\");\n}\n//#endregion\n//#region src/partial-scoring.ts\nvar s = /* @__PURE__ */ t({ enabled: () => c });\nfunction c(e, t, n) {\n\treturn e?.partialScoring === !1 || t?.partialScoring === !1 ? !1 : typeof n == \"boolean\" ? n : !0;\n}\n//#endregion\nexport { a as getShuffledChoices, o as lockChoices, s as partialScoring };\n","// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/graphing/controller/src/index.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 debug from 'debug';\n\nimport { cloneDeep, isEmpty, uniqWith } from '@pie-element/shared-lodash';\nimport defaults from './defaults.js';\nimport { equalMarks, equalPointWithLabel, sortedAnswers } from './utils.js';\n\nimport { partialScoring } from '@pie-element/shared-controller-utils';\n\nconst log = debug('@pie-element:graphing:controller');\n\nconst initializeGraphMap = () => ({\n point: [],\n segment: [],\n line: [],\n ray: [],\n vector: [],\n polygon: [],\n circle: [],\n sine: [],\n parabola: [],\n absolute: [],\n exponential: [],\n});\n\nconst graphObjectsOrder = {\n incorrect: 0,\n correct: 1,\n missing: 2,\n};\n\nexport const compareMarks = (mark1, mark2) => {\n // marks can be compared with equalMarks[type] function only if they have the same type;\n // if type is different, they are clearly not equal\n return !!(\n mark1 &&\n mark2 &&\n mark1.type === mark2.type &&\n equalMarks[mark1.type] &&\n equalMarks[mark1.type](mark1, mark2)\n );\n};\n\nexport const comparLabelMarks = (mark1, mark2) => {\n return mark1.label === mark2.label ? 'correct' : 'incorrect';\n};\n\nexport const getAnswerCorrected = ({ sessionAnswers, marks: correctAnswers, withPointLabel = false }) => {\n sessionAnswers = sessionAnswers || [];\n correctAnswers = correctAnswers || [];\n\n const rez = cloneDeep(sessionAnswers).reduce((correctedAnswer, answer) => {\n const answerIsCorrect = correctAnswers.find((mark) => compareMarks(answer, mark));\n\n // For scoring points, check if both position AND label match\n const isCorrectForScoring = answerIsCorrect && answer.type === 'point' && withPointLabel \n ? equalPointWithLabel(answer, answerIsCorrect)\n : !!answerIsCorrect;\n\n answer.correctness = isCorrectForScoring ? 'correct' : 'incorrect';\n if (answerIsCorrect) {\n answer.correctnesslabel = comparLabelMarks(answer, answerIsCorrect);\n answer.correctlabel = answerIsCorrect.label ? answerIsCorrect.label : '';\n answer.label = answer.label ? answer.label : '';\n }\n return [...correctedAnswer, answer];\n }, []);\n\n // add missing objects from correct answer\n const missingAnswers = cloneDeep(correctAnswers).reduce((correctedAnswer, answer) => {\n const answerIndex = sessionAnswers.find((mark) => compareMarks(answer, mark));\n\n if (!answerIndex) {\n // means that corrected answer is missing from session, so we mark it as missing object\n return [...correctedAnswer, { ...answer, correctness: 'missing' }];\n }\n\n return correctedAnswer;\n }, []);\n\n return [...rez, ...missingAnswers];\n};\n\nconst getPartialScoring = ({ scoringType, env }) => {\n let pS = scoringType;\n\n // if scoringType is undefined, partialScoring should be considered undefined (not set)\n // because partialScoring.enabled is using that information\n // if it has a value, we check if it is partial scoring or dichotomous\n if (scoringType) {\n pS = scoringType === 'partial scoring';\n }\n\n return partialScoring.enabled({ partialScoring: pS }, env);\n};\n\nexport const getBestAnswer = (question, session, env = {}) => {\n // questionPossibleAnswers contains all possible answers (correct response and alternates);\n let { answers: questionPossibleAnswers = {}, scoringType } = question || {};\n let { answer } = session || {};\n\n // filter the incomplete objects\n Object.entries(questionPossibleAnswers || {}).forEach(\n ([key, value]) =>\n (questionPossibleAnswers[key] = { ...value, marks: value?.marks.filter((mark) => !mark.building) }),\n );\n\n // initialize answer if no values\n answer = answer || [];\n\n //filter the incomplete objects for student response - Fix for SC-33160\n answer = answer.filter((mark) => !mark.building);\n\n // initialize one possible answer if no values\n if (isEmpty(questionPossibleAnswers)) {\n questionPossibleAnswers = { correctAnswer: initializeGraphMap() };\n } else {\n questionPossibleAnswers = {\n correctAnswer: questionPossibleAnswers.correctAnswer,\n ...sortedAnswers(questionPossibleAnswers),\n };\n }\n\n const partialScoringEnabled = getPartialScoring({ scoringType, env });\n\n // student's answers without DUPLICATES\n const sessionAnswers = uniqWith(answer, compareMarks);\n // array of possible answers entries\n const possibleAnswers = Object.entries(questionPossibleAnswers);\n\n return possibleAnswers.reduce(\n (acc, entry) => {\n // iterating each possible answer (main + alternates)\n const possibleAnswerKey = entry[0];\n const possibleAnswer = entry[1] || {};\n let { marks } = possibleAnswer;\n\n if (!marks || !marks.length) {\n return acc;\n }\n\n // returns array of marks, each having 'correctness' property\n const correctedAnswer = getAnswerCorrected({ sessionAnswers, marks });\n const correctedAnswerWithLabels = getAnswerCorrected({ sessionAnswers, marks, withPointLabel: true });\n const correctMarks = correctedAnswerWithLabels.filter((answer) => answer.correctness === 'correct');\n // filter out missing objects because they do not affect the calculation of the score\n // only correct and incorrect are needed\n const scoredCorrectedAnswer = correctedAnswerWithLabels.filter((answer) => answer.correctness !== 'missing');\n\n const maxScore = marks.length;\n let score = correctMarks.length;\n\n // if extra placements\n if (scoredCorrectedAnswer.length > maxScore) {\n score -= scoredCorrectedAnswer.length - maxScore;\n }\n\n if (score < 0) {\n score = 0;\n }\n\n if (score / maxScore > acc.bestScore || !acc.foundOneSolution) {\n if (partialScoringEnabled) {\n acc.bestScore = parseFloat((score / maxScore).toFixed(2));\n } else {\n acc.bestScore = Math.floor(score / maxScore);\n }\n\n acc.bestScoreAnswerKey = possibleAnswerKey;\n acc.answersCorrected = correctedAnswer;\n acc.foundOneSolution = true;\n }\n\n return acc;\n },\n {\n bestScore: 0,\n bestScoreAnswerKey: null,\n // initially we just suppose all the answers are incorrect\n answersCorrected: cloneDeep(sessionAnswers).map((answer) => ({ ...answer, correctness: 'incorrect' })),\n foundOneSolution: false,\n },\n );\n};\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\nexport function model(question, session, env) {\n return new Promise((resolve) => {\n const normalizedQuestion = normalize(question);\n\n // added a sanity check for session for environments where it is not passed initially (ex. pie-website)\n if (session === undefined || session === null) {\n session = {};\n }\n // console.log('normalizedQuestion', normalizedQuestion);\n const { defaultTool, extraCSSRules, prompt, promptEnabled, graph, answers, toolbarTools, ...questionProps } =\n normalizedQuestion || {};\n let { arrows } = normalizedQuestion;\n const { mode, role } = env || {};\n\n // This is used for offering support for old models which have the property arrows: boolean\n // Same thing is set in authoring : packages/graphing/configure/src/configure.jsx - componentDidMount\n if (typeof arrows === 'boolean') {\n if (arrows) {\n arrows = {\n left: true,\n right: true,\n up: true,\n down: true,\n };\n } else {\n arrows = {\n left: false,\n right: false,\n up: false,\n down: false,\n };\n }\n }\n\n // added support for models without defaultTool defined; also used in packages/graphing/configure/src/index.js\n const toolbarToolsNoLabel = (toolbarTools || []).filter((tool) => tool !== 'label');\n const normalizedDefaultTool = defaultTool || (toolbarToolsNoLabel.length && toolbarToolsNoLabel[0]) || '';\n\n const base = {\n ...questionProps,\n answers,\n arrows,\n defaultTool: normalizedDefaultTool,\n disabled: env.mode !== 'gather',\n prompt: promptEnabled ? prompt : null,\n rationale: null,\n size: graph,\n showKeyLegend: env.mode === 'evaluate',\n showToggle:\n env.mode === 'evaluate' &&\n !isEmpty(answers) &&\n answers.correctAnswer &&\n answers.correctAnswer.marks &&\n !isEmpty(answers.correctAnswer.marks),\n teacherInstructions: null,\n toolbarTools,\n extraCSSRules,\n };\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n const { rationale, rationaleEnabled, teacherInstructions, teacherInstructionsEnabled } = normalizedQuestion || {};\n\n base.rationale = rationaleEnabled ? rationale : null;\n base.teacherInstructions = teacherInstructionsEnabled ? teacherInstructions : null;\n }\n\n if (mode === 'evaluate') {\n if (\n !isEmpty(answers) &&\n answers.correctAnswer &&\n answers.correctAnswer.marks &&\n !isEmpty(answers.correctAnswer.marks)\n ) {\n const { answersCorrected, bestScoreAnswerKey, bestScore } = getBestAnswer(normalizedQuestion, session, env);\n // array of marks from session with 'correctness' property set\n base.answersCorrected = answersCorrected.sort(\n (a, b) => graphObjectsOrder[a.correctness] - graphObjectsOrder[b.correctness],\n );\n base.correctResponse = bestScoreAnswerKey ? (answers[bestScoreAnswerKey] || {}).marks : [];\n base.showToggle = base.showToggle && bestScore !== 1;\n } else {\n base.answersCorrected = (session && session.answer) || [];\n base.correctResponse = [];\n }\n }\n\n log('base: ', base);\n resolve(base);\n });\n}\n\n /**\n * Generates detailed trace log for scoring evaluation\n * @param {Object} model - the question model\n * @param {Object} session - the student session\n * @param {Object} env - the environment\n * @returns {Array} traceLog - array of trace messages\n */\nexport const getLogTrace = (question, session, env) => {\n const traceLog = [];\n const { answers = {}, scoringType } = question || {};\n const studentMarks = (session && session.answer) || [];\n\n if (!studentMarks.length) {\n return ['Student did not interact with the graph.'];\n }\n\n traceLog.push(`Student added ${studentMarks.length} object(s) to the graph.`);\n\n const partialScoringEnabled = getPartialScoring({ scoringType, env });\n\n const {\n answersCorrected,\n bestScore,\n bestScoreAnswerKey,\n } = getBestAnswer(question, session, env);\n\n const correctResponse =\n bestScoreAnswerKey && answers[bestScoreAnswerKey]\n ? answers[bestScoreAnswerKey].marks || []\n : [];\n\n let correctCount = 0;\n let incorrectCount = 0;\n let missingCount = 0;\n\n for (let i = 0; i < answersCorrected.length; i++) {\n const c = answersCorrected[i].correctness;\n if (c === 'correct') correctCount++;\n else if (c === 'incorrect') incorrectCount++;\n else if (c === 'missing') missingCount++;\n }\n\n if (correctCount > 0) {\n traceLog.push(`Correct objects: ${correctCount}.`);\n }\n\n if (incorrectCount > 0) {\n traceLog.push(`Incorrect objects: ${incorrectCount}.`);\n }\n\n if (missingCount > 0) {\n traceLog.push(`Missing required objects: ${missingCount}.`);\n }\n\n answersCorrected.forEach((mark, index) => {\n const objectType = mark.type || 'graph object';\n const objectLabel = mark.label ? `'${mark.label}'` : '';\n const objectIndex = `with index ${index + 1}`;\n\n if (mark.correctness === 'correct') {\n traceLog.push(\n `${objectType.charAt(0).toUpperCase() + objectType.slice(1)} ${objectLabel || objectIndex} is correct.`\n );\n }\n\n if (mark.correctness === 'incorrect') {\n traceLog.push(\n `${objectType.charAt(0).toUpperCase() + objectType.slice(1)} ${objectLabel || objectIndex} does not match the expected ${objectType}.`\n );\n }\n\n if (mark.correctness === 'missing') {\n traceLog.push(`Expected ${objectType} ${objectLabel || objectIndex} was not plotted by the student.`);\n }\n });\n\n if (studentMarks.length > correctResponse.length) {\n const extra = studentMarks.length - correctResponse.length;\n traceLog.push(`${extra} extra object(s) were plotted and are penalized in scoring.`);\n }\n\n if (partialScoringEnabled) {\n traceLog.push('Score calculated using partial scoring.');\n } else {\n traceLog.push('Score calculated using all-or-nothing scoring.');\n }\n\n traceLog.push(`Final score: ${bestScore}.`);\n\n return traceLog;\n};\n\n\nexport function outcome(question, session, env = {}) {\n return new Promise((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true, logTrace: ['Student did not interact with the graph.'] });\n }\n\n if (\n env.mode !== 'evaluate' ||\n isEmpty(question.answers) ||\n (question.answers && question.answers.correctAnswer && isEmpty(question.answers.correctAnswer.marks))\n ) {\n resolve({ score: 0, empty: true, logTrace: ['Student did not interact with the graph.'] });\n }\n\n const { bestScore } = getBestAnswer(question, session, env);\n\n resolve({ score: bestScore, empty: false, logTrace: getLogTrace(question, session, env) });\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { answers } = question || {};\n let marks = [];\n\n if (answers && Object.values(answers)) {\n const correctAnswer = answers.correctAnswer || Object.values(answers)[0] || {};\n marks = correctAnswer.marks || [];\n }\n\n resolve({\n answer: marks,\n id: '1',\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { answers, toolbarTools } = model;\n const errors = {};\n const correctAnswerErrors = {};\n const toolbarToolsNoLabel = (toolbarTools || []).filter((tool) => tool !== 'label');\n\n if (!toolbarToolsNoLabel.length) {\n errors.toolbarToolsError = 'There should be at least 1 tool defined.';\n }\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n Object.entries(answers || {}).forEach(([key, value]) => {\n if (!value.marks.length) {\n correctAnswerErrors[key] = 'At least 1 graph object should be defined.';\n }\n\n // check if all graph objects are correctly defined with respect to root, edge and from, to\n if (value.marks.length > 0) {\n value.marks.forEach((mark) => {\n if (mark.building) {\n correctAnswerErrors[key] = 'At least 1 graph object is not correctly defined.';\n }\n });\n }\n });\n\n if (!isEmpty(correctAnswerErrors)) {\n errors.correctAnswerErrors = correctAnswerErrors;\n }\n\n return errors;\n};\n"],"mappings":";;mCA2BA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,GCvDa,KAAc,GAAG,OAC5B,IAAI,EAAE,GAAG,EAAE,GACX,IAAI,EAAE,GAAG,EAAE,GAEJ,EAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,EAAQ,EAAE,GAAG,EAAE,CAAC,IAGjC,KAAuB,GAAG,MAAM;CAK3C,IAAI,IAAa;CASjB,OAPA,IAAI,EAAE,GAAG,EAAE,GACX,IAA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