@pie-element/multi-trait-rubric 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 (188) hide show
  1. package/dist/author/common.d.ts +91 -0
  2. package/dist/author/common.d.ts.map +1 -0
  3. package/dist/author/common.js +275 -0
  4. package/dist/author/defaults.d.ts +154 -0
  5. package/dist/author/defaults.d.ts.map +1 -0
  6. package/dist/author/defaults.js +113 -0
  7. package/dist/author/index.d.ts +23 -0
  8. package/dist/author/index.d.ts.map +1 -0
  9. package/dist/author/index.js +89 -0
  10. package/dist/author/main.d.ts +44 -0
  11. package/dist/author/main.d.ts.map +1 -0
  12. package/dist/author/main.js +249 -0
  13. package/dist/author/modals.d.ts +95 -0
  14. package/dist/author/modals.d.ts.map +1 -0
  15. package/dist/author/modals.js +171 -0
  16. package/dist/author/scale.d.ts +47 -0
  17. package/dist/author/scale.d.ts.map +1 -0
  18. package/dist/author/scale.js +280 -0
  19. package/dist/author/trait.d.ts +71 -0
  20. package/dist/author/trait.d.ts.map +1 -0
  21. package/dist/author/trait.js +202 -0
  22. package/dist/author/traitsHeader.d.ts +29 -0
  23. package/dist/author/traitsHeader.d.ts.map +1 -0
  24. package/dist/author/traitsHeader.js +172 -0
  25. package/dist/author/utils.d.ts +11 -0
  26. package/dist/author/utils.d.ts.map +1 -0
  27. package/dist/author/utils.js +41 -0
  28. package/dist/controller/defaults.d.ts +21 -0
  29. package/dist/controller/defaults.d.ts.map +1 -0
  30. package/dist/controller/defaults.js +14 -0
  31. package/dist/controller/index.d.ts +27 -0
  32. package/dist/controller/index.d.ts.map +1 -0
  33. package/dist/controller/index.js +57 -0
  34. package/dist/controller/utils.d.ts +10 -0
  35. package/dist/controller/utils.d.ts.map +1 -0
  36. package/dist/controller/utils.js +4 -0
  37. package/dist/delivery/index.d.ts +18 -0
  38. package/dist/delivery/index.d.ts.map +1 -0
  39. package/dist/delivery/index.js +37 -0
  40. package/dist/delivery/main.d.ts +16 -0
  41. package/dist/delivery/main.d.ts.map +1 -0
  42. package/dist/delivery/main.js +95 -0
  43. package/dist/delivery/scale.d.ts +18 -0
  44. package/dist/delivery/scale.d.ts.map +1 -0
  45. package/dist/delivery/scale.js +175 -0
  46. package/dist/delivery/trait.d.ts +28 -0
  47. package/dist/delivery/trait.d.ts.map +1 -0
  48. package/dist/delivery/trait.js +44 -0
  49. package/dist/index.d.ts +2 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.iife.d.ts +9 -0
  52. package/dist/index.iife.d.ts.map +1 -0
  53. package/dist/index.iife.js +145 -0
  54. package/dist/index.js +2 -0
  55. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js +6 -0
  56. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Hash.js +16 -0
  57. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_ListCache.js +16 -0
  58. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Map.js +6 -0
  59. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_MapCache.js +16 -0
  60. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js +6 -0
  61. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Set.js +6 -0
  62. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Stack.js +13 -0
  63. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Symbol.js +5 -0
  64. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js +5 -0
  65. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js +6 -0
  66. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js +7 -0
  67. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js +10 -0
  68. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js +15 -0
  69. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js +7 -0
  70. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js +10 -0
  71. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assocIndexOf.js +8 -0
  72. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js +8 -0
  73. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js +8 -0
  74. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js +12 -0
  75. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js +57 -0
  76. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js +14 -0
  77. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
  78. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetTag.js +10 -0
  79. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js +9 -0
  80. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js +9 -0
  81. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNative.js +11 -0
  82. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js +9 -0
  83. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
  84. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js +12 -0
  85. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js +13 -0
  86. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js +7 -0
  87. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTrim.js +8 -0
  88. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js +8 -0
  89. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
  90. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js +10 -0
  91. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js +8 -0
  92. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js +8 -0
  93. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js +8 -0
  94. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js +8 -0
  95. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js +8 -0
  96. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js +14 -0
  97. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js +8 -0
  98. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js +8 -0
  99. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_coreJsData.js +5 -0
  100. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js +10 -0
  101. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_freeGlobal.js +4 -0
  102. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js +9 -0
  103. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js +9 -0
  104. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getMapData.js +8 -0
  105. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getNative.js +9 -0
  106. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js +5 -0
  107. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getRawTag.js +14 -0
  108. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js +10 -0
  109. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js +11 -0
  110. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js +23 -0
  111. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getValue.js +6 -0
  112. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashClear.js +7 -0
  113. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashDelete.js +7 -0
  114. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashGet.js +13 -0
  115. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashHas.js +9 -0
  116. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashSet.js +9 -0
  117. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js +8 -0
  118. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js +33 -0
  119. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js +9 -0
  120. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js +8 -0
  121. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKeyable.js +7 -0
  122. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isMasked.js +11 -0
  123. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js +8 -0
  124. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js +6 -0
  125. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheDelete.js +9 -0
  126. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheGet.js +8 -0
  127. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheHas.js +7 -0
  128. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheSet.js +8 -0
  129. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheClear.js +13 -0
  130. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheDelete.js +8 -0
  131. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheGet.js +7 -0
  132. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheHas.js +7 -0
  133. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheSet.js +8 -0
  134. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js +5 -0
  135. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js +5 -0
  136. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js +8 -0
  137. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js +9 -0
  138. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_objectToString.js +7 -0
  139. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js +8 -0
  140. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_root.js +5 -0
  141. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackClear.js +7 -0
  142. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackDelete.js +7 -0
  143. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackGet.js +6 -0
  144. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackHas.js +6 -0
  145. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackSet.js +16 -0
  146. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toSource.js +15 -0
  147. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_trimmedEndIndex.js +8 -0
  148. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js +8 -0
  149. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/debounce.js +50 -0
  150. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/eq.js +6 -0
  151. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js +10 -0
  152. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArray.js +4 -0
  153. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js +8 -0
  154. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js +6 -0
  155. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEmpty.js +21 -0
  156. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isFunction.js +11 -0
  157. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isLength.js +7 -0
  158. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isMap.js +7 -0
  159. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObject.js +7 -0
  160. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js +6 -0
  161. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSet.js +7 -0
  162. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSymbol.js +9 -0
  163. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js +7 -0
  164. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keys.js +9 -0
  165. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js +9 -0
  166. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/now.js +7 -0
  167. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js +6 -0
  168. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js +6 -0
  169. package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toNumber.js +19 -0
  170. package/package.json +70 -0
  171. package/src/author/common.tsx +473 -0
  172. package/src/author/defaults.tsx +157 -0
  173. package/src/author/index.ts +174 -0
  174. package/src/author/main.tsx +407 -0
  175. package/src/author/modals.tsx +254 -0
  176. package/src/author/scale.tsx +453 -0
  177. package/src/author/trait.tsx +305 -0
  178. package/src/author/traitsHeader.tsx +301 -0
  179. package/src/author/utils.ts +83 -0
  180. package/src/controller/defaults.ts +21 -0
  181. package/src/controller/index.ts +137 -0
  182. package/src/controller/utils.ts +13 -0
  183. package/src/delivery/index.ts +61 -0
  184. package/src/delivery/main.tsx +140 -0
  185. package/src/delivery/scale.tsx +313 -0
  186. package/src/delivery/trait.tsx +86 -0
  187. package/src/index.iife.ts +16 -0
  188. package/src/index.ts +1 -0
