@pie-element/ebsr 14.2.1 → 14.2.2-next.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 (243) hide show
  1. package/configure.js +2 -0
  2. package/controller.js +1 -0
  3. package/dist/author/defaults.d.ts +66 -0
  4. package/dist/author/defaults.js +161 -0
  5. package/dist/author/index.d.ts +34 -0
  6. package/dist/author/index.js +78 -0
  7. package/dist/author/main.d.ts +22 -0
  8. package/dist/author/main.js +121 -0
  9. package/dist/browser/_Uint8Array-fRN8Lsus.js +193 -0
  10. package/dist/browser/_Uint8Array-fRN8Lsus.js.map +1 -0
  11. package/dist/browser/author/index.js +14046 -0
  12. package/dist/browser/author/index.js.map +1 -0
  13. package/dist/browser/browser-CdX8WGiZ.js +207 -0
  14. package/dist/browser/browser-CdX8WGiZ.js.map +1 -0
  15. package/dist/browser/cloneDeep-o_mWij0W.js +251 -0
  16. package/dist/browser/cloneDeep-o_mWij0W.js.map +1 -0
  17. package/dist/browser/controller/index.js +435 -0
  18. package/dist/browser/controller/index.js.map +1 -0
  19. package/dist/browser/delivery/index.js +133 -0
  20. package/dist/browser/delivery/index.js.map +1 -0
  21. package/dist/browser/dist-D9ARZhQk.js +1426 -0
  22. package/dist/browser/dist-D9ARZhQk.js.map +1 -0
  23. package/dist/browser/dist-DQkngCcw.js +36 -0
  24. package/dist/browser/dist-DQkngCcw.js.map +1 -0
  25. package/dist/browser/get-BfBCyZ1r.js +333 -0
  26. package/dist/browser/get-BfBCyZ1r.js.map +1 -0
  27. package/dist/browser/print/index.js +108 -0
  28. package/dist/browser/print/index.js.map +1 -0
  29. package/dist/controller/defaults.d.ts +15 -0
  30. package/dist/controller/defaults.js +26 -0
  31. package/dist/controller/index.d.ts +42 -0
  32. package/dist/controller/index.js +186 -0
  33. package/dist/controller/utils.d.ts +10 -0
  34. package/dist/controller/utils.js +8 -0
  35. package/dist/delivery/index.d.ts +26 -0
  36. package/dist/delivery/index.js +132 -0
  37. package/dist/index.d.ts +1 -0
  38. package/dist/index.iife.d.ts +8 -0
  39. package/dist/index.iife.js +165 -0
  40. package/dist/index.js +2 -0
  41. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_DataView.js +6 -0
  42. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Hash.js +16 -0
  43. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_ListCache.js +16 -0
  44. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Map.js +6 -0
  45. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_MapCache.js +16 -0
  46. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Promise.js +6 -0
  47. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Set.js +6 -0
  48. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_SetCache.js +11 -0
  49. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Stack.js +14 -0
  50. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Symbol.js +5 -0
  51. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Uint8Array.js +5 -0
  52. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_WeakMap.js +6 -0
  53. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_apply.js +12 -0
  54. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayEach.js +7 -0
  55. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayFilter.js +10 -0
  56. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayLikeKeys.js +15 -0
  57. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayMap.js +7 -0
  58. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayPush.js +7 -0
  59. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arraySome.js +7 -0
  60. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assignValue.js +10 -0
  61. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assocIndexOf.js +8 -0
  62. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssign.js +8 -0
  63. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignIn.js +8 -0
  64. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignValue.js +12 -0
  65. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseClone.js +57 -0
  66. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseCreate.js +14 -0
  67. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGet.js +10 -0
  68. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
  69. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetTag.js +10 -0
  70. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsArguments.js +9 -0
  71. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsEqual.js +8 -0
  72. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsEqualDeep.js +30 -0
  73. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsMap.js +9 -0
  74. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsNative.js +11 -0
  75. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsSet.js +9 -0
  76. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
  77. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeys.js +12 -0
  78. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeysIn.js +13 -0
  79. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseRest.js +9 -0
  80. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseSetToString.js +14 -0
  81. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseTimes.js +7 -0
  82. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseToString.js +15 -0
  83. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseUnary.js +8 -0
  84. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cacheHas.js +6 -0
  85. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_castPath.js +10 -0
  86. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
  87. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneBuffer.js +10 -0
  88. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneDataView.js +8 -0
  89. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneRegExp.js +8 -0
  90. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneSymbol.js +8 -0
  91. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneTypedArray.js +8 -0
  92. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyArray.js +8 -0
  93. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyObject.js +14 -0
  94. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbols.js +8 -0
  95. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbolsIn.js +8 -0
  96. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_coreJsData.js +5 -0
  97. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_defineProperty.js +10 -0
  98. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_equalArrays.js +35 -0
  99. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_equalByTag.js +35 -0
  100. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_equalObjects.js +32 -0
  101. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_freeGlobal.js +4 -0
  102. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeys.js +9 -0
  103. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeysIn.js +9 -0
  104. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getMapData.js +8 -0
  105. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getNative.js +9 -0
  106. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getPrototype.js +5 -0
  107. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getRawTag.js +14 -0
  108. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbols.js +10 -0
  109. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbolsIn.js +11 -0
  110. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getTag.js +23 -0
  111. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getValue.js +6 -0
  112. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashClear.js +7 -0
  113. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashDelete.js +7 -0
  114. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashGet.js +13 -0
  115. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashHas.js +9 -0
  116. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashSet.js +9 -0
  117. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneArray.js +8 -0
  118. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneByTag.js +33 -0
  119. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneObject.js +9 -0
  120. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isIndex.js +8 -0
  121. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isIterateeCall.js +12 -0
  122. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isKey.js +11 -0
  123. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isKeyable.js +7 -0
  124. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isMasked.js +11 -0
  125. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isPrototype.js +8 -0
  126. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheClear.js +6 -0
  127. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheDelete.js +9 -0
  128. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheGet.js +8 -0
  129. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheHas.js +7 -0
  130. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheSet.js +8 -0
  131. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheClear.js +13 -0
  132. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheDelete.js +8 -0
  133. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheGet.js +7 -0
  134. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheHas.js +7 -0
  135. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheSet.js +8 -0
  136. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapToArray.js +9 -0
  137. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_memoizeCapped.js +11 -0
  138. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeCreate.js +5 -0
  139. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeys.js +5 -0
  140. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeysIn.js +8 -0
  141. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nodeUtil.js +9 -0
  142. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_objectToString.js +7 -0
  143. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_overArg.js +8 -0
  144. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_overRest.js +13 -0
  145. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_root.js +5 -0
  146. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setCacheAdd.js +7 -0
  147. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setCacheHas.js +6 -0
  148. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setToArray.js +9 -0
  149. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setToString.js +6 -0
  150. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_shortOut.js +14 -0
  151. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackClear.js +7 -0
  152. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackDelete.js +7 -0
  153. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackGet.js +6 -0
  154. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackHas.js +6 -0
  155. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackSet.js +16 -0
  156. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stringToPath.js +10 -0
  157. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_toKey.js +10 -0
  158. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_toSource.js +15 -0
  159. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/cloneDeep.js +8 -0
  160. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/constant.js +8 -0
  161. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/defaults.js +16 -0
  162. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/eq.js +6 -0
  163. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/get.js +8 -0
  164. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/identity.js +6 -0
  165. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArguments.js +10 -0
  166. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArray.js +4 -0
  167. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArrayLike.js +8 -0
  168. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isBuffer.js +6 -0
  169. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isEmpty.js +21 -0
  170. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isEqual.js +7 -0
  171. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isFunction.js +11 -0
  172. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isLength.js +7 -0
  173. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isMap.js +7 -0
  174. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObject.js +7 -0
  175. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObjectLike.js +6 -0
  176. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isSet.js +7 -0
  177. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isSymbol.js +9 -0
  178. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isTypedArray.js +7 -0
  179. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keys.js +9 -0
  180. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keysIn.js +9 -0
  181. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/memoize.js +16 -0
  182. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubArray.js +6 -0
  183. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubFalse.js +6 -0
  184. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/toString.js +7 -0
  185. package/dist/print/index.d.ts +25 -0
  186. package/dist/print/index.js +107 -0
  187. package/package.json +83 -18
  188. package/CHANGELOG.json +0 -1547
  189. package/CHANGELOG.md +0 -2285
  190. package/LICENSE.md +0 -5
  191. package/README.md +0 -62
  192. package/configure/CHANGELOG.json +0 -992
  193. package/configure/CHANGELOG.md +0 -2148
  194. package/configure/lib/defaults.js +0 -229
  195. package/configure/lib/defaults.js.map +0 -1
  196. package/configure/lib/index.js +0 -154
  197. package/configure/lib/index.js.map +0 -1
  198. package/configure/lib/main.js +0 -222
  199. package/configure/lib/main.js.map +0 -1
  200. package/configure/package.json +0 -23
  201. package/configure/src/__tests__/index.test.js +0 -492
  202. package/configure/src/defaults.js +0 -173
  203. package/configure/src/index.js +0 -174
  204. package/configure/src/main.jsx +0 -235
  205. package/controller/CHANGELOG.json +0 -552
  206. package/controller/CHANGELOG.md +0 -1286
  207. package/controller/lib/defaults.js +0 -31
  208. package/controller/lib/defaults.js.map +0 -1
  209. package/controller/lib/index.js +0 -448
  210. package/controller/lib/index.js.map +0 -1
  211. package/controller/lib/utils.js +0 -18
  212. package/controller/lib/utils.js.map +0 -1
  213. package/controller/package.json +0 -18
  214. package/controller/src/__tests__/index.test.js +0 -591
  215. package/controller/src/__tests__/utils.test.js +0 -48
  216. package/controller/src/defaults.js +0 -25
  217. package/controller/src/index.js +0 -442
  218. package/controller/src/utils.js +0 -18
  219. package/docs/config-schema.json +0 -5787
  220. package/docs/config-schema.json.md +0 -4278
  221. package/docs/demo/config.js +0 -8
  222. package/docs/demo/generate.js +0 -52
  223. package/docs/demo/index.html +0 -2
  224. package/docs/demo/session.js +0 -14
  225. package/docs/pie-schema.json +0 -2911
  226. package/docs/pie-schema.json.md +0 -2142
  227. package/ebsr.png +0 -0
  228. package/lib/index.js +0 -207
  229. package/lib/index.js.map +0 -1
  230. package/lib/print.js +0 -186
  231. package/lib/print.js.map +0 -1
  232. package/module/configure.js +0 -1
  233. package/module/controller.js +0 -5664
  234. package/module/demo.js +0 -77
  235. package/module/element.js +0 -1
  236. package/module/index.html +0 -21
  237. package/module/manifest.json +0 -14
  238. package/module/print-demo.js +0 -115
  239. package/module/print.html +0 -18
  240. package/module/print.js +0 -1
  241. package/src/__tests__/index.test.js +0 -129
  242. package/src/index.js +0 -222
  243. package/src/print.js +0 -207
