@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,466 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/multiple-choice/src/multiple-choice.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 React from 'react';
12
+ import PropTypes from 'prop-types';
13
+ import CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';
14
+ import classNames from 'classnames';
15
+ import { styled } from '@mui/material/styles';
16
+ import Box from '@mui/material/Box';
17
+ import { color, Collapsible as CollapsibleImport, PreviewPrompt as PreviewPromptImport } from '@pie-lib/render-ui';
18
+
19
+ function isRenderableReactInteropType(value: any) {
20
+ return (
21
+ typeof value === 'function' ||
22
+ (typeof value === 'object' && value !== null && typeof value.$$typeof === 'symbol')
23
+ );
24
+ }
25
+
26
+ function unwrapReactInteropSymbol(maybeSymbol: any, namedExport?: string) {
27
+ if (!maybeSymbol) return maybeSymbol;
28
+ if (isRenderableReactInteropType(maybeSymbol)) return maybeSymbol;
29
+ if (isRenderableReactInteropType(maybeSymbol.default)) return maybeSymbol.default;
30
+ if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport])) {
31
+ return maybeSymbol[namedExport];
32
+ }
33
+ if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport]?.default)) {
34
+ return maybeSymbol[namedExport].default;
35
+ }
36
+ return maybeSymbol;
37
+ }
38
+ const PreviewPrompt = unwrapReactInteropSymbol(PreviewPromptImport, 'PreviewPrompt') || unwrapReactInteropSymbol(renderUi.PreviewPrompt, 'PreviewPrompt');
39
+ const Collapsible = unwrapReactInteropSymbol(CollapsibleImport, 'Collapsible') || unwrapReactInteropSymbol(renderUi.Collapsible, 'Collapsible');
40
+ import * as RenderUiNamespace from '@pie-lib/render-ui';
41
+ const renderUiNamespaceAny = RenderUiNamespace as any;
42
+ const renderUiDefaultMaybe = renderUiNamespaceAny['default'];
43
+ const renderUi =
44
+ renderUiDefaultMaybe && typeof renderUiDefaultMaybe === 'object'
45
+ ? renderUiDefaultMaybe
46
+ : renderUiNamespaceAny;
47
+ import Translator from '@pie-lib/translator';
48
+
49
+ import Choice from './choice.js';
50
+
51
+ const { translator } = Translator;
52
+
53
+ const MainContainer: any = styled(Box)({
54
+ color: color.text(),
55
+ backgroundColor: color.background(),
56
+ '& *': {
57
+ '-webkit-font-smoothing': 'antialiased',
58
+ },
59
+ position: 'relative',
60
+ // remove border from legend tags inside main to override the OT default styles
61
+ '& legend': {
62
+ border: 'none !important',
63
+ },
64
+ });
65
+
66
+ const PartLabel: any = styled('h2')(({ theme }) => ({
67
+ display: 'block',
68
+ fontSize: 'inherit',
69
+ margin: '0',
70
+ fontWeight: 'normal',
71
+ paddingBottom: theme.spacing(2),
72
+ }));
73
+
74
+ const TeacherInstructions: any = styled(Box)(({ theme }) => ({
75
+ marginBottom: theme.spacing(2),
76
+ }));
77
+
78
+ const HorizontalLayout: any = styled(Box)({
79
+ display: 'flex',
80
+ flexDirection: 'row',
81
+ flexWrap: 'wrap',
82
+ });
83
+
84
+ const GridLayout: any = styled(Box)({
85
+ display: 'grid',
86
+ });
87
+
88
+ const StyledFieldset: any = styled('fieldset')({
89
+ border: '0px',
90
+ padding: '0.01em 0 0 0',
91
+ margin: '0px',
92
+ minWidth: '0px',
93
+ '&:focus': {
94
+ outline: 'none',
95
+ },
96
+ });
97
+
98
+ const SrOnly: any = styled('h3')({
99
+ position: 'absolute',
100
+ left: '-10000px',
101
+ top: 'auto',
102
+ width: '1px',
103
+ height: '1px',
104
+ overflow: 'hidden',
105
+ });
106
+
107
+ const ErrorText: any = styled('div')(({ theme }) => ({
108
+ fontSize: theme.typography.fontSize - 2,
109
+ color: theme.palette.error.main,
110
+ paddingTop: theme.spacing(1),
111
+ }));
112
+
113
+ export class MultipleChoice extends React.Component {
114
+ static propTypes = {
115
+ className: PropTypes.string,
116
+ mode: PropTypes.oneOf(['gather', 'view', 'evaluate']),
117
+ choiceMode: PropTypes.oneOf(['radio', 'checkbox']),
118
+ keyMode: PropTypes.oneOf(['numbers', 'letters', 'none']),
119
+ choices: PropTypes.array,
120
+ partLabel: PropTypes.string,
121
+ prompt: PropTypes.string,
122
+ teacherInstructions: PropTypes.string,
123
+ session: PropTypes.object,
124
+ disabled: PropTypes.bool,
125
+ onChoiceChanged: PropTypes.func,
126
+ responseCorrect: PropTypes.bool,
127
+ correctResponse: PropTypes.array,
128
+ choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),
129
+ gridColumns: PropTypes.string,
130
+ alwaysShowCorrect: PropTypes.bool,
131
+ animationsDisabled: PropTypes.bool,
132
+ language: PropTypes.string,
133
+ selectedAnswerBackgroundColor: PropTypes.string,
134
+ selectedAnswerStrokeColor: PropTypes.string,
135
+ selectedAnswerStrokeWidth: PropTypes.string,
136
+ hoverAnswerBackgroundColor: PropTypes.string,
137
+ hoverAnswerStrokeColor: PropTypes.string,
138
+ hoverAnswerStrokeWidth: PropTypes.string,
139
+ onShowCorrectToggle: PropTypes.func,
140
+ isSelectionButtonBelow: PropTypes.bool,
141
+ minSelections: PropTypes.number,
142
+ maxSelections: PropTypes.number,
143
+ autoplayAudioEnabled: PropTypes.bool,
144
+ customAudioButton: {
145
+ playImage: PropTypes.string,
146
+ pauseImage: PropTypes.string,
147
+ },
148
+ options: PropTypes.object,
149
+ };
150
+
151
+ constructor(props) {
152
+ super(props);
153
+
154
+ this.state = {
155
+ showCorrect: (this.props.options && this.props.alwaysShowCorrect) || false,
156
+ maxSelectionsErrorState: false,
157
+ };
158
+
159
+ this.onToggle = this.onToggle.bind(this);
160
+ this.firstInputRef = React.createRef();
161
+ }
162
+
163
+ isSelected(value) {
164
+ const sessionValue = this.props.session && this.props.session.value;
165
+
166
+ return sessionValue && sessionValue.indexOf && sessionValue.indexOf(value) >= 0;
167
+ }
168
+
169
+ // handleChange was added for accessibility. Please see comments and videos from PD-2441.
170
+ handleChange: any = (event) => {
171
+ const { value, checked } = event.target;
172
+ const { maxSelections, onChoiceChanged, session } = this.props;
173
+
174
+ if (session.value && session.value.length >= maxSelections) {
175
+ // show/hide max selections error when user select/deselect an answer
176
+ this.setState({ maxSelectionsErrorState: checked });
177
+
178
+ if (checked) {
179
+ // prevent selecting more answers
180
+ return;
181
+ }
182
+ }
183
+
184
+ onChoiceChanged({ value, selected: checked, selector: 'Mouse' });
185
+ };
186
+
187
+ onToggle: any = () => {
188
+ if (this.props.mode === 'evaluate') {
189
+ this.setState({ showCorrect: !this.state.showCorrect }, () => {
190
+ if (this.props.onShowCorrectToggle) {
191
+ this.props.onShowCorrectToggle();
192
+ }
193
+ });
194
+ }
195
+ };
196
+
197
+ UNSAFE_componentWillReceiveProps(nextProps) {
198
+ if (!nextProps.correctResponse && this.state.showCorrect !== false) {
199
+ this.setState({ showCorrect: false }, () => {
200
+ if (this.props.onShowCorrectToggle) {
201
+ this.props.onShowCorrectToggle();
202
+ }
203
+ });
204
+ }
205
+
206
+ if (nextProps.options && nextProps.alwaysShowCorrect && this.state.showCorrect !== true) {
207
+ this.setState({ showCorrect: true }, () => {
208
+ if (this.props.onShowCorrectToggle) {
209
+ this.props.onShowCorrectToggle();
210
+ }
211
+ });
212
+ }
213
+ }
214
+
215
+ indexToSymbol(index) {
216
+ if (this.props.keyMode === 'numbers') {
217
+ return `${index + 1}`;
218
+ }
219
+
220
+ if (this.props.keyMode === 'letters') {
221
+ return String.fromCharCode(97 + index).toUpperCase();
222
+ }
223
+
224
+ return '';
225
+ }
226
+
227
+ getCorrectness: any = (choice = {}) => {
228
+ const isCorrect = choice.correct;
229
+ const isChecked = this.isSelected(choice.value);
230
+
231
+ if (this.state.showCorrect) {
232
+ return isCorrect ? 'correct' : undefined;
233
+ }
234
+
235
+ if (isCorrect) {
236
+ if (isChecked) {
237
+ // A correct answer is selected: marked with a green checkmark
238
+ return 'correct';
239
+ } else {
240
+ // A correct answer is NOT selected: marked with an orange X
241
+ return 'incorrect';
242
+ }
243
+ } else {
244
+ if (isChecked) {
245
+ // An incorrect answer is selected: marked with an orange X
246
+ return 'incorrect';
247
+ } else {
248
+ // An incorrect answer is NOT selected: not marked
249
+ return undefined;
250
+ }
251
+ }
252
+ };
253
+
254
+ getChecked(choice) {
255
+ // check for print context: options prop is passed from print.js and alwaysShowCorrect is true
256
+ const isPrintMode = this.props.options && this.props.alwaysShowCorrect;
257
+
258
+ if (isPrintMode) {
259
+ return choice.correct || false;
260
+ }
261
+
262
+ // evaluate mode with show correct toggled
263
+ const isEvaluateMode = this.state.showCorrect && this.props.mode === 'evaluate';
264
+
265
+ if (isEvaluateMode) {
266
+ return choice.correct || false;
267
+ }
268
+
269
+ // default behavior: show what the user has selected
270
+ return this.isSelected(choice.value);
271
+ }
272
+
273
+ // renderHeading function was added for accessibility.
274
+ renderHeading() {
275
+ const { mode, choiceMode } = this.props;
276
+
277
+ if (mode !== 'gather') {
278
+ return null;
279
+ }
280
+
281
+ return choiceMode === 'radio' ? (
282
+ <SrOnly>Multiple Choice Question</SrOnly>
283
+ ) : (
284
+ <SrOnly>Multiple Select Question</SrOnly>
285
+ );
286
+ }
287
+
288
+ handleGroupFocus: any = (e) => {
289
+ const fieldset = e.currentTarget;
290
+ const activeEl = document.activeElement;
291
+
292
+ if (fieldset.contains(activeEl) && activeEl !== fieldset) {
293
+ return;
294
+ }
295
+
296
+ // Only focus the first input if user is tabbing forward
297
+ if (!e.relatedTarget || fieldset.compareDocumentPosition(e.relatedTarget) & Node.DOCUMENT_POSITION_PRECEDING) {
298
+ if (this.firstInputRef?.current) {
299
+ this.firstInputRef.current.focus();
300
+ }
301
+ }
302
+ };
303
+
304
+ render() {
305
+ const {
306
+ mode,
307
+ disabled,
308
+ className,
309
+ choices = [],
310
+ choiceMode,
311
+ gridColumns,
312
+ partLabel,
313
+ prompt,
314
+ responseCorrect,
315
+ teacherInstructions,
316
+ alwaysShowCorrect,
317
+ animationsDisabled,
318
+ language,
319
+ isSelectionButtonBelow,
320
+ minSelections,
321
+ maxSelections,
322
+ autoplayAudioEnabled,
323
+ session,
324
+ customAudioButton,
325
+ options,
326
+ } = this.props;
327
+ const { showCorrect, maxSelectionsErrorState } = this.state;
328
+ const isEvaluateMode = mode === 'evaluate';
329
+ const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;
330
+ const columnsStyle = gridColumns > 1 ? { gridTemplateColumns: `repeat(${gridColumns}, 1fr)` } : undefined;
331
+ const selections = (session.value && session.value.length) || 0;
332
+
333
+ const teacherInstructionsDiv = (
334
+ <PreviewPrompt
335
+ tagName="div"
336
+ className="prompt"
337
+ defaultClassName="teacher-instructions"
338
+ prompt={teacherInstructions}
339
+ />
340
+ );
341
+
342
+ const getMultipleChoiceMinSelectionErrorMessage = () => {
343
+ if (minSelections && maxSelections) {
344
+ return minSelections === maxSelections
345
+ ? translator.t('translation:multipleChoice:minmaxSelections_equal', { lng: language, minSelections })
346
+ : translator.t('translation:multipleChoice:minmaxSelections_range', {
347
+ lng: language,
348
+ minSelections,
349
+ maxSelections,
350
+ });
351
+ }
352
+
353
+ if (minSelections) {
354
+ return translator.t('translation:multipleChoice:minSelections', { lng: language, minSelections });
355
+ }
356
+
357
+ return '';
358
+ };
359
+
360
+ const LayoutComponent = this.props.choicesLayout === 'grid'
361
+ ? GridLayout
362
+ : this.props.choicesLayout === 'horizontal'
363
+ ? HorizontalLayout
364
+ : Box;
365
+
366
+ return (
367
+ <MainContainer id={'main-container'} className={classNames(className, 'multiple-choice')}>
368
+ {partLabel && <PartLabel>{partLabel}</PartLabel>}
369
+
370
+ {this.renderHeading()}
371
+
372
+ {teacherInstructions && (
373
+ <TeacherInstructions>
374
+ {!animationsDisabled ? (
375
+ <Collapsible
376
+ labels={{
377
+ hidden: 'Show Teacher Instructions',
378
+ visible: 'Hide Teacher Instructions',
379
+ }}
380
+ >
381
+ {teacherInstructionsDiv}
382
+ </Collapsible>
383
+ ) : (
384
+ teacherInstructionsDiv
385
+ )}
386
+ </TeacherInstructions>
387
+ )}
388
+
389
+ <StyledFieldset
390
+ tabIndex={0}
391
+ onFocus={this.handleGroupFocus}
392
+ role={choiceMode === 'radio' ? 'radiogroup' : 'group'}
393
+ >
394
+ <PreviewPrompt
395
+ className="prompt"
396
+ defaultClassName="prompt"
397
+ prompt={prompt}
398
+ tagName={'legend'}
399
+ autoplayAudioEnabled={autoplayAudioEnabled}
400
+ customAudioButton={customAudioButton}
401
+ />
402
+
403
+ {!(options && alwaysShowCorrect) && (
404
+ <CorrectAnswerToggle
405
+ show={showCorrectAnswerToggle}
406
+ toggled={showCorrect}
407
+ onToggle={this.onToggle.bind(this)}
408
+ language={language}
409
+ />
410
+ )}
411
+
412
+ <LayoutComponent style={columnsStyle}>
413
+ {choices.map((choice, index) => (
414
+ <Choice
415
+ autoFocusRef={index === 0 ? this.firstInputRef : null}
416
+ choicesLayout={this.props.choicesLayout}
417
+ selectedAnswerBackgroundColor={this.props.selectedAnswerBackgroundColor}
418
+ selectedAnswerStrokeColor={this.props.selectedAnswerStrokeColor}
419
+ selectedAnswerStrokeWidth={this.props.selectedAnswerStrokeWidth}
420
+ hoverAnswerBackgroundColor={this.props.hoverAnswerBackgroundColor}
421
+ hoverAnswerStrokeColor={this.props.hoverAnswerStrokeColor}
422
+ hoverAnswerStrokeWidth={this.props.hoverAnswerStrokeWidth}
423
+ gridColumns={gridColumns}
424
+ key={`choice-${index}`}
425
+ choice={choice}
426
+ index={index}
427
+ choicesLength={choices.length}
428
+ showCorrect={showCorrect}
429
+ isEvaluateMode={isEvaluateMode}
430
+ choiceMode={choiceMode}
431
+ disabled={disabled}
432
+ tagName={partLabel ? `group-${partLabel}` : 'group'}
433
+ onChoiceChanged={this.handleChange}
434
+ hideTick={choice.hideTick}
435
+ checked={this.getChecked(choice)}
436
+ correctness={isEvaluateMode ? this.getCorrectness(choice) : undefined}
437
+ displayKey={this.indexToSymbol(index)}
438
+ isSelectionButtonBelow={isSelectionButtonBelow}
439
+ />
440
+ ))}
441
+ </LayoutComponent>
442
+ </StyledFieldset>
443
+
444
+ {choiceMode === 'checkbox' && selections < minSelections && (
445
+ <ErrorText>{getMultipleChoiceMinSelectionErrorMessage()}</ErrorText>
446
+ )}
447
+ {choiceMode === 'checkbox' && maxSelectionsErrorState && (
448
+ <ErrorText>
449
+ {translator.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {
450
+ lng: language,
451
+ maxSelections,
452
+ })}
453
+ </ErrorText>
454
+ )}
455
+ </MainContainer>
456
+ );
457
+ }
458
+ }
459
+
460
+ MultipleChoice.defaultProps = {
461
+ session: {
462
+ value: [],
463
+ },
464
+ };
465
+
466
+ export default MultipleChoice;
@@ -0,0 +1,41 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/multiple-choice/src/session-updater.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 function updateSessionValue(session, choiceMode, data) {
12
+ session.value = session.value || [];
13
+ if (choiceMode === 'checkbox') {
14
+ if (data.selected) {
15
+ session.value = Array.from(new Set([...session.value, data.value]));
16
+ } else {
17
+ session.value = session.value.filter(v => v !== data.value);
18
+ }
19
+ }
20
+
21
+ if (choiceMode === 'radio') {
22
+ if (data.selected) {
23
+ session.value = [data.value];
24
+ } else {
25
+ session.value = [];
26
+ }
27
+ }
28
+
29
+ //update session value metadata
30
+ session.selector = data.selector; //the input method used to select the choice (e.g. mouse, keyboard)
31
+ }
32
+
33
+ export function updateSessionMetadata(session, metadata) {
34
+ session.audioStartTime = session.audioStartTime || metadata.audioStartTime; //timestamp when auto-played audio started playing
35
+ session.audioEndTime = session.audioEndTime || metadata.audioEndTime; //timestamp when auto-played audio completed playing
36
+
37
+ if(!session.waitTime && session.audioStartTime && session.audioEndTime) {
38
+ // waitTime is elapsed time the user waited for auto-played audio to finish
39
+ session.waitTime = (session.audioEndTime - session.audioStartTime);
40
+ }
41
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * IIFE entry point for multiple-choice element
3
+ * This file is only used for IIFE builds and includes auto-registration
4
+ *
5
+ * @sync-generated - Auto-generated during sync from pie-elements
6
+ */
7
+
8
+ import Element from './index.js';
9
+
10
+ // Auto-register the custom element for IIFE mode
11
+ if (typeof window !== 'undefined' && !customElements.get('multiple-choice-element')) {
12
+ customElements.define('multiple-choice-element', Element);
13
+ }
14
+
15
+ // Export for IIFE global
16
+ export default Element;
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { default } from './delivery/index.js';
@@ -0,0 +1,112 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/multiple-choice/src/print.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 { cloneDeep, debounce } from 'lodash-es';
14
+ import Main from '../delivery/main.js';
15
+ import { renderMath } from '@pie-element/shared-math-rendering-mathjax';
16
+ import debug from 'debug';
17
+
18
+ const log = debug('pie-element:multiple-choice:print');
19
+
20
+ /**
21
+ * Live in same package as main element - so we can access some of the shared comps!
22
+ *
23
+ * - update pslb to build print if src/print.js is there
24
+ * - update demo el
25
+ * - get configure/controller building
26
+ */
27
+
28
+ const preparePrintModel = (model, opts) => {
29
+ const instr = opts.role === 'instructor';
30
+
31
+ model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
32
+ model.teacherInstructions =
33
+ instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
34
+ model.showTeacherInstructions = instr;
35
+ model.alwaysShowCorrect = instr;
36
+ model.mode = instr ? 'evaluate' : model.mode;
37
+
38
+ model.disabled = true;
39
+ model.animationsDisabled = true;
40
+ model.lockChoiceOrder = true;
41
+ model.choicesLayout = model.choicesLayout || 'vertical';
42
+
43
+ const choices = cloneDeep(model.choices);
44
+
45
+ model.choices = choices.map((c) => {
46
+ c.rationale = instr && model.rationaleEnabled !== false ? c.rationale : undefined;
47
+ c.hideTick = instr;
48
+ c.feedback = undefined;
49
+ return c;
50
+ });
51
+
52
+ model.keyMode = model.choicePrefix || 'letters';
53
+
54
+ return model;
55
+ };
56
+
57
+ export default class MultipleChoicePrint extends HTMLElement {
58
+ constructor() {
59
+ super();
60
+ this._options = null;
61
+ this._model = null;
62
+ this._session = [];
63
+ this._root = null;
64
+ this._rerender = debounce(
65
+ () => {
66
+ if (this._model && this._session) {
67
+ const printModel = preparePrintModel(this._model, this._options);
68
+
69
+ const element =
70
+ this._options &&
71
+ React.createElement(Main, {
72
+ model: printModel,
73
+ session: {},
74
+ options: this._options,
75
+ });
76
+
77
+ if (!this._root) {
78
+ this._root = createRoot(this);
79
+ }
80
+ this._root.render(element);
81
+ // Use double requestAnimationFrame so React has committed to the DOM before we render math
82
+ requestAnimationFrame(() => {
83
+ requestAnimationFrame(() => {
84
+ log('render complete - render math');
85
+ renderMath(this);
86
+ });
87
+ });
88
+ } else {
89
+ log('skip');
90
+ }
91
+ },
92
+ 50,
93
+ { leading: false, trailing: true },
94
+ );
95
+ }
96
+ set options(o) {
97
+ this._options = o;
98
+ }
99
+
100
+ set model(s) {
101
+ this._model = s;
102
+ this._rerender();
103
+ }
104
+
105
+ connectedCallback() {}
106
+
107
+ disconnectedCallback() {
108
+ if (this._root) {
109
+ this._root.unmount();
110
+ }
111
+ }
112
+ }