@@ -0,0 +1,137 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/multi-trait-rubric/controller/src/index.js
4
+ * @auto-generated
5
+ *
6
+ * This file is automatically synced from pie-elements and converted to TypeScript.
7
+ * Manual edits will be overwritten on next sync.
8
+ * To make changes, edit the upstream JavaScript file and run sync again.
9
+ */
10
+
11
+ import defaults from './defaults.js';
12
+ import { markupToText } from './utils.js';
13
+
14
+ export function createDefaultModel(model = {}) {
15
+ return new Promise((resolve) => resolve({ ...defaults, ...model }));
16
+ }
17
+
18
+ export const normalize = (question) => ({ ...defaults, ...question });
19
+
20
+ /**
21
+ *
22
+ * @param {*} question
23
+ * @param {*} session
24
+ * @param {*} env
25
+ */
26
+ export async function model(question, session, env) {
27
+ const normalizedQuestion = normalize(question);
28
+
29
+ if (!env.role || env.role === 'student') {
30
+ normalizedQuestion.visible = normalizedQuestion.visibleToStudent;
31
+ } else {
32
+ normalizedQuestion.visible = true;
33
+ }
34
+
35
+ // todo update pie-ui instead of parsing this here:
36
+ const { scales, excludeZero } = normalizedQuestion || {};
37
+ const parsedScales = (scales || []).map((scale) => ({ ...scale, excludeZero }));
38
+
39
+ return {
40
+ ...normalizedQuestion,
41
+ scales: parsedScales,
42
+ };
43
+ }
44
+
45
+ export const getScore = () => 0;
46
+
47
+ /**
48
+ * @param {Object} model - the main model
49
+ * @param {*} session
50
+ * @param {Object} env
51
+ */
52
+ export function outcome() {
53
+ return new Promise((resolve) => resolve({ score: 0, empty: true }));
54
+ }
55
+
56
+ export const createCorrectResponseSession = (question, env) => {
57
+ return new Promise((resolve) => {
58
+ if (env.mode !== 'evaluate' && env.role === 'instructor') {
59
+ resolve({ id: '1' });
60
+ } else {
61
+ resolve(null);
62
+ }
63
+ });
64
+ };
65
+
66
+ // IMPORTANT! If you make any changes to this function, please make sure you also update complex-rubric/controller/validateMultiTraitRubric function!“.
67
+ export const validate = (model, config) => {
68
+ const { scales, description = false, pointLabels = false } = model;
69
+ const errors = {};
70
+ const traitsErrors = {};
71
+ const scorePointsErrors = {};
72
+
73
+ (scales || []).forEach((scale, scaleIndex) => {
74
+ const { traits = [] } = scale;
75
+ const { scorePointsLabels = [] } = scale;
76
+ const scaleErrors = {};
77
+ const scorePointsLabelsErrors = {};
78
+
79
+ if (pointLabels) {
80
+ scorePointsLabels.forEach((scorePointLabel, scoreIndex) => {
81
+ if (!scorePointLabel || scorePointLabel === '<div></div>') {
82
+ scorePointsLabelsErrors[scoreIndex] = 'Points labels should not be empty.';
83
+ } else {
84
+ const identicalScorePointLabel = scorePointsLabels
85
+ .slice(scoreIndex + 1)
86
+ .some((s) => markupToText(s) === markupToText(scorePointLabel));
87
+
88
+ if (identicalScorePointLabel) {
89
+ scorePointsLabelsErrors[scoreIndex] = 'Points labels should be unique.';
90
+ }
91
+ }
92
+ });
93
+ }
94
+
95
+ if (Object.keys(scorePointsLabelsErrors).length > 0) {
96
+ scorePointsErrors[scaleIndex] = scorePointsLabelsErrors;
97
+ }
98
+
99
+ traits.forEach((trait, traitIndex) => {
100
+ if (!trait.name || trait.name === '<div></div>') {
101
+ scaleErrors[traitIndex] = { name: 'Trait names should not be empty.' };
102
+ } else {
103
+ const identicalTraitName = traits
104
+ .slice(traitIndex + 1)
105
+ .some((t) => markupToText(t.name) === markupToText(trait.name));
106
+
107
+ if (identicalTraitName) {
108
+ scaleErrors[traitIndex] = { name: 'Trait names should be unique.' };
109
+ }
110
+ }
111
+ if (description && (!trait.description || trait.description === '<div></div>')) {
112
+ scaleErrors[traitIndex] = { ...scaleErrors[traitIndex], description: 'Trait description should not be empty' };
113
+ } else {
114
+ const identicalTraitDescr = traits
115
+ .slice(traitIndex + 1)
116
+ .some((t) => markupToText(t.description) === markupToText(trait.description));
117
+
118
+ if (description && identicalTraitDescr) {
119
+ scaleErrors[traitIndex] = { ...scaleErrors[traitIndex], description: 'Trait descriptions should be unique.' };
120
+ }
121
+ }
122
+ });
123
+ if (Object.keys(scaleErrors).length > 0) {
124
+ traitsErrors[scaleIndex] = scaleErrors;
125
+ }
126
+ });
127
+
128
+ if (Object.keys(traitsErrors).length > 0) {
129
+ errors.traitsErrors = traitsErrors;
130
+ }
131
+
132
+ if (Object.keys(scorePointsErrors).length > 0) {
133
+ errors.scorePointsErrors = scorePointsErrors;
134
+ }
135
+
136
+ return errors;
137
+ };
@@ -0,0 +1,13 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/multi-trait-rubric/controller/src/utils.js
4
+ * @auto-generated
5
+ *
6
+ * This file is automatically synced from pie-elements and converted to TypeScript.
7
+ * Manual edits will be overwritten on next sync.
8
+ * To make changes, edit the upstream JavaScript file and run sync again.
9
+ */
10
+
11
+ export const markupToText = (s) => {
12
+ return (s || '').replace(/(<([^>]+)>)/ig, '');
13
+ };
@@ -0,0 +1,61 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/multi-trait-rubric/src/index.js
4
+ * @auto-generated
5
+ *
6
+ * This file is automatically synced from pie-elements and converted to TypeScript.
7
+ * Manual edits will be overwritten on next sync.
8
+ * To make changes, edit the upstream JavaScript file and run sync again.
9
+ */
10
+
11
+ import React from 'react';
12
+ import { createRoot } from 'react-dom/client';
13
+ import { ModelSetEvent } from '@pie-element/shared-player-events';
14
+ import Main from './main.js';
15
+ import { renderMath } from '@pie-element/shared-math-rendering-mathjax';
16
+
17
+ export default class MultiTraitRubric extends HTMLElement {
18
+ constructor() {
19
+ super();
20
+ this._model = {};
21
+ this._session = null;
22
+ this._root = null;
23
+ }
24
+
25
+ set model(s) {
26
+ this._model = s;
27
+ this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this._session, !!this._model));
28
+
29
+ this._render();
30
+ }
31
+
32
+ set session(s) {
33
+ this._session = s;
34
+ }
35
+
36
+ get session() {
37
+ return this._session;
38
+ }
39
+
40
+ connectedCallback() {
41
+ this._render();
42
+ }
43
+
44
+ _render() {
45
+ const el = React.createElement(Main, { model: this._model, session: this._session });
46
+
47
+ if (!this._root) {
48
+ this._root = createRoot(this);
49
+ }
50
+ this._root.render(el);
51
+ queueMicrotask(() => {
52
+ renderMath(this);
53
+ });
54
+ }
55
+
56
+ disconnectedCallback() {
57
+ if (this._root) {
58
+ this._root.unmount();
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,140 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/multi-trait-rubric/src/main.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
+
14
+ import Scale from './scale.js';
15
+ import Link from '@mui/material/Link';
16
+ import Collapse from '@mui/material/Collapse';
17
+ import { color, UiLayout as UiLayoutImport } 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 UiLayout = unwrapReactInteropSymbol(UiLayoutImport, 'UiLayout') || unwrapReactInteropSymbol(renderUi.UiLayout, 'UiLayout');
39
+ import * as RenderUiNamespace from '@pie-lib/render-ui';
40
+ const renderUiNamespaceAny = RenderUiNamespace as any;
41
+ const renderUiDefaultMaybe = renderUiNamespaceAny['default'];
42
+ const renderUi =
43
+ renderUiDefaultMaybe && typeof renderUiDefaultMaybe === 'object'
44
+ ? renderUiDefaultMaybe
45
+ : renderUiNamespaceAny;
46
+ class Main extends React.Component {
47
+ constructor(props) {
48
+ super(props);
49
+ this.state = {
50
+ rubricOpen: false,
51
+ linkPrefix: 'Show',
52
+ };
53
+ this.toggleRubric = this.toggleRubric.bind(this);
54
+ }
55
+
56
+ toggleRubric() {
57
+ this.setState({ rubricOpen: !this.state.rubricOpen });
58
+ this.setState({ linkPrefix: this.state.rubricOpen ? 'Show' : 'Hide' });
59
+ }
60
+
61
+ render() {
62
+ const { model } = this.props;
63
+ let { animationsDisabled } = this.props;
64
+ const { extraCSSRules, halfScoring, scales, visible, pointLabels, description, standards, arrowsDisabled } =
65
+ model || {};
66
+ animationsDisabled = animationsDisabled || model.animationsDisabled;
67
+
68
+ if (!scales || !visible) {
69
+ return null;
70
+ }
71
+
72
+ const rubricItem = (
73
+ <UiLayout
74
+ extraCSSRules={extraCSSRules}
75
+ style={{ fontFamily: 'Cerebri Sans', color: color.text(), backgroundColor: color.background() }}
76
+ >
77
+ {halfScoring ? (
78
+ <div style={{ marginBottom: '16px' }}>* Half-point or in-between scores are permitted under this rubric.</div>
79
+ ) : null}
80
+
81
+ {scales.map((scale, scaleIndex) => (
82
+ <Scale
83
+ key={`scale_${scaleIndex}`}
84
+ scale={scale}
85
+ scaleIndex={scaleIndex}
86
+ showPointsLabels={pointLabels}
87
+ showDescription={description}
88
+ showStandards={standards}
89
+ arrowsDisabled={arrowsDisabled}
90
+ />
91
+ ))}
92
+ </UiLayout>
93
+ );
94
+
95
+ if (animationsDisabled) {
96
+ return rubricItem;
97
+ }
98
+
99
+ return (
100
+ <UiLayout extraCSSRules={extraCSSRules} style={{ color: color.text(), backgroundColor: color.background() }}>
101
+ <Link style={{ backgroundColor: color.background() }} href={this.dudUrl} onClick={this.toggleRubric}>
102
+ {this.state.linkPrefix} Rubric
103
+ </Link>
104
+ <Collapse style={{ marginTop: '16px' }} in={this.state.rubricOpen} timeout={{ enter: 225, exit: 195 }}>
105
+ {rubricItem}
106
+ </Collapse>
107
+ </UiLayout>
108
+ );
109
+ }
110
+ }
111
+
112
+ Main.propTypes = {
113
+ model: PropTypes.shape({
114
+ halfScoring: PropTypes.bool,
115
+ scales: PropTypes.arrayOf(
116
+ PropTypes.shape({
117
+ excludeZero: PropTypes.bool,
118
+ maxPoints: PropTypes.number,
119
+ scorePointsLabels: PropTypes.arrayOf(PropTypes.string),
120
+ traitLabel: PropTypes.string,
121
+ traits: PropTypes.arrayOf(
122
+ PropTypes.shape({
123
+ name: PropTypes.string,
124
+ description: PropTypes.string,
125
+ scorePointsDescriptors: PropTypes.arrayOf(PropTypes.string),
126
+ standards: PropTypes.arrayOf(PropTypes.string),
127
+ }),
128
+ ),
129
+ }),
130
+ ),
131
+ visible: PropTypes.bool,
132
+ pointLabels: PropTypes.bool,
133
+ description: PropTypes.bool,
134
+ standards: PropTypes.bool,
135
+ animationsDisabled: PropTypes.bool,
136
+ }),
137
+ animationsDisabled: PropTypes.bool,
138
+ };
139
+
140
+ export default Main;
@@ -0,0 +1,313 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-elements/packages/multi-trait-rubric/src/scale.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 { styled } from '@mui/material/styles';
14
+ import { color } from '@pie-lib/render-ui';
15
+ import Trait from './trait.js';
16
+ import ArrowBackIosIcon from '@mui/icons-material/ArrowBackIos';
17
+ import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos';
18
+
19
+ const Wrapper: any = styled('div')({
20
+ display: 'flex',
21
+ position: 'relative',
22
+ });
23
+
24
+ const TableWrapper: any = styled('div')({
25
+ width: '100%',
26
+ overflow: 'auto',
27
+ });
28
+
29
+ const Table: any = styled('table')(({ theme }) => ({
30
+ borderSpacing: 0,
31
+ marginBottom: theme.spacing(2),
32
+ borderRadius: '4px',
33
+ color: color.text(),
34
+ fontSize: theme.typography.fontSize,
35
+ lineHeight: '16px',
36
+ overflow: 'unset',
37
+
38
+ '& ul, ol': {
39
+ marginBlockStart: 0,
40
+ paddingInlineStart: theme.spacing(2),
41
+ },
42
+
43
+ '& th': {
44
+ padding: theme.spacing(2),
45
+ textAlign: 'left',
46
+ backgroundColor: color.secondaryBackground(),
47
+ verticalAlign: 'bottom',
48
+ },
49
+
50
+ '& th div': {
51
+ width: '200px',
52
+ },
53
+
54
+ '& td': {
55
+ width: '200px',
56
+ padding: `${theme.spacing(2)} ${theme.spacing(1)}`,
57
+ verticalAlign: 'top',
58
+ },
59
+ }));
60
+
61
+ const ScorePointHeaderTable: any = styled('table')({
62
+ '& td': {
63
+ border: 0,
64
+ padding: 0,
65
+ textAlign: 'center',
66
+ minWidth: '200px',
67
+ },
68
+ });
69
+
70
+ const PointLabel: any = styled('div')({
71
+ marginBottom: '4px',
72
+ });
73
+
74
+ const ScorePointValue: any = styled('td')({
75
+ fontWeight: 'normal',
76
+ });
77
+
78
+ const ArrowContainer = ({ show, onClick, extraStyles, children }) => (
79
+ <div
80
+ style={{
81
+ height: 'calc(100% - 1px)',
82
+ top: '1px',
83
+ display: show ? 'flex' : 'none',
84
+ width: '50px',
85
+ margin: 'auto',
86
+ position: 'absolute',
87
+ alignItems: 'center',
88
+ justifyContent: 'center',
89
+ cursor: 'pointer',
90
+ ...extraStyles,
91
+ }}
92
+ onClick={onClick}
93
+ >
94
+ {children}
95
+ </div>
96
+ );
97
+
98
+ ArrowContainer.propTypes = {
99
+ show: PropTypes.bool,
100
+ onClick: PropTypes.func,
101
+ extraStyles: PropTypes.object,
102
+ children: PropTypes.object,
103
+ };
104
+
105
+ class Scale extends React.Component {
106
+ state = {};
107
+
108
+ componentDidMount() {
109
+ if (this.tableWrapper) {
110
+ if (this.tableWrapper.offsetWidth < this.tableWrapper.scrollWidth) {
111
+ this.setState({ showRight: true });
112
+ }
113
+ }
114
+ }
115
+
116
+ scrollLeft: any = () => {
117
+ this.tableWrapper.scrollLeft -= this.tableWrapper.offsetWidth / 2;
118
+
119
+ this.setState({
120
+ showRight: this.tableWrapper.scrollLeft < this.tableWrapper.scrollWidth,
121
+ showLeft: this.tableWrapper.scrollLeft < this.tableWrapper.scrollWidth && this.tableWrapper.scrollLeft > 0,
122
+ });
123
+ };
124
+
125
+ scrollRight: any = () => {
126
+ const initialScrollLeft = this.tableWrapper.scrollLeft;
127
+ this.tableWrapper.scrollLeft += this.tableWrapper.offsetWidth / 2;
128
+
129
+ this.setState({
130
+ showRight:
131
+ initialScrollLeft !== this.tableWrapper.scrollLeft &&
132
+ this.tableWrapper.scrollLeft < this.tableWrapper.scrollWidth,
133
+ showLeft: this.tableWrapper.scrollLeft < this.tableWrapper.scrollWidth && this.tableWrapper.scrollLeft > 0,
134
+ });
135
+ };
136
+
137
+ render() {
138
+ const { showRight, showLeft } = this.state;
139
+ const { scale, scaleIndex, showDescription, showPointsLabels, showStandards, arrowsDisabled } = this.props;
140
+ const { excludeZero, maxPoints, traitLabel, traits, scorePointsLabels } = scale || {};
141
+
142
+ let scorePointsValues = [];
143
+ let descriptions;
144
+ let pointsLabels;
145
+ let standards;
146
+
147
+ try {
148
+ // determining the score points values
149
+ for (let pointValue = maxPoints; pointValue >= excludeZero ? 1 : 0; pointValue -= 1) {
150
+ scorePointsValues.push(pointValue);
151
+ }
152
+
153
+ const { traitStandards, traitDescriptions } = traits.reduce(
154
+ (tcc, trait) => ({
155
+ traitStandards: [...tcc.traitStandards, ...(trait.standards || [])],
156
+ traitDescriptions: [...tcc.traitDescriptions, ...(trait.description || [])],
157
+ }),
158
+ {
159
+ traitStandards: [],
160
+ traitDescriptions: [],
161
+ },
162
+ );
163
+
164
+ descriptions = showDescription && traitDescriptions.length;
165
+ pointsLabels = showPointsLabels && scorePointsLabels.length;
166
+ standards = showStandards && traitStandards.length;
167
+ } catch (e) {
168
+ descriptions = false;
169
+ pointsLabels = false;
170
+ standards = false;
171
+ }
172
+
173
+ return (
174
+ <Wrapper>
175
+ <ArrowContainer
176
+ show={showLeft && !arrowsDisabled}
177
+ onClick={this.scrollLeft}
178
+ extraStyles={{
179
+ left: 0,
180
+ background: `linear-gradient(to right, white, ${color.background()})`,
181
+ }}
182
+ >
183
+ <ArrowBackIosIcon />
184
+ </ArrowContainer>
185
+
186
+ <TableWrapper
187
+ ref={(ref) => {
188
+ this.tableWrapper = ref;
189
+ }}
190
+ onScroll={() => {
191
+ this.setState({
192
+ // 5 is a margin of error
193
+ showRight:
194
+ this.tableWrapper.scrollLeft + this.tableWrapper.offsetWidth < this.tableWrapper.scrollWidth - 5 &&
195
+ this.tableWrapper.scrollLeft < this.tableWrapper.scrollWidth,
196
+ showLeft:
197
+ this.tableWrapper.scrollLeft < this.tableWrapper.scrollWidth && this.tableWrapper.scrollLeft > 0,
198
+ });
199
+ }}
200
+ >
201
+ {arrowsDisabled && (showRight || showLeft) ? <div>The item is too large to fit in print mode.</div> : null}
202
+ <Table key={`scale-${scaleIndex}`}>
203
+ <thead>
204
+ <tr>
205
+ <th>
206
+ <div dangerouslySetInnerHTML={{ __html: traitLabel }} />
207
+ </th>
208
+
209
+ {standards ? (
210
+ <th>
211
+ <div>Standard(s)</div>
212
+ </th>
213
+ ) : null}
214
+
215
+ {descriptions ? (
216
+ <th>
217
+ <div>Description</div>
218
+ </th>
219
+ ) : null}
220
+
221
+ {scorePointsValues &&
222
+ scorePointsValues.map((scorePointValue, index) => {
223
+ let pointLabel = '';
224
+
225
+ // to handle the case when there aren't enough labels
226
+ try {
227
+ pointLabel = scorePointsLabels[scorePointsValues.length - index - 1] || '';
228
+ } catch (e) {
229
+ pointLabel = '';
230
+ }
231
+
232
+ return (
233
+ <th key={`table-header-${index}`}>
234
+ <ScorePointHeaderTable>
235
+ <thead>
236
+ {pointsLabels ? (
237
+ <tr>
238
+ <td>
239
+ <PointLabel
240
+ dangerouslySetInnerHTML={{ __html: pointLabel }}
241
+ />
242
+ </td>
243
+ </tr>
244
+ ) : null}
245
+ <tr>
246
+ <ScorePointValue>
247
+ {scorePointValue === 1 ? `${scorePointValue} point` : `${scorePointValue} points`}
248
+ </ScorePointValue>
249
+ </tr>
250
+ </thead>
251
+ </ScorePointHeaderTable>
252
+ </th>
253
+ );
254
+ })}
255
+ </tr>
256
+ </thead>
257
+
258
+ <tbody>
259
+ {traits &&
260
+ traits.map((trait, traitIndex) => (
261
+ <Trait
262
+ key={`trait_${scaleIndex}_${traitIndex}`}
263
+ trait={trait}
264
+ traitIndex={traitIndex}
265
+ showDescription={!!descriptions}
266
+ showStandards={!!standards}
267
+ scaleIndex={scaleIndex}
268
+ scorePointsValues={scorePointsValues}
269
+ excludeZero={excludeZero}
270
+ />
271
+ ))}
272
+ </tbody>
273
+ </Table>
274
+ </TableWrapper>
275
+
276
+ <ArrowContainer
277
+ show={showRight && !arrowsDisabled}
278
+ onClick={this.scrollRight}
279
+ extraStyles={{
280
+ right: 0,
281
+ background: `linear-gradient(to left, white, ${color.background()})`,
282
+ }}
283
+ >
284
+ <ArrowForwardIosIcon />
285
+ </ArrowContainer>
286
+ </Wrapper>
287
+ );
288
+ }
289
+ }
290
+
291
+ Scale.propTypes = {
292
+ scaleIndex: PropTypes.number,
293
+ scale: PropTypes.shape({
294
+ excludeZero: PropTypes.bool,
295
+ maxPoints: PropTypes.number,
296
+ scorePointsLabels: PropTypes.arrayOf(PropTypes.string),
297
+ traitLabel: PropTypes.string,
298
+ traits: PropTypes.arrayOf(
299
+ PropTypes.shape({
300
+ name: PropTypes.string,
301
+ standards: PropTypes.arrayOf(PropTypes.string),
302
+ scorePointsDescriptors: PropTypes.arrayOf(PropTypes.string),
303
+ description: PropTypes.string,
304
+ }),
305
+ ),
306
+ }),
307
+ showPointsLabels: PropTypes.bool,
308
+ showDescription: PropTypes.bool,
309
+ showStandards: PropTypes.bool,
310
+ arrowsDisabled: PropTypes.bool,
311
+ };
312
+
313
+ export default Scale;