@pie-element/graphing-solution-set 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.
Files changed (217) hide show
  1. package/dist/author/configure.d.ts +27 -0
  2. package/dist/author/configure.d.ts.map +1 -0
  3. package/dist/author/configure.js +190 -0
  4. package/dist/author/correct-response.d.ts +34 -0
  5. package/dist/author/correct-response.d.ts.map +1 -0
  6. package/dist/author/correct-response.js +206 -0
  7. package/dist/author/defaults.d.ts +239 -0
  8. package/dist/author/defaults.d.ts.map +1 -0
  9. package/dist/author/defaults.js +339 -0
  10. package/dist/author/graphing-config.d.ts +34 -0
  11. package/dist/author/graphing-config.d.ts.map +1 -0
  12. package/dist/author/graphing-config.js +238 -0
  13. package/dist/author/index.d.ts +63 -0
  14. package/dist/author/index.d.ts.map +1 -0
  15. package/dist/author/index.js +87 -0
  16. package/dist/author/utils.d.ts +47 -0
  17. package/dist/author/utils.d.ts.map +1 -0
  18. package/dist/author/utils.js +474 -0
  19. package/dist/controller/defaults.d.ts +65 -0
  20. package/dist/controller/defaults.d.ts.map +1 -0
  21. package/dist/controller/defaults.js +54 -0
  22. package/dist/controller/index.d.ts +25 -0
  23. package/dist/controller/index.d.ts.map +1 -0
  24. package/dist/controller/index.js +112 -0
  25. package/dist/controller/utils.d.ts +21 -0
  26. package/dist/controller/utils.d.ts.map +1 -0
  27. package/dist/controller/utils.js +42 -0
  28. package/dist/delivery/index.d.ts +23 -0
  29. package/dist/delivery/index.d.ts.map +1 -0
  30. package/dist/delivery/index.js +62 -0
  31. package/dist/delivery/main.d.ts +32 -0
  32. package/dist/delivery/main.d.ts.map +1 -0
  33. package/dist/delivery/main.js +198 -0
  34. package/dist/delivery/utils.d.ts +13 -0
  35. package/dist/delivery/utils.d.ts.map +1 -0
  36. package/dist/delivery/utils.js +220 -0
  37. package/dist/graphing-solution-set.css +2 -0
  38. package/dist/index.d.ts +2 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.iife.d.ts +9 -0
  41. package/dist/index.iife.d.ts.map +1 -0
  42. package/dist/index.iife.js +373 -0
  43. package/dist/index.js +2 -0
  44. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js +6 -0
  45. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Hash.js +16 -0
  46. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_ListCache.js +16 -0
  47. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Map.js +6 -0
  48. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_MapCache.js +16 -0
  49. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js +6 -0
  50. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Set.js +6 -0
  51. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_SetCache.js +11 -0
  52. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Stack.js +13 -0
  53. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Symbol.js +5 -0
  54. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js +5 -0
  55. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js +6 -0
  56. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_apply.js +12 -0
  57. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js +7 -0
  58. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js +10 -0
  59. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayIncludes.js +7 -0
  60. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayIncludesWith.js +7 -0
  61. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js +15 -0
  62. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayMap.js +7 -0
  63. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js +7 -0
  64. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arraySome.js +7 -0
  65. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js +10 -0
  66. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assocIndexOf.js +8 -0
  67. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js +8 -0
  68. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js +8 -0
  69. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js +12 -0
  70. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js +57 -0
  71. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js +14 -0
  72. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseDifference.js +23 -0
  73. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseFindIndex.js +7 -0
  74. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseFlatten.js +13 -0
  75. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
  76. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetTag.js +10 -0
  77. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIndexOf.js +9 -0
  78. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js +9 -0
  79. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqual.js +8 -0
  80. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqualDeep.js +30 -0
  81. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js +9 -0
  82. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNaN.js +6 -0
  83. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNative.js +11 -0
  84. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js +9 -0
  85. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
  86. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js +12 -0
  87. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js +13 -0
  88. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseRest.js +9 -0
  89. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseSet.js +22 -0
  90. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseSetToString.js +14 -0
  91. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js +7 -0
  92. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseToString.js +15 -0
  93. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js +8 -0
  94. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUniq.js +27 -0
  95. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cacheHas.js +6 -0
  96. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_castPath.js +10 -0
  97. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
  98. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js +10 -0
  99. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js +8 -0
  100. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js +8 -0
  101. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js +8 -0
  102. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js +8 -0
  103. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js +8 -0
  104. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js +14 -0
  105. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js +8 -0
  106. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js +8 -0
  107. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_coreJsData.js +5 -0
  108. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createSet.js +9 -0
  109. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js +10 -0
  110. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalArrays.js +35 -0
  111. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalByTag.js +35 -0
  112. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalObjects.js +32 -0
  113. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_freeGlobal.js +4 -0
  114. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js +9 -0
  115. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js +9 -0
  116. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getMapData.js +8 -0
  117. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getNative.js +9 -0
  118. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js +5 -0
  119. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getRawTag.js +14 -0
  120. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js +10 -0
  121. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js +11 -0
  122. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js +23 -0
  123. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getValue.js +6 -0
  124. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashClear.js +7 -0
  125. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashDelete.js +7 -0
  126. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashGet.js +13 -0
  127. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashHas.js +9 -0
  128. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashSet.js +9 -0
  129. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js +8 -0
  130. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js +33 -0
  131. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js +9 -0
  132. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isFlattenable.js +10 -0
  133. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js +8 -0
  134. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKey.js +11 -0
  135. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKeyable.js +7 -0
  136. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isMasked.js +11 -0
  137. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js +8 -0
  138. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js +6 -0
  139. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheDelete.js +9 -0
  140. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheGet.js +8 -0
  141. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheHas.js +7 -0
  142. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheSet.js +8 -0
  143. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheClear.js +13 -0
  144. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheDelete.js +8 -0
  145. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheGet.js +7 -0
  146. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheHas.js +7 -0
  147. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheSet.js +8 -0
  148. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapToArray.js +9 -0
  149. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_memoizeCapped.js +11 -0
  150. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js +5 -0
  151. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js +5 -0
  152. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js +8 -0
  153. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js +9 -0
  154. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_objectToString.js +7 -0
  155. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js +8 -0
  156. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overRest.js +13 -0
  157. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_root.js +5 -0
  158. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheAdd.js +7 -0
  159. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheHas.js +6 -0
  160. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToArray.js +9 -0
  161. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToString.js +6 -0
  162. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_shortOut.js +14 -0
  163. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackClear.js +7 -0
  164. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackDelete.js +7 -0
  165. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackGet.js +6 -0
  166. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackHas.js +6 -0
  167. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackSet.js +16 -0
  168. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_strictIndexOf.js +7 -0
  169. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stringToPath.js +10 -0
  170. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toKey.js +10 -0
  171. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toSource.js +15 -0
  172. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js +8 -0
  173. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/constant.js +8 -0
  174. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/differenceWith.js +12 -0
  175. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/eq.js +6 -0
  176. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/identity.js +6 -0
  177. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js +10 -0
  178. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArray.js +4 -0
  179. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js +8 -0
  180. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLikeObject.js +8 -0
  181. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js +6 -0
  182. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEmpty.js +21 -0
  183. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEqual.js +7 -0
  184. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isFunction.js +11 -0
  185. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isLength.js +7 -0
  186. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isMap.js +7 -0
  187. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObject.js +7 -0
  188. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js +6 -0
  189. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSet.js +7 -0
  190. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSymbol.js +9 -0
  191. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js +7 -0
  192. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keys.js +9 -0
  193. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js +9 -0
  194. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/last.js +7 -0
  195. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/memoize.js +16 -0
  196. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/noop.js +4 -0
  197. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/set.js +7 -0
  198. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js +6 -0
  199. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js +6 -0
  200. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toString.js +7 -0
  201. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/uniq.js +7 -0
  202. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/uniqWith.js +7 -0
  203. package/package.json +70 -0
  204. package/src/author/configure.tsx +266 -0
  205. package/src/author/correct-response.tsx +408 -0
  206. package/src/author/defaults.tsx +366 -0
  207. package/src/author/graphing-config.tsx +318 -0
  208. package/src/author/index.ts +176 -0
  209. package/src/author/utils.ts +577 -0
  210. package/src/controller/defaults.ts +72 -0
  211. package/src/controller/index.ts +313 -0
  212. package/src/controller/utils.ts +195 -0
  213. package/src/delivery/index.ts +159 -0
  214. package/src/delivery/main.tsx +361 -0
  215. package/src/delivery/utils.ts +465 -0
  216. package/src/index.iife.ts +16 -0
  217. package/src/index.ts +1 -0
