@pie-element/graphing 0.1.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/dist/author/configure.d.ts +27 -0
- package/dist/author/configure.d.ts.map +1 -0
- package/dist/author/configure.js +208 -0
- package/dist/author/correct-response.d.ts +55 -0
- package/dist/author/correct-response.d.ts.map +1 -0
- package/dist/author/correct-response.js +304 -0
- package/dist/author/defaults.d.ts +295 -0
- package/dist/author/defaults.d.ts.map +1 -0
- package/dist/author/defaults.js +415 -0
- package/dist/author/graphing-config.d.ts +35 -0
- package/dist/author/graphing-config.d.ts.map +1 -0
- package/dist/author/graphing-config.js +244 -0
- package/dist/author/index.d.ts +60 -0
- package/dist/author/index.d.ts.map +1 -0
- package/dist/author/index.js +96 -0
- package/dist/author/utils.d.ts +44 -0
- package/dist/author/utils.d.ts.map +1 -0
- package/dist/author/utils.js +260 -0
- package/dist/controller/defaults.d.ts +60 -0
- package/dist/controller/defaults.d.ts.map +1 -0
- package/dist/controller/defaults.js +61 -0
- package/dist/controller/index.d.ts +34 -0
- package/dist/controller/index.d.ts.map +1 -0
- package/dist/controller/index.js +177 -0
- package/dist/controller/utils.d.ts +37 -0
- package/dist/controller/utils.d.ts.map +1 -0
- package/dist/controller/utils.js +111 -0
- package/dist/delivery/index.d.ts +22 -0
- package/dist/delivery/index.d.ts.map +1 -0
- package/dist/delivery/index.js +43 -0
- package/dist/delivery/main.d.ts +24 -0
- package/dist/delivery/main.d.ts.map +1 -0
- package/dist/delivery/main.js +107 -0
- package/dist/delivery/utils.d.ts +23 -0
- package/dist/delivery/utils.d.ts.map +1 -0
- package/dist/graphing.css +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.iife.d.ts +9 -0
- package/dist/index.iife.d.ts.map +1 -0
- package/dist/index.iife.js +374 -0
- package/dist/index.js +2 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Hash.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_ListCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Map.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_MapCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Set.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_SetCache.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Stack.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Symbol.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_apply.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayIncludes.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayIncludesWith.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayMap.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arraySome.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assocIndexOf.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js +57 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseDifference.js +23 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseFindIndex.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseFlatten.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetTag.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIndexOf.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIntersection.js +29 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqual.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqualDeep.js +30 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNaN.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNative.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseRest.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseSet.js +22 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseSetToString.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseToString.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUniq.js +27 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cacheHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_castArrayLikeObject.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_castPath.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_coreJsData.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalArrays.js +35 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalByTag.js +35 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalObjects.js +32 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_freeGlobal.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getMapData.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getNative.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getRawTag.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js +23 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getValue.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashGet.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashHas.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js +33 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isFlattenable.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKey.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKeyable.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isMasked.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheDelete.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheGet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheClear.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheDelete.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheGet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapToArray.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_memoizeCapped.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_objectToString.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overRest.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_root.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheAdd.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToArray.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToString.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_shortOut.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackGet.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackSet.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_strictIndexOf.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stringToPath.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toKey.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toSource.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/constant.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/differenceWith.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/eq.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/identity.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/intersection.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArray.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLikeObject.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEmpty.js +21 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEqual.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isFunction.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isLength.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isMap.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObject.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSymbol.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/last.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/memoize.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/noop.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/set.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toString.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/uniq.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/uniqWith.js +7 -0
- package/package.json +72 -0
- package/src/author/configure.tsx +299 -0
- package/src/author/correct-response.tsx +490 -0
- package/src/author/defaults.tsx +434 -0
- package/src/author/graphing-config.tsx +333 -0
- package/src/author/index.ts +204 -0
- package/src/author/utils.ts +144 -0
- package/src/controller/defaults.ts +74 -0
- package/src/controller/index.ts +458 -0
- package/src/controller/utils.ts +361 -0
- package/src/delivery/index.ts +79 -0
- package/src/delivery/main.tsx +180 -0
- package/src/delivery/utils.ts +34 -0
- package/src/index.iife.ts +16 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/graphing/controller/src/defaults.js
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// TODO: This is lifted from @pie-lib/graphing, however importing this will break a controller build because it has jsx source in that package.
|
|
12
|
+
const allTools = [
|
|
13
|
+
'circle',
|
|
14
|
+
'line',
|
|
15
|
+
'label',
|
|
16
|
+
'parabola',
|
|
17
|
+
'point',
|
|
18
|
+
'polygon',
|
|
19
|
+
'ray',
|
|
20
|
+
'segment',
|
|
21
|
+
'sine',
|
|
22
|
+
'vector',
|
|
23
|
+
// 'absolute', // - not available as default
|
|
24
|
+
// 'exponential', // - not available as default
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
/* model defaults */
|
|
28
|
+
export default {
|
|
29
|
+
answers: {
|
|
30
|
+
correctAnswer: {
|
|
31
|
+
name: 'Correct Answer',
|
|
32
|
+
marks: [],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
arrows: {
|
|
36
|
+
left: true,
|
|
37
|
+
right: true,
|
|
38
|
+
up: true,
|
|
39
|
+
down: true,
|
|
40
|
+
},
|
|
41
|
+
backgroundMarks: [],
|
|
42
|
+
coordinatesOnHover: false,
|
|
43
|
+
defaultGridConfiguration: 0,
|
|
44
|
+
domain: {
|
|
45
|
+
min: -5,
|
|
46
|
+
max: 5,
|
|
47
|
+
step: 1,
|
|
48
|
+
labelStep: 1,
|
|
49
|
+
axisLabel: 'x',
|
|
50
|
+
},
|
|
51
|
+
graph: { width: 500, height: 500 },
|
|
52
|
+
includeAxes: true,
|
|
53
|
+
labels: {},
|
|
54
|
+
labelsEnabled: true,
|
|
55
|
+
padding: true,
|
|
56
|
+
prompt: '',
|
|
57
|
+
promptEnabled: true,
|
|
58
|
+
range: {
|
|
59
|
+
min: -5,
|
|
60
|
+
max: 5,
|
|
61
|
+
step: 1,
|
|
62
|
+
labelStep: 1,
|
|
63
|
+
axisLabel: 'y',
|
|
64
|
+
},
|
|
65
|
+
rationale: '',
|
|
66
|
+
rationaleEnabled: true,
|
|
67
|
+
standardGrid: false,
|
|
68
|
+
studentInstructionsEnabled: true,
|
|
69
|
+
teacherInstructions: '',
|
|
70
|
+
teacherInstructionsEnabled: true,
|
|
71
|
+
title: '',
|
|
72
|
+
titleEnabled: true,
|
|
73
|
+
toolbarTools: allTools,
|
|
74
|
+
};
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/graphing/controller/src/index.js
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import debug from 'debug';
|
|
12
|
+
|
|
13
|
+
import { cloneDeep, isEmpty, uniqWith } from 'lodash-es';
|
|
14
|
+
import defaults from './defaults.js';
|
|
15
|
+
import { equalMarks, sortedAnswers } from './utils.js';
|
|
16
|
+
|
|
17
|
+
import { partialScoring } from '@pie-element/shared-controller-utils';
|
|
18
|
+
|
|
19
|
+
const log = debug('@pie-element:graphing:controller');
|
|
20
|
+
|
|
21
|
+
const initializeGraphMap = () => ({
|
|
22
|
+
point: [],
|
|
23
|
+
segment: [],
|
|
24
|
+
line: [],
|
|
25
|
+
ray: [],
|
|
26
|
+
vector: [],
|
|
27
|
+
polygon: [],
|
|
28
|
+
circle: [],
|
|
29
|
+
sine: [],
|
|
30
|
+
parabola: [],
|
|
31
|
+
absolute: [],
|
|
32
|
+
exponential: [],
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const graphObjectsOrder = {
|
|
36
|
+
incorrect: 0,
|
|
37
|
+
correct: 1,
|
|
38
|
+
missing: 2,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const compareMarks = (mark1, mark2) => {
|
|
42
|
+
// marks can be compared with equalMarks[type] function only if they have the same type;
|
|
43
|
+
// if type is different, they are clearly not equal
|
|
44
|
+
return !!(
|
|
45
|
+
mark1 &&
|
|
46
|
+
mark2 &&
|
|
47
|
+
mark1.type === mark2.type &&
|
|
48
|
+
equalMarks[mark1.type] &&
|
|
49
|
+
equalMarks[mark1.type](mark1, mark2)
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const comparLabelMarks = (mark1, mark2) => {
|
|
54
|
+
return mark1.label === mark2.label ? 'correct' : 'incorrect';
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const getAnswerCorrected = ({ sessionAnswers, marks: correctAnswers }) => {
|
|
58
|
+
sessionAnswers = sessionAnswers || [];
|
|
59
|
+
correctAnswers = correctAnswers || [];
|
|
60
|
+
|
|
61
|
+
const rez = cloneDeep(sessionAnswers).reduce((correctedAnswer, answer) => {
|
|
62
|
+
const answerIsCorrect = correctAnswers.find((mark) => compareMarks(answer, mark));
|
|
63
|
+
|
|
64
|
+
answer.correctness = answerIsCorrect ? 'correct' : 'incorrect';
|
|
65
|
+
if (answerIsCorrect) {
|
|
66
|
+
answer.correctnesslabel = comparLabelMarks(answer, answerIsCorrect);
|
|
67
|
+
answer.correctlabel = answerIsCorrect.label ? answerIsCorrect.label : '';
|
|
68
|
+
answer.label = answer.label ? answer.label : '';
|
|
69
|
+
}
|
|
70
|
+
return [...correctedAnswer, answer];
|
|
71
|
+
}, []);
|
|
72
|
+
|
|
73
|
+
// add missing objects from correct answer
|
|
74
|
+
const missingAnswers = cloneDeep(correctAnswers).reduce((correctedAnswer, answer) => {
|
|
75
|
+
const answerIndex = sessionAnswers.find((mark) => compareMarks(answer, mark));
|
|
76
|
+
|
|
77
|
+
if (!answerIndex) {
|
|
78
|
+
// means that corrected answer is missing from session, so we mark it as missing object
|
|
79
|
+
return [...correctedAnswer, { ...answer, correctness: 'missing' }];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return correctedAnswer;
|
|
83
|
+
}, []);
|
|
84
|
+
|
|
85
|
+
return [...rez, ...missingAnswers];
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const getPartialScoring = ({ scoringType, env }) => {
|
|
89
|
+
let pS = scoringType;
|
|
90
|
+
|
|
91
|
+
// if scoringType is undefined, partialScoring should be considered undefined (not set)
|
|
92
|
+
// because partialScoring.enabled is using that information
|
|
93
|
+
// if it has a value, we check if it is partial scoring or dichotomous
|
|
94
|
+
if (scoringType) {
|
|
95
|
+
pS = scoringType === 'partial scoring';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return partialScoring.enabled({ partialScoring: pS }, env);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const getBestAnswer = (question, session, env = {}) => {
|
|
102
|
+
// questionPossibleAnswers contains all possible answers (correct response and alternates);
|
|
103
|
+
let { answers: questionPossibleAnswers = {}, scoringType } = question || {};
|
|
104
|
+
let { answer } = session || {};
|
|
105
|
+
|
|
106
|
+
// filter the incomplete objects
|
|
107
|
+
Object.entries(questionPossibleAnswers || {}).forEach(
|
|
108
|
+
([key, value]) =>
|
|
109
|
+
(questionPossibleAnswers[key] = { ...value, marks: value?.marks.filter((mark) => !mark.building) }),
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// initialize answer if no values
|
|
113
|
+
answer = answer || [];
|
|
114
|
+
|
|
115
|
+
//filter the incomplete objects for student response - Fix for SC-33160
|
|
116
|
+
answer = answer.filter((mark) => !mark.building);
|
|
117
|
+
|
|
118
|
+
// initialize one possible answer if no values
|
|
119
|
+
if (isEmpty(questionPossibleAnswers)) {
|
|
120
|
+
questionPossibleAnswers = { correctAnswer: initializeGraphMap() };
|
|
121
|
+
} else {
|
|
122
|
+
questionPossibleAnswers = {
|
|
123
|
+
correctAnswer: questionPossibleAnswers.correctAnswer,
|
|
124
|
+
...sortedAnswers(questionPossibleAnswers),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const partialScoringEnabled = getPartialScoring({ scoringType, env });
|
|
129
|
+
|
|
130
|
+
// student's answers without DUPLICATES
|
|
131
|
+
const sessionAnswers = uniqWith(answer, compareMarks);
|
|
132
|
+
// array of possible answers entries
|
|
133
|
+
const possibleAnswers = Object.entries(questionPossibleAnswers);
|
|
134
|
+
|
|
135
|
+
return possibleAnswers.reduce(
|
|
136
|
+
(acc, entry) => {
|
|
137
|
+
// iterating each possible answer (main + alternates)
|
|
138
|
+
const possibleAnswerKey = entry[0];
|
|
139
|
+
const possibleAnswer = entry[1] || {};
|
|
140
|
+
let { marks } = possibleAnswer;
|
|
141
|
+
|
|
142
|
+
if (!marks || !marks.length) {
|
|
143
|
+
return acc;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// returns array of marks, each having 'correctness' property
|
|
147
|
+
const correctedAnswer = getAnswerCorrected({ sessionAnswers, marks });
|
|
148
|
+
const correctMarks = correctedAnswer.filter((answer) => answer.correctness === 'correct');
|
|
149
|
+
// filter out missing objects because they do not affect the calculation of the score
|
|
150
|
+
// only correct and incorrect are needed
|
|
151
|
+
const scoredCorrectedAnswer = correctedAnswer.filter((answer) => answer.correctness !== 'missing');
|
|
152
|
+
|
|
153
|
+
const maxScore = marks.length;
|
|
154
|
+
let score = correctMarks.length;
|
|
155
|
+
|
|
156
|
+
// if extra placements
|
|
157
|
+
if (scoredCorrectedAnswer.length > maxScore) {
|
|
158
|
+
score -= scoredCorrectedAnswer.length - maxScore;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (score < 0) {
|
|
162
|
+
score = 0;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (score / maxScore > acc.bestScore || !acc.foundOneSolution) {
|
|
166
|
+
if (partialScoringEnabled) {
|
|
167
|
+
acc.bestScore = parseFloat((score / maxScore).toFixed(2));
|
|
168
|
+
} else {
|
|
169
|
+
acc.bestScore = Math.floor(score / maxScore);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
acc.bestScoreAnswerKey = possibleAnswerKey;
|
|
173
|
+
acc.answersCorrected = correctedAnswer;
|
|
174
|
+
acc.foundOneSolution = true;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return acc;
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
bestScore: 0,
|
|
181
|
+
bestScoreAnswerKey: null,
|
|
182
|
+
// initially we just suppose all the answers are incorrect
|
|
183
|
+
answersCorrected: cloneDeep(sessionAnswers).map((answer) => ({ ...answer, correctness: 'incorrect' })),
|
|
184
|
+
foundOneSolution: false,
|
|
185
|
+
},
|
|
186
|
+
);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export const normalize = (question) => ({ ...defaults, ...question });
|
|
190
|
+
|
|
191
|
+
export function model(question, session, env) {
|
|
192
|
+
return new Promise((resolve) => {
|
|
193
|
+
const normalizedQuestion = normalize(question);
|
|
194
|
+
|
|
195
|
+
// added a sanity check for session for environments where it is not passed initially (ex. pie-website)
|
|
196
|
+
if (session === undefined || session === null) {
|
|
197
|
+
session = {};
|
|
198
|
+
}
|
|
199
|
+
// console.log('normalizedQuestion', normalizedQuestion);
|
|
200
|
+
const { defaultTool, extraCSSRules, prompt, promptEnabled, graph, answers, toolbarTools, ...questionProps } =
|
|
201
|
+
normalizedQuestion || {};
|
|
202
|
+
let { arrows } = normalizedQuestion;
|
|
203
|
+
const { mode, role } = env || {};
|
|
204
|
+
|
|
205
|
+
// This is used for offering support for old models which have the property arrows: boolean
|
|
206
|
+
// Same thing is set in authoring : packages/graphing/configure/src/configure.jsx - componentDidMount
|
|
207
|
+
if (typeof arrows === 'boolean') {
|
|
208
|
+
if (arrows) {
|
|
209
|
+
arrows = {
|
|
210
|
+
left: true,
|
|
211
|
+
right: true,
|
|
212
|
+
up: true,
|
|
213
|
+
down: true,
|
|
214
|
+
};
|
|
215
|
+
} else {
|
|
216
|
+
arrows = {
|
|
217
|
+
left: false,
|
|
218
|
+
right: false,
|
|
219
|
+
up: false,
|
|
220
|
+
down: false,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// added support for models without defaultTool defined; also used in packages/graphing/configure/src/index.js
|
|
226
|
+
const toolbarToolsNoLabel = (toolbarTools || []).filter((tool) => tool !== 'label');
|
|
227
|
+
const normalizedDefaultTool = defaultTool || (toolbarToolsNoLabel.length && toolbarToolsNoLabel[0]) || '';
|
|
228
|
+
|
|
229
|
+
const base = {
|
|
230
|
+
...questionProps,
|
|
231
|
+
answers,
|
|
232
|
+
arrows,
|
|
233
|
+
defaultTool: normalizedDefaultTool,
|
|
234
|
+
disabled: env.mode !== 'gather',
|
|
235
|
+
prompt: promptEnabled ? prompt : null,
|
|
236
|
+
rationale: null,
|
|
237
|
+
size: graph,
|
|
238
|
+
showKeyLegend: env.mode === 'evaluate',
|
|
239
|
+
showToggle:
|
|
240
|
+
env.mode === 'evaluate' &&
|
|
241
|
+
!isEmpty(answers) &&
|
|
242
|
+
answers.correctAnswer &&
|
|
243
|
+
answers.correctAnswer.marks &&
|
|
244
|
+
!isEmpty(answers.correctAnswer.marks),
|
|
245
|
+
teacherInstructions: null,
|
|
246
|
+
toolbarTools,
|
|
247
|
+
extraCSSRules,
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
|
|
251
|
+
const { rationale, rationaleEnabled, teacherInstructions, teacherInstructionsEnabled } = normalizedQuestion || {};
|
|
252
|
+
|
|
253
|
+
base.rationale = rationaleEnabled ? rationale : null;
|
|
254
|
+
base.teacherInstructions = teacherInstructionsEnabled ? teacherInstructions : null;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (mode === 'evaluate') {
|
|
258
|
+
if (
|
|
259
|
+
!isEmpty(answers) &&
|
|
260
|
+
answers.correctAnswer &&
|
|
261
|
+
answers.correctAnswer.marks &&
|
|
262
|
+
!isEmpty(answers.correctAnswer.marks)
|
|
263
|
+
) {
|
|
264
|
+
const { answersCorrected, bestScoreAnswerKey, bestScore } = getBestAnswer(normalizedQuestion, session, env);
|
|
265
|
+
// array of marks from session with 'correctness' property set
|
|
266
|
+
base.answersCorrected = answersCorrected.sort(
|
|
267
|
+
(a, b) => graphObjectsOrder[a.correctness] - graphObjectsOrder[b.correctness],
|
|
268
|
+
);
|
|
269
|
+
base.correctResponse = bestScoreAnswerKey ? (answers[bestScoreAnswerKey] || {}).marks : [];
|
|
270
|
+
base.showToggle = base.showToggle && bestScore !== 1;
|
|
271
|
+
} else {
|
|
272
|
+
base.answersCorrected = (session && session.answer) || [];
|
|
273
|
+
base.correctResponse = [];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
log('base: ', base);
|
|
278
|
+
resolve(base);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Generates detailed trace log for scoring evaluation
|
|
284
|
+
* @param {Object} model - the question model
|
|
285
|
+
* @param {Object} session - the student session
|
|
286
|
+
* @param {Object} env - the environment
|
|
287
|
+
* @returns {Array} traceLog - array of trace messages
|
|
288
|
+
*/
|
|
289
|
+
export const getLogTrace = (question, session, env) => {
|
|
290
|
+
const traceLog = [];
|
|
291
|
+
const { answers = {}, scoringType } = question || {};
|
|
292
|
+
const studentMarks = (session && session.answer) || [];
|
|
293
|
+
|
|
294
|
+
if (!studentMarks.length) {
|
|
295
|
+
return ['Student did not interact with the graph.'];
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
traceLog.push(`Student added ${studentMarks.length} object(s) to the graph.`);
|
|
299
|
+
|
|
300
|
+
const partialScoringEnabled = getPartialScoring({ scoringType, env });
|
|
301
|
+
|
|
302
|
+
const {
|
|
303
|
+
answersCorrected,
|
|
304
|
+
bestScore,
|
|
305
|
+
bestScoreAnswerKey,
|
|
306
|
+
} = getBestAnswer(question, session, env);
|
|
307
|
+
|
|
308
|
+
const correctResponse =
|
|
309
|
+
bestScoreAnswerKey && answers[bestScoreAnswerKey]
|
|
310
|
+
? answers[bestScoreAnswerKey].marks || []
|
|
311
|
+
: [];
|
|
312
|
+
|
|
313
|
+
let correctCount = 0;
|
|
314
|
+
let incorrectCount = 0;
|
|
315
|
+
let missingCount = 0;
|
|
316
|
+
|
|
317
|
+
for (let i = 0; i < answersCorrected.length; i++) {
|
|
318
|
+
const c = answersCorrected[i].correctness;
|
|
319
|
+
if (c === 'correct') correctCount++;
|
|
320
|
+
else if (c === 'incorrect') incorrectCount++;
|
|
321
|
+
else if (c === 'missing') missingCount++;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (correctCount > 0) {
|
|
325
|
+
traceLog.push(`Correct objects: ${correctCount}.`);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
if (incorrectCount > 0) {
|
|
329
|
+
traceLog.push(`Incorrect objects: ${incorrectCount}.`);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (missingCount > 0) {
|
|
333
|
+
traceLog.push(`Missing required objects: ${missingCount}.`);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
answersCorrected.forEach((mark, index) => {
|
|
337
|
+
const objectType = mark.type || 'graph object';
|
|
338
|
+
const objectLabel = mark.label ? `'${mark.label}'` : '';
|
|
339
|
+
const objectIndex = `with index ${index + 1}`;
|
|
340
|
+
|
|
341
|
+
if (mark.correctness === 'correct') {
|
|
342
|
+
traceLog.push(
|
|
343
|
+
`${objectType.charAt(0).toUpperCase() + objectType.slice(1)} ${objectLabel || objectIndex} is correct.`
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (mark.correctness === 'incorrect') {
|
|
348
|
+
traceLog.push(
|
|
349
|
+
`${objectType.charAt(0).toUpperCase() + objectType.slice(1)} ${objectLabel || objectIndex} does not match the expected ${objectType}.`
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (mark.correctness === 'missing') {
|
|
354
|
+
traceLog.push(`Expected ${objectType} ${objectLabel || objectIndex} was not plotted by the student.`);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
if (studentMarks.length > correctResponse.length) {
|
|
359
|
+
const extra = studentMarks.length - correctResponse.length;
|
|
360
|
+
traceLog.push(`${extra} extra object(s) were plotted and are penalized in scoring.`);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (partialScoringEnabled) {
|
|
364
|
+
traceLog.push('Score calculated using partial scoring.');
|
|
365
|
+
} else {
|
|
366
|
+
traceLog.push('Score calculated using all-or-nothing scoring.');
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
traceLog.push(`Final score: ${bestScore}.`);
|
|
370
|
+
|
|
371
|
+
return traceLog;
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
export function outcome(question, session, env = {}) {
|
|
376
|
+
return new Promise((resolve) => {
|
|
377
|
+
if (!session || isEmpty(session)) {
|
|
378
|
+
resolve({ score: 0, empty: true, logTrace: ['Student did not interact with the graph.'] });
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (
|
|
382
|
+
env.mode !== 'evaluate' ||
|
|
383
|
+
isEmpty(question.answers) ||
|
|
384
|
+
(question.answers && question.answers.correctAnswer && isEmpty(question.answers.correctAnswer.marks))
|
|
385
|
+
) {
|
|
386
|
+
resolve({ score: 0, empty: true, logTrace: ['Student did not interact with the graph.'] });
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const { bestScore } = getBestAnswer(question, session, env);
|
|
390
|
+
|
|
391
|
+
resolve({ score: bestScore, empty: false, logTrace: getLogTrace(question, session, env) });
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export const createCorrectResponseSession = (question, env) => {
|
|
396
|
+
return new Promise((resolve) => {
|
|
397
|
+
if (env.mode !== 'evaluate' && env.role === 'instructor') {
|
|
398
|
+
const { answers } = question || {};
|
|
399
|
+
let marks = [];
|
|
400
|
+
|
|
401
|
+
if (answers && Object.values(answers)) {
|
|
402
|
+
const correctAnswer = answers.correctAnswer || Object.values(answers)[0] || {};
|
|
403
|
+
marks = correctAnswer.marks || [];
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
resolve({
|
|
407
|
+
answer: marks,
|
|
408
|
+
id: '1',
|
|
409
|
+
});
|
|
410
|
+
} else {
|
|
411
|
+
resolve(null);
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
// remove all html tags
|
|
417
|
+
const getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');
|
|
418
|
+
|
|
419
|
+
// remove all html tags except img, iframe and source tag for audio
|
|
420
|
+
const getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
|
|
421
|
+
|
|
422
|
+
export const validate = (model = {}, config = {}) => {
|
|
423
|
+
const { answers, toolbarTools } = model;
|
|
424
|
+
const errors = {};
|
|
425
|
+
const correctAnswerErrors = {};
|
|
426
|
+
const toolbarToolsNoLabel = (toolbarTools || []).filter((tool) => tool !== 'label');
|
|
427
|
+
|
|
428
|
+
if (!toolbarToolsNoLabel.length) {
|
|
429
|
+
errors.toolbarToolsError = 'There should be at least 1 tool defined.';
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {
|
|
433
|
+
if (config[field]?.required && !getContent(model[field])) {
|
|
434
|
+
errors[field] = 'This field is required.';
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
Object.entries(answers || {}).forEach(([key, value]) => {
|
|
439
|
+
if (!value.marks.length) {
|
|
440
|
+
correctAnswerErrors[key] = 'At least 1 graph object should be defined.';
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// check if all graph objects are correctly defined with respect to root, edge and from, to
|
|
444
|
+
if (value.marks.length > 0) {
|
|
445
|
+
value.marks.forEach((mark) => {
|
|
446
|
+
if (mark.building) {
|
|
447
|
+
correctAnswerErrors[key] = 'At least 1 graph object is not correctly defined.';
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
if (!isEmpty(correctAnswerErrors)) {
|
|
454
|
+
errors.correctAnswerErrors = correctAnswerErrors;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
return errors;
|
|
458
|
+
};
|