@pie-element/fraction-model 6.1.1-next.11 → 6.1.2-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configure.js +2 -0
- package/controller.js +1 -0
- package/dist/author/card-bar.d.ts +20 -0
- package/dist/author/card-bar.js +40 -0
- package/dist/author/defaults.d.ts +113 -0
- package/dist/author/defaults.js +84 -0
- package/dist/author/index.d.ts +44 -0
- package/dist/author/index.js +88 -0
- package/dist/author/main.d.ts +25 -0
- package/dist/author/main.js +156 -0
- package/dist/author/model-options.d.ts +32 -0
- package/dist/author/model-options.js +85 -0
- package/dist/author/number-text-field.d.ts +15 -0
- package/dist/author/number-text-field.js +24 -0
- package/dist/browser/author/index.js +37287 -0
- package/dist/browser/author/index.js.map +1 -0
- package/dist/browser/controller/index.js +78 -0
- package/dist/browser/controller/index.js.map +1 -0
- package/dist/browser/delivery/index.js +2 -0
- package/dist/browser/delivery-BSG67wbh.js +28213 -0
- package/dist/browser/delivery-BSG67wbh.js.map +1 -0
- package/dist/browser/fraction-model.css +2 -0
- package/dist/browser/isEmpty-Cj-5W3cl.js +16 -0
- package/dist/browser/isEmpty-Cj-5W3cl.js.map +1 -0
- package/dist/browser/isTypedArray-yL07_GBh.js +171 -0
- package/dist/browser/isTypedArray-yL07_GBh.js.map +1 -0
- package/dist/controller/defaults.d.ts +21 -0
- package/dist/controller/defaults.js +13 -0
- package/dist/controller/index.d.ts +23 -0
- package/dist/controller/index.js +68 -0
- package/dist/delivery/answer-fraction.d.ts +27 -0
- package/dist/delivery/answer-fraction.js +69 -0
- package/dist/delivery/fraction-model-chart.d.ts +11 -0
- package/dist/delivery/fraction-model-chart.js +154 -0
- package/dist/delivery/index.d.ts +22 -0
- package/dist/delivery/index.js +54 -0
- package/dist/delivery/main.d.ts +38 -0
- package/dist/delivery/main.js +136 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.iife.d.ts +8 -0
- package/dist/index.iife.js +179 -0
- package/dist/index.js +2 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_DataView.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Hash.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_ListCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Map.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_MapCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Promise.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Set.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Stack.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Symbol.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Uint8Array.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_WeakMap.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayEach.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayFilter.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayLikeKeys.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayPush.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assignValue.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assocIndexOf.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssign.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignValue.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseClone.js +57 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseCreate.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetTag.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsArguments.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsMap.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsNative.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeys.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeysIn.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseTimes.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseUnary.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneBuffer.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneDataView.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneRegExp.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneSymbol.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneTypedArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyObject.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbols.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbolsIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_coreJsData.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_defineProperty.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_freeGlobal.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getMapData.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getNative.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getPrototype.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getRawTag.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbols.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbolsIn.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getTag.js +23 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getValue.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashGet.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashHas.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneByTag.js +33 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneObject.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isIndex.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isKeyable.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isMasked.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isPrototype.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheClear.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheDelete.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheGet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheClear.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheDelete.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheGet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeCreate.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeys.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeysIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nodeUtil.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_objectToString.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_overArg.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_root.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackGet.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackSet.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_toSource.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/cloneDeep.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/eq.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArguments.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArray.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArrayLike.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isBuffer.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isEmpty.js +21 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isFunction.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isLength.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isMap.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObject.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObjectLike.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isSet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isTypedArray.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubArray.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubFalse.js +6 -0
- package/package.json +79 -19
- package/CHANGELOG.json +0 -1
- package/CHANGELOG.md +0 -584
- package/LICENSE.md +0 -5
- package/README.md +0 -18
- package/configure/CHANGELOG.json +0 -1
- package/configure/CHANGELOG.md +0 -549
- package/configure/lib/card-bar.js +0 -57
- package/configure/lib/card-bar.js.map +0 -1
- package/configure/lib/defaults.js +0 -114
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/index.js +0 -163
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/main.js +0 -253
- package/configure/lib/main.js.map +0 -1
- package/configure/lib/model-options.js +0 -144
- package/configure/lib/model-options.js.map +0 -1
- package/configure/lib/number-text-field.js +0 -47
- package/configure/lib/number-text-field.js.map +0 -1
- package/configure/package.json +0 -24
- package/controller/CHANGELOG.json +0 -1
- package/controller/CHANGELOG.md +0 -476
- package/controller/lib/defaults.js +0 -20
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -215
- package/controller/lib/index.js.map +0 -1
- package/controller/package.json +0 -15
- package/docs/config-schema.json +0 -1796
- package/docs/config-schema.json.md +0 -1318
- package/docs/demo/config.js +0 -8
- package/docs/demo/generate.js +0 -6
- package/docs/demo/index.html +0 -1
- package/docs/demo/session.js +0 -6
- package/docs/pie-schema.json +0 -873
- package/docs/pie-schema.json.md +0 -639
- package/lib/answer-fraction.js +0 -109
- package/lib/answer-fraction.js.map +0 -1
- package/lib/fraction-model-chart.js +0 -279
- package/lib/fraction-model-chart.js.map +0 -1
- package/lib/index.js +0 -91
- package/lib/index.js.map +0 -1
- package/lib/main.js +0 -203
- package/lib/main.js.map +0 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { t as e } from "../isEmpty-Cj-5W3cl.js";
|
|
2
|
+
//#region src/controller/defaults.ts
|
|
3
|
+
var t = { model: {
|
|
4
|
+
correctResponse: [],
|
|
5
|
+
title: "",
|
|
6
|
+
prompt: "",
|
|
7
|
+
modelTypeSelected: "bar",
|
|
8
|
+
maxModelSelected: 1,
|
|
9
|
+
partsPerModel: 5,
|
|
10
|
+
allowedStudentConfig: !1,
|
|
11
|
+
showGraphLabels: !1
|
|
12
|
+
} }, n = (e, t, n = {}) => {
|
|
13
|
+
let r;
|
|
14
|
+
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";
|
|
15
|
+
}, r = (e, t, r = {}) => {
|
|
16
|
+
if (t.mode === "evaluate") return n(e, r, t);
|
|
17
|
+
}, i = (e, t, n = {}) => +(r(e, t, n) === "correct"), a = (t, n, r) => new Promise((a) => {
|
|
18
|
+
!n || e(n) ? a({
|
|
19
|
+
score: 0,
|
|
20
|
+
empty: !0
|
|
21
|
+
}) : r.mode === "evaluate" ? a({ score: i(t, r, n.answers) }) : a({
|
|
22
|
+
score: void 0,
|
|
23
|
+
completed: void 0
|
|
24
|
+
});
|
|
25
|
+
}), o = (e, t) => {
|
|
26
|
+
let n = 0, r = 0;
|
|
27
|
+
for (let t = 0; t < e.length; t++) n += e[t].value;
|
|
28
|
+
for (let e = 0; e < t.length; e++) r += t[e].value;
|
|
29
|
+
return n === r;
|
|
30
|
+
}, s = (e, t) => {
|
|
31
|
+
if (e.length > 0) {
|
|
32
|
+
let n = 0;
|
|
33
|
+
return e.forEach((e) => {
|
|
34
|
+
e.value !== t && n++;
|
|
35
|
+
}), n <= 1;
|
|
36
|
+
} else return !1;
|
|
37
|
+
}, c = (e = {}) => ({
|
|
38
|
+
...t.model,
|
|
39
|
+
...e
|
|
40
|
+
}), l = (t, n, a) => new Promise((o) => {
|
|
41
|
+
n ||= {};
|
|
42
|
+
let s = c(t), l, u;
|
|
43
|
+
(!n || e(n)) && a.mode === "evaluate" ? (l = "unanswered", u = "0%") : (l = r(s, a, n && n.answers), u = `${i(s, a, n && n.answers) * 100}%`);
|
|
44
|
+
let d = {
|
|
45
|
+
score: u,
|
|
46
|
+
correctness: l
|
|
47
|
+
}, f = {
|
|
48
|
+
env: a,
|
|
49
|
+
...s,
|
|
50
|
+
view: a.mode === "view" || a.mode === "evaluate"
|
|
51
|
+
};
|
|
52
|
+
a.mode === "evaluate" && Object.assign(f, { correctness: d }), o(f);
|
|
53
|
+
}), u = (e, t) => new Promise((n) => {
|
|
54
|
+
if (t.mode !== "evaluate" && t.role === "instructor") {
|
|
55
|
+
let { correctResponse: t, maxModelSelected: r, partsPerModel: i } = e;
|
|
56
|
+
n({
|
|
57
|
+
answers: {
|
|
58
|
+
response: t,
|
|
59
|
+
noOfModel: r,
|
|
60
|
+
partsPerModel: i
|
|
61
|
+
},
|
|
62
|
+
id: "1"
|
|
63
|
+
});
|
|
64
|
+
} else n(null);
|
|
65
|
+
}), d = (e = {}, t = {}) => {
|
|
66
|
+
let n = {};
|
|
67
|
+
if (e.correctResponse.length === 0 && (n.correctResponse = "To save the item, at least one section must be marked as correct."), e.correctResponse.length > 0) {
|
|
68
|
+
let t = 0;
|
|
69
|
+
e.correctResponse.forEach((n) => {
|
|
70
|
+
n.value !== e.partsPerModel && t++;
|
|
71
|
+
}), t > 1 && (n.correctResponse = "The correct answer should include no more than one partially-filled model");
|
|
72
|
+
}
|
|
73
|
+
return n;
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
export { u as createCorrectResponseSession, c as createDefaultModel, n as getResponseCorrectness, l as model, a as outcome, d as validate };
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/controller/defaults.ts","../../../src/controller/index.ts"],"sourcesContent":["// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/fraction-model/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// Should be exactly the same as configure/defaults.js\nexport default {\n model: {\n correctResponse: [],\n title: '',\n prompt: '',\n modelTypeSelected: 'bar',\n maxModelSelected: 1,\n partsPerModel: 5,\n allowedStudentConfig: false,\n showGraphLabels: false,\n },\n};\n","// @ts-nocheck\n/**\n * @synced-from pie-elements/packages/fraction-model/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 { isEmpty } from 'lodash-es';\nimport defaults from './defaults.js';\n\n/*\n * Function to check the correctness of the response\n * @param {model} model contains the model object\n * @param {answers} answers contains the answers object\n * @param {env} env contains the environment object\n * @returns {string} returns the correctness of the response\n * */\nexport const getResponseCorrectness = (model, answers, env = {}) => {\n let correct;\n if (model.allowedStudentConfig) {\n correct = !!(\n answers.partsPerModel === model.partsPerModel &&\n partialFillCheck(answers.response, model.partsPerModel) &&\n numeratorCheck(model.correctResponse, answers.response)\n );\n } else {\n correct = !!(\n partialFillCheck(answers.response, model.partsPerModel) && numeratorCheck(model.correctResponse, answers.response)\n );\n }\n return correct ? 'correct' : 'incorrect';\n};\n\n/*\n * Function to get the correctness of the response\n * @param {question} question contains the question object\n * @param {env} env contains the environment object\n * @param {answers} answers contains the answers object\n * @returns {string} returns the correctness\n * */\nconst getCorrectness = (question, env, answers = {}) => {\n if (env.mode === 'evaluate') {\n return getResponseCorrectness(question, answers, env);\n }\n};\n\n/*\n * Function to get the outcome score\n * @param {question} question contains the question object\n * @param {env} env contains the environment object\n * @param {answers} answers contains the answers object\n * @returns {number} returns the score\n * */\nconst getOutComeScore = (question, env, answers = {}) => {\n const correctness = getCorrectness(question, env, answers);\n return correctness === 'correct' ? 1 : 0;\n};\n\n/*\n * Function to check outcome of the session\n * @param {model} model contains the model object\n * @param {session} session contains the session object\n * @param {env} env contains the environment object\n * @returns {Promise} returns the score\n */\nexport const outcome = (model, session, env) =>\n new Promise((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n } else {\n if (env.mode !== 'evaluate') {\n resolve({ score: undefined, completed: undefined });\n } else {\n resolve({ score: getOutComeScore(model, env, session.answers) });\n }\n }\n });\n\n/*\n * Function to check if the numerator of the response matches the numerator of the correct response\n * @param {correctResponse} correctResponse contains the correct response object\n * @param {response} response contains the response object\n * @returns {boolean} returns true if the numerators match\n * */\nconst numeratorCheck = (correctResponse, response) => {\n let correctNumerator = 0;\n let responseNumerator = 0;\n for (let i = 0; i < correctResponse.length; i++) {\n correctNumerator += correctResponse[i].value;\n }\n for (let i = 0; i < response.length; i++) {\n responseNumerator += response[i].value;\n }\n return correctNumerator === responseNumerator;\n};\n\n/*\n * Function to check if the response contains more than one partially-filled model\n * @param {response} response contains the response object\n * @param {partsPerModel} partsPerModel contains the number of parts per model\n * */\nconst partialFillCheck = (response, partsPerModel) => {\n if (response.length > 0) {\n let partialModelCount = 0;\n response.forEach((selection) => {\n if (selection.value !== partsPerModel) {\n partialModelCount++;\n }\n });\n return partialModelCount <= 1;\n } else {\n return false;\n }\n};\n\n/*\n * Function to create a default model\n * @param {model} model contains the model object\n * */\nexport const createDefaultModel = (model = {}) => ({\n ...defaults.model,\n ...model,\n});\n\n/*\n * Return the model object\n * */\nexport const model = (question, session, env) => {\n return new Promise((resolve) => {\n session = session || {};\n const model = createDefaultModel(question);\n let correctness, score;\n if ((!session || isEmpty(session)) && env.mode === 'evaluate') {\n correctness = 'unanswered';\n score = '0%';\n } else {\n correctness = getCorrectness(model, env, session && session.answers);\n score = `${getOutComeScore(model, env, session && session.answers) * 100}%`;\n }\n const correctInfo = {\n score,\n correctness,\n };\n const out = {\n env,\n ...model,\n view: env.mode === 'view' || env.mode === 'evaluate',\n };\n if (env.mode === 'evaluate') {\n Object.assign(out, {\n correctness: correctInfo,\n });\n }\n resolve(out);\n });\n};\n\n/*\n * Function to create a correct response session\n * @param {model} model contains the model object\n * @param {env} env contains the environment object\n * @returns {Promise} returns the correct response session\n * */\nexport const createCorrectResponseSession = (model, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { correctResponse, maxModelSelected, partsPerModel } = model;\n resolve({\n answers: {\n response: correctResponse,\n noOfModel: maxModelSelected,\n partsPerModel,\n },\n id: '1',\n });\n } else {\n resolve(null);\n }\n });\n};\n\n/*\n * Function to validate the model\n * @param {model} model contains the model object\n * @param {config} config contains the config object\n * */\nexport const validate = (model = {}, config = {}) => {\n const errors = {};\n if (model.correctResponse.length === 0) {\n errors.correctResponse = 'To save the item, at least one section must be marked as correct.';\n }\n if (model.correctResponse.length > 0) {\n let partialModelCount = 0;\n model.correctResponse.forEach((selection) => {\n if (selection.value !== model.partsPerModel) {\n partialModelCount++;\n }\n });\n if (partialModelCount > 1) {\n errors.correctResponse = 'The correct answer should include no more than one partially-filled model';\n }\n }\n return errors;\n};\n"],"mappings":";;AAWA,IAAA,IAAe,EAC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