@pie-element/multiple-choice 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 (218) hide show
  1. package/dist/author/defaults.d.ts +206 -0
  2. package/dist/author/defaults.d.ts.map +1 -0
  3. package/dist/author/defaults.js +151 -0
  4. package/dist/author/index.d.ts +27 -0
  5. package/dist/author/index.d.ts.map +1 -0
  6. package/dist/author/index.js +116 -0
  7. package/dist/author/main.d.ts +35 -0
  8. package/dist/author/main.d.ts.map +1 -0
  9. package/dist/author/main.js +290 -0
  10. package/dist/author/utils.d.ts +10 -0
  11. package/dist/author/utils.d.ts.map +1 -0
  12. package/dist/author/utils.js +7 -0
  13. package/dist/controller/defaults.d.ts +36 -0
  14. package/dist/controller/defaults.d.ts.map +1 -0
  15. package/dist/controller/defaults.js +29 -0
  16. package/dist/controller/index.d.ts +66 -0
  17. package/dist/controller/index.d.ts.map +1 -0
  18. package/dist/controller/index.js +124 -0
  19. package/dist/controller/utils.d.ts +11 -0
  20. package/dist/controller/utils.d.ts.map +1 -0
  21. package/dist/controller/utils.js +8 -0
  22. package/dist/delivery/choice-input.d.ts +45 -0
  23. package/dist/delivery/choice-input.d.ts.map +1 -0
  24. package/dist/delivery/choice-input.js +269 -0
  25. package/dist/delivery/choice.d.ts +21 -0
  26. package/dist/delivery/choice.d.ts.map +1 -0
  27. package/dist/delivery/choice.js +109 -0
  28. package/dist/delivery/feedback-tick.d.ts +21 -0
  29. package/dist/delivery/feedback-tick.d.ts.map +1 -0
  30. package/dist/delivery/feedback-tick.js +104 -0
  31. package/dist/delivery/index.d.ts +34 -0
  32. package/dist/delivery/index.d.ts.map +1 -0
  33. package/dist/delivery/index.js +167 -0
  34. package/dist/delivery/main.d.ts +30 -0
  35. package/dist/delivery/main.d.ts.map +1 -0
  36. package/dist/delivery/main.js +47 -0
  37. package/dist/delivery/multiple-choice.d.ts +61 -0
  38. package/dist/delivery/multiple-choice.d.ts.map +1 -0
  39. package/dist/delivery/multiple-choice.js +241 -0
  40. package/dist/delivery/session-updater.d.ts +11 -0
  41. package/dist/delivery/session-updater.d.ts.map +1 -0
  42. package/dist/delivery/session-updater.js +9 -0
  43. package/dist/index.d.ts +2 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.iife.d.ts +9 -0
  46. package/dist/index.iife.d.ts.map +1 -0
  47. package/dist/index.iife.js +148 -0
  48. package/dist/index.js +2 -0
  49. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js +6 -0
  50. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Hash.js +16 -0
  51. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_ListCache.js +16 -0
  52. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Map.js +6 -0
  53. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_MapCache.js +16 -0
  54. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js +6 -0
  55. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Set.js +6 -0
  56. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_SetCache.js +11 -0
  57. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Stack.js +13 -0
  58. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Symbol.js +5 -0
  59. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js +5 -0
  60. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js +6 -0
  61. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_apply.js +12 -0
  62. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js +7 -0
  63. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js +10 -0
  64. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js +15 -0
  65. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js +7 -0
  66. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arraySome.js +7 -0
  67. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignMergeValue.js +8 -0
  68. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js +10 -0
  69. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assocIndexOf.js +8 -0
  70. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js +8 -0
  71. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js +8 -0
  72. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js +12 -0
  73. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js +57 -0
  74. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js +14 -0
  75. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseFor.js +5 -0
  76. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
  77. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetTag.js +10 -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/_baseIsNative.js +11 -0
  83. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js +9 -0
  84. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
  85. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js +12 -0
  86. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js +13 -0
  87. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseMerge.js +19 -0
  88. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseMergeDeep.js +31 -0
  89. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseRest.js +9 -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/_baseTrim.js +8 -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/_cacheHas.js +6 -0
  95. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
  96. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js +10 -0
  97. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js +8 -0
  98. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js +8 -0
  99. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js +8 -0
  100. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js +8 -0
  101. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js +8 -0
  102. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js +14 -0
  103. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js +8 -0
  104. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js +8 -0
  105. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_coreJsData.js +5 -0
  106. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createAssigner.js +15 -0
  107. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createBaseFor.js +12 -0
  108. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js +10 -0
  109. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalArrays.js +35 -0
  110. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalByTag.js +35 -0
  111. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalObjects.js +32 -0
  112. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_freeGlobal.js +4 -0
  113. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js +9 -0
  114. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js +9 -0
  115. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getMapData.js +8 -0
  116. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getNative.js +9 -0
  117. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js +5 -0
  118. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getRawTag.js +14 -0
  119. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js +10 -0
  120. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js +11 -0
  121. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js +23 -0
  122. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getValue.js +6 -0
  123. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashClear.js +7 -0
  124. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashDelete.js +7 -0
  125. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashGet.js +13 -0
  126. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashHas.js +9 -0
  127. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashSet.js +9 -0
  128. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js +8 -0
  129. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js +33 -0
  130. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js +9 -0
  131. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js +8 -0
  132. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIterateeCall.js +12 -0
  133. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKeyable.js +7 -0
  134. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isMasked.js +11 -0
  135. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js +8 -0
  136. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js +6 -0
  137. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheDelete.js +9 -0
  138. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheGet.js +8 -0
  139. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheHas.js +7 -0
  140. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheSet.js +8 -0
  141. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheClear.js +13 -0
  142. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheDelete.js +8 -0
  143. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheGet.js +7 -0
  144. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheHas.js +7 -0
  145. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheSet.js +8 -0
  146. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapToArray.js +9 -0
  147. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js +5 -0
  148. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js +5 -0
  149. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js +8 -0
  150. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js +9 -0
  151. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_objectToString.js +7 -0
  152. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js +8 -0
  153. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overRest.js +13 -0
  154. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_root.js +5 -0
  155. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_safeGet.js +6 -0
  156. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheAdd.js +7 -0
  157. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheHas.js +6 -0
  158. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToArray.js +9 -0
  159. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToString.js +6 -0
  160. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_shortOut.js +14 -0
  161. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackClear.js +7 -0
  162. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackDelete.js +7 -0
  163. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackGet.js +6 -0
  164. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackHas.js +6 -0
  165. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackSet.js +16 -0
  166. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toSource.js +15 -0
  167. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_trimmedEndIndex.js +8 -0
  168. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js +8 -0
  169. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/constant.js +8 -0
  170. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/debounce.js +50 -0
  171. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/defaults.js +16 -0
  172. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/eq.js +6 -0
  173. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/identity.js +6 -0
  174. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js +10 -0
  175. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArray.js +4 -0
  176. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js +8 -0
  177. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLikeObject.js +8 -0
  178. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js +6 -0
  179. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEmpty.js +21 -0
  180. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEqual.js +7 -0
  181. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isFunction.js +11 -0
  182. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isLength.js +7 -0
  183. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isMap.js +7 -0
  184. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObject.js +7 -0
  185. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js +6 -0
  186. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isPlainObject.js +14 -0
  187. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSet.js +7 -0
  188. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSymbol.js +9 -0
  189. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js +7 -0
  190. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keys.js +9 -0
  191. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js +9 -0
  192. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/merge.js +8 -0
  193. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/now.js +7 -0
  194. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js +6 -0
  195. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js +6 -0
  196. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toNumber.js +19 -0
  197. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toPlainObject.js +8 -0
  198. package/dist/print/index.d.ts +16 -0
  199. package/dist/print/index.d.ts.map +1 -0
  200. package/dist/print/index.js +44 -0
  201. package/package.json +77 -0
  202. package/src/author/defaults.ts +168 -0
  203. package/src/author/index.ts +258 -0
  204. package/src/author/main.tsx +509 -0
  205. package/src/author/utils.ts +25 -0
  206. package/src/controller/defaults.ts +36 -0
  207. package/src/controller/index.ts +302 -0
  208. package/src/controller/utils.ts +22 -0
  209. package/src/delivery/choice-input.tsx +413 -0
  210. package/src/delivery/choice.tsx +203 -0
  211. package/src/delivery/feedback-tick.tsx +156 -0
  212. package/src/delivery/index.ts +411 -0
  213. package/src/delivery/main.tsx +81 -0
  214. package/src/delivery/multiple-choice.tsx +466 -0
  215. package/src/delivery/session-updater.ts +41 -0
  216. package/src/index.iife.ts +16 -0
  217. package/src/index.ts +1 -0
  218. package/src/print/index.tsx +112 -0