@@ -1,442 +0,0 @@
1
- import defaults from './defaults';
2
- import { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils';
3
- import { isResponseCorrect } from './utils';
4
- import { get, isEmpty } from 'lodash-es';
5
- import Translator from '@pie-lib/translator';
6
-
7
- const { translator } = Translator;
8
-
9
- const prepareChoice = (model, env, defaultFeedback) => (choice) => {
10
- const out = {
11
- label: choice.label,
12
- value: choice.value,
13
- };
14
-
15
- if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
16
- out.rationale = model.rationaleEnabled ? choice.rationale : null;
17
- } else {
18
- out.rationale = null;
19
- }
20
-
21
- if (env.mode === 'evaluate') {
22
- out.correct = !!choice.correct;
23
-
24
- if (model.feedbackEnabled) {
25
- const feedbackType = (choice.feedback && choice.feedback.type) || 'none';
26
-
27
- if (feedbackType === 'default') {
28
- out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];
29
- } else if (feedbackType === 'custom') {
30
- out.feedback = choice.feedback.value;
31
- }
32
- }
33
- }
34
-
35
- return out;
36
- };
37
-
38
- const parsePart = (part, key, session, env) => {
39
- const defaultFeedback = Object.assign({ correct: 'Correct', incorrect: 'Incorrect' }, part.defaultFeedback);
40
-
41
- let choices = part.choices ? part.choices.map(prepareChoice(part, env, defaultFeedback)) : [];
42
-
43
- return {
44
- ...part,
45
- choices,
46
- disabled: env.mode !== 'gather',
47
- complete: {
48
- min: part.choices.filter((c) => c.correct).length,
49
- },
50
- responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(part, key, session) : undefined,
51
- };
52
- };
53
-
54
- const normalizePart = (model, base) => ({
55
- ...base,
56
- ...model,
57
- choicesLayout: model.choicesLayout || (model.verticalMode === false && 'horizontal') || 'vertical',
58
- });
59
-
60
- export const normalize = ({ partA = {}, partB = {}, language, ...question }) => ({
61
- ...defaults,
62
- ...question,
63
- partA: normalizePart(partA, { ...defaults.partA, language }),
64
- partB: normalizePart(partB, { ...defaults.partB, language }),
65
- });
66
-
67
- /**
68
- *
69
- * @param {*} question
70
- * @param {*} session
71
- * @param {*} env
72
- * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
73
- */
74
- export async function model(question, session, env, updateSession) {
75
- const normalizedQuestion = normalize(question);
76
- const partA = parsePart(normalizedQuestion.partA, 'partA', session, env);
77
- const partB = parsePart(normalizedQuestion.partB, 'partB', session, env);
78
-
79
- const shuffledValues = {};
80
-
81
- const us = (part) => (id, element, update) =>
82
- new Promise((resolve) => {
83
- shuffledValues[part] = update.shuffledValues;
84
- resolve();
85
- });
86
-
87
- const partASession = get(session, 'value.partA');
88
- const partALockChoiceOrder = lockChoices(normalizedQuestion.partA, partASession, env);
89
-
90
- const { choices: partAChoices } = partA || {};
91
- const { choices: partBChoices } = partB || {};
92
-
93
- if (!partALockChoiceOrder && partAChoices && partAChoices.length) {
94
- partA.choices = await getShuffledChoices(
95
- partAChoices,
96
- { shuffledValues: (session.shuffledValues || {}).partA },
97
- us('partA'),
98
- 'value',
99
- );
100
- }
101
-
102
- const partBSession = get(session, 'value.partB');
103
- const partBLockChoiceOrder = lockChoices(normalizedQuestion.partB, partBSession, env);
104
-
105
- if (!partBLockChoiceOrder && partBChoices && partBChoices.length) {
106
- partB.choices = await getShuffledChoices(
107
- partBChoices,
108
- { shuffledValues: (session.shuffledValues || {}).partB },
109
- us('partB'),
110
- 'value',
111
- );
112
- }
113
-
114
- if (!isEmpty(shuffledValues)) {
115
- if (updateSession && typeof updateSession === 'function') {
116
- updateSession(session.id, session.element, {
117
- shuffledValues,
118
- }).catch((e) => {
119
- // eslint-disable-next-line no-console
120
- console.error('update session failed', e);
121
- });
122
- }
123
- }
124
-
125
- if (normalizedQuestion.partLabels) {
126
- const language = normalizedQuestion.language;
127
- partA.partLabel = translator.t('ebsr.part', {
128
- lng: language,
129
- index: normalizedQuestion.partLabelType === 'Letters' ? 'A' : '1',
130
- });
131
- partB.partLabel = translator.t('ebsr.part', {
132
- lng: language,
133
- index: normalizedQuestion.partLabelType === 'Letters' ? 'B' : '2',
134
- });
135
- } else {
136
- partA.partLabel = undefined;
137
- partB.partLabel = undefined;
138
- }
139
-
140
- if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
141
- partA.teacherInstructions = normalizedQuestion.partA.teacherInstructionsEnabled
142
- ? normalizedQuestion.partA.teacherInstructions
143
- : null;
144
- partB.teacherInstructions = normalizedQuestion.partB.teacherInstructionsEnabled
145
- ? normalizedQuestion.partB.teacherInstructions
146
- : null;
147
- } else {
148
- partA.teacherInstructions = null;
149
- partB.teacherInstructions = null;
150
- }
151
-
152
- partA.prompt = normalizedQuestion.partA.promptEnabled ? normalizedQuestion.partA.prompt : null;
153
- partB.prompt = normalizedQuestion.partB.promptEnabled ? normalizedQuestion.partB.prompt : null;
154
-
155
- return new Promise((resolve) => {
156
- resolve({
157
- disabled: env.mode !== 'gather',
158
- mode: env.mode,
159
- extraCSSRules: normalizedQuestion.extraCSSRules,
160
- partA,
161
- partB,
162
- });
163
- });
164
- }
165
-
166
- export const createDefaultModel = (model = {}) =>
167
- new Promise((resolve) => {
168
- resolve({
169
- ...defaults,
170
- ...model,
171
- });
172
- });
173
-
174
- const isCorrect = (c) => c.correct === true;
175
-
176
- const getScore = (config, sessionPart, key, partialScoringEnabled) => {
177
- const { choices = [] } = (config && config[key]) || {};
178
- const maxScore = choices.length;
179
- const { value: sessionPartValue } = sessionPart || {};
180
-
181
- const chosen = (c) => !!(sessionPartValue || []).find((v) => v === c.value);
182
- const correctAndNotChosen = (c) => isCorrect(c) && !chosen(c);
183
- const incorrectAndChosen = (c) => !isCorrect(c) && chosen(c);
184
- const correctChoices = choices.reduce((total, choice) => {
185
- if (correctAndNotChosen(choice) || incorrectAndChosen(choice)) {
186
- return total - 1;
187
- } else {
188
- return total;
189
- }
190
- }, choices.length);
191
-
192
- // determine score for a part
193
- if (!partialScoringEnabled && correctChoices < maxScore) {
194
- return 0;
195
- }
196
-
197
- return parseFloat(maxScore ? (correctChoices / maxScore).toFixed(2) : 0);
198
- };
199
-
200
- /**
201
- * Generates detailed trace log for math-templated scoring evaluation
202
- * @param {Object} question
203
- * @param {Object} session
204
- * @param {Object} env
205
- * @returns {Array<string>} traceLog
206
- */
207
- export const getLogTrace = (question, session, env) => {
208
- const traceLog = [];
209
-
210
- if (!session || !session.value) {
211
- traceLog.push('Student did not answer the question.');
212
- return traceLog;
213
- }
214
-
215
- const { value } = session;
216
- const { partA, partB } = value;
217
-
218
- const partialScoringEnabled = partialScoring.enabled(question, env);
219
-
220
- traceLog.push(
221
- `Scoring method: ${partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring'}.`
222
- );
223
-
224
- const partAquestionType =
225
- question.partA.choiceMode === 'radio'
226
- ? 'multiple-choice (radio)'
227
- : 'multiple-select (checkbox)';
228
- traceLog.push(`Part A question type: ${partAquestionType}.`);
229
-
230
- const partASelections = partA?.value || [];
231
- const partACorrectChoices = (question.partA.choices || []).filter((c) => c.correct);
232
- const partACorrectValues = partACorrectChoices.map((c) => c.value);
233
- const partACorrectSelected = partASelections.filter((v) => partACorrectValues.includes(v));
234
- const partAIncorrectSelected = partASelections.filter((v) => !partACorrectValues.includes(v));
235
-
236
- if (partASelections.length) {
237
- traceLog.push(
238
- `Part A: student selected ${partASelections.length} choice(s) (${partACorrectSelected.length} correct, ${partAIncorrectSelected.length} incorrect).`
239
- );
240
- }
241
-
242
- const scoreA = getScore(question, partA, 'partA', partialScoringEnabled);
243
- traceLog.push(`Part A score: ${scoreA}.`);
244
-
245
- const partBquestionType =
246
- question.partB.choiceMode === 'radio'
247
- ? 'multiple-choice (radio)'
248
- : 'multiple-select (checkbox)';
249
- traceLog.push(`Part B question type: ${partBquestionType}.`);
250
-
251
- const partBSelections = partB?.value || [];
252
- const partBCorrectChoices = (question.partB.choices || []).filter((c) => c.correct);
253
- const partBCorrectValues = partBCorrectChoices.map((c) => c.value);
254
- const correctSelected = partBSelections.filter((v) => partBCorrectValues.includes(v));
255
- const incorrectSelected = partBSelections.filter((v) => !partBCorrectValues.includes(v));
256
-
257
- if (partBSelections.length) {
258
- traceLog.push(
259
- `Part B: student selected ${partBSelections.length} choice(s) (${correctSelected.length} correct, ${incorrectSelected.length} incorrect).`
260
- );
261
- }
262
-
263
- const scoreB = getScore(question, partB, 'partB', partialScoringEnabled);
264
- traceLog.push(`Part B score: ${scoreB}.`);
265
-
266
- if (!partialScoringEnabled) {
267
- traceLog.push(
268
- 'Final score is awarded only if both Part A and Part B are completely correct.'
269
- );
270
- traceLog.push(`Final score: ${scoreA === 1 && scoreB === 1 ? 1 : 0}.`);
271
- } else {
272
- traceLog.push(
273
- 'With partial scoring enabled, Part A must be correct to earn any credit.'
274
- );
275
-
276
- let finalScore = 0;
277
- if (scoreA === 1 && scoreB === 1) {
278
- finalScore = 2;
279
- } else if (scoreA === 1 && scoreB < 1) {
280
- finalScore = 1;
281
- }
282
-
283
- traceLog.push(`Final score: ${finalScore}.`);
284
- }
285
-
286
- return traceLog;
287
- };
288
-
289
- export function outcome(config, session, env) {
290
- return new Promise((resolve) => {
291
- const { value } = session || {};
292
-
293
- if (!session || !value) {
294
- resolve({ score: 0, scoreA: 0, scoreB: 0, empty: true, logTrace: ['Student did not answer the question.'] });
295
- }
296
-
297
- if (value) {
298
- const { partA, partB } = value || {};
299
-
300
- const partialScoringEnabled = partialScoring.enabled(config, env);
301
-
302
- const scoreA = getScore(config, partA, 'partA', partialScoringEnabled);
303
- const scoreB = getScore(config, partB, 'partB', partialScoringEnabled);
304
- const logTrace = getLogTrace(config, session, env);
305
-
306
- if (!partialScoringEnabled) {
307
- // The EBSR item is worth 1 point
308
- // That point is awarded if and only if both parts are fully correct, otherwise no points are awarded
309
- resolve({ score: scoreA === 1 && scoreB === 1 ? 1 : 0, scoreA, scoreB, max: 1, logTrace });
310
- } else {
311
- // The EBSR item is worth 2 points
312
- if (scoreA === 1) {
313
- if (scoreB === 1) {
314
- // If Part A and Part B are both correct, 2 points are awarded
315
- resolve({ score: 2, scoreA, scoreB, max: 2, logTrace });
316
- } else {
317
- // If Part A is correct and part B is incorrect, 1 point is awarded
318
- resolve({ score: 1, scoreA, scoreB, max: 2, logTrace });
319
- }
320
- } else {
321
- // For all other combinations, no points are awarded
322
- resolve({ score: 0, scoreA, scoreB, max: 2, logTrace });
323
- }
324
- }
325
- }
326
- });
327
- }
328
-
329
- const returnPartCorrect = (choices) => {
330
- let answers = [];
331
-
332
- choices.forEach((i) => {
333
- const { correct, value } = i;
334
- if (correct) {
335
- answers.push(value);
336
- }
337
- });
338
- return answers;
339
- };
340
-
341
- export const createCorrectResponseSession = (question, env) => {
342
- return new Promise((resolve) => {
343
- if (env.mode !== 'evaluate' && env.role === 'instructor') {
344
- const { partA, partB } = question;
345
-
346
- const partACorrect = returnPartCorrect(partA.choices);
347
- const partBCorrect = returnPartCorrect(partB.choices);
348
-
349
- resolve({
350
- value: {
351
- partA: {
352
- id: 'partA',
353
- value: partACorrect,
354
- },
355
- partB: {
356
- id: 'partB',
357
- value: partBCorrect,
358
- },
359
- },
360
- id: '1',
361
- });
362
- } else {
363
- resolve(null);
364
- }
365
- });
366
- };
367
-
368
- // remove all html tags
369
- const getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');
370
-
371
- // remove all html tags except img, iframe and source tag for audio
372
- const getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
373
-
374
- const validatePart = (model = {}, config = {}) => {
375
- const { choices } = model;
376
- const { minAnswerChoices = 2, maxAnswerChoices } = config;
377
- const reversedChoices = [...(choices || [])].reverse();
378
- const errors = {};
379
- const choicesErrors = {};
380
- const rationaleErrors = {};
381
- let hasCorrectResponse = false;
382
-
383
- ['teacherInstructions', 'prompt'].forEach((field) => {
384
- if (config[field]?.required && !getContent(model[field])) {
385
- errors[field] = 'This field is required.';
386
- }
387
- });
388
-
389
- reversedChoices.forEach((choice, index) => {
390
- const { correct, value, label, rationale } = choice;
391
-
392
- if (correct) {
393
- hasCorrectResponse = true;
394
- }
395
-
396
- if (!getContent(label)) {
397
- choicesErrors[value] = 'Content should not be empty.';
398
- } else {
399
- const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);
400
-
401
- if (identicalAnswer) {
402
- choicesErrors[value] = 'Content should be unique.';
403
- }
404
- }
405
-
406
- if (config.rationale?.required && !getContent(rationale)) {
407
- rationaleErrors[value] = 'This field is required.';
408
- }
409
- });
410
-
411
- const nbOfChoices = (choices || []).length;
412
-
413
- if (nbOfChoices < minAnswerChoices) {
414
- errors.answerChoices = `There should be at least ${minAnswerChoices} choices defined.`;
415
- } else if (nbOfChoices > maxAnswerChoices) {
416
- errors.answerChoices = `No more than ${maxAnswerChoices} choices should be defined.`;
417
- }
418
-
419
- if (!hasCorrectResponse) {
420
- errors.correctResponse = 'No correct response defined.';
421
- }
422
-
423
- if (!isEmpty(choicesErrors)) {
424
- errors.choices = choicesErrors;
425
- }
426
-
427
- if (!isEmpty(rationaleErrors)) {
428
- errors.rationale = rationaleErrors;
429
- }
430
-
431
- return errors;
432
- };
433
-
434
- export const validate = (model = {}, config = {}) => {
435
- const { partA, partB } = model || {};
436
- const { partA: partAConfig, partB: partBConfig } = config || {};
437
-
438
- const partAErrors = validatePart(partA, partAConfig);
439
- const partBErrors = validatePart(partB, partBConfig);
440
-
441
- return { partA: partAErrors, partB: partBErrors };
442
- };
@@ -1,18 +0,0 @@
1
- import { isEqual } from 'lodash-es';
2
-
3
- export const getCorrectResponse = (choices) =>
4
- choices &&
5
- choices
6
- .filter((c) => c.correct)
7
- .map((c) => c.value)
8
- .sort();
9
-
10
- export const isResponseCorrect = (question, key, session) => {
11
- let correctResponse = getCorrectResponse(question.choices);
12
-
13
- if (session && session.value) {
14
- return isEqual((session.value[key].value || []).sort(), correctResponse);
15
- }
16
-
17
- return false;
18
- };