@pie-element/math-templated 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/defaults.d.ts +174 -0
- package/dist/author/defaults.d.ts.map +1 -0
- package/dist/author/defaults.js +123 -0
- package/dist/author/design.d.ts +36 -0
- package/dist/author/design.d.ts.map +1 -0
- package/dist/author/design.js +494 -0
- package/dist/author/index.d.ts +43 -0
- package/dist/author/index.d.ts.map +1 -0
- package/dist/author/index.js +98 -0
- package/dist/author/markupUtils.d.ts +12 -0
- package/dist/author/markupUtils.d.ts.map +1 -0
- package/dist/author/markupUtils.js +10 -0
- package/dist/author/response.d.ts +42 -0
- package/dist/author/response.d.ts.map +1 -0
- package/dist/author/response.js +342 -0
- package/dist/author/utils.d.ts +10 -0
- package/dist/author/utils.d.ts.map +1 -0
- package/dist/author/utils.js +7 -0
- package/dist/controller/defaults.d.ts +30 -0
- package/dist/controller/defaults.d.ts.map +1 -0
- package/dist/controller/defaults.js +23 -0
- package/dist/controller/index.d.ts +38 -0
- package/dist/controller/index.d.ts.map +1 -0
- package/dist/controller/index.js +125 -0
- package/dist/delivery/index.d.ts +21 -0
- package/dist/delivery/index.d.ts.map +1 -0
- package/dist/delivery/index.js +51 -0
- package/dist/delivery/main.d.ts +40 -0
- package/dist/delivery/main.d.ts.map +1 -0
- package/dist/delivery/main.js +538 -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 +224 -0
- package/dist/index.js +2 -0
- package/dist/math-templated.css +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/_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/_baseFlatten.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGet.js +10 -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/_baseHasIn.js +6 -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/_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/_basePick.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_basePickBy.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/_baseTrim.js +8 -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/_cacheHas.js +6 -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/_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/_flatRest.js +9 -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/_hasPath.js +18 -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/_isIterateeCall.js +12 -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/_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/_trimmedEndIndex.js +8 -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/debounce.js +50 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/defaults.js +16 -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/flatten.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/hasIn.js +8 -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/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/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/memoize.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/now.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/pick.js +8 -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/throttle.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toNumber.js +19 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toString.js +7 -0
- package/dist/print/index.d.ts +16 -0
- package/dist/print/index.d.ts.map +1 -0
- package/dist/print/index.js +47 -0
- package/package.json +80 -0
- package/src/author/defaults.ts +133 -0
- package/src/author/design.tsx +526 -0
- package/src/author/index.ts +195 -0
- package/src/author/markupUtils.tsx +55 -0
- package/src/author/response.tsx +397 -0
- package/src/author/utils.ts +24 -0
- package/src/controller/defaults.ts +31 -0
- package/src/controller/index.ts +294 -0
- package/src/delivery/index.ts +94 -0
- package/src/delivery/main.tsx +800 -0
- package/src/index.iife.ts +16 -0
- package/src/index.ts +1 -0
- package/src/print/index.tsx +99 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/math-templated/configure/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 React from 'react';
|
|
12
|
+
import { createRoot } from 'react-dom/client';
|
|
13
|
+
import debug from 'debug';
|
|
14
|
+
import { defaults, isArray } from 'lodash-es';
|
|
15
|
+
import {
|
|
16
|
+
ModelUpdatedEvent,
|
|
17
|
+
DeleteImageEvent,
|
|
18
|
+
InsertImageEvent,
|
|
19
|
+
InsertSoundEvent,
|
|
20
|
+
DeleteSoundEvent,
|
|
21
|
+
} from '@pie-element/shared-configure-events';
|
|
22
|
+
|
|
23
|
+
import Main from './design';
|
|
24
|
+
|
|
25
|
+
import sensibleDefaults from './defaults';
|
|
26
|
+
import { processMarkup, createSlateMarkup } from './markupUtils';
|
|
27
|
+
|
|
28
|
+
const log = debug('math-templated:configure');
|
|
29
|
+
|
|
30
|
+
export default class MathTemplateConfigure extends HTMLElement {
|
|
31
|
+
static prepareModel = (model = {}) => {
|
|
32
|
+
const { validationDefault, allowTrailingZerosDefault, ignoreOrderDefault, responses = {} } = model;
|
|
33
|
+
|
|
34
|
+
const updatedResponses = Object.keys(responses).reduce((acc, responseId) => {
|
|
35
|
+
const correctResponse = responses[responseId];
|
|
36
|
+
|
|
37
|
+
acc[responseId] = {
|
|
38
|
+
...correctResponse,
|
|
39
|
+
validation: correctResponse.validation || validationDefault,
|
|
40
|
+
allowTrailingZeros: correctResponse.allowTrailingZeros || allowTrailingZerosDefault,
|
|
41
|
+
ignoreOrder: correctResponse.ignoreOrder || ignoreOrderDefault,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return acc;
|
|
45
|
+
}, {});
|
|
46
|
+
|
|
47
|
+
const joinedObj = {
|
|
48
|
+
...sensibleDefaults.model,
|
|
49
|
+
...model,
|
|
50
|
+
responses: updatedResponses,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const slateMarkup = joinedObj.slateMarkup || createSlateMarkup(joinedObj.markup, joinedObj.responses);
|
|
54
|
+
const processedMarkup = processMarkup(slateMarkup);
|
|
55
|
+
|
|
56
|
+
// this was added to treat an exception, when the model has responses without the "answer" property
|
|
57
|
+
if (joinedObj.responses) {
|
|
58
|
+
Object.keys(joinedObj.responses).forEach((key) => {
|
|
59
|
+
if (isArray(joinedObj.responses[key])) {
|
|
60
|
+
joinedObj.responses[key] = (joinedObj.responses[key] || []).map((item, index) => {
|
|
61
|
+
if (!item.answer) {
|
|
62
|
+
log('Choice does not contain "answer" property, which is required.', item);
|
|
63
|
+
return { answer: `${index}`, ...item };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return item;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
...joinedObj,
|
|
74
|
+
slateMarkup,
|
|
75
|
+
markup: processedMarkup,
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
constructor() {
|
|
80
|
+
super();
|
|
81
|
+
this._root = null;
|
|
82
|
+
this._model = MathTemplateConfigure.prepareModel();
|
|
83
|
+
this._configuration = sensibleDefaults.configuration;
|
|
84
|
+
this.onModelChanged = this.onModelChanged.bind(this);
|
|
85
|
+
this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
set model(s) {
|
|
89
|
+
this._model = MathTemplateConfigure.prepareModel(s);
|
|
90
|
+
this._render();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
set configuration(c) {
|
|
94
|
+
this._configuration = defaults(c, sensibleDefaults.configuration);
|
|
95
|
+
|
|
96
|
+
// if language:enabled is true, then the corresponding default item model should include a language value;
|
|
97
|
+
// if it is false, then the language field should be omitted from the item model.
|
|
98
|
+
// if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
|
|
99
|
+
// then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
|
|
100
|
+
if (c.language?.enabled) {
|
|
101
|
+
if (c.languageChoices?.options?.length) {
|
|
102
|
+
this._model.language = c.languageChoices.options[0].value;
|
|
103
|
+
}
|
|
104
|
+
} else if (c.language.settings && this._model.language) {
|
|
105
|
+
this._configuration.language.enabled = true;
|
|
106
|
+
|
|
107
|
+
if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
|
|
108
|
+
this._configuration.languageChoices.options = [];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// check if the language is already included in the languageChoices.options array
|
|
112
|
+
// and if not, then add it.
|
|
113
|
+
if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) {
|
|
114
|
+
this._configuration.languageChoices.options.push({
|
|
115
|
+
value: this._model.language,
|
|
116
|
+
label: this._model.language,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
delete this._model.language;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
this._render();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
set disableSidePanel(s) {
|
|
127
|
+
this._disableSidePanel = s;
|
|
128
|
+
this._render();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
dispatchModelUpdated(reset) {
|
|
132
|
+
const resetValue = !!reset;
|
|
133
|
+
|
|
134
|
+
this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
onModelChanged(m, reset) {
|
|
138
|
+
this._model = MathTemplateConfigure.prepareModel(m);
|
|
139
|
+
this._render();
|
|
140
|
+
this.dispatchModelUpdated(reset);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
onConfigurationChanged(c) {
|
|
144
|
+
this._configuration = c;
|
|
145
|
+
this._render();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** @param {done, progress, file} handler */
|
|
149
|
+
insertImage(handler) {
|
|
150
|
+
this.dispatchEvent(new InsertImageEvent(handler));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
onDeleteImage(src, done) {
|
|
154
|
+
this.dispatchEvent(new DeleteImageEvent(src, done));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
insertSound(handler) {
|
|
158
|
+
this.dispatchEvent(new InsertSoundEvent(handler));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
onDeleteSound(src, done) {
|
|
162
|
+
this.dispatchEvent(new DeleteSoundEvent(src, done));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
_render() {
|
|
166
|
+
log('_render');
|
|
167
|
+
|
|
168
|
+
let element = React.createElement(Main, {
|
|
169
|
+
model: this._model,
|
|
170
|
+
configuration: this._configuration,
|
|
171
|
+
onModelChanged: this.onModelChanged,
|
|
172
|
+
onConfigurationChanged: this.onConfigurationChanged,
|
|
173
|
+
disableSidePanel: this._disableSidePanel,
|
|
174
|
+
imageSupport: {
|
|
175
|
+
add: this.insertImage.bind(this),
|
|
176
|
+
delete: this.onDeleteImage.bind(this),
|
|
177
|
+
},
|
|
178
|
+
uploadSoundSupport: {
|
|
179
|
+
add: this.insertSound.bind(this),
|
|
180
|
+
delete: this.onDeleteSound.bind(this),
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
if (!this._root) {
|
|
185
|
+
this._root = createRoot(this);
|
|
186
|
+
}
|
|
187
|
+
this._root.render(element);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
disconnectedCallback() {
|
|
191
|
+
if (this._root) {
|
|
192
|
+
this._root.unmount();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/math-templated/configure/src/markupUtils.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
|
+
// do not remove \t from \times, \triangle, \tan, \theta or \therefore
|
|
12
|
+
const tSymbols = 'imes|riangle|an|heta|herefore';
|
|
13
|
+
// do not remove \n from \nthroot, \nparallel, \ncong, \napprox, \neq, \ne or \nsim
|
|
14
|
+
const nSymbols = 'throot|parallel|cong|approx|eq|e|sim';
|
|
15
|
+
// match all \t and \n that are not part of math symbols that starts with \t or \n
|
|
16
|
+
const matchTabAndNewLine = new RegExp(
|
|
17
|
+
`(\\t(?!${tSymbols}))|(\\n(?!${nSymbols}))|(\\\\t(?!${tSymbols}))|(\\\\n(?!${nSymbols}))`,
|
|
18
|
+
'g'
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export const removeUnwantedCharacters = (markup) =>
|
|
22
|
+
markup.replace(matchTabAndNewLine, '').replace(/\\"/g, '"').replace(/\\\//g, '/');
|
|
23
|
+
|
|
24
|
+
const createElementFromHTML = (htmlString = '') => {
|
|
25
|
+
const div = document.createElement('div');
|
|
26
|
+
|
|
27
|
+
div.innerHTML = htmlString.trim();
|
|
28
|
+
|
|
29
|
+
return div;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const processMarkup = (markup) => {
|
|
33
|
+
const newMarkup = removeUnwantedCharacters(markup || '');
|
|
34
|
+
const slateMarkup = createElementFromHTML(newMarkup || '');
|
|
35
|
+
|
|
36
|
+
slateMarkup.querySelectorAll('[data-type="math_templated"]')
|
|
37
|
+
.forEach((s) => s.replaceWith(`{{${s.dataset.index}}}`));
|
|
38
|
+
|
|
39
|
+
return slateMarkup.innerHTML;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const REGEX = /\{\{(\d+)\}\}/g;
|
|
43
|
+
|
|
44
|
+
export const createSlateMarkup = (markup, responses) => {
|
|
45
|
+
if (!markup) {
|
|
46
|
+
return '';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const newMarkup = removeUnwantedCharacters(markup);
|
|
50
|
+
|
|
51
|
+
return newMarkup.replace(REGEX, (match, groupIndex) => {
|
|
52
|
+
const responseValue = responses[groupIndex]?.answer || '';
|
|
53
|
+
return `<span data-type="math_templated" data-index="${groupIndex}" data-value="${responseValue}"></span>`;
|
|
54
|
+
});
|
|
55
|
+
};
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/math-templated/configure/src/response.jsx
|
|
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 * as React from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import { InputContainer } from '@pie-lib/config-ui';
|
|
14
|
+
import { MathToolbar } from '@pie-lib/math-toolbar';
|
|
15
|
+
import Card from '@mui/material/Card';
|
|
16
|
+
import CardContent from '@mui/material/CardContent';
|
|
17
|
+
import Button from '@mui/material/Button';
|
|
18
|
+
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
19
|
+
import Typography from '@mui/material/Typography';
|
|
20
|
+
import InputLabel from '@mui/material/InputLabel';
|
|
21
|
+
import Checkbox from '@mui/material/Checkbox';
|
|
22
|
+
import Select from '@mui/material/Select';
|
|
23
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
24
|
+
import { styled } from '@mui/material/styles';
|
|
25
|
+
import IconButton from '@mui/material/IconButton';
|
|
26
|
+
import Delete from '@mui/icons-material/Delete';
|
|
27
|
+
import { color } from '@pie-lib/render-ui';
|
|
28
|
+
|
|
29
|
+
const ResponseContainer: any = styled(Card)(({ theme }) => ({
|
|
30
|
+
marginBottom: theme.spacing(2.5),
|
|
31
|
+
width: '100%',
|
|
32
|
+
minWidth: '548px',
|
|
33
|
+
border: `1px solid ${theme.palette.grey[700]}`,
|
|
34
|
+
display: 'flex',
|
|
35
|
+
flexDirection: 'column',
|
|
36
|
+
justifyContent: 'space-between',
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
const StyledCardContent: any = styled(CardContent)(({ theme }) => ({
|
|
40
|
+
paddingBottom: `${theme.spacing(2)}px !important`,
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
const StyledTitle: any = styled(Typography)({
|
|
44
|
+
fontWeight: 700,
|
|
45
|
+
fontSize: '1.2rem',
|
|
46
|
+
flex: 3,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const StyledSelectContainer: any = styled(InputContainer)(({ theme }) => ({
|
|
50
|
+
flex: 2,
|
|
51
|
+
'& > *:not(label)': {
|
|
52
|
+
marginTop: theme.spacing(1),
|
|
53
|
+
},
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
const InputContainerWrapper: any = styled('div')(({ theme }) => ({
|
|
57
|
+
marginBottom: theme.spacing(2),
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
const TitleBar: any = styled('div')({
|
|
61
|
+
display: 'flex',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
justifyContent: 'space-between',
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const FlexContainer: any = styled('div')({
|
|
67
|
+
display: 'flex',
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const AlternateButton: any = styled(Button)(({ theme }) => ({
|
|
71
|
+
border: `1px solid ${theme.palette.grey['A400']}`,
|
|
72
|
+
color: color.text(),
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
const RemoveAlternateButton: any = styled(IconButton)(({ theme }) => ({
|
|
76
|
+
marginLeft: theme.spacing(1),
|
|
77
|
+
}));
|
|
78
|
+
|
|
79
|
+
const ErrorText: any = styled('div')(({ theme }) => ({
|
|
80
|
+
fontSize: theme.typography.fontSize - 2,
|
|
81
|
+
color: theme.palette.error.main,
|
|
82
|
+
paddingTop: theme.spacing(1),
|
|
83
|
+
}));
|
|
84
|
+
|
|
85
|
+
const ResponseBox: any = styled('div')(({ theme }) => ({
|
|
86
|
+
background: theme.palette.grey['A100'],
|
|
87
|
+
color: theme.palette.grey['A700'],
|
|
88
|
+
display: 'inline',
|
|
89
|
+
minWidth: '50px',
|
|
90
|
+
padding: '8px',
|
|
91
|
+
border: '1px solid #C0C3CF',
|
|
92
|
+
}));
|
|
93
|
+
|
|
94
|
+
const AlternateBar: any = styled('div')({
|
|
95
|
+
display: 'flex',
|
|
96
|
+
justifyContent: 'space-between',
|
|
97
|
+
alignItems: 'center',
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const CustomColorCheckbox: any = styled(Checkbox)({
|
|
101
|
+
color: `${color.tertiary()} !important`,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// CSS for MathToolbar classNames (used as strings)
|
|
105
|
+
if (typeof document !== 'undefined') {
|
|
106
|
+
const styleId = 'math-templated-response-styles';
|
|
107
|
+
if (!document.getElementById(styleId)) {
|
|
108
|
+
const style = document.createElement('style');
|
|
109
|
+
style.id = styleId;
|
|
110
|
+
style.textContent = `
|
|
111
|
+
.response-editor {
|
|
112
|
+
display: flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
justify-content: center;
|
|
115
|
+
width: 100%;
|
|
116
|
+
min-width: 500px;
|
|
117
|
+
max-width: 900px;
|
|
118
|
+
height: auto;
|
|
119
|
+
min-height: 40px;
|
|
120
|
+
}
|
|
121
|
+
.math-toolbar {
|
|
122
|
+
width: 100%;
|
|
123
|
+
}
|
|
124
|
+
`;
|
|
125
|
+
document.head.appendChild(style);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export class Response extends React.Component {
|
|
130
|
+
static propTypes = {
|
|
131
|
+
defaultResponse: PropTypes.bool,
|
|
132
|
+
error: PropTypes.object,
|
|
133
|
+
mode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
134
|
+
onResponseChange: PropTypes.func.isRequired,
|
|
135
|
+
onResponseDone: PropTypes.func.isRequired,
|
|
136
|
+
response: PropTypes.object.isRequired,
|
|
137
|
+
cIgnoreOrder: PropTypes.object.isRequired,
|
|
138
|
+
cAllowTrailingZeros: PropTypes.object.isRequired,
|
|
139
|
+
responseKey: PropTypes.number.isRequired,
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
static defaultProps = {
|
|
143
|
+
defaultResponse: false,
|
|
144
|
+
mode: '8',
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
constructor(props) {
|
|
148
|
+
super(props);
|
|
149
|
+
|
|
150
|
+
const { response: { alternates } = {} } = props || {};
|
|
151
|
+
const alternatesLength = Object.keys(alternates || {}).length;
|
|
152
|
+
|
|
153
|
+
this.state = {
|
|
154
|
+
alternateIdCounter: alternatesLength + 1,
|
|
155
|
+
showKeypad: {
|
|
156
|
+
openCount: 0,
|
|
157
|
+
main: false,
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
onChange = (name) => (evt) => {
|
|
163
|
+
const { response, onResponseChange, responseKey } = this.props;
|
|
164
|
+
const newResponse = { ...response };
|
|
165
|
+
|
|
166
|
+
newResponse[name] = evt.target.value;
|
|
167
|
+
|
|
168
|
+
onResponseChange(newResponse, responseKey);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
onConfigChanged = (name) => (evt) => {
|
|
172
|
+
const { response, onResponseChange, responseKey } = this.props;
|
|
173
|
+
const newResponse = { ...response };
|
|
174
|
+
|
|
175
|
+
newResponse[name] = evt.target.checked;
|
|
176
|
+
|
|
177
|
+
onResponseChange(newResponse, responseKey);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
onLiteralOptionsChange = (name) => () => {
|
|
181
|
+
const { response, onResponseChange, responseKey } = this.props;
|
|
182
|
+
const newResponse = { ...response };
|
|
183
|
+
|
|
184
|
+
newResponse[name] = !response[name];
|
|
185
|
+
|
|
186
|
+
onResponseChange(newResponse, responseKey);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
onAnswerChange: any = (answer) => {
|
|
190
|
+
const { response, onResponseChange, responseKey } = this.props;
|
|
191
|
+
const newResponse = { ...response };
|
|
192
|
+
|
|
193
|
+
newResponse.answer = answer;
|
|
194
|
+
|
|
195
|
+
onResponseChange(newResponse, responseKey);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
onAlternateAnswerChange = (alternateId) => (answer) => {
|
|
199
|
+
const { response, onResponseChange, responseKey } = this.props;
|
|
200
|
+
const newResponse = { ...response };
|
|
201
|
+
|
|
202
|
+
newResponse.alternates[alternateId] = answer;
|
|
203
|
+
|
|
204
|
+
onResponseChange(newResponse, responseKey);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
onAddAlternate: any = () => {
|
|
208
|
+
const { response, onResponseChange, responseKey } = this.props;
|
|
209
|
+
const { alternateIdCounter } = this.state;
|
|
210
|
+
const newResponse = { ...response };
|
|
211
|
+
|
|
212
|
+
if (!newResponse.alternates) {
|
|
213
|
+
newResponse.alternates = {};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
newResponse.alternates[alternateIdCounter] = '';
|
|
217
|
+
|
|
218
|
+
onResponseChange(newResponse, responseKey);
|
|
219
|
+
|
|
220
|
+
this.setState({
|
|
221
|
+
alternateIdCounter: alternateIdCounter + 1,
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
onRemoveAlternate = (alternateId) => () => {
|
|
226
|
+
const { response, onResponseChange, responseKey } = this.props;
|
|
227
|
+
const newResponse = { ...response };
|
|
228
|
+
|
|
229
|
+
delete newResponse.alternates[alternateId];
|
|
230
|
+
|
|
231
|
+
onResponseChange(newResponse, responseKey);
|
|
232
|
+
|
|
233
|
+
this.setState((state) => ({
|
|
234
|
+
showKeypad: {
|
|
235
|
+
...state.showKeypad,
|
|
236
|
+
openCount: !state.showKeypad[alternateId] ? state.showKeypad.openCount : state.showKeypad.openCount - 1,
|
|
237
|
+
},
|
|
238
|
+
}));
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
onDone: any = () => {
|
|
242
|
+
const { onResponseDone } = this.props;
|
|
243
|
+
this.setState((state) => ({
|
|
244
|
+
showKeypad: {
|
|
245
|
+
...state.showKeypad,
|
|
246
|
+
openCount: state.showKeypad.openCount - 1,
|
|
247
|
+
main: false,
|
|
248
|
+
},
|
|
249
|
+
}));
|
|
250
|
+
|
|
251
|
+
onResponseDone();
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
onFocus: any = () => {
|
|
255
|
+
this.setState((state) => ({
|
|
256
|
+
showKeypad: {
|
|
257
|
+
...state.showKeypad,
|
|
258
|
+
openCount: !state.showKeypad.main ? state.showKeypad.openCount + 1 : state.showKeypad.openCount,
|
|
259
|
+
main: true,
|
|
260
|
+
},
|
|
261
|
+
}));
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
onAlternateFocus = (alternateId) => () => {
|
|
265
|
+
this.setState((state) => ({
|
|
266
|
+
showKeypad: {
|
|
267
|
+
...state.showKeypad,
|
|
268
|
+
openCount: !state.showKeypad[alternateId] ? state.showKeypad.openCount + 1 : state.showKeypad.openCount,
|
|
269
|
+
[alternateId]: true,
|
|
270
|
+
},
|
|
271
|
+
}));
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
onAlternateDone = (alternateId) => () => {
|
|
275
|
+
this.setState((state) => ({
|
|
276
|
+
showKeypad: {
|
|
277
|
+
...state.showKeypad,
|
|
278
|
+
openCount: state.showKeypad.openCount - 1,
|
|
279
|
+
[alternateId]: false,
|
|
280
|
+
},
|
|
281
|
+
}));
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
render() {
|
|
285
|
+
const { mode, responseKey, response, cAllowTrailingZeros, cIgnoreOrder, error } = this.props;
|
|
286
|
+
const { showKeypad } = this.state;
|
|
287
|
+
const { validation, answer, alternates, ignoreOrder, allowTrailingZeros } = response;
|
|
288
|
+
const hasAlternates = Object.keys(alternates || {}).length > 0;
|
|
289
|
+
const classNames = {
|
|
290
|
+
editor: 'response-editor',
|
|
291
|
+
mathToolbar: 'math-toolbar',
|
|
292
|
+
};
|
|
293
|
+
const styles = {
|
|
294
|
+
minHeight: `${showKeypad.openCount > 0 ? 430 : 230}px`,
|
|
295
|
+
};
|
|
296
|
+
// add 1 to index to display R 1 instead of R 0
|
|
297
|
+
const keyToDisplay = `R ${parseInt(responseKey) + 1}`;
|
|
298
|
+
|
|
299
|
+
return (
|
|
300
|
+
<ResponseContainer style={styles}>
|
|
301
|
+
<StyledCardContent>
|
|
302
|
+
<TitleBar>
|
|
303
|
+
<StyledTitle component="div">
|
|
304
|
+
Response for <ResponseBox>{keyToDisplay}</ResponseBox>
|
|
305
|
+
</StyledTitle>
|
|
306
|
+
|
|
307
|
+
<StyledSelectContainer label="Validation">
|
|
308
|
+
<Select onChange={this.onChange('validation')} value={validation || 'literal'} MenuProps={{transitionDuration: { enter: 225, exit: 195 } }}>
|
|
309
|
+
<MenuItem value="literal">Literal Validation</MenuItem>
|
|
310
|
+
<MenuItem value="symbolic">Symbolic Validation</MenuItem>
|
|
311
|
+
</Select>
|
|
312
|
+
</StyledSelectContainer>
|
|
313
|
+
</TitleBar>
|
|
314
|
+
|
|
315
|
+
{validation === 'literal' && (
|
|
316
|
+
<FlexContainer>
|
|
317
|
+
{cAllowTrailingZeros.enabled && (
|
|
318
|
+
<FormControlLabel
|
|
319
|
+
label={cAllowTrailingZeros.label}
|
|
320
|
+
control={
|
|
321
|
+
<CustomColorCheckbox
|
|
322
|
+
checked={allowTrailingZeros}
|
|
323
|
+
onChange={this.onLiteralOptionsChange('allowTrailingZeros')}
|
|
324
|
+
/>
|
|
325
|
+
}
|
|
326
|
+
/>
|
|
327
|
+
)}
|
|
328
|
+
|
|
329
|
+
{cIgnoreOrder.enabled && (
|
|
330
|
+
<FormControlLabel
|
|
331
|
+
label={cIgnoreOrder.label}
|
|
332
|
+
control={
|
|
333
|
+
<CustomColorCheckbox
|
|
334
|
+
checked={ignoreOrder}
|
|
335
|
+
onChange={this.onLiteralOptionsChange('ignoreOrder')}
|
|
336
|
+
/>
|
|
337
|
+
}
|
|
338
|
+
/>
|
|
339
|
+
)}
|
|
340
|
+
</FlexContainer>
|
|
341
|
+
)}
|
|
342
|
+
|
|
343
|
+
<InputContainerWrapper>
|
|
344
|
+
<InputLabel>Correct Answer</InputLabel>
|
|
345
|
+
<MathToolbar
|
|
346
|
+
keypadMode={mode}
|
|
347
|
+
classNames={classNames}
|
|
348
|
+
controlledKeypad
|
|
349
|
+
showKeypad={showKeypad.main}
|
|
350
|
+
latex={answer || ''}
|
|
351
|
+
onChange={this.onAnswerChange}
|
|
352
|
+
onFocus={this.onFocus}
|
|
353
|
+
onDone={this.onDone}
|
|
354
|
+
error={error && error.answer}
|
|
355
|
+
/>
|
|
356
|
+
{error && error.answer ? <ErrorText>{error.answer}</ErrorText> : null}
|
|
357
|
+
</InputContainerWrapper>
|
|
358
|
+
|
|
359
|
+
{hasAlternates &&
|
|
360
|
+
Object.keys(alternates).map((alternateId, altIdx) => (
|
|
361
|
+
<InputContainerWrapper key={alternateId}>
|
|
362
|
+
<InputLabel>
|
|
363
|
+
Alternate
|
|
364
|
+
{Object.keys(alternates).length > 1 ? ` ${altIdx + 1}` : ''}
|
|
365
|
+
</InputLabel>
|
|
366
|
+
<AlternateBar>
|
|
367
|
+
<MathToolbar
|
|
368
|
+
classNames={classNames}
|
|
369
|
+
controlledKeypad
|
|
370
|
+
keypadMode={mode}
|
|
371
|
+
showKeypad={showKeypad[alternateId] || false}
|
|
372
|
+
latex={alternates[alternateId] || ''}
|
|
373
|
+
onChange={this.onAlternateAnswerChange(alternateId)}
|
|
374
|
+
onFocus={this.onAlternateFocus(alternateId)}
|
|
375
|
+
onDone={this.onAlternateDone(alternateId)}
|
|
376
|
+
error={error && error[alternateId]}
|
|
377
|
+
/>
|
|
378
|
+
<RemoveAlternateButton
|
|
379
|
+
onClick={this.onRemoveAlternate(alternateId)}
|
|
380
|
+
size="large">
|
|
381
|
+
<Delete />
|
|
382
|
+
</RemoveAlternateButton>
|
|
383
|
+
</AlternateBar>
|
|
384
|
+
{error && error[alternateId] ? <ErrorText>{error[alternateId]}</ErrorText> : null}
|
|
385
|
+
</InputContainerWrapper>
|
|
386
|
+
))}
|
|
387
|
+
|
|
388
|
+
<AlternateButton type="primary" onClick={this.onAddAlternate}>
|
|
389
|
+
ADD ALTERNATE
|
|
390
|
+
</AlternateButton>
|
|
391
|
+
</StyledCardContent>
|
|
392
|
+
</ResponseContainer>
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export default Response;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/math-templated/configure/src/utils.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
|
+
export const generateValidationMessage = (config) => {
|
|
12
|
+
const { maxResponseAreas } = config;
|
|
13
|
+
|
|
14
|
+
const responseAreasMessage =
|
|
15
|
+
'\nCorrect answers should not be blank.' +
|
|
16
|
+
'\nEach answer defined for a response area should be unique.' +
|
|
17
|
+
'\nThere should be at least 1 ' +
|
|
18
|
+
(maxResponseAreas ? `and at most ${maxResponseAreas} ` : '') +
|
|
19
|
+
'response area' +
|
|
20
|
+
(maxResponseAreas ? 's' : '') +
|
|
21
|
+
' defined.';
|
|
22
|
+
|
|
23
|
+
return 'Validation requirements:' + responseAreasMessage;
|
|
24
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/math-templated/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
|
+
// Should be exactly the same as configure/defaults.js
|
|
12
|
+
export default {
|
|
13
|
+
model: {
|
|
14
|
+
allowTrailingZerosDefault: false,
|
|
15
|
+
equationEditor: '8',
|
|
16
|
+
ignoreOrderDefault: false,
|
|
17
|
+
markup: '',
|
|
18
|
+
playerSpellCheckEnabled: true,
|
|
19
|
+
prompt: '',
|
|
20
|
+
promptEnabled: true,
|
|
21
|
+
rationale: '',
|
|
22
|
+
rationaleEnabled: true,
|
|
23
|
+
responses: {},
|
|
24
|
+
spellCheckEnabled: true,
|
|
25
|
+
teacherInstructions: '',
|
|
26
|
+
teacherInstructionsEnabled: true,
|
|
27
|
+
toolbarEditorPosition: 'bottom',
|
|
28
|
+
validationDefault: 'literal',
|
|
29
|
+
},
|
|
30
|
+
configuration: {},
|
|
31
|
+
};
|