@@ -0,0 +1,313 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/graphing-solution-set/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
+ import { cloneDeep, isEmpty, uniqWith } from 'lodash-es';
13
+ import defaults from './defaults.js';
14
+ import { equalMarks, sortedAnswers, removeInvalidAnswers } from './utils.js';
15
+
16
+ const log = debug('@pie-element:graphing-solution-set:controller');
17
+
18
+ const initializeGraphMap = () => ({
19
+ line: [],
20
+ });
21
+
22
+ /*
23
+ * Function to compare two marks
24
+ * @param {Object} mark1 - first mark
25
+ * @param {Object} mark2 - second mark
26
+ * */
27
+ export const compareMarks = (mark1, mark2) => {
28
+ // marks can be compared with equalMarks[type] function only if they have the same type;
29
+ // if type is different, they are clearly not equal
30
+ return !!(
31
+ mark1 &&
32
+ mark2 &&
33
+ mark1.type === mark2.type &&
34
+ equalMarks[mark1.type] &&
35
+ equalMarks[mark1.type](mark1, mark2)
36
+ );
37
+ };
38
+
39
+ /*
40
+ * Function to get the corrected answer
41
+ * @param {Object} sessionAnswers - array of marks from session
42
+ * @param {Object} marks - array of marks from correct answer
43
+ * */
44
+ export const getAnswerCorrected = ({ sessionAnswers, marks: correctAnswers }) => {
45
+ sessionAnswers = sessionAnswers || [];
46
+ correctAnswers = correctAnswers || [];
47
+ const rez = cloneDeep(sessionAnswers).reduce((correctedAnswer, answer) => {
48
+ const answerIsCorrect = correctAnswers.find((mark) => compareMarks(answer, mark));
49
+ answer.correctness = answerIsCorrect ? 'correct' : 'incorrect';
50
+ return [...correctedAnswer, answer];
51
+ }, []);
52
+ // add missing objects from correct answer
53
+ const missingAnswers = cloneDeep(correctAnswers).reduce((correctedAnswer, answer) => {
54
+ const answerIndex = sessionAnswers.find((mark) => compareMarks(answer, mark));
55
+ if (!answerIndex) {
56
+ // means that corrected answer is missing from session, so we mark it as missing object
57
+ return [...correctedAnswer, { ...answer, correctness: 'missing' }];
58
+ }
59
+ return correctedAnswer;
60
+ }, []);
61
+ return [...rez, ...missingAnswers];
62
+ };
63
+
64
+ /*
65
+ * Function to get the best answer
66
+ * @param {Object} question - question object
67
+ * @param {Object} session - session object
68
+ * @param {Object} env - env object
69
+ * */
70
+ export const getBestAnswer = (question, session, env = {}) => {
71
+ // questionPossibleAnswers contains all possible answers (correct response and alternates);
72
+ let { answers: questionPossibleAnswers = {}, scoringType } = question || {};
73
+ let { answer } = session || {};
74
+ // filter the incomplete objects
75
+ Object.entries(questionPossibleAnswers || {}).forEach(
76
+ ([key, value]) =>
77
+ (questionPossibleAnswers[key] = { ...value, marks: value?.marks.filter((mark) => !mark.building) }),
78
+ );
79
+ // initialize answer if no values
80
+ answer = answer || [];
81
+ // initialize one possible answer if no values
82
+ if (isEmpty(questionPossibleAnswers)) {
83
+ questionPossibleAnswers = { correctAnswer: initializeGraphMap() };
84
+ } else {
85
+ questionPossibleAnswers = {
86
+ correctAnswer: questionPossibleAnswers.correctAnswer,
87
+ ...sortedAnswers(questionPossibleAnswers),
88
+ };
89
+ }
90
+ // student's answers without DUPLICATES
91
+ const sessionAnswers = uniqWith(answer, compareMarks);
92
+ // array of possible answers entries
93
+ const possibleAnswers = Object.entries(questionPossibleAnswers);
94
+ return possibleAnswers.reduce(
95
+ (acc, entry) => {
96
+ // iterating each possible answer (main + alternates)
97
+ const possibleAnswerKey = entry[0];
98
+ const possibleAnswer = entry[1] || {};
99
+ let { marks } = possibleAnswer;
100
+ if (!marks || !marks.length) {
101
+ return acc;
102
+ }
103
+ // returns array of marks, each having 'correctness' property
104
+ const correctedAnswer = getAnswerCorrected({ sessionAnswers, marks });
105
+ const correctMarks = correctedAnswer.filter((answer) => answer.correctness === 'correct');
106
+ // filter out missing objects because they do not affect the calculation of the score
107
+ // only correct and incorrect are needed
108
+ const scoredCorrectedAnswer = correctedAnswer.filter((answer) => answer.correctness !== 'missing');
109
+ const maxScore = marks.length;
110
+ let score = correctMarks.length;
111
+ // if extra placements
112
+ if (scoredCorrectedAnswer.length > maxScore) {
113
+ score -= scoredCorrectedAnswer.length - maxScore;
114
+ }
115
+ if (score < 0) {
116
+ score = 0;
117
+ }
118
+ if (score / maxScore > acc.bestScore || !acc.foundOneSolution) {
119
+ acc.bestScore = Math.floor(score / maxScore);
120
+ acc.bestScoreAnswerKey = possibleAnswerKey;
121
+ acc.answersCorrected = correctedAnswer;
122
+ acc.foundOneSolution = true;
123
+ }
124
+ return acc;
125
+ },
126
+ {
127
+ bestScore: 0,
128
+ bestScoreAnswerKey: null,
129
+ // initially we just suppose all the answers are incorrect
130
+ answersCorrected: cloneDeep(sessionAnswers).map((answer) => ({ ...answer, correctness: 'incorrect' })),
131
+ foundOneSolution: false,
132
+ },
133
+ );
134
+ };
135
+
136
+ /*
137
+ * Constant normalize
138
+ * @param {Object} question - question object
139
+ * */
140
+ export const normalize = (question) => ({ ...defaults, ...question });
141
+
142
+ /*
143
+ * Function to set model
144
+ * @param {Object} question - question object
145
+ * @param {Object} session - session object
146
+ * @param {Object} env - env object
147
+ * */
148
+ export function model(question, session, env) {
149
+ return new Promise((resolve) => {
150
+ const normalizedQuestion = normalize(question);
151
+ // ensure removing of invalid answers
152
+ // need this if undo redo was last operation
153
+ session.answer = removeInvalidAnswers(session.answer);
154
+ // console.log('normalizedQuestion', normalizedQuestion);
155
+ const { defaultTool, extraCSSRules, prompt, promptEnabled, graph, answers, toolbarTools, ...questionProps } =
156
+ normalizedQuestion || {};
157
+ let { arrows } = normalizedQuestion;
158
+ const { mode, role } = env || {};
159
+
160
+ // This is used for offering support for old models which have the property arrows: boolean
161
+ // Same thing is set in authoring : packages/graphing/configure/src/configure.jsx - componentDidMount
162
+ if (typeof arrows === 'boolean') {
163
+ if (arrows) {
164
+ arrows = {
165
+ left: true,
166
+ right: true,
167
+ up: true,
168
+ down: true,
169
+ };
170
+ } else {
171
+ arrows = {
172
+ left: false,
173
+ right: false,
174
+ up: false,
175
+ down: false,
176
+ };
177
+ }
178
+ }
179
+
180
+ const base = {
181
+ ...questionProps,
182
+ answers,
183
+ arrows,
184
+ defaultTool: 'line',
185
+ disabled: env.mode !== 'gather',
186
+ prompt: promptEnabled ? prompt : null,
187
+ rationale: null,
188
+ size: graph,
189
+ showToggle:
190
+ env.mode === 'evaluate' &&
191
+ !isEmpty(answers) &&
192
+ answers.correctAnswer &&
193
+ answers.correctAnswer.marks &&
194
+ !isEmpty(answers.correctAnswer.marks),
195
+ teacherInstructions: null,
196
+ toolbarTools,
197
+ extraCSSRules,
198
+ };
199
+
200
+ if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
201
+ const { rationale, rationaleEnabled, teacherInstructions, teacherInstructionsEnabled } = normalizedQuestion || {};
202
+
203
+ base.rationale = rationaleEnabled ? rationale : null;
204
+ base.teacherInstructions = teacherInstructionsEnabled ? teacherInstructions : null;
205
+ }
206
+
207
+ if (mode === 'evaluate') {
208
+ if (
209
+ !isEmpty(answers) &&
210
+ answers.correctAnswer &&
211
+ answers.correctAnswer.marks &&
212
+ !isEmpty(answers.correctAnswer.marks)
213
+ ) {
214
+ const { answersCorrected, bestScoreAnswerKey, bestScore } = getBestAnswer(normalizedQuestion, session, env);
215
+ // array of marks from session with 'correctness' property set
216
+ base.answersCorrected = answersCorrected;
217
+ base.correctResponse = bestScoreAnswerKey ? (answers[bestScoreAnswerKey] || {}).marks : [];
218
+ base.showToggle = base.showToggle && bestScore !== 1;
219
+ } else {
220
+ base.answersCorrected = (session && session.answer) || [];
221
+ base.correctResponse = [];
222
+ }
223
+ }
224
+
225
+ log('base: ', base);
226
+ resolve(base);
227
+ });
228
+ }
229
+
230
+ /*
231
+ * Function to check the outcome
232
+ * @param {Object} question - question object
233
+ * @param {Object} session - session object
234
+ * @param {Object} env - env object
235
+ * */
236
+ export function outcome(question, session, env = {}) {
237
+ return new Promise((resolve) => {
238
+ if (!session || isEmpty(session)) {
239
+ resolve({ score: 0, empty: true });
240
+ }
241
+ if (
242
+ env.mode !== 'evaluate' ||
243
+ isEmpty(question.answers) ||
244
+ (question.answers && question.answers.correctAnswer && isEmpty(question.answers.correctAnswer.marks))
245
+ ) {
246
+ resolve({ score: 0 });
247
+ }
248
+ const { bestScore } = getBestAnswer(question, session, env);
249
+ resolve({ score: bestScore });
250
+ });
251
+ }
252
+
253
+ /*
254
+ * Constant to create correct response session
255
+ * @param {Object} question - question object
256
+ * @param {Object} env - env object
257
+ * */
258
+ export const createCorrectResponseSession = (question, env) => {
259
+ return new Promise((resolve) => {
260
+ if (env.mode !== 'evaluate' && env.role === 'instructor') {
261
+ const { answers } = question || {};
262
+ let marks = [];
263
+ if (answers && Object.values(answers)) {
264
+ const correctAnswer = answers.correctAnswer || Object.values(answers)[0] || {};
265
+ marks = correctAnswer.marks || [];
266
+ }
267
+ resolve({
268
+ answer: marks,
269
+ id: '1',
270
+ });
271
+ } else {
272
+ resolve(null);
273
+ }
274
+ });
275
+ };
276
+
277
+ /*
278
+ * Constant to validate model before saving item
279
+ * @param {Object} model - model object
280
+ * */
281
+ export const validate = (model = {}) => {
282
+ const { answers, gssLineData } = model;
283
+ const errors = {};
284
+ const correctAnswerErrors = {};
285
+ let found = false;
286
+ if (gssLineData.numberOfLines === 1) {
287
+ if (answers.correctAnswer.marks.length < 1) {
288
+ found = true;
289
+ correctAnswerErrors.correctAnswer = 'At least 1 line object should be defined.';
290
+ } else if (answers.correctAnswer.marks.length === 1 && answers.correctAnswer.marks[0].building) {
291
+ found = true;
292
+ correctAnswerErrors.correctAnswer = '1 or more graph object should be correctly defined.';
293
+ }
294
+ } else {
295
+ if (answers.correctAnswer.marks.length < 2) {
296
+ found = true;
297
+ correctAnswerErrors.correctAnswer = 'At least 2 line object should be defined.';
298
+ } else if (answers.correctAnswer.marks.length === 2) {
299
+ if (answers.correctAnswer.marks[0].building || answers.correctAnswer.marks[1].building) {
300
+ found = true;
301
+ correctAnswerErrors.correctAnswer = '1 or more graph object should be correctly defined.';
302
+ }
303
+ }
304
+ }
305
+ let polygon = answers.correctAnswer.marks.find((mark) => mark.type === 'polygon');
306
+ if (!found && (!gssLineData.selectedTool === 'solutionSet' || !polygon)) {
307
+ correctAnswerErrors.correctAnswer = 'Please select a solution set for the graphing solution set item.';
308
+ }
309
+ if (!isEmpty(correctAnswerErrors)) {
310
+ errors.correctAnswerErrors = correctAnswerErrors;
311
+ }
312
+ return errors;
313
+ };
@@ -0,0 +1,195 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/graphing-solution-set/controller/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
+ import { isEqual, differenceWith, uniq, uniqWith } from 'lodash-es';
12
+
13
+ /*
14
+ * Constant to check equal segments
15
+ * @param {Object} segment1 - segment 1
16
+ * @param {Object} segment2 - segment 2
17
+ * */
18
+ export const equalSegment = (segment1, segment2) => {
19
+ // A.from = B.from, A.to = B.to OR A.from = B.to, A.to = B.from
20
+ // x1 = x3 & y1 = y3 & x2 = x4 & y2 = y4
21
+ return (
22
+ (isEqual(segment1.from, segment2.from) && isEqual(segment1.to, segment2.to)) ||
23
+ (isEqual(segment1.to, segment2.from) && isEqual(segment1.from, segment2.to))
24
+ );
25
+ };
26
+
27
+ // this function is implemented in configure as well
28
+ /*
29
+ * Constant to get sorted answers
30
+ * @param {Object} answers - answers
31
+ * */
32
+ export const sortedAnswers = (answers) =>
33
+ Object.keys(answers || {})
34
+ .sort()
35
+ .reduce((result, key) => {
36
+ if (key !== 'correctAnswer') {
37
+ result[key] = answers[key];
38
+ }
39
+ return result;
40
+ }, {});
41
+
42
+ /*
43
+ * Constant to return line equation coefficients
44
+ * @param {Object} line - line
45
+ * */
46
+ const returnLineEquationCoefficients = (line) => {
47
+ line = { ...line, to: { ...line.to }, from: { ...line.from } };
48
+ const xA = line.from.x;
49
+ const yA = line.from.y;
50
+ const xB = line.to.x;
51
+ const yB = line.to.y;
52
+ return {
53
+ a: yB - yA,
54
+ b: xA - xB,
55
+ c: xB * yA - xA * yB,
56
+ };
57
+ };
58
+
59
+ /*
60
+ * Constant to get significant decimals
61
+ * @param {Number} number - number
62
+ * */
63
+ const getSignificantDecimals = (number) => Math.round(number * 10000) / 10000;
64
+
65
+ /*
66
+ * Constant to check equal lines
67
+ * @param {Object} line1 - line 1
68
+ * @param {Object} line2 - line 2
69
+ * */
70
+ export const equalLine = (line1, line2) => {
71
+ // line equation: ax + by + c = 0
72
+ // 2 lines are equal if a1/a2 = b1/b2 = c1/c2, where a, b, c are the coefficients in line equation
73
+ // line equation knowing 2 points: (y - yA) / (yB - yA) = (x - xA) / (xB - xA)
74
+ // extending this equation, we get: x * (yB - yA) + y * (xA - xB) + (xB * yA - xA * yB) = 0
75
+ // where a = yB - yA; b = xA - xB; c = xB * yA - xA * yB
76
+ const { a: a1, b: b1, c: c1 } = returnLineEquationCoefficients(line1);
77
+ const { a: a2, b: b2, c: c2 } = returnLineEquationCoefficients(line2);
78
+ const proportions = [];
79
+ if (a2 !== 0) {
80
+ proportions.push(getSignificantDecimals(a1 / a2));
81
+ } else if (a1 !== a2) {
82
+ return false;
83
+ }
84
+ if (b2 !== 0) {
85
+ proportions.push(getSignificantDecimals(b1 / b2));
86
+ } else if (b1 !== b2) {
87
+ return false;
88
+ }
89
+ if (c2 !== 0) {
90
+ proportions.push(getSignificantDecimals(c1 / c2));
91
+ } else if (c1 !== c2) {
92
+ return false;
93
+ }
94
+ return uniq(proportions).length === 1 && line1.fill === line2.fill;
95
+ // (y2 - y1)/(x2 - x1) = (y4 - y3)/(x4 - x3);
96
+ // return ((Math.abs((line1.to.y - line1.from.y) / (line1.to.x - line1.from.x))) === (Math.abs((line2.to.y - line2.from.y) / (line2.to.x - line2.from.x))));
97
+ };
98
+
99
+ /*
100
+ * Constant to construct segments from points
101
+ * @param {Array} points - points
102
+ * */
103
+ export const constructSegmentsFromPoints = (points) => {
104
+ // takes the list of points that represent a polygon and transforms it into a list of segments; eg.:
105
+ // points: A, B, C, D => segments: AB, BC, CD, DA
106
+ return (points || []).map((point, index) => ({ from: point, to: points[(index + 1) % points.length] }));
107
+ };
108
+
109
+ /*
110
+ * Constant to remove duplicate segments
111
+ * @param {Array} segments - segments
112
+ * */
113
+ export const removeDuplicateSegments = (segments) => {
114
+ segments = segments || [];
115
+ // removes segments that are duplicates; eg. These segments are the same, so one will be removed:
116
+ // segment1: from: { x: 1, y: 1 }, to: { x: 2, y: 1 }
117
+ // segment2: from: { x: 2, y: 1 }, to: { x: 1, y: 1 }
118
+ return uniqWith(segments, (s1, s2) => equalSegment(s1, s2));
119
+ };
120
+
121
+ /*
122
+ * Constant to remove invalid segments
123
+ * @param {Array} segments - segments
124
+ * */
125
+ export const removeInvalidSegments = (segments) => {
126
+ segments = segments || [];
127
+ // removes segments that start in a point and end in the same point (eg.: from: { x: 1, y: 1 }, to: { x: 1, y: 1 })
128
+ return segments.filter((segment) => !isEqual(segment.from, segment.to));
129
+ };
130
+
131
+ /*
132
+ * Constant to check equal polygons
133
+ * @param {Object} poly1 - polygon 1 points
134
+ * @param {Object} poly2 - polygon 2 points
135
+ * */
136
+ export const equalPolygon = (poly1, poly2) => {
137
+ const { points: points1 } = poly1;
138
+ const { points: points2 } = poly2;
139
+ // generate segments
140
+ const segments1 = constructSegmentsFromPoints(points1);
141
+ const segments2 = constructSegmentsFromPoints(points2);
142
+ const segments1NoDuplicates = removeDuplicateSegments(removeInvalidSegments(segments1));
143
+ const segments2NoDuplicates = removeDuplicateSegments(removeInvalidSegments(segments2));
144
+ const differentSegments1 = differenceWith(segments1NoDuplicates, segments2NoDuplicates, equalSegment);
145
+ const differentSegments2 = differenceWith(segments2NoDuplicates, segments1NoDuplicates, equalSegment);
146
+ return (!differentSegments1 || !differentSegments1.length) && (!differentSegments2 || !differentSegments2.length);
147
+ };
148
+
149
+ /*
150
+ * Constant to compare equal marks
151
+ * */
152
+ export const equalMarks = {
153
+ line: (sessAnswer, mark) => equalLine(sessAnswer, mark),
154
+ polygon: (sessAnswer, poly) => equalPolygon(sessAnswer, poly),
155
+ };
156
+
157
+ /*
158
+ * Check if a point is correct and complete
159
+ * @param {Object} point - point object
160
+ * */
161
+ const completePoint = (point) => point && Number.isFinite(point.x) && Number.isFinite(point.y);
162
+
163
+ /*
164
+ * Check if a line is complete
165
+ * @param {Object} item - mark object
166
+ * */
167
+ const completeFromTo = (item) => item && completeMark.point(item.from) && completeMark.point(item.to);
168
+
169
+ /*
170
+ * Check if a point is correct and complete
171
+ * @param {Object} item - mark object
172
+ * */
173
+ const completePoints = (item) =>
174
+ item &&
175
+ item.points &&
176
+ item.points.length &&
177
+ (item.points.filter((point) => completePoint(point)) || []).length === item.points.length;
178
+
179
+ /*
180
+ * Complete mark object for line and point
181
+ * */
182
+ const completeMark = {
183
+ point: completePoint,
184
+ line: completeFromTo,
185
+ polygon: completePoints,
186
+ };
187
+
188
+ /*
189
+ * Function to remove invalid answers
190
+ * @param {Array} answers - answers array
191
+ * */
192
+ export const removeInvalidAnswers = (answers) =>
193
+ answers
194
+ ? (answers || []).filter(({ type, ...answer }) => (completeMark[type] ? completeMark[type](answer) : false))
195
+ : [];
@@ -0,0 +1,159 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/graphing-solution-set/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 { SessionChangedEvent } from '@pie-element/shared-player-events';
14
+ import { renderMath } from '@pie-element/shared-math-rendering-mathjax';
15
+ import { findSectionsInSolutionSet, removeInvalidAnswers } from './utils.js';
16
+ import Main from './main.js';
17
+
18
+ export { Main as Component };
19
+
20
+ export default class Graphing extends HTMLElement {
21
+ constructor() {
22
+ super();
23
+ this._root = null;
24
+ }
25
+
26
+ /*
27
+ * Function to set model
28
+ * @param {object} m - Model object
29
+ * */
30
+ set model(m) {
31
+ this._model = m;
32
+ this._render();
33
+ }
34
+
35
+ /*
36
+ * Function to set session
37
+ * @param {object} s - Session object
38
+ * */
39
+ set session(s) {
40
+ this._session = s;
41
+ if (!this._session.answer) {
42
+ this._session.answer = [];
43
+ }
44
+ const { answer } = this._session || {};
45
+ const { gssLineData, domain, range } = this._model;
46
+ let section = answer && answer.filter((mark) => mark.type === 'polygon').length > 0;
47
+ if (gssLineData.numberOfLines === 1) {
48
+ this._model.gssData = {
49
+ numberOfLines: 1,
50
+ selectedTool: section ? 'solutionSet' : 'lineA',
51
+ sections: [],
52
+ lineA: {
53
+ lineType: answer && answer.length > 0 ? answer[0].fill : 'Solid',
54
+ },
55
+ };
56
+ } else {
57
+ this._model.gssData = {
58
+ numberOfLines: 2,
59
+ selectedTool: section ? 'solutionSet' : 'lineA',
60
+ sections: [],
61
+ lineA: {
62
+ lineType: answer && answer.length > 0 ? answer[0].fill : 'Solid',
63
+ },
64
+ lineB: {
65
+ lineType: answer && answer.length > 1 ? answer[1].fill : 'Solid',
66
+ },
67
+ };
68
+ }
69
+ if (section) {
70
+ this._model.gssData = findSectionsInSolutionSet(this._model.gssData, answer, domain, range);
71
+ }
72
+ this._render();
73
+ }
74
+
75
+ /*
76
+ * Function to get session
77
+ * */
78
+ get session() {
79
+ return this._session;
80
+ }
81
+
82
+ connectedCallback() {
83
+ this._render();
84
+ }
85
+
86
+ /*
87
+ * Is complete function
88
+ * @param {object} answer - Answer object
89
+ * */
90
+ isComplete = (answer) => Array.isArray(answer) && answer.length > 0;
91
+
92
+ /*
93
+ * Callback function to change answers
94
+ * @param {object} answer - Answer object
95
+ * @param {boolean} isUndoOperation - Boolean value to check if undo operation is performed
96
+ * */
97
+ changeAnswers: any = (answer, isUndoOperation) => {
98
+ // avoid removeInvalidObjects when undo or redo operations are executed
99
+ // in order to preserve the logic of undo and redo
100
+ const { gssData } = this._model;
101
+ if (gssData.selectedTool === 'lineA' && answer.length > 0) {
102
+ answer[0].fill = gssData['lineA'].lineType;
103
+ }
104
+ if (gssData.selectedTool === 'lineB' && answer.length > 1) {
105
+ answer[1].fill = gssData['lineB'].lineType;
106
+ }
107
+ if (answer.length === 0) {
108
+ gssData.selectedTool = 'lineA';
109
+ this._model.gssData = gssData;
110
+ }
111
+ if (!isUndoOperation) {
112
+ this._session.answer = removeInvalidAnswers(answer);
113
+ } else {
114
+ this._session.answer = answer;
115
+ }
116
+ this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete(this._session.answer)));
117
+ this._render();
118
+ };
119
+
120
+ /*
121
+ * Function to set gssData object and session object
122
+ * @param {object} gssData - GSS Data object
123
+ * @param {object} session - Session object
124
+ * */
125
+ setGssData: any = (gssData, session) => {
126
+ this._model.gssData = gssData;
127
+ this._session = session;
128
+ this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete(this._session.answer)));
129
+ this._render();
130
+ };
131
+
132
+ /*
133
+ * Render function
134
+ * */
135
+ _render() {
136
+ if (!this._model || !this._session) {
137
+ return;
138
+ }
139
+ const el = React.createElement(Main, {
140
+ model: this._model,
141
+ session: this._session,
142
+ onAnswersChange: this.changeAnswers,
143
+ setGssData: this.setGssData,
144
+ });
145
+ if (!this._root) {
146
+ this._root = createRoot(this);
147
+ }
148
+ this._root.render(el);
149
+ queueMicrotask(() => {
150
+ renderMath(this);
151
+ });
152
+ }
153
+
154
+ disconnectedCallback() {
155
+ if (this._root) {
156
+ this._root.unmount();
157
+ }
158
+ }
159
+ }