@pie-element/ebsr 11.0.0 → 12.0.1-esmbeta.1

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 (284) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/configure/CHANGELOG.md +8 -0
  3. package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.json +1972 -0
  4. package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.md +4186 -0
  5. package/configure/node_modules/@pie-element/multiple-choice/LICENSE.md +5 -0
  6. package/configure/node_modules/@pie-element/multiple-choice/PRINT.md +35 -0
  7. package/configure/node_modules/@pie-element/multiple-choice/README.md +56 -0
  8. package/configure/node_modules/@pie-element/multiple-choice/choice.png +0 -0
  9. package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.json +1387 -0
  10. package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.md +3332 -0
  11. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js +202 -0
  12. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js.map +1 -0
  13. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js +248 -0
  14. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js.map +1 -0
  15. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js +597 -0
  16. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js.map +1 -0
  17. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js +18 -0
  18. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js.map +1 -0
  19. package/configure/node_modules/@pie-element/multiple-choice/configure/package.json +20 -0
  20. package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.json +527 -0
  21. package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.md +2297 -0
  22. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js +34 -0
  23. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js.map +1 -0
  24. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js +346 -0
  25. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js.map +1 -0
  26. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js +28 -0
  27. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js.map +1 -0
  28. package/configure/node_modules/@pie-element/multiple-choice/controller/package.json +15 -0
  29. package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json +2993 -0
  30. package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json.md +2217 -0
  31. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/config.js +8 -0
  32. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/generate.js +61 -0
  33. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/index.html +1 -0
  34. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/session.js +7 -0
  35. package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json +1332 -0
  36. package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json.md +1015 -0
  37. package/configure/node_modules/@pie-element/multiple-choice/esm/configure.css +847 -0
  38. package/configure/node_modules/@pie-element/multiple-choice/esm/configure.js +1218 -0
  39. package/configure/node_modules/@pie-element/multiple-choice/esm/configure.js.map +1 -0
  40. package/configure/node_modules/@pie-element/multiple-choice/esm/controller.css +847 -0
  41. package/configure/node_modules/@pie-element/multiple-choice/esm/controller.js +324 -0
  42. package/configure/node_modules/@pie-element/multiple-choice/esm/controller.js.map +1 -0
  43. package/configure/node_modules/@pie-element/multiple-choice/esm/element.css +847 -0
  44. package/configure/node_modules/@pie-element/multiple-choice/esm/element.js +3287 -0
  45. package/configure/node_modules/@pie-element/multiple-choice/esm/element.js.map +1 -0
  46. package/configure/node_modules/@pie-element/multiple-choice/esm/print.css +847 -0
  47. package/configure/node_modules/@pie-element/multiple-choice/esm/print.js +3017 -0
  48. package/configure/node_modules/@pie-element/multiple-choice/esm/print.js.map +1 -0
  49. package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js +427 -0
  50. package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js.map +1 -0
  51. package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js +252 -0
  52. package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js.map +1 -0
  53. package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js +174 -0
  54. package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js.map +1 -0
  55. package/configure/node_modules/@pie-element/multiple-choice/lib/index.js +388 -0
  56. package/configure/node_modules/@pie-element/multiple-choice/lib/index.js.map +1 -0
  57. package/configure/node_modules/@pie-element/multiple-choice/lib/main.js +108 -0
  58. package/configure/node_modules/@pie-element/multiple-choice/lib/main.js.map +1 -0
  59. package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js +469 -0
  60. package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js.map +1 -0
  61. package/configure/node_modules/@pie-element/multiple-choice/lib/print.js +129 -0
  62. package/configure/node_modules/@pie-element/multiple-choice/lib/print.js.map +1 -0
  63. package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js +48 -0
  64. package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js.map +1 -0
  65. package/configure/node_modules/@pie-element/multiple-choice/module/configure.js +1 -0
  66. package/configure/node_modules/@pie-element/multiple-choice/module/controller.js +3472 -0
  67. package/configure/node_modules/@pie-element/multiple-choice/module/demo.js +86 -0
  68. package/configure/node_modules/@pie-element/multiple-choice/module/element.js +1 -0
  69. package/configure/node_modules/@pie-element/multiple-choice/module/index.html +21 -0
  70. package/configure/node_modules/@pie-element/multiple-choice/module/index.js +2 -0
  71. package/configure/node_modules/@pie-element/multiple-choice/module/manifest.json +10 -0
  72. package/configure/node_modules/@pie-element/multiple-choice/module/print-demo.js +124 -0
  73. package/configure/node_modules/@pie-element/multiple-choice/module/print.html +18 -0
  74. package/configure/node_modules/@pie-element/multiple-choice/module/print.js +1 -0
  75. package/configure/node_modules/@pie-element/multiple-choice/package.json +53 -0
  76. package/configure/node_modules/@pie-lib/correct-answer-toggle/CHANGELOG.json +1 -0
  77. package/configure/node_modules/@pie-lib/correct-answer-toggle/CHANGELOG.md +898 -0
  78. package/configure/node_modules/@pie-lib/correct-answer-toggle/NEXT.CHANGELOG.json +1 -0
  79. package/configure/node_modules/@pie-lib/correct-answer-toggle/esm/index.js +262 -0
  80. package/configure/node_modules/@pie-lib/correct-answer-toggle/esm/index.js.map +1 -0
  81. package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/expander.js +88 -0
  82. package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/expander.js.map +1 -0
  83. package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/index.js +181 -0
  84. package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/index.js.map +1 -0
  85. package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/styles.js +66 -0
  86. package/configure/node_modules/@pie-lib/correct-answer-toggle/lib/styles.js.map +1 -0
  87. package/configure/node_modules/@pie-lib/correct-answer-toggle/package.json +44 -0
  88. package/configure/node_modules/@pie-lib/correct-answer-toggle/src/__tests__/index.test.jsx +99 -0
  89. package/configure/node_modules/@pie-lib/correct-answer-toggle/src/expander.jsx +61 -0
  90. package/configure/node_modules/@pie-lib/correct-answer-toggle/src/index.jsx +98 -0
  91. package/configure/node_modules/@pie-lib/correct-answer-toggle/src/styles.js +61 -0
  92. package/configure/node_modules/@pie-lib/icons/CHANGELOG.json +1 -0
  93. package/configure/node_modules/@pie-lib/icons/CHANGELOG.md +539 -0
  94. package/configure/node_modules/@pie-lib/icons/NEXT.CHANGELOG.json +1 -0
  95. package/configure/node_modules/@pie-lib/icons/esm/index.js +1153 -0
  96. package/configure/node_modules/@pie-lib/icons/esm/index.js.map +1 -0
  97. package/configure/node_modules/@pie-lib/icons/lib/correct-icon.js +89 -0
  98. package/configure/node_modules/@pie-lib/icons/lib/correct-icon.js.map +1 -0
  99. package/configure/node_modules/@pie-lib/icons/lib/correct-response-icon.js +153 -0
  100. package/configure/node_modules/@pie-lib/icons/lib/correct-response-icon.js.map +1 -0
  101. package/configure/node_modules/@pie-lib/icons/lib/icon-base.js +206 -0
  102. package/configure/node_modules/@pie-lib/icons/lib/icon-base.js.map +1 -0
  103. package/configure/node_modules/@pie-lib/icons/lib/icon-root.js +130 -0
  104. package/configure/node_modules/@pie-lib/icons/lib/icon-root.js.map +1 -0
  105. package/configure/node_modules/@pie-lib/icons/lib/incorrect-icon.js +92 -0
  106. package/configure/node_modules/@pie-lib/icons/lib/incorrect-icon.js.map +1 -0
  107. package/configure/node_modules/@pie-lib/icons/lib/index.js +72 -0
  108. package/configure/node_modules/@pie-lib/icons/lib/index.js.map +1 -0
  109. package/configure/node_modules/@pie-lib/icons/lib/instructions-icon.js +229 -0
  110. package/configure/node_modules/@pie-lib/icons/lib/instructions-icon.js.map +1 -0
  111. package/configure/node_modules/@pie-lib/icons/lib/learn-more-icon.js +145 -0
  112. package/configure/node_modules/@pie-lib/icons/lib/learn-more-icon.js.map +1 -0
  113. package/configure/node_modules/@pie-lib/icons/lib/nothing-submitted-icon.js +183 -0
  114. package/configure/node_modules/@pie-lib/icons/lib/nothing-submitted-icon.js.map +1 -0
  115. package/configure/node_modules/@pie-lib/icons/lib/partially-correct-icon.js +82 -0
  116. package/configure/node_modules/@pie-lib/icons/lib/partially-correct-icon.js.map +1 -0
  117. package/configure/node_modules/@pie-lib/icons/lib/show-rationale-icon.js +206 -0
  118. package/configure/node_modules/@pie-lib/icons/lib/show-rationale-icon.js.map +1 -0
  119. package/configure/node_modules/@pie-lib/icons/lib/sized.js +41 -0
  120. package/configure/node_modules/@pie-lib/icons/lib/sized.js.map +1 -0
  121. package/configure/node_modules/@pie-lib/icons/package.json +35 -0
  122. package/configure/node_modules/@pie-lib/icons/src/__tests__/index.test.js +3 -0
  123. package/configure/node_modules/@pie-lib/icons/src/correct-icon.jsx +64 -0
  124. package/configure/node_modules/@pie-lib/icons/src/correct-response-icon.jsx +121 -0
  125. package/configure/node_modules/@pie-lib/icons/src/icon-base.jsx +158 -0
  126. package/configure/node_modules/@pie-lib/icons/src/icon-root.jsx +76 -0
  127. package/configure/node_modules/@pie-lib/icons/src/incorrect-icon.jsx +61 -0
  128. package/configure/node_modules/@pie-lib/icons/src/index.js +19 -0
  129. package/configure/node_modules/@pie-lib/icons/src/instructions-icon.jsx +189 -0
  130. package/configure/node_modules/@pie-lib/icons/src/learn-more-icon.jsx +107 -0
  131. package/configure/node_modules/@pie-lib/icons/src/nothing-submitted-icon.jsx +130 -0
  132. package/configure/node_modules/@pie-lib/icons/src/partially-correct-icon.jsx +49 -0
  133. package/configure/node_modules/@pie-lib/icons/src/show-rationale-icon.jsx +152 -0
  134. package/configure/node_modules/@pie-lib/icons/src/sized.jsx +25 -0
  135. package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.json +1 -0
  136. package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.md +775 -0
  137. package/configure/node_modules/@pie-lib/math-rendering/NEXT.CHANGELOG.json +1 -0
  138. package/configure/node_modules/@pie-lib/math-rendering/esm/index.js +690 -0
  139. package/configure/node_modules/@pie-lib/math-rendering/esm/index.js.map +1 -0
  140. package/configure/node_modules/@pie-lib/math-rendering/lib/index.js +38 -0
  141. package/configure/node_modules/@pie-lib/math-rendering/lib/index.js.map +1 -0
  142. package/configure/node_modules/@pie-lib/math-rendering/lib/mml-to-latex.js +15 -0
  143. package/configure/node_modules/@pie-lib/math-rendering/lib/mml-to-latex.js.map +1 -0
  144. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js +296 -0
  145. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js.map +1 -0
  146. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js +23 -0
  147. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js.map +1 -0
  148. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js +109 -0
  149. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js.map +1 -0
  150. package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js +95 -0
  151. package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js.map +1 -0
  152. package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js +438 -0
  153. package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js.map +1 -0
  154. package/configure/node_modules/@pie-lib/math-rendering/package.json +28 -0
  155. package/configure/node_modules/@pie-lib/math-rendering/src/__tests__/mml-to-latex.test.js +14 -0
  156. package/configure/node_modules/@pie-lib/math-rendering/src/__tests__/normalization.test.js +50 -0
  157. package/configure/node_modules/@pie-lib/math-rendering/src/__tests__/render-math.test.js +155 -0
  158. package/configure/node_modules/@pie-lib/math-rendering/src/index.js +5 -0
  159. package/configure/node_modules/@pie-lib/math-rendering/src/mml-to-latex.js +2 -0
  160. package/configure/node_modules/@pie-lib/math-rendering/src/mstack/__tests__/__snapshots__/chtml.test.js.snap +9 -0
  161. package/configure/node_modules/@pie-lib/math-rendering/src/mstack/__tests__/chtml.test.js +104 -0
  162. package/configure/node_modules/@pie-lib/math-rendering/src/mstack/chtml.js +220 -0
  163. package/configure/node_modules/@pie-lib/math-rendering/src/mstack/index.js +13 -0
  164. package/configure/node_modules/@pie-lib/math-rendering/src/mstack/mml.js +24 -0
  165. package/configure/node_modules/@pie-lib/math-rendering/src/normalization.js +69 -0
  166. package/configure/node_modules/@pie-lib/math-rendering/src/render-math.js +387 -0
  167. package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.json +1 -0
  168. package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.md +1026 -0
  169. package/configure/node_modules/@pie-lib/render-ui/NEXT.CHANGELOG.json +1 -0
  170. package/configure/node_modules/@pie-lib/render-ui/esm/index.js +1616 -0
  171. package/configure/node_modules/@pie-lib/render-ui/esm/index.js.map +1 -0
  172. package/configure/node_modules/@pie-lib/render-ui/lib/append-css-rules.js +88 -0
  173. package/configure/node_modules/@pie-lib/render-ui/lib/append-css-rules.js.map +1 -0
  174. package/configure/node_modules/@pie-lib/render-ui/lib/assets/enableAudioAutoplayImage.js +9 -0
  175. package/configure/node_modules/@pie-lib/render-ui/lib/assets/enableAudioAutoplayImage.js.map +1 -0
  176. package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js +135 -0
  177. package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js.map +1 -0
  178. package/configure/node_modules/@pie-lib/render-ui/lib/color.js +344 -0
  179. package/configure/node_modules/@pie-lib/render-ui/lib/color.js.map +1 -0
  180. package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js +150 -0
  181. package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js.map +1 -0
  182. package/configure/node_modules/@pie-lib/render-ui/lib/has-media.js +27 -0
  183. package/configure/node_modules/@pie-lib/render-ui/lib/has-media.js.map +1 -0
  184. package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js +28 -0
  185. package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js.map +1 -0
  186. package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js +74 -0
  187. package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js.map +1 -0
  188. package/configure/node_modules/@pie-lib/render-ui/lib/index.js +136 -0
  189. package/configure/node_modules/@pie-lib/render-ui/lib/index.js.map +1 -0
  190. package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js +60 -0
  191. package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js.map +1 -0
  192. package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js +145 -0
  193. package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js.map +1 -0
  194. package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js +321 -0
  195. package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js.map +1 -0
  196. package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js +28 -0
  197. package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js.map +1 -0
  198. package/configure/node_modules/@pie-lib/render-ui/lib/readable.js +28 -0
  199. package/configure/node_modules/@pie-lib/render-ui/lib/readable.js.map +1 -0
  200. package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js +151 -0
  201. package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js.map +1 -0
  202. package/configure/node_modules/@pie-lib/render-ui/lib/ui-layout.js +122 -0
  203. package/configure/node_modules/@pie-lib/render-ui/lib/ui-layout.js.map +1 -0
  204. package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js +181 -0
  205. package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js.map +1 -0
  206. package/configure/node_modules/@pie-lib/render-ui/package.json +40 -0
  207. package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/html-and-math.test.js.snap +11 -0
  208. package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/preview-prompt.test.jsx.snap +37 -0
  209. package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/purpose.test.jsx.snap +42 -0
  210. package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/readable.test.jsx.snap +64 -0
  211. package/configure/node_modules/@pie-lib/render-ui/src/__tests__/__snapshots__/response-indicators.test.jsx.snap +27 -0
  212. package/configure/node_modules/@pie-lib/render-ui/src/__tests__/color.test.js +12 -0
  213. package/configure/node_modules/@pie-lib/render-ui/src/__tests__/has-media.test.js +20 -0
  214. package/configure/node_modules/@pie-lib/render-ui/src/__tests__/has-text.test.js +21 -0
  215. package/configure/node_modules/@pie-lib/render-ui/src/__tests__/html-and-math.test.js +24 -0
  216. package/configure/node_modules/@pie-lib/render-ui/src/__tests__/preview-prompt.test.jsx +56 -0
  217. package/configure/node_modules/@pie-lib/render-ui/src/__tests__/purpose.test.jsx +47 -0
  218. package/configure/node_modules/@pie-lib/render-ui/src/__tests__/readable.test.jsx +64 -0
  219. package/configure/node_modules/@pie-lib/render-ui/src/__tests__/response-indicators.test.jsx +16 -0
  220. package/configure/node_modules/@pie-lib/render-ui/src/__tests__/ui-layout.test.jsx +34 -0
  221. package/configure/node_modules/@pie-lib/render-ui/src/__tests__/withUndoReset.test.jsx +254 -0
  222. package/configure/node_modules/@pie-lib/render-ui/src/append-css-rules.js +51 -0
  223. package/configure/node_modules/@pie-lib/render-ui/src/assets/enableAudioAutoplayImage.js +1 -0
  224. package/configure/node_modules/@pie-lib/render-ui/src/collapsible/__tests__/__snapshots__/index.test.jsx.snap +18 -0
  225. package/configure/node_modules/@pie-lib/render-ui/src/collapsible/__tests__/index.test.jsx +13 -0
  226. package/configure/node_modules/@pie-lib/render-ui/src/collapsible/index.jsx +64 -0
  227. package/configure/node_modules/@pie-lib/render-ui/src/color.js +121 -0
  228. package/configure/node_modules/@pie-lib/render-ui/src/feedback.jsx +99 -0
  229. package/configure/node_modules/@pie-lib/render-ui/src/has-media.js +16 -0
  230. package/configure/node_modules/@pie-lib/render-ui/src/has-text.js +18 -0
  231. package/configure/node_modules/@pie-lib/render-ui/src/html-and-math.js +21 -0
  232. package/configure/node_modules/@pie-lib/render-ui/src/index.js +35 -0
  233. package/configure/node_modules/@pie-lib/render-ui/src/input-container.jsx +41 -0
  234. package/configure/node_modules/@pie-lib/render-ui/src/preview-layout.jsx +95 -0
  235. package/configure/node_modules/@pie-lib/render-ui/src/preview-prompt.jsx +254 -0
  236. package/configure/node_modules/@pie-lib/render-ui/src/purpose.jsx +17 -0
  237. package/configure/node_modules/@pie-lib/render-ui/src/readable.jsx +19 -0
  238. package/configure/node_modules/@pie-lib/render-ui/src/response-indicators.jsx +89 -0
  239. package/configure/node_modules/@pie-lib/render-ui/src/ui-layout.jsx +66 -0
  240. package/configure/node_modules/@pie-lib/render-ui/src/withUndoReset.jsx +116 -0
  241. package/configure/node_modules/@pie-lib/test-utils/CHANGELOG.json +1 -0
  242. package/configure/node_modules/@pie-lib/test-utils/CHANGELOG.md +410 -0
  243. package/configure/node_modules/@pie-lib/test-utils/NEXT.CHANGELOG.json +1 -0
  244. package/configure/node_modules/@pie-lib/test-utils/esm/index.js +39 -0
  245. package/configure/node_modules/@pie-lib/test-utils/esm/index.js.map +1 -0
  246. package/configure/node_modules/@pie-lib/test-utils/lib/index.js +40 -0
  247. package/configure/node_modules/@pie-lib/test-utils/lib/index.js.map +1 -0
  248. package/configure/node_modules/@pie-lib/test-utils/package.json +25 -0
  249. package/configure/node_modules/@pie-lib/test-utils/src/__tests__/index.test.js +45 -0
  250. package/configure/node_modules/@pie-lib/test-utils/src/index.js +18 -0
  251. package/configure/node_modules/@pie-lib/translator/CHANGELOG.json +1 -0
  252. package/configure/node_modules/@pie-lib/translator/CHANGELOG.md +282 -0
  253. package/configure/node_modules/@pie-lib/translator/NEXT.CHANGELOG.json +1 -0
  254. package/configure/node_modules/@pie-lib/translator/esm/index.js +257 -0
  255. package/configure/node_modules/@pie-lib/translator/esm/index.js.map +1 -0
  256. package/configure/node_modules/@pie-lib/translator/lib/en.js +102 -0
  257. package/configure/node_modules/@pie-lib/translator/lib/en.js.map +1 -0
  258. package/configure/node_modules/@pie-lib/translator/lib/es.js +102 -0
  259. package/configure/node_modules/@pie-lib/translator/lib/es.js.map +1 -0
  260. package/configure/node_modules/@pie-lib/translator/lib/index.js +69 -0
  261. package/configure/node_modules/@pie-lib/translator/lib/index.js.map +1 -0
  262. package/configure/node_modules/@pie-lib/translator/package.json +25 -0
  263. package/configure/node_modules/@pie-lib/translator/src/en.js +99 -0
  264. package/configure/node_modules/@pie-lib/translator/src/es.js +99 -0
  265. package/configure/node_modules/@pie-lib/translator/src/index.js +43 -0
  266. package/configure/package.json +3 -3
  267. package/controller/CHANGELOG.md +8 -0
  268. package/controller/package.json +3 -3
  269. package/esm/configure.js +40550 -0
  270. package/esm/configure.js.map +1 -0
  271. package/esm/controller.js +3358 -0
  272. package/esm/controller.js.map +1 -0
  273. package/esm/element.js +2203 -0
  274. package/esm/element.js.map +1 -0
  275. package/esm/package.json +4 -0
  276. package/esm/print.js +4090 -0
  277. package/esm/print.js.map +1 -0
  278. package/module/controller.js +4973 -2252
  279. package/module/element.js +1 -1
  280. package/module/index.html +1 -1
  281. package/module/manifest.json +1 -1
  282. package/module/print.html +1 -1
  283. package/module/print.js +1 -1
  284. package/package.json +24 -6
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _default = {
8
+ choiceMode: 'checkbox',
9
+ choicePrefix: 'letters',
10
+ choices: [],
11
+ choicesLayout: 'vertical',
12
+ feedbackEnabled: false,
13
+ gridColumns: 2,
14
+ lockChoiceOrder: true,
15
+ partialScoring: true,
16
+ prompt: '',
17
+ promptEnabled: true,
18
+ rationale: '',
19
+ rationaleEnabled: true,
20
+ scoringType: 'auto',
21
+ studentInstructionsEnabled: true,
22
+ teacherInstructions: '',
23
+ teacherInstructionsEnabled: true,
24
+ toolbarEditorPosition: 'bottom',
25
+ selectedAnswerBackgroundColor: 'initial',
26
+ selectedAnswerStrokeColor: 'initial',
27
+ selectedAnswerStrokeWidth: 'initial',
28
+ hoverAnswerBackgroundColor: 'initial',
29
+ hoverAnswerStrokeColor: 'initial',
30
+ hoverAnswerStrokeWidth: 'initial',
31
+ keyboardEventsEnabled: false
32
+ };
33
+ exports["default"] = _default;
34
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/defaults.js"],"names":["choiceMode","choicePrefix","choices","choicesLayout","feedbackEnabled","gridColumns","lockChoiceOrder","partialScoring","prompt","promptEnabled","rationale","rationaleEnabled","scoringType","studentInstructionsEnabled","teacherInstructions","teacherInstructionsEnabled","toolbarEditorPosition","selectedAnswerBackgroundColor","selectedAnswerStrokeColor","selectedAnswerStrokeWidth","hoverAnswerBackgroundColor","hoverAnswerStrokeColor","hoverAnswerStrokeWidth","keyboardEventsEnabled"],"mappings":";;;;;;eAAe;AACbA,EAAAA,UAAU,EAAE,UADC;AAEbC,EAAAA,YAAY,EAAE,SAFD;AAGbC,EAAAA,OAAO,EAAE,EAHI;AAIbC,EAAAA,aAAa,EAAE,UAJF;AAKbC,EAAAA,eAAe,EAAE,KALJ;AAMbC,EAAAA,WAAW,EAAE,CANA;AAObC,EAAAA,eAAe,EAAE,IAPJ;AAQbC,EAAAA,cAAc,EAAE,IARH;AASbC,EAAAA,MAAM,EAAE,EATK;AAUbC,EAAAA,aAAa,EAAE,IAVF;AAWbC,EAAAA,SAAS,EAAE,EAXE;AAYbC,EAAAA,gBAAgB,EAAE,IAZL;AAabC,EAAAA,WAAW,EAAE,MAbA;AAcbC,EAAAA,0BAA0B,EAAE,IAdf;AAebC,EAAAA,mBAAmB,EAAE,EAfR;AAgBbC,EAAAA,0BAA0B,EAAE,IAhBf;AAiBbC,EAAAA,qBAAqB,EAAE,QAjBV;AAkBbC,EAAAA,6BAA6B,EAAE,SAlBlB;AAmBbC,EAAAA,yBAAyB,EAAE,SAnBd;AAoBbC,EAAAA,yBAAyB,EAAE,SApBd;AAqBbC,EAAAA,0BAA0B,EAAE,SArBf;AAsBbC,EAAAA,sBAAsB,EAAE,SAtBX;AAuBbC,EAAAA,sBAAsB,EAAE,SAvBX;AAwBbC,EAAAA,qBAAqB,EAAE;AAxBV,C","sourcesContent":["export default {\n choiceMode: 'checkbox',\n choicePrefix: 'letters',\n choices: [],\n choicesLayout: 'vertical',\n feedbackEnabled: false,\n gridColumns: 2,\n lockChoiceOrder: true,\n partialScoring: true,\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n scoringType: 'auto',\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n selectedAnswerBackgroundColor: 'initial',\n selectedAnswerStrokeColor: 'initial',\n selectedAnswerStrokeWidth: 'initial',\n hoverAnswerBackgroundColor: 'initial',\n hoverAnswerStrokeColor: 'initial',\n hoverAnswerStrokeWidth: 'initial',\n keyboardEventsEnabled: false,\n};\n"],"file":"defaults.js"}
@@ -0,0 +1,346 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createCorrectResponseSession = void 0;
9
+ exports.createDefaultModel = createDefaultModel;
10
+ exports.getScore = void 0;
11
+ exports.model = model;
12
+ exports.normalize = void 0;
13
+ exports.outcome = outcome;
14
+ exports.validate = void 0;
15
+
16
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
17
+
18
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
19
+
20
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
21
+
22
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
23
+
24
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
+
26
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
27
+
28
+ var _utils = require("./utils");
29
+
30
+ var _defaults = _interopRequireDefault(require("./defaults"));
31
+
32
+ var _controllerUtils = require("@pie-lib/controller-utils");
33
+
34
+ var _excluded = ["verticalMode", "choicesLayout"];
35
+
36
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
37
+
38
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
39
+
40
+ var prepareChoice = function prepareChoice(model, env, defaultFeedback) {
41
+ return function (choice) {
42
+ var _ref = env || {},
43
+ role = _ref.role,
44
+ mode = _ref.mode;
45
+
46
+ var out = {
47
+ label: choice.label,
48
+ value: choice.value
49
+ };
50
+
51
+ if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
52
+ out.rationale = model.rationaleEnabled ? choice.rationale : null;
53
+ } else {
54
+ out.rationale = null;
55
+ }
56
+
57
+ if (mode === 'evaluate') {
58
+ out.correct = !!choice.correct;
59
+
60
+ if (model.feedbackEnabled) {
61
+ var feedbackType = choice.feedback && choice.feedback.type || 'none';
62
+
63
+ if (feedbackType === 'default') {
64
+ out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];
65
+ } else if (feedbackType === 'custom') {
66
+ out.feedback = choice.feedback.value;
67
+ }
68
+ }
69
+ }
70
+
71
+ return out;
72
+ };
73
+ };
74
+
75
+ function createDefaultModel() {
76
+ var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
77
+ return new Promise(function (resolve) {
78
+ return resolve(_objectSpread(_objectSpread({}, _defaults["default"]), model));
79
+ });
80
+ }
81
+
82
+ var normalize = function normalize(question) {
83
+ var _ref2 = question || {},
84
+ verticalMode = _ref2.verticalMode,
85
+ choicesLayout = _ref2.choicesLayout,
86
+ questionProps = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
87
+
88
+ return _objectSpread(_objectSpread(_objectSpread({}, _defaults["default"]), questionProps), {}, {
89
+ // This is used for offering support for old models which have the property verticalMode
90
+ // Same thing is set in authoring : packages/multiple-choice/configure/src/index.jsx - createDefaultModel
91
+ choicesLayout: choicesLayout || verticalMode === false && 'horizontal' || _defaults["default"].choicesLayout
92
+ });
93
+ };
94
+ /**
95
+ *
96
+ * @param {*} question
97
+ * @param {*} session
98
+ * @param {*} env
99
+ * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
100
+ */
101
+
102
+
103
+ exports.normalize = normalize;
104
+
105
+ function model(_x, _x2, _x3, _x4) {
106
+ return _model.apply(this, arguments);
107
+ }
108
+
109
+ function _model() {
110
+ _model = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(question, session, env, updateSession) {
111
+ var normalizedQuestion, defaultFeedback, choices, lockChoiceOrder, out, _ref4, role, mode;
112
+
113
+ return _regenerator["default"].wrap(function _callee$(_context) {
114
+ while (1) {
115
+ switch (_context.prev = _context.next) {
116
+ case 0:
117
+ normalizedQuestion = normalize(question);
118
+ defaultFeedback = Object.assign({
119
+ correct: 'Correct',
120
+ incorrect: 'Incorrect'
121
+ }, normalizedQuestion.defaultFeedback);
122
+ choices = (normalizedQuestion.choices || []).map(prepareChoice(normalizedQuestion, env, defaultFeedback));
123
+ lockChoiceOrder = (0, _controllerUtils.lockChoices)(normalizedQuestion, session, env);
124
+
125
+ if (lockChoiceOrder) {
126
+ _context.next = 8;
127
+ break;
128
+ }
129
+
130
+ _context.next = 7;
131
+ return (0, _controllerUtils.getShuffledChoices)(choices, session, updateSession, 'value');
132
+
133
+ case 7:
134
+ choices = _context.sent;
135
+
136
+ case 8:
137
+ out = {
138
+ disabled: env.mode !== 'gather',
139
+ mode: env.mode,
140
+ prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,
141
+ choicesLayout: normalizedQuestion.choicesLayout,
142
+ gridColumns: normalizedQuestion.gridColumns,
143
+ choiceMode: normalizedQuestion.choiceMode,
144
+ keyMode: normalizedQuestion.choicePrefix,
145
+ choices: choices,
146
+ responseCorrect: env.mode === 'evaluate' ? (0, _utils.isResponseCorrect)(normalizedQuestion, session) : undefined,
147
+ language: normalizedQuestion.language,
148
+ extraCSSRules: normalizedQuestion.extraCSSRules,
149
+ fontSizeFactor: normalizedQuestion.fontSizeFactor,
150
+ isSelectionButtonBelow: normalizedQuestion.isSelectionButtonBelow,
151
+ selectedAnswerBackgroundColor: normalizedQuestion.selectedAnswerBackgroundColor || 'initial',
152
+ selectedAnswerStrokeColor: normalizedQuestion.selectedAnswerStrokeColor || 'initial',
153
+ selectedAnswerStrokeWidth: normalizedQuestion.selectedAnswerStrokeWidth || 'initial',
154
+ hoverAnswerBackgroundColor: normalizedQuestion.hoverAnswerBackgroundColor || 'initial',
155
+ hoverAnswerStrokeColor: normalizedQuestion.hoverAnswerStrokeColor || 'initial',
156
+ hoverAnswerStrokeWidth: normalizedQuestion.hoverAnswerStrokeWidth || 'initial',
157
+ minSelections: normalizedQuestion.minSelections,
158
+ maxSelections: normalizedQuestion.maxSelections,
159
+ keyboardEventsEnabled: normalizedQuestion.keyboardEventsEnabled,
160
+ autoplayAudioEnabled: normalizedQuestion.autoplayAudioEnabled,
161
+ completeAudioEnabled: normalizedQuestion.completeAudioEnabled,
162
+ customAudioButton: normalizedQuestion.customAudioButton
163
+ };
164
+ _ref4 = env || {}, role = _ref4.role, mode = _ref4.mode;
165
+
166
+ if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
167
+ out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
168
+ } else {
169
+ out.teacherInstructions = null;
170
+ }
171
+
172
+ return _context.abrupt("return", out);
173
+
174
+ case 12:
175
+ case "end":
176
+ return _context.stop();
177
+ }
178
+ }
179
+ }, _callee);
180
+ }));
181
+ return _model.apply(this, arguments);
182
+ }
183
+
184
+ var getScore = function getScore(config, session) {
185
+ if (!session || (0, _isEmpty["default"])(session)) {
186
+ return 0;
187
+ }
188
+
189
+ var selectedChoices = session.value || [];
190
+ var correctChoices = (config.choices || []).filter(function (ch) {
191
+ return ch.correct;
192
+ });
193
+ var score = selectedChoices.reduce(function (acc, selectedChoice) {
194
+ return acc + (correctChoices.find(function (ch) {
195
+ return ch.value === selectedChoice;
196
+ }) ? 1 : 0);
197
+ }, 0);
198
+
199
+ if (correctChoices.length < selectedChoices.length) {
200
+ score -= selectedChoices.length - correctChoices.length;
201
+
202
+ if (score < 0) {
203
+ score = 0;
204
+ }
205
+ }
206
+
207
+ var str = correctChoices.length ? score / correctChoices.length : 0;
208
+ return parseFloat(str.toFixed(2));
209
+ };
210
+ /**
211
+ *
212
+ * The score is partial by default for checkbox mode, allOrNothing for radio mode.
213
+ * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring = false. the value in `env` will
214
+ * override the value in `model`.
215
+ * @param {Object} model - the main model
216
+ * @param {*} session
217
+ * @param {Object} env
218
+ */
219
+
220
+
221
+ exports.getScore = getScore;
222
+
223
+ function outcome(model, session, env) {
224
+ return new Promise(function (resolve) {
225
+ if (!session || (0, _isEmpty["default"])(session)) {
226
+ resolve({
227
+ score: 0,
228
+ empty: true
229
+ });
230
+ } else {
231
+ var partialScoringEnabled = _controllerUtils.partialScoring.enabled(model, env) && model.choiceMode !== 'radio';
232
+ var score = getScore(model, session);
233
+ resolve({
234
+ score: partialScoringEnabled ? score : score === 1 ? 1 : 0,
235
+ empty: false
236
+ });
237
+ }
238
+ });
239
+ }
240
+
241
+ var createCorrectResponseSession = function createCorrectResponseSession(question, env) {
242
+ return new Promise(function (resolve) {
243
+ if (env.mode !== 'evaluate' && env.role === 'instructor') {
244
+ var _ref3 = question || {
245
+ choices: []
246
+ },
247
+ choices = _ref3.choices;
248
+
249
+ resolve({
250
+ id: '1',
251
+ value: choices.filter(function (c) {
252
+ return c.correct;
253
+ }).map(function (c) {
254
+ return c.value;
255
+ })
256
+ });
257
+ } else {
258
+ resolve(null);
259
+ }
260
+ });
261
+ }; // remove all html tags
262
+
263
+
264
+ exports.createCorrectResponseSession = createCorrectResponseSession;
265
+
266
+ var getInnerText = function getInnerText(html) {
267
+ return (html || '').replaceAll(/<[^>]*>/g, '');
268
+ }; // remove all html tags except img, iframe and source tag for audio
269
+
270
+
271
+ var getContent = function getContent(html) {
272
+ return (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
273
+ };
274
+
275
+ var validate = function validate() {
276
+ var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
277
+ var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
278
+ var choices = model.choices;
279
+ var _config$minAnswerChoi = config.minAnswerChoices,
280
+ minAnswerChoices = _config$minAnswerChoi === void 0 ? 2 : _config$minAnswerChoi,
281
+ maxAnswerChoices = config.maxAnswerChoices;
282
+ var reversedChoices = (0, _toConsumableArray2["default"])(choices || []).reverse();
283
+ var choicesErrors = {};
284
+ var rationaleErrors = {};
285
+ var errors = {};
286
+ ['teacherInstructions', 'prompt'].forEach(function (field) {
287
+ var _config$field;
288
+
289
+ if ((_config$field = config[field]) !== null && _config$field !== void 0 && _config$field.required && !getContent(model[field])) {
290
+ errors[field] = 'This field is required.';
291
+ }
292
+ });
293
+ var hasCorrectResponse = false;
294
+ reversedChoices.forEach(function (choice, index) {
295
+ var _config$rationale;
296
+
297
+ var correct = choice.correct,
298
+ value = choice.value,
299
+ label = choice.label,
300
+ rationale = choice.rationale;
301
+
302
+ if (correct) {
303
+ hasCorrectResponse = true;
304
+ }
305
+
306
+ if (!getContent(label)) {
307
+ choicesErrors[value] = 'Content should not be empty.';
308
+ } else {
309
+ var identicalAnswer = reversedChoices.slice(index + 1).some(function (c) {
310
+ return c.label === label;
311
+ });
312
+
313
+ if (identicalAnswer) {
314
+ choicesErrors[value] = 'Content should be unique.';
315
+ }
316
+ }
317
+
318
+ if ((_config$rationale = config.rationale) !== null && _config$rationale !== void 0 && _config$rationale.required && !getContent(rationale)) {
319
+ rationaleErrors[value] = 'This field is required.';
320
+ }
321
+ });
322
+ var nbOfChoices = (choices || []).length;
323
+
324
+ if (nbOfChoices < minAnswerChoices) {
325
+ errors.answerChoices = "There should be at least ".concat(minAnswerChoices, " choices defined.");
326
+ } else if (nbOfChoices > maxAnswerChoices) {
327
+ errors.answerChoices = "No more than ".concat(maxAnswerChoices, " choices should be defined.");
328
+ }
329
+
330
+ if (!hasCorrectResponse) {
331
+ errors.correctResponse = 'No correct response defined.';
332
+ }
333
+
334
+ if (!(0, _isEmpty["default"])(choicesErrors)) {
335
+ errors.choices = choicesErrors;
336
+ }
337
+
338
+ if (!(0, _isEmpty["default"])(rationaleErrors)) {
339
+ errors.rationale = rationaleErrors;
340
+ }
341
+
342
+ return errors;
343
+ };
344
+
345
+ exports.validate = validate;
346
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.js"],"names":["prepareChoice","model","env","defaultFeedback","choice","role","mode","out","label","value","rationale","rationaleEnabled","correct","feedbackEnabled","feedbackType","feedback","type","createDefaultModel","Promise","resolve","defaults","normalize","question","verticalMode","choicesLayout","questionProps","session","updateSession","normalizedQuestion","Object","assign","incorrect","choices","map","lockChoiceOrder","disabled","prompt","promptEnabled","gridColumns","choiceMode","keyMode","choicePrefix","responseCorrect","undefined","language","extraCSSRules","fontSizeFactor","isSelectionButtonBelow","selectedAnswerBackgroundColor","selectedAnswerStrokeColor","selectedAnswerStrokeWidth","hoverAnswerBackgroundColor","hoverAnswerStrokeColor","hoverAnswerStrokeWidth","minSelections","maxSelections","keyboardEventsEnabled","autoplayAudioEnabled","completeAudioEnabled","customAudioButton","teacherInstructions","teacherInstructionsEnabled","getScore","config","selectedChoices","correctChoices","filter","ch","score","reduce","acc","selectedChoice","find","length","str","parseFloat","toFixed","outcome","empty","partialScoringEnabled","partialScoring","enabled","createCorrectResponseSession","id","c","getInnerText","html","replaceAll","getContent","replace","validate","minAnswerChoices","maxAnswerChoices","reversedChoices","reverse","choicesErrors","rationaleErrors","errors","forEach","field","required","hasCorrectResponse","index","identicalAnswer","slice","some","nbOfChoices","answerChoices","correctResponse"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAAQC,GAAR,EAAaC,eAAb;AAAA,SAAiC,UAACC,MAAD,EAAY;AAC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UAACrB,CAAD;AAAA,eAAOA,CAAC,CAAC5E,KAAF,KAAYA,KAAnB;AAAA,OAAtC,CAAxB;;AAEA,UAAI+F,eAAJ,EAAqB;AACnBR,QAAAA,aAAa,CAACtF,KAAD,CAAb,GAAuB,2BAAvB;AACD;AACF;;AAED,QAAI,qBAAAsD,MAAM,CAACrD,SAAP,gEAAkB0F,QAAlB,IAA8B,CAACZ,UAAU,CAAC9E,SAAD,CAA7C,EAA0D;AACxDsF,MAAAA,eAAe,CAACvF,KAAD,CAAf,GAAyB,yBAAzB;AACD;AACF,GApBD;AAsBA,MAAMiG,WAAW,GAAG,CAAC1E,OAAO,IAAI,EAAZ,EAAgByC,MAApC;;AAEA,MAAIiC,WAAW,GAAGf,gBAAlB,EAAoC;AAClCM,IAAAA,MAAM,CAACU,aAAP,sCAAmDhB,gBAAnD;AACD,GAFD,MAEO,IAAIe,WAAW,GAAGd,gBAAlB,EAAoC;AACzCK,IAAAA,MAAM,CAACU,aAAP,0BAAuCf,gBAAvC;AACD;;AAED,MAAI,CAACS,kBAAL,EAAyB;AACvBJ,IAAAA,MAAM,CAACW,eAAP,GAAyB,8BAAzB;AACD;;AAED,MAAI,CAAC,yBAAQb,aAAR,CAAL,EAA6B;AAC3BE,IAAAA,MAAM,CAACjE,OAAP,GAAiB+D,aAAjB;AACD;;AAED,MAAI,CAAC,yBAAQC,eAAR,CAAL,EAA+B;AAC7BC,IAAAA,MAAM,CAACvF,SAAP,GAAmBsF,eAAnB;AACD;;AAED,SAAOC,MAAP;AACD,CA3DM","sourcesContent":["/* eslint-disable no-console */\nimport isEmpty from 'lodash/isEmpty';\nimport { isResponseCorrect } from './utils';\nimport defaults from './defaults';\nimport { lockChoices, partialScoring, getShuffledChoices } from '@pie-lib/controller-utils';\n\nconst prepareChoice = (model, env, defaultFeedback) => (choice) => {\n const { role, mode } = env || {};\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = model.rationaleEnabled ? choice.rationale : null;\n } else {\n out.rationale = null;\n }\n\n if (mode === 'evaluate') {\n out.correct = !!choice.correct;\n\n if (model.feedbackEnabled) {\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n }\n\n return out;\n};\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => resolve({ ...defaults, ...model }));\n}\n\nexport const normalize = (question) => {\n const { verticalMode, choicesLayout, ...questionProps } = question || {};\n\n return {\n ...defaults,\n ...questionProps,\n // This is used for offering support for old models which have the property verticalMode\n // Same thing is set in authoring : packages/multiple-choice/configure/src/index.jsx - createDefaultModel\n choicesLayout: choicesLayout || (verticalMode === false && 'horizontal') || defaults.choicesLayout,\n };\n};\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport async function model(question, session, env, updateSession) {\n const normalizedQuestion = normalize(question);\n\n const defaultFeedback = Object.assign(\n { correct: 'Correct', incorrect: 'Incorrect' },\n normalizedQuestion.defaultFeedback,\n );\n\n let choices = (normalizedQuestion.choices || []).map(prepareChoice(normalizedQuestion, env, defaultFeedback));\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session, updateSession, 'value');\n }\n\n const out = {\n disabled: env.mode !== 'gather',\n mode: env.mode,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n choicesLayout: normalizedQuestion.choicesLayout,\n gridColumns: normalizedQuestion.gridColumns,\n choiceMode: normalizedQuestion.choiceMode,\n keyMode: normalizedQuestion.choicePrefix,\n choices,\n responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined,\n language: normalizedQuestion.language,\n extraCSSRules: normalizedQuestion.extraCSSRules,\n fontSizeFactor: normalizedQuestion.fontSizeFactor,\n isSelectionButtonBelow: normalizedQuestion.isSelectionButtonBelow,\n selectedAnswerBackgroundColor: normalizedQuestion.selectedAnswerBackgroundColor || 'initial',\n selectedAnswerStrokeColor: normalizedQuestion.selectedAnswerStrokeColor || 'initial',\n selectedAnswerStrokeWidth: normalizedQuestion.selectedAnswerStrokeWidth || 'initial',\n hoverAnswerBackgroundColor: normalizedQuestion.hoverAnswerBackgroundColor || 'initial',\n hoverAnswerStrokeColor: normalizedQuestion.hoverAnswerStrokeColor || 'initial',\n hoverAnswerStrokeWidth: normalizedQuestion.hoverAnswerStrokeWidth || 'initial',\n minSelections: normalizedQuestion.minSelections,\n maxSelections: normalizedQuestion.maxSelections,\n keyboardEventsEnabled: normalizedQuestion.keyboardEventsEnabled,\n autoplayAudioEnabled: normalizedQuestion.autoplayAudioEnabled,\n completeAudioEnabled: normalizedQuestion.completeAudioEnabled,\n customAudioButton: normalizedQuestion.customAudioButton,\n };\n\n const { role, mode } = env || {};\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.teacherInstructions = null;\n }\n\n return out;\n}\n\nexport const getScore = (config, session) => {\n if (!session || isEmpty(session)) {\n return 0;\n }\n\n const selectedChoices = session.value || [];\n const correctChoices = (config.choices || []).filter((ch) => ch.correct);\n\n let score = selectedChoices.reduce(\n (acc, selectedChoice) => acc + (correctChoices.find((ch) => ch.value === selectedChoice) ? 1 : 0),\n 0,\n );\n\n if (correctChoices.length < selectedChoices.length) {\n score -= selectedChoices.length - correctChoices.length;\n\n if (score < 0) {\n score = 0;\n }\n }\n\n const str = correctChoices.length ? score / correctChoices.length : 0;\n\n return parseFloat(str.toFixed(2));\n};\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring = false. the value in `env` will\n * override the value in `model`.\n * @param {Object} model - the main model\n * @param {*} session\n * @param {Object} env\n */\nexport function outcome(model, session, env) {\n return new Promise((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ score: 0, empty: true });\n } else {\n const partialScoringEnabled = partialScoring.enabled(model, env) && model.choiceMode !== 'radio';\n const score = getScore(model, session);\n\n resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: false });\n }\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { choices } = question || { choices: [] };\n\n resolve({\n id: '1',\n value: choices.filter((c) => c.correct).map((c) => c.value),\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { choices } = model;\n const { minAnswerChoices = 2, maxAnswerChoices } = config;\n const reversedChoices = [...(choices || [])].reverse();\n const choicesErrors = {};\n const rationaleErrors = {};\n const errors = {};\n\n ['teacherInstructions', 'prompt'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n let hasCorrectResponse = false;\n\n reversedChoices.forEach((choice, index) => {\n const { correct, value, label, rationale } = choice;\n\n if (correct) {\n hasCorrectResponse = true;\n }\n\n if (!getContent(label)) {\n choicesErrors[value] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[value] = 'Content should be unique.';\n }\n }\n\n if (config.rationale?.required && !getContent(rationale)) {\n rationaleErrors[value] = 'This field is required.';\n }\n });\n\n const nbOfChoices = (choices || []).length;\n\n if (nbOfChoices < minAnswerChoices) {\n errors.answerChoices = `There should be at least ${minAnswerChoices} choices defined.`;\n } else if (nbOfChoices > maxAnswerChoices) {\n errors.answerChoices = `No more than ${maxAnswerChoices} choices should be defined.`;\n }\n\n if (!hasCorrectResponse) {\n errors.correctResponse = 'No correct response defined.';\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choices = choicesErrors;\n }\n\n if (!isEmpty(rationaleErrors)) {\n errors.rationale = rationaleErrors;\n }\n\n return errors;\n};\n"],"file":"index.js"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.isResponseCorrect = exports.getCorrectResponse = void 0;
9
+
10
+ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
11
+
12
+ var getCorrectResponse = function getCorrectResponse(choices) {
13
+ return choices.filter(function (c) {
14
+ return c.correct;
15
+ }).map(function (c) {
16
+ return c.value;
17
+ }).sort();
18
+ };
19
+
20
+ exports.getCorrectResponse = getCorrectResponse;
21
+
22
+ var isResponseCorrect = function isResponseCorrect(question, session) {
23
+ var correctResponse = getCorrectResponse(question.choices);
24
+ return session && (0, _isEqual["default"])((session.value || []).sort(), correctResponse);
25
+ };
26
+
27
+ exports.isResponseCorrect = isResponseCorrect;
28
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils.js"],"names":["getCorrectResponse","choices","filter","c","correct","map","value","sort","isResponseCorrect","question","session","correctResponse"],"mappings":";;;;;;;;;AAAA;;AAEO,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,OAAD;AAAA,SAChCA,OAAO,CACJC,MADH,CACU,UAACC,CAAD;AAAA,WAAOA,CAAC,CAACC,OAAT;AAAA,GADV,EAEGC,GAFH,CAEO,UAACF,CAAD;AAAA,WAAOA,CAAC,CAACG,KAAT;AAAA,GAFP,EAGGC,IAHH,EADgC;AAAA,CAA3B;;;;AAMA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,QAAD,EAAWC,OAAX,EAAuB;AACtD,MAAIC,eAAe,GAAGX,kBAAkB,CAACS,QAAQ,CAACR,OAAV,CAAxC;AACA,SAAOS,OAAO,IAAI,yBAAQ,CAACA,OAAO,CAACJ,KAAR,IAAiB,EAAlB,EAAsBC,IAAtB,EAAR,EAAsCI,eAAtC,CAAlB;AACD,CAHM","sourcesContent":["import isEqual from 'lodash/isEqual';\n\nexport const getCorrectResponse = (choices) =>\n choices\n .filter((c) => c.correct)\n .map((c) => c.value)\n .sort();\n\nexport const isResponseCorrect = (question, session) => {\n let correctResponse = getCorrectResponse(question.choices);\n return session && isEqual((session.value || []).sort(), correctResponse);\n};\n"],"file":"utils.js"}
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@pie-element/multiple-choice-controller",
3
+ "private": true,
4
+ "version": "11.0.5-esm.1",
5
+ "description": "",
6
+ "main": "lib/index.js",
7
+ "module": "src/index.js",
8
+ "author": "",
9
+ "license": "ISC",
10
+ "dependencies": {
11
+ "@pie-lib/controller-utils": "^0.19.2",
12
+ "debug": "^3.1.0",
13
+ "lodash": "^4.17.15"
14
+ }
15
+ }