@@ -0,0 +1,44 @@
1
+ import e from "../delivery/main.js";
2
+ import t from "../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js";
3
+ import n from "../node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/debounce.js";
4
+ import r from "react";
5
+ import { createRoot as i } from "react-dom/client";
6
+ import a from "debug";
7
+ import { renderMath as o } from "@pie-element/shared-math-rendering-mathjax";
8
+ //#region src/print/index.tsx
9
+ var s = a("pie-element:multiple-choice:print"), c = (e, n) => {
10
+ let r = n.role === "instructor";
11
+ return e.prompt = e.promptEnabled === !1 ? void 0 : e.prompt, e.teacherInstructions = r && e.teacherInstructionsEnabled !== !1 ? e.teacherInstructions : void 0, e.showTeacherInstructions = r, e.alwaysShowCorrect = r, e.mode = r ? "evaluate" : e.mode, e.disabled = !0, e.animationsDisabled = !0, e.lockChoiceOrder = !0, e.choicesLayout = e.choicesLayout || "vertical", e.choices = t(e.choices).map((t) => (t.rationale = r && e.rationaleEnabled !== !1 ? t.rationale : void 0, t.hideTick = r, t.feedback = void 0, t)), e.keyMode = e.choicePrefix || "letters", e;
12
+ }, l = class extends HTMLElement {
13
+ constructor() {
14
+ super(), this._options = null, this._model = null, this._session = [], this._root = null, this._rerender = n(() => {
15
+ if (this._model && this._session) {
16
+ let t = c(this._model, this._options), n = this._options && r.createElement(e, {
17
+ model: t,
18
+ session: {},
19
+ options: this._options
20
+ });
21
+ this._root ||= i(this), this._root.render(n), requestAnimationFrame(() => {
22
+ requestAnimationFrame(() => {
23
+ s("render complete - render math"), o(this);
24
+ });
25
+ });
26
+ } else s("skip");
27
+ }, 50, {
28
+ leading: !1,
29
+ trailing: !0
30
+ });
31
+ }
32
+ set options(e) {
33
+ this._options = e;
34
+ }
35
+ set model(e) {
36
+ this._model = e, this._rerender();
37
+ }
38
+ connectedCallback() {}
39
+ disconnectedCallback() {
40
+ this._root && this._root.unmount();
41
+ }
42
+ };
43
+ //#endregion
44
+ export { l as default };
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "@pie-element/multiple-choice",
3
+ "version": "0.1.0",
4
+ "description": "React implementation of multiple-choice element synced from pie-elements",
5
+ "dependencies": {
6
+ "@emotion/react": "^11.14.0",
7
+ "@emotion/style": "^0.8.0",
8
+ "@mui/icons-material": "^7.3.4",
9
+ "@mui/material": "^7.3.4",
10
+ "@pie-lib/correct-answer-toggle": "0.1.0",
11
+ "@pie-lib/render-ui": "0.1.0",
12
+ "@pie-lib/translator": "0.1.0",
13
+ "classnames": "^2.2.5",
14
+ "debug": "^4.1.1",
15
+ "lodash-es": "^4.17.23",
16
+ "prop-types": "^15.8.1",
17
+ "react-transition-group": "^4.4.5",
18
+ "@pie-element/shared-configure-events": "0.1.0",
19
+ "@pie-lib/config-ui": "0.1.0",
20
+ "@pie-lib/editable-html-tip-tap": "0.1.0",
21
+ "@pie-element/shared-controller-utils": "0.1.0",
22
+ "@pie-element/shared-player-events": "0.1.0",
23
+ "@pie-element/shared-math-rendering-mathjax": "0.1.0"
24
+ },
25
+ "peerDependencies": {
26
+ "react": "^18.0.0",
27
+ "react-dom": "^18.0.0"
28
+ },
29
+ "exports": {
30
+ ".": {
31
+ "development": "./src/index.ts",
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "./delivery": {
36
+ "development": "./src/delivery/index.ts",
37
+ "types": "./dist/delivery/index.d.ts",
38
+ "default": "./dist/delivery/index.js"
39
+ },
40
+ "./author": {
41
+ "development": "./src/author/index.ts",
42
+ "types": "./dist/author/index.d.ts",
43
+ "default": "./dist/author/index.js"
44
+ },
45
+ "./controller": {
46
+ "development": "./src/controller/index.ts",
47
+ "types": "./dist/controller/index.d.ts",
48
+ "default": "./dist/controller/index.js"
49
+ },
50
+ "./print": {
51
+ "development": "./src/print/index.tsx",
52
+ "types": "./dist/print/index.d.ts",
53
+ "default": "./dist/print/index.js"
54
+ }
55
+ },
56
+ "type": "module",
57
+ "main": "./dist/index.js",
58
+ "types": "./dist/index.d.ts",
59
+ "files": [
60
+ "dist",
61
+ "src"
62
+ ],
63
+ "sideEffects": false,
64
+ "devDependencies": {
65
+ "vite": "^8.0.1",
66
+ "typescript": "^5.9.3",
67
+ "@vitejs/plugin-react": "^6.0.1",
68
+ "@types/react": "^18.2.0",
69
+ "@types/react-dom": "^18.2.0"
70
+ },
71
+ "scripts": {
72
+ "build": "bun x vite build && bun x vite build --config vite.config.iife.ts && bun x tsc --emitDeclarationOnly",
73
+ "dev": "bun x vite",
74
+ "demo": "bun x vite --mode demo",
75
+ "test": "bun x vitest run"
76
+ }
77
+ }
@@ -0,0 +1,168 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/multiple-choice/configure/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
+ /** NOTE: teacherInstructions, studentInstructions, rationale & scoringType
12
+ * functionalities are not defined yet - the value for those can belong to
13
+ * model or to configure
14
+ */
15
+ export default {
16
+ model: {
17
+ choiceMode: 'checkbox',
18
+ choicePrefix: 'letters',
19
+ choices: [],
20
+ choicesLayout: 'vertical',
21
+ feedbackEnabled: false,
22
+ gridColumns: 2,
23
+ lockChoiceOrder: true,
24
+ partialScoring: true,
25
+ prompt: '',
26
+ promptEnabled: true,
27
+ rationale: '',
28
+ rationaleEnabled: true,
29
+ scoringType: 'auto',
30
+ studentInstructionsEnabled: true,
31
+ teacherInstructions: '',
32
+ teacherInstructionsEnabled: true,
33
+ toolbarEditorPosition: 'bottom',
34
+ selectedAnswerBackgroundColor: 'initial',
35
+ keyboardEventsEnabled: false,
36
+ },
37
+ configuration: {
38
+ baseInputConfiguration: {
39
+ h3: { disabled: true },
40
+ audio: { disabled: false },
41
+ video: { disabled: false },
42
+ image: { disabled: false },
43
+ textAlign: { disabled: true },
44
+ showParagraphs: { disabled: false },
45
+ separateParagraphs: { disabled: true },
46
+ },
47
+ choices: {
48
+ inputConfiguration: {
49
+ audio: { disabled: false },
50
+ video: { disabled: false },
51
+ image: { disabled: false },
52
+ },
53
+ },
54
+ spellCheck: {
55
+ label: 'Spellcheck',
56
+ settings: false,
57
+ enabled: true,
58
+ },
59
+ choicesLayout: {
60
+ settings: false,
61
+ label: 'Choices Layout',
62
+ },
63
+ gridColumns: {
64
+ label: 'Grid columns',
65
+ },
66
+ answerChoiceCount: 0,
67
+ addChoiceButton: {
68
+ settings: true,
69
+ label: 'Add a Choice',
70
+ },
71
+ choiceMode: {
72
+ settings: true,
73
+ label: 'Response Type',
74
+ },
75
+ choicePrefix: {
76
+ settings: true,
77
+ label: 'Choice Labels',
78
+ },
79
+ deleteChoice: {
80
+ settings: true,
81
+ },
82
+ feedback: {
83
+ settings: true,
84
+ label: 'Feedback',
85
+ },
86
+ prompt: {
87
+ settings: true,
88
+ label: 'Prompt',
89
+ inputConfiguration: {
90
+ audio: { disabled: false },
91
+ video: { disabled: false },
92
+ image: { disabled: false },
93
+ },
94
+ required: false,
95
+ },
96
+ lockChoiceOrder: {
97
+ settings: true,
98
+ label: 'Lock Choice Order',
99
+ },
100
+ partialScoring: {
101
+ settings: false,
102
+ label: 'Allow Partial Scoring',
103
+ },
104
+ rationale: {
105
+ settings: true,
106
+ label: 'Rationale',
107
+ inputConfiguration: {
108
+ audio: { disabled: true },
109
+ video: { disabled: true },
110
+ image: { disabled: false },
111
+ },
112
+ required: false,
113
+ },
114
+ scoringType: {
115
+ settings: false,
116
+ label: 'Scoring Type',
117
+ },
118
+ studentInstructions: {
119
+ settings: false,
120
+ label: 'Student Instructions',
121
+ },
122
+ teacherInstructions: {
123
+ settings: true,
124
+ label: 'Teacher Instructions',
125
+ inputConfiguration: {
126
+ audio: { disabled: false },
127
+ video: { disabled: false },
128
+ image: { disabled: false },
129
+ },
130
+ required: false,
131
+ },
132
+ toolbarEditorPosition: {
133
+ settings: false,
134
+ label: 'Toolbar Editor Position',
135
+ },
136
+ minAnswerChoices: 2,
137
+ maxAnswerChoices: 5,
138
+ maxImageWidth: {
139
+ teacherInstructions: 300,
140
+ prompt: 300,
141
+ rationale: 636,
142
+ choices: 900,
143
+ },
144
+ maxImageHeight: {
145
+ teacherInstructions: 300,
146
+ prompt: 300,
147
+ rationale: 300,
148
+ choices: 300,
149
+ },
150
+ withRubric: {
151
+ settings: false,
152
+ label: 'Add Rubric',
153
+ },
154
+ mathMlOptions: {
155
+ mmlOutput: false,
156
+ mmlEditing: false,
157
+ },
158
+ language: {
159
+ settings: false,
160
+ label: 'Specify Language',
161
+ enabled: false,
162
+ },
163
+ languageChoices: {
164
+ label: 'Language Choices',
165
+ options: [],
166
+ },
167
+ },
168
+ };
@@ -0,0 +1,258 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/multiple-choice/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 {
15
+ DeleteImageEvent,
16
+ InsertImageEvent,
17
+ ModelUpdatedEvent,
18
+ InsertSoundEvent,
19
+ DeleteSoundEvent,
20
+ } from '@pie-element/shared-configure-events';
21
+
22
+ import Main from './main.js';
23
+ import { choiceUtils as utils } from '@pie-lib/config-ui';
24
+ import { defaults } from 'lodash-es';
25
+
26
+ import sensibleDefaults from './defaults.js';
27
+
28
+ const log = debug('multiple-choice:configure');
29
+
30
+ const generateFormattedChoices = (choices, choiceCount = 0) => {
31
+ if (!choices || choices.length === 0) {
32
+ let formattedChoices = [];
33
+
34
+ for (let i = 0; i < choiceCount; i++) {
35
+ formattedChoices.push({
36
+ value: `${i}`,
37
+ label: '',
38
+ feedback: {
39
+ type: 'none',
40
+ value: '',
41
+ },
42
+ });
43
+ }
44
+
45
+ return formattedChoices;
46
+ }
47
+
48
+ return choices;
49
+ };
50
+
51
+ const prepareCustomizationObject = (config, model) => {
52
+ const configuration = defaults(config, sensibleDefaults.configuration);
53
+
54
+ return {
55
+ configuration,
56
+ model: {
57
+ ...model,
58
+ choices: generateFormattedChoices(
59
+ (model && model.choices) || [],
60
+ configuration && configuration.answerChoiceCount,
61
+ ),
62
+ },
63
+ };
64
+ };
65
+
66
+ export default class MultipleChoice extends HTMLElement {
67
+ static createDefaultModel = (model = {}) => {
68
+ const normalizedModel = utils.normalizeChoices({
69
+ ...sensibleDefaults.model,
70
+ ...model,
71
+ choices: generateFormattedChoices((model && model.choices) || []),
72
+ });
73
+
74
+ // This is used for offering support for old models which have the property "verticalMode"
75
+ normalizedModel.choicesLayout =
76
+ model.choicesLayout || (model.verticalMode === false && 'horizontal') || sensibleDefaults.model.choicesLayout;
77
+
78
+ return normalizedModel;
79
+ };
80
+
81
+ constructor() {
82
+ super();
83
+ this._root = null;
84
+ this._reactContainer = null;
85
+ this._model = MultipleChoice.createDefaultModel();
86
+ this._configuration = sensibleDefaults.configuration;
87
+ this.onModelChanged = this.onModelChanged.bind(this);
88
+ this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
89
+ }
90
+
91
+ set model(s) {
92
+ this._model = MultipleChoice.createDefaultModel(s);
93
+
94
+ this._render();
95
+ }
96
+
97
+ set configuration(c) {
98
+ const info = prepareCustomizationObject(c, this._model);
99
+
100
+ this.onModelChanged(info.model);
101
+
102
+ const newConfiguration = {
103
+ ...sensibleDefaults.configuration,
104
+ ...info.configuration,
105
+ };
106
+ this._configuration = newConfiguration;
107
+
108
+ // if language:enabled is true, then the corresponding default item model should include a language value;
109
+ // if it is false, then the language field should be omitted from the item model.
110
+ // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
111
+ // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
112
+ if (newConfiguration?.language?.enabled) {
113
+ if (newConfiguration?.languageChoices?.options?.length) {
114
+ this._model.language = newConfiguration?.languageChoices.options[0].value;
115
+ }
116
+ } else if (newConfiguration.language.settings && this._model.language) {
117
+ this._configuration.language.enabled = true;
118
+
119
+ if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
120
+ this._configuration.languageChoices.options = [];
121
+ }
122
+
123
+ // check if the language is already included in the languageChoices.options array
124
+ // and if not, then add it.
125
+ if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) {
126
+ this._configuration.languageChoices.options.push({
127
+ value: this._model.language,
128
+ label: this._model.language,
129
+ });
130
+ }
131
+ } else {
132
+ delete this._model.language;
133
+ }
134
+
135
+ this._render();
136
+ }
137
+
138
+ set disableSidePanel(s) {
139
+ this._disableSidePanel = s;
140
+ this._render();
141
+ }
142
+
143
+ dispatchModelUpdated(reset) {
144
+ const resetValue = !!reset;
145
+
146
+ this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));
147
+ }
148
+
149
+ onModelChanged(m, reset) {
150
+ this._model = m;
151
+ this._render();
152
+
153
+ this.dispatchModelUpdated(reset);
154
+ }
155
+
156
+ onConfigurationChanged(c) {
157
+ this._configuration = prepareCustomizationObject(c, this._model).configuration;
158
+
159
+ if (this._model) {
160
+ this.onModelChanged(this._model);
161
+ }
162
+
163
+ this._render();
164
+ }
165
+
166
+ /** @param {done, progress, file} handler */
167
+ insertImage(handler) {
168
+ this.dispatchEvent(new InsertImageEvent(handler));
169
+ }
170
+
171
+ onDeleteImage(src, done) {
172
+ this.dispatchEvent(new DeleteImageEvent(src, done));
173
+ }
174
+
175
+ insertSound(handler) {
176
+ this.dispatchEvent(new InsertSoundEvent(handler));
177
+ }
178
+
179
+ onDeleteSound(src, done) {
180
+ this.dispatchEvent(new DeleteSoundEvent(src, done));
181
+ }
182
+
183
+ _render() {
184
+ console.log('🔧 [multiple-choice-configure] _render - Starting render');
185
+ console.log('🔧 [multiple-choice-configure] _render - Model:', this._model ? 'present' : 'missing');
186
+ console.log('🔧 [multiple-choice-configure] _render - Configuration:', this._configuration ? 'present' : 'missing');
187
+ console.log('🔧 [multiple-choice-configure] _render - Root exists:', !!this._root);
188
+ log('_render - Starting render');
189
+ log('_render - Model:', this._model ? 'present' : 'missing');
190
+ log('_render - Configuration:', this._configuration ? 'present' : 'missing');
191
+ log('_render - Root exists:', !!this._root);
192
+
193
+ try {
194
+ let element = React.createElement(Main, {
195
+ model: this._model,
196
+ configuration: this._configuration,
197
+ onModelChanged: this.onModelChanged,
198
+ onConfigurationChanged: this.onConfigurationChanged,
199
+ disableSidePanel: this._disableSidePanel,
200
+ imageSupport: {
201
+ add: this.insertImage.bind(this),
202
+ delete: this.onDeleteImage.bind(this),
203
+ },
204
+ uploadSoundSupport: {
205
+ add: this.insertSound.bind(this),
206
+ delete: this.onDeleteSound.bind(this),
207
+ },
208
+ });
209
+
210
+ if (!this._root) {
211
+ console.log('🔧 [multiple-choice-configure] _render - Creating React container');
212
+ log('_render - Creating React container');
213
+
214
+ // Create a container div for React to render into
215
+ this._reactContainer = document.createElement('div');
216
+ this._reactContainer.className = 'pie-configure-wrapper';
217
+ this.appendChild(this._reactContainer);
218
+
219
+ console.log('🔧 [multiple-choice-configure] _render - Creating new React root');
220
+ log('_render - Creating new React root');
221
+ this._root = createRoot(this._reactContainer);
222
+ console.log('✅ [multiple-choice-configure] _render - React root created successfully');
223
+ log('_render - React root created successfully');
224
+ }
225
+
226
+ console.log('🔧 [multiple-choice-configure] _render - Calling root.render()');
227
+ log('_render - Calling root.render()');
228
+ this._root.render(element);
229
+ console.log('✅ [multiple-choice-configure] _render - Render completed successfully');
230
+ log('_render - Render completed successfully');
231
+ } catch (error) {
232
+ console.error('❌ [multiple-choice-configure] Render error:', error);
233
+ console.error('Error stack:', error.stack);
234
+ throw error;
235
+ }
236
+ }
237
+
238
+ connectedCallback() {
239
+ console.log('🔧 [multiple-choice-configure] connectedCallback - Component connected to DOM');
240
+ log('connectedCallback - Component connected to DOM');
241
+ log('connectedCallback - Model:', this._model ? 'present' : 'missing');
242
+ log('connectedCallback - Configuration:', this._configuration ? 'present' : 'missing');
243
+ }
244
+
245
+ disconnectedCallback() {
246
+ console.log('🔧 [multiple-choice-configure] disconnectedCallback - Component disconnected from DOM');
247
+ log('disconnectedCallback - Component disconnected from DOM');
248
+ if (this._root) {
249
+ console.log('🔧 [multiple-choice-configure] disconnectedCallback - Unmounting React root');
250
+ log('disconnectedCallback - Unmounting React root');
251
+ this._root.unmount();
252
+ this._root = null;
253
+ }
254
+ if (this._reactContainer) {
255
+ this._reactContainer = null;
256
+ }
257
+ }
258
+ }