@pie-lib/categorize 0.25.0 → 0.25.3
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.
- package/esm/index.js +107 -113
- package/esm/index.js.map +1 -1
- package/package.json +2 -2
package/esm/index.js
CHANGED
|
@@ -2,46 +2,46 @@ import debug from 'debug';
|
|
|
2
2
|
import clone from 'lodash/clone';
|
|
3
3
|
import remove from 'lodash/remove';
|
|
4
4
|
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
function _extends() {
|
|
6
|
+
_extends = Object.assign || function (target) {
|
|
7
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
8
|
+
var source = arguments[i];
|
|
9
|
+
|
|
10
|
+
for (var key in source) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
12
|
+
target[key] = source[key];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
}
|
|
17
|
+
return target;
|
|
18
|
+
};
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
return _extends.apply(this, arguments);
|
|
21
|
+
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
var log$1 = debug('@pie-lib:categorize:scoring');
|
|
23
|
+
const log$1 = debug('@pie-lib:categorize:scoring');
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const getWeightingRules = scoring => {
|
|
26
26
|
if (!scoring || !scoring.weighting) {
|
|
27
27
|
return [];
|
|
28
28
|
} else {
|
|
29
29
|
if (!scoring.weighting.enabled) {
|
|
30
30
|
return [];
|
|
31
31
|
} else {
|
|
32
|
-
|
|
32
|
+
const rules = scoring.weighting ? scoring.weighting.rules || [] : [];
|
|
33
33
|
return rules;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
const getPartialRulesForCategory = (partial, categoryId) => {
|
|
39
39
|
log$1('partial? ', partial);
|
|
40
40
|
|
|
41
41
|
if (!partial || !partial.enabled) {
|
|
42
42
|
return;
|
|
43
43
|
} else {
|
|
44
|
-
|
|
44
|
+
const pr = partial.rules.find(pr => pr.category === categoryId);
|
|
45
45
|
return pr ? pr.rules || [] : [];
|
|
46
46
|
}
|
|
47
47
|
};
|
|
@@ -54,25 +54,25 @@ var getPartialRulesForCategory = (partial, categoryId) => {
|
|
|
54
54
|
*/
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
const score = (categories, scoring) => new Promise(resolve => {
|
|
58
58
|
log$1('categories: ', categories, 'scoring: ', scoring);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
const weightingRules = getWeightingRules(scoring);
|
|
60
|
+
const weights = categories.map(c => {
|
|
61
|
+
const r = weightingRules.find(r => r.category === c.id) || {
|
|
62
62
|
points: 1
|
|
63
63
|
};
|
|
64
|
-
return
|
|
64
|
+
return _extends({}, r, {
|
|
65
65
|
category: c.id
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
68
|
log$1('weights: ', weights);
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
const weightTotal = categories.reduce((total, c) => {
|
|
70
|
+
const r = weights.find(r => r.category === c.id);
|
|
71
71
|
return total += r.points;
|
|
72
72
|
}, 0);
|
|
73
73
|
log$1('total: ', weightTotal);
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const withScore = categories.map(c => {
|
|
75
|
+
const w = weights.find(r => r.category === c.id).points;
|
|
76
76
|
log$1('category: ', c);
|
|
77
77
|
|
|
78
78
|
if (c.correct === true) {
|
|
@@ -82,7 +82,7 @@ var score = (categories, scoring) => new Promise(resolve => {
|
|
|
82
82
|
points: w
|
|
83
83
|
};
|
|
84
84
|
} else {
|
|
85
|
-
|
|
85
|
+
const rules = getPartialRulesForCategory(scoring.partial, c.id);
|
|
86
86
|
log$1('partial rules for category: ', rules);
|
|
87
87
|
|
|
88
88
|
if (!rules) {
|
|
@@ -92,20 +92,18 @@ var score = (categories, scoring) => new Promise(resolve => {
|
|
|
92
92
|
points: w
|
|
93
93
|
};
|
|
94
94
|
} else {
|
|
95
|
-
|
|
95
|
+
const correctCount = (c.choices || []).filter(h => h.correct).length;
|
|
96
96
|
log$1('correctCount: ', correctCount);
|
|
97
|
-
|
|
97
|
+
let rule = rules.find(u => u.count === correctCount);
|
|
98
98
|
log$1('rule: ', rule);
|
|
99
99
|
rule = rule || {
|
|
100
100
|
percent: 0,
|
|
101
101
|
count: correctCount
|
|
102
102
|
};
|
|
103
|
-
|
|
104
|
-
var _score = w * (rule.percent / 100);
|
|
105
|
-
|
|
103
|
+
const score = w * (rule.percent / 100);
|
|
106
104
|
return {
|
|
107
105
|
category: c.id,
|
|
108
|
-
score
|
|
106
|
+
score,
|
|
109
107
|
points: w,
|
|
110
108
|
partial: {
|
|
111
109
|
correctChoices: correctCount,
|
|
@@ -115,11 +113,11 @@ var score = (categories, scoring) => new Promise(resolve => {
|
|
|
115
113
|
}
|
|
116
114
|
}
|
|
117
115
|
});
|
|
118
|
-
|
|
116
|
+
const weightedScore = withScore.reduce((sum, c) => {
|
|
119
117
|
return sum += c.score;
|
|
120
118
|
}, 0);
|
|
121
119
|
log$1('weightedScore: ', weightedScore);
|
|
122
|
-
|
|
120
|
+
const score = parseFloat((weightedScore / weightTotal).toFixed(2), 10);
|
|
123
121
|
resolve({
|
|
124
122
|
score,
|
|
125
123
|
details: {
|
|
@@ -132,14 +130,11 @@ var score = (categories, scoring) => new Promise(resolve => {
|
|
|
132
130
|
});
|
|
133
131
|
});
|
|
134
132
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
var limitChoices = (choiceId, count, choices) => {
|
|
141
|
-
var out = choices.reduce((acc, id) => {
|
|
142
|
-
var foundCount = countInChoices(choiceId, acc.choices);
|
|
133
|
+
const FooTwo = 'foo-two';
|
|
134
|
+
const log = debug('@pie-lib:categorize');
|
|
135
|
+
const limitChoices = (choiceId, count, choices) => {
|
|
136
|
+
const out = choices.reduce((acc, id) => {
|
|
137
|
+
const foundCount = countInChoices(choiceId, acc.choices);
|
|
143
138
|
|
|
144
139
|
if (id !== choiceId || foundCount < count) {
|
|
145
140
|
acc.choices.push(id);
|
|
@@ -159,11 +154,11 @@ var limitChoices = (choiceId, count, choices) => {
|
|
|
159
154
|
* @param {*} limit
|
|
160
155
|
*/
|
|
161
156
|
|
|
162
|
-
|
|
157
|
+
const limitInArrays = (id, arrays, limit) => {
|
|
163
158
|
arrays = arrays || [];
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
159
|
+
const result = arrays.reduce((acc, array) => {
|
|
160
|
+
const l = limit - acc.count;
|
|
161
|
+
const result = limitInArray(id, array, l);
|
|
167
162
|
acc.out.push(result.array);
|
|
168
163
|
acc.count = acc.count + (result.count || 0);
|
|
169
164
|
return acc;
|
|
@@ -181,17 +176,17 @@ var limitInArrays = (id, arrays, limit) => {
|
|
|
181
176
|
* @param {number} limit
|
|
182
177
|
*/
|
|
183
178
|
|
|
184
|
-
|
|
179
|
+
const limitInArray = (id, arr, limit) => {
|
|
185
180
|
arr = arr || [];
|
|
186
181
|
|
|
187
182
|
if (limit === 0) {
|
|
188
|
-
|
|
183
|
+
const stripped = arr.filter(v => v !== id);
|
|
189
184
|
return {
|
|
190
185
|
array: stripped,
|
|
191
186
|
count: arr.length - stripped.length
|
|
192
187
|
};
|
|
193
188
|
} else {
|
|
194
|
-
|
|
189
|
+
const result = arr.reduce((acc, v) => {
|
|
195
190
|
if (v === id) {
|
|
196
191
|
if (acc.count < limit) {
|
|
197
192
|
acc.count += 1;
|
|
@@ -218,18 +213,17 @@ var limitInArray = (id, arr, limit) => {
|
|
|
218
213
|
* @param {{id:string,categoryCount:number}} choices
|
|
219
214
|
*/
|
|
220
215
|
|
|
221
|
-
|
|
216
|
+
const ensureNoExtraChoicesInAnswer = (answer, choices) => {
|
|
222
217
|
choices = choices || [];
|
|
223
|
-
|
|
218
|
+
const out = choices.reduce((answerArray, choice) => {
|
|
224
219
|
log('choice: ----> ', choice.id, 'categoryCount: ', choice.categoryCount);
|
|
225
220
|
|
|
226
221
|
if (choice.categoryCount === undefined || choice.categoryCount === 0) {
|
|
227
222
|
return answerArray;
|
|
228
223
|
} else {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
var updatedArray = result.map((r, index) => {
|
|
224
|
+
const choices = answerArray.map(a => a.choices);
|
|
225
|
+
const result = limitInArrays(choice.id, choices, choice.categoryCount);
|
|
226
|
+
const updatedArray = result.map((r, index) => {
|
|
233
227
|
return {
|
|
234
228
|
category: answerArray[index].category,
|
|
235
229
|
alternateResponses: answerArray[index].alternateResponses,
|
|
@@ -247,15 +241,15 @@ var ensureNoExtraChoicesInAnswer = (answer, choices) => {
|
|
|
247
241
|
* @param {{id:string,categoryCount:number}} choices
|
|
248
242
|
*/
|
|
249
243
|
|
|
250
|
-
|
|
244
|
+
const ensureNoExtraChoicesInAlternate = (answer, choices) => {
|
|
251
245
|
choices = choices || [];
|
|
252
|
-
|
|
246
|
+
const out = choices.reduce((answerArray, choice) => {
|
|
253
247
|
log('choice: ----> ', choice.id, 'categoryCount: ', choice.categoryCount);
|
|
254
248
|
|
|
255
249
|
if (choice.categoryCount === undefined || choice.categoryCount === 0) {
|
|
256
250
|
return answerArray;
|
|
257
251
|
} else {
|
|
258
|
-
|
|
252
|
+
let alternatePair = {};
|
|
259
253
|
answerArray.forEach(answer => (answer.alternateResponses || []).forEach((alternate, index) => {
|
|
260
254
|
if (index in alternatePair) {
|
|
261
255
|
alternatePair[index].push(alternate);
|
|
@@ -264,9 +258,9 @@ var ensureNoExtraChoicesInAlternate = (answer, choices) => {
|
|
|
264
258
|
alternatePair[index].push(alternate);
|
|
265
259
|
}
|
|
266
260
|
}));
|
|
267
|
-
|
|
261
|
+
const recreatedAlternate = [];
|
|
268
262
|
Object.keys(alternatePair).forEach(k => {
|
|
269
|
-
|
|
263
|
+
const limitAlternate = limitInArrays(choice.id, alternatePair[k], choice.categoryCount);
|
|
270
264
|
alternatePair[k] = limitAlternate;
|
|
271
265
|
alternatePair[k].forEach((item, index) => {
|
|
272
266
|
if (!recreatedAlternate[index]) {
|
|
@@ -277,7 +271,7 @@ var ensureNoExtraChoicesInAlternate = (answer, choices) => {
|
|
|
277
271
|
}
|
|
278
272
|
});
|
|
279
273
|
});
|
|
280
|
-
|
|
274
|
+
const updatedArray = answerArray.map((answer, index) => {
|
|
281
275
|
return {
|
|
282
276
|
category: answer.category,
|
|
283
277
|
alternateResponses: recreatedAlternate[index] || answer.alternateResponses,
|
|
@@ -295,19 +289,19 @@ var ensureNoExtraChoicesInAlternate = (answer, choices) => {
|
|
|
295
289
|
* @param {{category: string, choices: string[]}[]} answer
|
|
296
290
|
*/
|
|
297
291
|
|
|
298
|
-
|
|
299
|
-
|
|
292
|
+
const countInAnswer = (choiceId, answer) => {
|
|
293
|
+
const out = answer.reduce((acc, a) => acc + countInChoices(choiceId, a.choices), 0);
|
|
300
294
|
log('[countInAnswer] choiceId:', choiceId, answer);
|
|
301
295
|
return out;
|
|
302
296
|
};
|
|
303
|
-
|
|
297
|
+
const countInChoices = (choiceId, choices) => (choices || []).filter(c => c === choiceId).length;
|
|
304
298
|
/**
|
|
305
299
|
* Count the number of times a choice has been selected in categories.
|
|
306
300
|
* @param {*} choice
|
|
307
301
|
* @param {*} categories
|
|
308
302
|
*/
|
|
309
303
|
|
|
310
|
-
|
|
304
|
+
const countChosen = (choice, categories) => {
|
|
311
305
|
if (!choice || !choice.id) {
|
|
312
306
|
return 0;
|
|
313
307
|
}
|
|
@@ -317,7 +311,7 @@ var countChosen = (choice, categories) => {
|
|
|
317
311
|
}
|
|
318
312
|
|
|
319
313
|
return categories.reduce((acc, c) => {
|
|
320
|
-
|
|
314
|
+
const count = (c.choices || []).filter(h => h && h.id === choice.id).length;
|
|
321
315
|
return acc + count;
|
|
322
316
|
}, 0);
|
|
323
317
|
};
|
|
@@ -326,19 +320,19 @@ var countChosen = (choice, categories) => {
|
|
|
326
320
|
* @param {{category:string, choices: string[]}} answers
|
|
327
321
|
*/
|
|
328
322
|
|
|
329
|
-
|
|
323
|
+
const removeCategory = (categoryId, answers) => answers.filter(a => a.category !== categoryId);
|
|
330
324
|
/**
|
|
331
325
|
* @param {string} choiceId
|
|
332
326
|
* @param {{category:string, choices: string[]}} answers
|
|
333
327
|
* @param {string?} categoryId - optional categegory id
|
|
334
328
|
*/
|
|
335
329
|
|
|
336
|
-
|
|
330
|
+
const removeAllChoices = (choiceId, answers, categoryId) => {
|
|
337
331
|
return answers.map(a => {
|
|
338
332
|
if (!categoryId || a.category === categoryId) {
|
|
339
|
-
|
|
333
|
+
const cloned = clone(a.choices);
|
|
340
334
|
remove(cloned, v => v === choiceId);
|
|
341
|
-
return
|
|
335
|
+
return _extends({}, a, {
|
|
342
336
|
choices: cloned
|
|
343
337
|
});
|
|
344
338
|
} else {
|
|
@@ -346,7 +340,7 @@ var removeAllChoices = (choiceId, answers, categoryId) => {
|
|
|
346
340
|
}
|
|
347
341
|
});
|
|
348
342
|
};
|
|
349
|
-
|
|
343
|
+
const rearrangeChoices = (choices, indexFrom, indexTo) => {
|
|
350
344
|
if (choices.length === 0) {
|
|
351
345
|
return choices;
|
|
352
346
|
}
|
|
@@ -354,7 +348,7 @@ var rearrangeChoices = (choices, indexFrom, indexTo) => {
|
|
|
354
348
|
choices.splice(indexFrom, 1, choices.splice(indexTo, 1, choices[indexFrom])[0]);
|
|
355
349
|
return choices;
|
|
356
350
|
};
|
|
357
|
-
|
|
351
|
+
const verifyAllowMultiplePlacements = (choice, categoryId, answers) => {
|
|
358
352
|
return answers.map(a => {
|
|
359
353
|
if (a.category !== categoryId) {
|
|
360
354
|
a.choices = (a.choices || []).filter(c => c !== choice.id);
|
|
@@ -362,7 +356,7 @@ var verifyAllowMultiplePlacements = (choice, categoryId, answers) => {
|
|
|
362
356
|
} else {
|
|
363
357
|
a.choices = a.choices.reduce((acc, currentValue) => {
|
|
364
358
|
if (currentValue.id === choice.id) {
|
|
365
|
-
|
|
359
|
+
const foundIndex = acc.findIndex(c => c.id === choice.id);
|
|
366
360
|
|
|
367
361
|
if (foundIndex === -1) {
|
|
368
362
|
acc.push(currentValue);
|
|
@@ -377,12 +371,12 @@ var verifyAllowMultiplePlacements = (choice, categoryId, answers) => {
|
|
|
377
371
|
}
|
|
378
372
|
});
|
|
379
373
|
};
|
|
380
|
-
|
|
374
|
+
const removeChoiceFromCategory = (choiceId, categoryId, choiceIndex, answers) => {
|
|
381
375
|
log('[removeChoiceFromCategory] choiceIndex:', choiceIndex);
|
|
382
376
|
return answers.map(a => {
|
|
383
377
|
if (a.category === categoryId) {
|
|
384
|
-
|
|
385
|
-
|
|
378
|
+
const cloned = clone(a.choices);
|
|
379
|
+
const index = cloned.findIndex((v, index) => {
|
|
386
380
|
return v === choiceId && index >= choiceIndex;
|
|
387
381
|
});
|
|
388
382
|
|
|
@@ -390,7 +384,7 @@ var removeChoiceFromCategory = (choiceId, categoryId, choiceIndex, answers) => {
|
|
|
390
384
|
cloned.splice(index, 1);
|
|
391
385
|
}
|
|
392
386
|
|
|
393
|
-
return
|
|
387
|
+
return _extends({}, a, {
|
|
394
388
|
choices: cloned
|
|
395
389
|
});
|
|
396
390
|
} else {
|
|
@@ -398,10 +392,10 @@ var removeChoiceFromCategory = (choiceId, categoryId, choiceIndex, answers) => {
|
|
|
398
392
|
}
|
|
399
393
|
});
|
|
400
394
|
};
|
|
401
|
-
|
|
395
|
+
const removeChoiceFromAlternate = (choiceId, categoryId, choiceIndex, altIndex, answers) => {
|
|
402
396
|
return (answers || []).map(a => {
|
|
403
|
-
if ((a
|
|
404
|
-
|
|
397
|
+
if ((a == null ? void 0 : a.category) === categoryId) {
|
|
398
|
+
const newAlternates = ((a == null ? void 0 : a.alternateResponses) || []).map((altArray, idx) => {
|
|
405
399
|
if (idx === altIndex) {
|
|
406
400
|
(altArray || []).splice(choiceIndex, 1);
|
|
407
401
|
return altArray;
|
|
@@ -409,7 +403,7 @@ var removeChoiceFromAlternate = (choiceId, categoryId, choiceIndex, altIndex, an
|
|
|
409
403
|
|
|
410
404
|
return altArray;
|
|
411
405
|
});
|
|
412
|
-
return
|
|
406
|
+
return _extends({}, a, {
|
|
413
407
|
alternateResponses: newAlternates
|
|
414
408
|
});
|
|
415
409
|
}
|
|
@@ -417,7 +411,7 @@ var removeChoiceFromAlternate = (choiceId, categoryId, choiceIndex, altIndex, an
|
|
|
417
411
|
return a;
|
|
418
412
|
});
|
|
419
413
|
};
|
|
420
|
-
|
|
414
|
+
const moveChoiceToCategory = (choiceId, from, to, choiceIndex, answers) => {
|
|
421
415
|
log('[moveChoiceToCategory] choice: ', choiceId, 'from: ', from, 'to: ', to, 'answers: ', answers);
|
|
422
416
|
|
|
423
417
|
if (from === to) {
|
|
@@ -428,7 +422,7 @@ var moveChoiceToCategory = (choiceId, from, to, choiceIndex, answers) => {
|
|
|
428
422
|
answers = removeChoiceFromCategory(choiceId, from, choiceIndex, answers);
|
|
429
423
|
}
|
|
430
424
|
|
|
431
|
-
|
|
425
|
+
const index = answers.findIndex(a => a.category === to);
|
|
432
426
|
|
|
433
427
|
if (index === -1) {
|
|
434
428
|
answers.push({
|
|
@@ -448,7 +442,7 @@ var moveChoiceToCategory = (choiceId, from, to, choiceIndex, answers) => {
|
|
|
448
442
|
});
|
|
449
443
|
}
|
|
450
444
|
};
|
|
451
|
-
|
|
445
|
+
const moveChoiceToAlternate = (choiceId, from, to, choiceIndex, answers, alternateIndex, categoryCount) => {
|
|
452
446
|
log('[moveChoiceToAlternate] choice: ', choiceId, 'from: ', from, 'to: ', to, 'answers: ', answers, 'chocieIndex: ', choiceIndex);
|
|
453
447
|
|
|
454
448
|
if (from === to) {
|
|
@@ -476,9 +470,9 @@ var moveChoiceToAlternate = (choiceId, from, to, choiceIndex, answers, alternate
|
|
|
476
470
|
return a;
|
|
477
471
|
});
|
|
478
472
|
};
|
|
479
|
-
|
|
473
|
+
const stillSelectable = (h, builtCategories) => {
|
|
480
474
|
if (h.categoryCount > 0) {
|
|
481
|
-
|
|
475
|
+
const count = countChosen(h, builtCategories);
|
|
482
476
|
return count < h.categoryCount;
|
|
483
477
|
} else {
|
|
484
478
|
return true;
|
|
@@ -493,19 +487,19 @@ var stillSelectable = (h, builtCategories) => {
|
|
|
493
487
|
* BuiltChoice = { id: choiceId, content: choiceContent, correct: boolean }
|
|
494
488
|
*/
|
|
495
489
|
|
|
496
|
-
|
|
490
|
+
const buildChoices = (possibleResponseChoices, builtCategoryChoices) => {
|
|
497
491
|
return builtCategoryChoices.reduce((acc, builtChoice) => {
|
|
498
492
|
// set correct value on each choice that was selected by user
|
|
499
|
-
|
|
493
|
+
const index = acc.copyOfPossibleResponse.findIndex(cRC => builtChoice && cRC === builtChoice.id); // if the choice exists in the correct response
|
|
500
494
|
// set the correct: true
|
|
501
495
|
|
|
502
496
|
if (index >= 0) {
|
|
503
|
-
acc.builtChoices.push(
|
|
497
|
+
acc.builtChoices.push(_extends({}, builtChoice, {
|
|
504
498
|
correct: true
|
|
505
499
|
}));
|
|
506
500
|
acc.copyOfPossibleResponse = [...acc.copyOfPossibleResponse.slice(0, index), ...acc.copyOfPossibleResponse.slice(index + 1)];
|
|
507
501
|
} else {
|
|
508
|
-
acc.builtChoices.push(
|
|
502
|
+
acc.builtChoices.push(_extends({}, builtChoice, {
|
|
509
503
|
correct: false
|
|
510
504
|
}));
|
|
511
505
|
acc.allChoicesAreCorrect = false;
|
|
@@ -528,17 +522,17 @@ var buildChoices = (possibleResponseChoices, builtCategoryChoices) => {
|
|
|
528
522
|
* BuiltChoice = { id: choiceId, content: choiceContent, correct: boolean }
|
|
529
523
|
*/
|
|
530
524
|
|
|
531
|
-
|
|
532
|
-
|
|
525
|
+
const getBuiltCategories = (possibleResponse, builtCategories) => builtCategories.reduce((acc, builtCategory) => {
|
|
526
|
+
const possibleResponseChoices = possibleResponse[builtCategory.id] || []; // the correct choices for this category
|
|
533
527
|
|
|
534
|
-
|
|
528
|
+
const builtCategoryChoices = builtCategory.choices || []; // the choices in the answer
|
|
535
529
|
|
|
536
|
-
|
|
530
|
+
const {
|
|
537
531
|
builtChoices,
|
|
538
532
|
allChoicesAreCorrect
|
|
539
533
|
} = buildChoices(possibleResponseChoices, builtCategoryChoices);
|
|
540
|
-
|
|
541
|
-
acc.builtCategories.push(
|
|
534
|
+
const allChoicesAreInAnswer = builtCategoryChoices.length === possibleResponseChoices.length;
|
|
535
|
+
acc.builtCategories.push(_extends({}, builtCategory, {
|
|
542
536
|
correct: allChoicesAreCorrect && allChoicesAreInAnswer,
|
|
543
537
|
choices: builtChoices
|
|
544
538
|
}));
|
|
@@ -556,7 +550,7 @@ var getBuiltCategories = (possibleResponse, builtCategories) => builtCategories.
|
|
|
556
550
|
* Response = { CategoryId: ChoiceId[] },
|
|
557
551
|
*/
|
|
558
552
|
|
|
559
|
-
|
|
553
|
+
const getAllPossibleResponses = correctResponse => {
|
|
560
554
|
if (!correctResponse) {
|
|
561
555
|
return [];
|
|
562
556
|
}
|
|
@@ -598,16 +592,16 @@ var getAllPossibleResponses = correctResponse => {
|
|
|
598
592
|
* BuiltChoice = { id: choiceId, content: choiceContent }
|
|
599
593
|
*/
|
|
600
594
|
|
|
601
|
-
|
|
595
|
+
const buildCategories = (categories, choices, answers) => {
|
|
602
596
|
categories = categories || [];
|
|
603
597
|
answers = answers || [];
|
|
604
598
|
choices = choices || [];
|
|
605
599
|
return categories.map(category => {
|
|
606
|
-
|
|
607
|
-
|
|
600
|
+
const answer = answers.find(answer => answer.category === category.id);
|
|
601
|
+
const {
|
|
608
602
|
choices: answerChoices = []
|
|
609
603
|
} = answer || {};
|
|
610
|
-
return
|
|
604
|
+
return _extends({}, category, {
|
|
611
605
|
choices: answerChoices.map(chId => choices.find(ch => ch.id === chId))
|
|
612
606
|
});
|
|
613
607
|
});
|
|
@@ -622,19 +616,19 @@ var buildCategories = (categories, choices, answers) => {
|
|
|
622
616
|
* @returns { categories: Category[], choices: Choice[], correct: boolean, bestResponse: Response }, where Response: { categoryId: choiceId[] }
|
|
623
617
|
*/
|
|
624
618
|
|
|
625
|
-
|
|
619
|
+
const buildState = (categories, choices, answers, correctResponse) => {
|
|
626
620
|
categories = categories || [];
|
|
627
621
|
choices = choices || [];
|
|
628
622
|
answers = answers || [];
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
623
|
+
const allResponses = getAllPossibleResponses(correctResponse) || [];
|
|
624
|
+
let builtCategories = buildCategories(categories, choices, answers);
|
|
625
|
+
let bestResponse;
|
|
626
|
+
let entirelyCorrect; // at least one defined correct response
|
|
633
627
|
|
|
634
628
|
if (allResponses.length) {
|
|
635
|
-
|
|
629
|
+
const builtData = allResponses.reduce((acc, possibleResponse) => {
|
|
636
630
|
// set correctness for each possible response
|
|
637
|
-
|
|
631
|
+
const {
|
|
638
632
|
builtCategories: categoriesWithChoices,
|
|
639
633
|
correct
|
|
640
634
|
} = getBuiltCategories(possibleResponse, builtCategories); // if bestResponse not found yet OR no correct response found yet and this one is the correct one
|
|
@@ -658,7 +652,7 @@ var buildState = (categories, choices, answers, correctResponse) => {
|
|
|
658
652
|
entirelyCorrect = builtData.entirelyCorrect;
|
|
659
653
|
}
|
|
660
654
|
|
|
661
|
-
|
|
655
|
+
const filteredChoices = choices.map(ch => stillSelectable(ch, builtCategories) ? ch : {
|
|
662
656
|
empty: true
|
|
663
657
|
});
|
|
664
658
|
return {
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../node_modules/@babel/runtime/helpers/esm/defineProperty.js","../src/scoring.js","../src/index.js"],"sourcesContent":["export default function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}","import debug from 'debug';\n\nconst log = debug('@pie-lib:categorize:scoring');\n\nconst getWeightingRules = (scoring) => {\n if (!scoring || !scoring.weighting) {\n return [];\n } else {\n if (!scoring.weighting.enabled) {\n return [];\n } else {\n const rules = scoring.weighting ? scoring.weighting.rules || [] : [];\n\n return rules;\n }\n }\n};\n\nconst getPartialRulesForCategory = (partial, categoryId) => {\n log('partial? ', partial);\n\n if (!partial || !partial.enabled) {\n return;\n } else {\n const pr = partial.rules.find((pr) => pr.category === categoryId);\n\n return pr ? pr.rules || [] : [];\n }\n};\n\n/**\n *\n * Calculate score based on the categories model generated from `buildState` and the partial scoring rules.\n * @param {*} categories - this is the categories that you get from `buildState`.\n * @param {*} scoring - scoring config.\n * @see ../index#buildState\n */\n\nexport const score = (categories, scoring) =>\n new Promise((resolve) => {\n log('categories: ', categories, 'scoring: ', scoring);\n\n const weightingRules = getWeightingRules(scoring);\n\n const weights = categories.map((c) => {\n const r = weightingRules.find((r) => r.category === c.id) || { points: 1 };\n\n return { ...r, category: c.id };\n });\n\n log('weights: ', weights);\n\n const weightTotal = categories.reduce((total, c) => {\n const r = weights.find((r) => r.category === c.id);\n\n return (total += r.points);\n }, 0);\n\n log('total: ', weightTotal);\n\n const withScore = categories.map((c) => {\n const w = weights.find((r) => r.category === c.id).points;\n\n log('category: ', c);\n if (c.correct === true) {\n return { category: c.id, score: w, points: w };\n } else {\n const rules = getPartialRulesForCategory(scoring.partial, c.id);\n\n log('partial rules for category: ', rules);\n\n if (!rules) {\n return { category: c.id, score: 0, points: w };\n } else {\n const correctCount = (c.choices || []).filter((h) => h.correct).length;\n\n log('correctCount: ', correctCount);\n\n let rule = rules.find((u) => u.count === correctCount);\n\n log('rule: ', rule);\n\n rule = rule || { percent: 0, count: correctCount };\n\n const score = w * (rule.percent / 100);\n\n return {\n category: c.id,\n score,\n points: w,\n partial: {\n correctChoices: correctCount,\n rule: rule,\n },\n };\n }\n }\n });\n\n const weightedScore = withScore.reduce((sum, c) => {\n return (sum += c.score);\n }, 0);\n\n log('weightedScore: ', weightedScore);\n\n const score = parseFloat((weightedScore / weightTotal).toFixed(2), 10);\n\n resolve({\n score,\n details: {\n weighted: {\n total: weightTotal,\n score: weightedScore,\n },\n categories: withScore,\n },\n });\n });\n","import debug from 'debug';\nimport clone from 'lodash/clone';\nimport remove from 'lodash/remove';\nimport { score } from './scoring';\n\nexport { score };\n\nexport const FooTwo = 'foo-two';\n\nconst log = debug('@pie-lib:categorize');\n\nexport const limitChoices = (choiceId, count, choices) => {\n const out = choices.reduce(\n (acc, id) => {\n const foundCount = countInChoices(choiceId, acc.choices);\n\n if (id !== choiceId || foundCount < count) {\n acc.choices.push(id);\n }\n\n return acc;\n },\n { choices: [] },\n );\n\n return out.choices;\n};\n\n/**\n * Limit in an array of arrays.\n * So for an array with [[1,1],[1,1]] if you call limitInArray(1, arr, 3) you'll get: [[1,1], [1]]\n * @param {*} id\n * @param {*} arrays\n * @param {*} limit\n */\nexport const limitInArrays = (id, arrays, limit) => {\n arrays = arrays || [];\n\n const result = arrays.reduce(\n (acc, array) => {\n const l = limit - acc.count;\n const result = limitInArray(id, array, l);\n\n acc.out.push(result.array);\n acc.count = acc.count + (result.count || 0);\n\n return acc;\n },\n { out: [], count: 0 },\n );\n\n return result.out;\n};\n\n/**\n * Limit the id in the array to the limit set.\n * So for an array with [1,1,1,1] if you call limitInArray(1, arr, 2) you'll get: [1,1]\n * @param {string} id\n * @param {string[]} arr\n * @param {number} limit\n */\nexport const limitInArray = (id, arr, limit) => {\n arr = arr || [];\n\n if (limit === 0) {\n const stripped = arr.filter((v) => v !== id);\n\n return { array: stripped, count: arr.length - stripped.length };\n } else {\n const result = arr.reduce(\n (acc, v) => {\n if (v === id) {\n if (acc.count < limit) {\n acc.count += 1;\n acc.out.push(v);\n }\n } else {\n acc.out.push(v);\n }\n\n return acc;\n },\n { out: [], count: 0 },\n );\n\n return { array: result.out, count: result.count };\n }\n};\n\n/**\n * Ensure that there are no extra choices in answer, if a choice.categoryCount is > 0.\n * @param {{category: string, choices: string[]}[]} answer\n * @param {{id:string,categoryCount:number}} choices\n */\nexport const ensureNoExtraChoicesInAnswer = (answer, choices) => {\n choices = choices || [];\n\n const out = choices.reduce((answerArray, choice) => {\n log('choice: ----> ', choice.id, 'categoryCount: ', choice.categoryCount);\n\n if (choice.categoryCount === undefined || choice.categoryCount === 0) {\n return answerArray;\n } else {\n const choices = answerArray.map((a) => a.choices);\n const result = limitInArrays(choice.id, choices, choice.categoryCount);\n\n const updatedArray = result.map((r, index) => {\n return {\n category: answerArray[index].category,\n alternateResponses: answerArray[index].alternateResponses,\n choices: r,\n };\n });\n\n return updatedArray;\n }\n }, answer);\n return out;\n};\n\n/**\n * Ensure that there are no extra choices in alternate responses, if a choice.categoryCount is > 0.\n * @param {{category: string, choices: string[]}[]} answer\n * @param {{id:string,categoryCount:number}} choices\n */\n\nexport const ensureNoExtraChoicesInAlternate = (answer, choices) => {\n choices = choices || [];\n\n const out = choices.reduce((answerArray, choice) => {\n log('choice: ----> ', choice.id, 'categoryCount: ', choice.categoryCount);\n\n if (choice.categoryCount === undefined || choice.categoryCount === 0) {\n return answerArray;\n } else {\n let alternatePair = {};\n\n answerArray.forEach((answer) =>\n (answer.alternateResponses || []).forEach((alternate, index) => {\n if (index in alternatePair) {\n alternatePair[index].push(alternate);\n } else {\n alternatePair[index] = [];\n alternatePair[index].push(alternate);\n }\n }),\n );\n\n const recreatedAlternate = [];\n\n Object.keys(alternatePair).forEach((k) => {\n const limitAlternate = limitInArrays(choice.id, alternatePair[k], choice.categoryCount);\n alternatePair[k] = limitAlternate;\n\n alternatePair[k].forEach((item, index) => {\n if (!recreatedAlternate[index]) {\n recreatedAlternate[index] = [];\n recreatedAlternate[index].push(item);\n } else {\n recreatedAlternate[index].push(item);\n }\n });\n });\n\n const updatedArray = answerArray.map((answer, index) => {\n return {\n category: answer.category,\n alternateResponses: recreatedAlternate[index] || answer.alternateResponses,\n choices: answer.choices,\n };\n });\n return updatedArray;\n }\n }, answer);\n\n return out;\n};\n/**\n * Count the number of choice ids in a given answer array\n * @param {string} choiceId\n * @param {{category: string, choices: string[]}[]} answer\n */\nexport const countInAnswer = (choiceId, answer) => {\n const out = answer.reduce((acc, a) => acc + countInChoices(choiceId, a.choices), 0);\n\n log('[countInAnswer] choiceId:', choiceId, answer);\n\n return out;\n};\n\nexport const countInChoices = (choiceId, choices) => (choices || []).filter((c) => c === choiceId).length;\n\n/**\n * Count the number of times a choice has been selected in categories.\n * @param {*} choice\n * @param {*} categories\n */\nexport const countChosen = (choice, categories) => {\n if (!choice || !choice.id) {\n return 0;\n }\n\n if (!Array.isArray(categories)) {\n return 0;\n }\n\n return categories.reduce((acc, c) => {\n const count = (c.choices || []).filter((h) => h && h.id === choice.id).length;\n\n return acc + count;\n }, 0);\n};\n\n/**\n * @param {string?} categoryId\n * @param {{category:string, choices: string[]}} answers\n */\nexport const removeCategory = (categoryId, answers) => answers.filter((a) => a.category !== categoryId);\n\n/**\n * @param {string} choiceId\n * @param {{category:string, choices: string[]}} answers\n * @param {string?} categoryId - optional categegory id\n */\nexport const removeAllChoices = (choiceId, answers, categoryId) => {\n return answers.map((a) => {\n if (!categoryId || a.category === categoryId) {\n const cloned = clone(a.choices);\n\n remove(cloned, (v) => v === choiceId);\n\n return { ...a, choices: cloned };\n } else {\n return a;\n }\n });\n};\n\nexport const rearrangeChoices = (choices, indexFrom, indexTo) => {\n if (choices.length === 0) {\n return choices;\n }\n\n choices.splice(indexFrom, 1, choices.splice(indexTo, 1, choices[indexFrom])[0]);\n\n return choices;\n};\n\nexport const verifyAllowMultiplePlacements = (choice, categoryId, answers) => {\n return answers.map((a) => {\n if (a.category !== categoryId) {\n a.choices = (a.choices || []).filter((c) => c !== choice.id);\n\n return a;\n } else {\n a.choices = a.choices.reduce((acc, currentValue) => {\n if (currentValue.id === choice.id) {\n const foundIndex = acc.findIndex((c) => c.id === choice.id);\n\n if (foundIndex === -1) {\n acc.push(currentValue);\n }\n } else {\n acc.push(currentValue);\n }\n\n return acc;\n }, []);\n\n return a;\n }\n });\n};\n\nexport const removeChoiceFromCategory = (choiceId, categoryId, choiceIndex, answers) => {\n log('[removeChoiceFromCategory] choiceIndex:', choiceIndex);\n\n return answers.map((a) => {\n if (a.category === categoryId) {\n const cloned = clone(a.choices);\n const index = cloned.findIndex((v, index) => {\n return v === choiceId && index >= choiceIndex;\n });\n\n if (index !== -1) {\n cloned.splice(index, 1);\n }\n\n return { ...a, choices: cloned };\n } else {\n return a;\n }\n });\n};\n\nexport const removeChoiceFromAlternate = (choiceId, categoryId, choiceIndex, altIndex, answers) => {\n return (answers || []).map((a) => {\n if (a?.category === categoryId) {\n const newAlternates = (a?.alternateResponses || []).map((altArray, idx) => {\n if (idx === altIndex) {\n (altArray || []).splice(choiceIndex, 1);\n return altArray;\n }\n return altArray;\n });\n return { ...a, alternateResponses: newAlternates };\n }\n return a;\n });\n};\n\nexport const moveChoiceToCategory = (choiceId, from, to, choiceIndex, answers) => {\n log('[moveChoiceToCategory] choice: ', choiceId, 'from: ', from, 'to: ', to, 'answers: ', answers);\n\n if (from === to) {\n return answers;\n }\n\n if (from) {\n answers = removeChoiceFromCategory(choiceId, from, choiceIndex, answers);\n }\n\n const index = answers.findIndex((a) => a.category === to);\n if (index === -1) {\n answers.push({ category: to, choices: [choiceId] });\n\n return answers;\n } else {\n return answers.map((a) => {\n if (a.category === to) {\n a.choices = a.choices || [];\n a.choices.push(choiceId);\n\n return a;\n }\n\n return a;\n });\n }\n};\n\nexport const moveChoiceToAlternate = (choiceId, from, to, choiceIndex, answers, alternateIndex, categoryCount) => {\n log(\n '[moveChoiceToAlternate] choice: ',\n choiceId,\n 'from: ',\n from,\n 'to: ',\n to,\n 'answers: ',\n answers,\n 'chocieIndex: ',\n choiceIndex,\n );\n\n if (from === to) {\n return answers;\n }\n\n return answers.map((a) => {\n if (a.category === to) {\n if (categoryCount !== 0 && a.alternateResponses) {\n a.alternateResponses[alternateIndex] = (a.alternateResponses[alternateIndex] || []).filter(\n (resp) => resp !== choiceId,\n );\n }\n\n if (!a.alternateResponses) {\n a.alternateResponses = [];\n a.alternateResponses[alternateIndex] = [];\n }\n\n a.alternateResponses[alternateIndex].push(choiceId);\n }\n\n if (a.category === from && categoryCount !== 0 && a.alternateResponses && a.alternateResponses[alternateIndex]) {\n a.alternateResponses[alternateIndex] = a.alternateResponses[alternateIndex].filter((resp) => resp !== choiceId);\n }\n\n return a;\n });\n};\n\nexport const stillSelectable = (h, builtCategories) => {\n if (h.categoryCount > 0) {\n const count = countChosen(h, builtCategories);\n\n return count < h.categoryCount;\n } else {\n return true;\n }\n};\n\n/**\n * returns all choices with property 'correct' set to boolean\n * @param {string[]} possibleResponseChoices\n * @param {Object[]} builtCategoryChoices\n *\n * @returns {Object}, returns builtChoices: BuiltChoice[] and allChoicesAreCorrect: boolean\n * BuiltChoice = { id: choiceId, content: choiceContent, correct: boolean }\n */\nexport const buildChoices = (possibleResponseChoices, builtCategoryChoices) => {\n return builtCategoryChoices.reduce(\n (acc, builtChoice) => {\n // set correct value on each choice that was selected by user\n const index = acc.copyOfPossibleResponse.findIndex((cRC) => builtChoice && cRC === builtChoice.id);\n\n // if the choice exists in the correct response\n // set the correct: true\n if (index >= 0) {\n acc.builtChoices.push({\n ...builtChoice,\n correct: true,\n });\n acc.copyOfPossibleResponse = [\n ...acc.copyOfPossibleResponse.slice(0, index),\n ...acc.copyOfPossibleResponse.slice(index + 1),\n ];\n } else {\n acc.builtChoices.push({\n ...builtChoice,\n correct: false,\n });\n acc.allChoicesAreCorrect = false;\n }\n\n return acc;\n },\n {\n builtChoices: [],\n copyOfPossibleResponse: [...possibleResponseChoices],\n allChoicesAreCorrect: true,\n },\n );\n};\n\n/**\n * returns corrected answer using this possible correct response\n * @param {Object} possibleResponse, has form: { CategoryId: ChoiceId[] }\n * @param {Object[]} builtCategories\n *\n * @returns {Object}, returns builtCategories: BuiltCategory[] and correct: boolean\n * BuiltCategory = { id: categoryId, label: categoryLabel, correct: boolean, choices: BuiltChoice[] }\n * BuiltChoice = { id: choiceId, content: choiceContent, correct: boolean }\n */\nexport const getBuiltCategories = (possibleResponse, builtCategories) =>\n builtCategories.reduce(\n (acc, builtCategory) => {\n const possibleResponseChoices = possibleResponse[builtCategory.id] || []; // the correct choices for this category\n const builtCategoryChoices = builtCategory.choices || []; // the choices in the answer\n\n const { builtChoices, allChoicesAreCorrect } = buildChoices(possibleResponseChoices, builtCategoryChoices);\n const allChoicesAreInAnswer = builtCategoryChoices.length === possibleResponseChoices.length;\n\n acc.builtCategories.push({\n ...builtCategory,\n correct: allChoicesAreCorrect && allChoicesAreInAnswer,\n choices: builtChoices,\n });\n acc.correct = acc.correct && allChoicesAreCorrect && allChoicesAreInAnswer;\n\n return acc;\n },\n { builtCategories: [], correct: true },\n );\n\n/**\n * returns all the possible responses by combining the proper alternate responses\n * @param {Object[]} correctResponse\n *\n * @returns {Object[]}, returns Response[]\n * Response = { CategoryId: ChoiceId[] },\n */\nexport const getAllPossibleResponses = (correctResponse) => {\n if (!correctResponse) {\n return [];\n }\n\n return correctResponse.reduce((acc, cR) => {\n // main response\n if (acc[0]) {\n acc[0][cR.category] = cR.choices;\n } else {\n acc.push({ [cR.category]: cR.choices });\n }\n\n // alternate responses\n if (cR.alternateResponses) {\n cR.alternateResponses.forEach((aR, index) => {\n if (acc[index + 1]) {\n acc[index + 1][cR.category] = aR;\n } else {\n acc.push({ [cR.category]: aR });\n }\n });\n }\n\n return acc;\n }, []);\n};\n\n/**\n * build the categories to be displayed, where each category has its own list of choices\n * @param {Object[]} categories\n * @param {{id:string}[]} choices\n * @param {{category: string, choices:string[]}[]} answers\n *\n * @returns {Object[]}, returns BuiltCategory[]\n * BuiltCategory = { id: categoryId, label: categoryLabel, choices: BuiltChoice[]},\n * BuiltChoice = { id: choiceId, content: choiceContent }\n */\nexport const buildCategories = (categories, choices, answers) => {\n categories = categories || [];\n answers = answers || [];\n choices = choices || [];\n\n return categories.map((category) => {\n const answer = answers.find((answer) => answer.category === category.id);\n const { choices: answerChoices = [] } = answer || {};\n\n return {\n ...category,\n choices: answerChoices.map((chId) => choices.find((ch) => ch.id === chId)),\n };\n });\n};\n\n/**\n * build the choice and category state\n * @param {Object[]} categories\n * @param {{id:string}[]} choices\n * @param {{category: string, choices:string[]}[]} answers\n *\n * @param correctResponse\n * @returns { categories: Category[], choices: Choice[], correct: boolean, bestResponse: Response }, where Response: { categoryId: choiceId[] }\n */\nexport const buildState = (categories, choices, answers, correctResponse) => {\n categories = categories || [];\n choices = choices || [];\n answers = answers || [];\n\n const allResponses = getAllPossibleResponses(correctResponse) || [];\n\n let builtCategories = buildCategories(categories, choices, answers);\n let bestResponse;\n let entirelyCorrect;\n\n // at least one defined correct response\n if (allResponses.length) {\n const builtData = allResponses.reduce(\n (acc, possibleResponse) => {\n // set correctness for each possible response\n const { builtCategories: categoriesWithChoices, correct } = getBuiltCategories(\n possibleResponse,\n builtCategories,\n );\n\n // if bestResponse not found yet OR no correct response found yet and this one is the correct one\n if (acc.bestResponse === null || (!acc.entirelyCorrect && correct)) {\n return {\n bestResponse: possibleResponse,\n builtCategories: categoriesWithChoices,\n entirelyCorrect: correct,\n };\n }\n\n return acc;\n },\n {\n bestResponse: null,\n builtCategories: [],\n entirelyCorrect: false,\n },\n );\n\n builtCategories = builtData.builtCategories;\n bestResponse = builtData.bestResponse;\n entirelyCorrect = builtData.entirelyCorrect;\n }\n\n const filteredChoices = choices.map((ch) => (stillSelectable(ch, builtCategories) ? ch : { empty: true }));\n\n return {\n choices: filteredChoices,\n categories: builtCategories,\n correct: entirelyCorrect,\n bestResponse,\n };\n};\n"],"names":["log","debug","getWeightingRules","scoring","weighting","enabled","rules","getPartialRulesForCategory","partial","categoryId","pr","find","category","score","categories","Promise","resolve","weightingRules","weights","map","c","r","id","points","_objectSpread","weightTotal","reduce","total","withScore","w","correct","correctCount","choices","filter","h","length","rule","u","count","percent","correctChoices","weightedScore","sum","parseFloat","toFixed","details","weighted","FooTwo","limitChoices","choiceId","out","acc","foundCount","countInChoices","push","limitInArrays","arrays","limit","result","array","l","limitInArray","arr","stripped","v","ensureNoExtraChoicesInAnswer","answer","answerArray","choice","categoryCount","undefined","a","updatedArray","index","alternateResponses","ensureNoExtraChoicesInAlternate","alternatePair","forEach","alternate","recreatedAlternate","Object","keys","k","limitAlternate","item","countInAnswer","countChosen","Array","isArray","removeCategory","answers","removeAllChoices","cloned","clone","remove","rearrangeChoices","indexFrom","indexTo","splice","verifyAllowMultiplePlacements","currentValue","foundIndex","findIndex","removeChoiceFromCategory","choiceIndex","removeChoiceFromAlternate","altIndex","newAlternates","altArray","idx","moveChoiceToCategory","from","to","moveChoiceToAlternate","alternateIndex","resp","stillSelectable","builtCategories","buildChoices","possibleResponseChoices","builtCategoryChoices","builtChoice","copyOfPossibleResponse","cRC","builtChoices","slice","allChoicesAreCorrect","getBuiltCategories","possibleResponse","builtCategory","allChoicesAreInAnswer","getAllPossibleResponses","correctResponse","cR","aR","buildCategories","answerChoices","chId","ch","buildState","allResponses","bestResponse","entirelyCorrect","builtData","categoriesWithChoices","filteredChoices","empty"],"mappings":";;;;AAAe,SAAS,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE;AACzD,EAAE,IAAI,GAAG,IAAI,GAAG,EAAE;AAClB,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE;AACpC,MAAM,KAAK,EAAE,KAAK;AAClB,MAAM,UAAU,EAAE,IAAI;AACtB,MAAM,YAAY,EAAE,IAAI;AACxB,MAAM,QAAQ,EAAE;AAChB,KAAK,CAAC;AACN,EAAE,CAAC,MAAM;AACT,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK;AACpB,EAAE;;AAEF,EAAE,OAAO,GAAG;AACZ;;;;;ACXA,IAAMA,KAAG,GAAGC,KAAK,CAAC,6BAAD,CAAjB;;AAEA,IAAMC,iBAAiB,GAAIC,OAAD,IA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BADT;AAELX,UAAAA,eAAe,EAAE2B,qBAFZ;AAGLF,UAAAA,eAAe,EAAEhH;AAHZ,SAAP;AAKD,MAAA;;AAED,MAAA,OAAOqB,GAAP;AACD,IAAA,CAlBe,EAmBhB;AACE0F,MAAAA,YAAY,EAAE,IADhB;AAEExB,MAAAA,eAAe,EAAE,EAFnB;AAGEyB,MAAAA,eAAe,EAAE;AAHnB,KAnBgB,CAAlB;AA0BAzB,IAAAA,eAAe,GAAG0B,SAAS,CAAC1B,eAA5B;AACAwB,IAAAA,YAAY,GAAGE,SAAS,CAACF,YAAzB;AACAC,IAAAA,eAAe,GAAGC,SAAS,CAACD,eAA5B;AACD,EAAA;;AAED,EAAA,IAAMG,eAAe,GAAGjH,OAAO,CAACb,GAAR,CAAauH,EAAD,IAAStB,eAAe,CAACsB,EAAD,EAAKrB,eAAL,CAAf,GAAuCqB,EAAvC,GAA4C;AAAEQ,IAAAA,KAAK,EAAE;AAAT,GAAjE,CAAxB;AAEA,EAAA,OAAO;AACLlH,IAAAA,OAAO,EAAEiH,eADJ;AAELnI,IAAAA,UAAU,EAAEuG,eAFP;AAGLvF,IAAAA,OAAO,EAAEgH,eAHJ;AAILD,IAAAA;AAJK,GAAP;AAMD;;;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/scoring.js","../src/index.js"],"sourcesContent":["import debug from 'debug';\n\nconst log = debug('@pie-lib:categorize:scoring');\n\nconst getWeightingRules = (scoring) => {\n if (!scoring || !scoring.weighting) {\n return [];\n } else {\n if (!scoring.weighting.enabled) {\n return [];\n } else {\n const rules = scoring.weighting ? scoring.weighting.rules || [] : [];\n\n return rules;\n }\n }\n};\n\nconst getPartialRulesForCategory = (partial, categoryId) => {\n log('partial? ', partial);\n\n if (!partial || !partial.enabled) {\n return;\n } else {\n const pr = partial.rules.find((pr) => pr.category === categoryId);\n\n return pr ? pr.rules || [] : [];\n }\n};\n\n/**\n *\n * Calculate score based on the categories model generated from `buildState` and the partial scoring rules.\n * @param {*} categories - this is the categories that you get from `buildState`.\n * @param {*} scoring - scoring config.\n * @see ../index#buildState\n */\n\nexport const score = (categories, scoring) =>\n new Promise((resolve) => {\n log('categories: ', categories, 'scoring: ', scoring);\n\n const weightingRules = getWeightingRules(scoring);\n\n const weights = categories.map((c) => {\n const r = weightingRules.find((r) => r.category === c.id) || { points: 1 };\n\n return { ...r, category: c.id };\n });\n\n log('weights: ', weights);\n\n const weightTotal = categories.reduce((total, c) => {\n const r = weights.find((r) => r.category === c.id);\n\n return (total += r.points);\n }, 0);\n\n log('total: ', weightTotal);\n\n const withScore = categories.map((c) => {\n const w = weights.find((r) => r.category === c.id).points;\n\n log('category: ', c);\n if (c.correct === true) {\n return { category: c.id, score: w, points: w };\n } else {\n const rules = getPartialRulesForCategory(scoring.partial, c.id);\n\n log('partial rules for category: ', rules);\n\n if (!rules) {\n return { category: c.id, score: 0, points: w };\n } else {\n const correctCount = (c.choices || []).filter((h) => h.correct).length;\n\n log('correctCount: ', correctCount);\n\n let rule = rules.find((u) => u.count === correctCount);\n\n log('rule: ', rule);\n\n rule = rule || { percent: 0, count: correctCount };\n\n const score = w * (rule.percent / 100);\n\n return {\n category: c.id,\n score,\n points: w,\n partial: {\n correctChoices: correctCount,\n rule: rule,\n },\n };\n }\n }\n });\n\n const weightedScore = withScore.reduce((sum, c) => {\n return (sum += c.score);\n }, 0);\n\n log('weightedScore: ', weightedScore);\n\n const score = parseFloat((weightedScore / weightTotal).toFixed(2), 10);\n\n resolve({\n score,\n details: {\n weighted: {\n total: weightTotal,\n score: weightedScore,\n },\n categories: withScore,\n },\n });\n });\n","import debug from 'debug';\nimport clone from 'lodash/clone';\nimport remove from 'lodash/remove';\nimport { score } from './scoring';\n\nexport { score };\n\nexport const FooTwo = 'foo-two';\n\nconst log = debug('@pie-lib:categorize');\n\nexport const limitChoices = (choiceId, count, choices) => {\n const out = choices.reduce(\n (acc, id) => {\n const foundCount = countInChoices(choiceId, acc.choices);\n\n if (id !== choiceId || foundCount < count) {\n acc.choices.push(id);\n }\n\n return acc;\n },\n { choices: [] },\n );\n\n return out.choices;\n};\n\n/**\n * Limit in an array of arrays.\n * So for an array with [[1,1],[1,1]] if you call limitInArray(1, arr, 3) you'll get: [[1,1], [1]]\n * @param {*} id\n * @param {*} arrays\n * @param {*} limit\n */\nexport const limitInArrays = (id, arrays, limit) => {\n arrays = arrays || [];\n\n const result = arrays.reduce(\n (acc, array) => {\n const l = limit - acc.count;\n const result = limitInArray(id, array, l);\n\n acc.out.push(result.array);\n acc.count = acc.count + (result.count || 0);\n\n return acc;\n },\n { out: [], count: 0 },\n );\n\n return result.out;\n};\n\n/**\n * Limit the id in the array to the limit set.\n * So for an array with [1,1,1,1] if you call limitInArray(1, arr, 2) you'll get: [1,1]\n * @param {string} id\n * @param {string[]} arr\n * @param {number} limit\n */\nexport const limitInArray = (id, arr, limit) => {\n arr = arr || [];\n\n if (limit === 0) {\n const stripped = arr.filter((v) => v !== id);\n\n return { array: stripped, count: arr.length - stripped.length };\n } else {\n const result = arr.reduce(\n (acc, v) => {\n if (v === id) {\n if (acc.count < limit) {\n acc.count += 1;\n acc.out.push(v);\n }\n } else {\n acc.out.push(v);\n }\n\n return acc;\n },\n { out: [], count: 0 },\n );\n\n return { array: result.out, count: result.count };\n }\n};\n\n/**\n * Ensure that there are no extra choices in answer, if a choice.categoryCount is > 0.\n * @param {{category: string, choices: string[]}[]} answer\n * @param {{id:string,categoryCount:number}} choices\n */\nexport const ensureNoExtraChoicesInAnswer = (answer, choices) => {\n choices = choices || [];\n\n const out = choices.reduce((answerArray, choice) => {\n log('choice: ----> ', choice.id, 'categoryCount: ', choice.categoryCount);\n\n if (choice.categoryCount === undefined || choice.categoryCount === 0) {\n return answerArray;\n } else {\n const choices = answerArray.map((a) => a.choices);\n const result = limitInArrays(choice.id, choices, choice.categoryCount);\n\n const updatedArray = result.map((r, index) => {\n return {\n category: answerArray[index].category,\n alternateResponses: answerArray[index].alternateResponses,\n choices: r,\n };\n });\n\n return updatedArray;\n }\n }, answer);\n return out;\n};\n\n/**\n * Ensure that there are no extra choices in alternate responses, if a choice.categoryCount is > 0.\n * @param {{category: string, choices: string[]}[]} answer\n * @param {{id:string,categoryCount:number}} choices\n */\n\nexport const ensureNoExtraChoicesInAlternate = (answer, choices) => {\n choices = choices || [];\n\n const out = choices.reduce((answerArray, choice) => {\n log('choice: ----> ', choice.id, 'categoryCount: ', choice.categoryCount);\n\n if (choice.categoryCount === undefined || choice.categoryCount === 0) {\n return answerArray;\n } else {\n let alternatePair = {};\n\n answerArray.forEach((answer) =>\n (answer.alternateResponses || []).forEach((alternate, index) => {\n if (index in alternatePair) {\n alternatePair[index].push(alternate);\n } else {\n alternatePair[index] = [];\n alternatePair[index].push(alternate);\n }\n }),\n );\n\n const recreatedAlternate = [];\n\n Object.keys(alternatePair).forEach((k) => {\n const limitAlternate = limitInArrays(choice.id, alternatePair[k], choice.categoryCount);\n alternatePair[k] = limitAlternate;\n\n alternatePair[k].forEach((item, index) => {\n if (!recreatedAlternate[index]) {\n recreatedAlternate[index] = [];\n recreatedAlternate[index].push(item);\n } else {\n recreatedAlternate[index].push(item);\n }\n });\n });\n\n const updatedArray = answerArray.map((answer, index) => {\n return {\n category: answer.category,\n alternateResponses: recreatedAlternate[index] || answer.alternateResponses,\n choices: answer.choices,\n };\n });\n return updatedArray;\n }\n }, answer);\n\n return out;\n};\n/**\n * Count the number of choice ids in a given answer array\n * @param {string} choiceId\n * @param {{category: string, choices: string[]}[]} answer\n */\nexport const countInAnswer = (choiceId, answer) => {\n const out = answer.reduce((acc, a) => acc + countInChoices(choiceId, a.choices), 0);\n\n log('[countInAnswer] choiceId:', choiceId, answer);\n\n return out;\n};\n\nexport const countInChoices = (choiceId, choices) => (choices || []).filter((c) => c === choiceId).length;\n\n/**\n * Count the number of times a choice has been selected in categories.\n * @param {*} choice\n * @param {*} categories\n */\nexport const countChosen = (choice, categories) => {\n if (!choice || !choice.id) {\n return 0;\n }\n\n if (!Array.isArray(categories)) {\n return 0;\n }\n\n return categories.reduce((acc, c) => {\n const count = (c.choices || []).filter((h) => h && h.id === choice.id).length;\n\n return acc + count;\n }, 0);\n};\n\n/**\n * @param {string?} categoryId\n * @param {{category:string, choices: string[]}} answers\n */\nexport const removeCategory = (categoryId, answers) => answers.filter((a) => a.category !== categoryId);\n\n/**\n * @param {string} choiceId\n * @param {{category:string, choices: string[]}} answers\n * @param {string?} categoryId - optional categegory id\n */\nexport const removeAllChoices = (choiceId, answers, categoryId) => {\n return answers.map((a) => {\n if (!categoryId || a.category === categoryId) {\n const cloned = clone(a.choices);\n\n remove(cloned, (v) => v === choiceId);\n\n return { ...a, choices: cloned };\n } else {\n return a;\n }\n });\n};\n\nexport const rearrangeChoices = (choices, indexFrom, indexTo) => {\n if (choices.length === 0) {\n return choices;\n }\n\n choices.splice(indexFrom, 1, choices.splice(indexTo, 1, choices[indexFrom])[0]);\n\n return choices;\n};\n\nexport const verifyAllowMultiplePlacements = (choice, categoryId, answers) => {\n return answers.map((a) => {\n if (a.category !== categoryId) {\n a.choices = (a.choices || []).filter((c) => c !== choice.id);\n\n return a;\n } else {\n a.choices = a.choices.reduce((acc, currentValue) => {\n if (currentValue.id === choice.id) {\n const foundIndex = acc.findIndex((c) => c.id === choice.id);\n\n if (foundIndex === -1) {\n acc.push(currentValue);\n }\n } else {\n acc.push(currentValue);\n }\n\n return acc;\n }, []);\n\n return a;\n }\n });\n};\n\nexport const removeChoiceFromCategory = (choiceId, categoryId, choiceIndex, answers) => {\n log('[removeChoiceFromCategory] choiceIndex:', choiceIndex);\n\n return answers.map((a) => {\n if (a.category === categoryId) {\n const cloned = clone(a.choices);\n const index = cloned.findIndex((v, index) => {\n return v === choiceId && index >= choiceIndex;\n });\n\n if (index !== -1) {\n cloned.splice(index, 1);\n }\n\n return { ...a, choices: cloned };\n } else {\n return a;\n }\n });\n};\n\nexport const removeChoiceFromAlternate = (choiceId, categoryId, choiceIndex, altIndex, answers) => {\n return (answers || []).map((a) => {\n if (a?.category === categoryId) {\n const newAlternates = (a?.alternateResponses || []).map((altArray, idx) => {\n if (idx === altIndex) {\n (altArray || []).splice(choiceIndex, 1);\n return altArray;\n }\n return altArray;\n });\n return { ...a, alternateResponses: newAlternates };\n }\n return a;\n });\n};\n\nexport const moveChoiceToCategory = (choiceId, from, to, choiceIndex, answers) => {\n log('[moveChoiceToCategory] choice: ', choiceId, 'from: ', from, 'to: ', to, 'answers: ', answers);\n\n if (from === to) {\n return answers;\n }\n\n if (from) {\n answers = removeChoiceFromCategory(choiceId, from, choiceIndex, answers);\n }\n\n const index = answers.findIndex((a) => a.category === to);\n if (index === -1) {\n answers.push({ category: to, choices: [choiceId] });\n\n return answers;\n } else {\n return answers.map((a) => {\n if (a.category === to) {\n a.choices = a.choices || [];\n a.choices.push(choiceId);\n\n return a;\n }\n\n return a;\n });\n }\n};\n\nexport const moveChoiceToAlternate = (choiceId, from, to, choiceIndex, answers, alternateIndex, categoryCount) => {\n log(\n '[moveChoiceToAlternate] choice: ',\n choiceId,\n 'from: ',\n from,\n 'to: ',\n to,\n 'answers: ',\n answers,\n 'chocieIndex: ',\n choiceIndex,\n );\n\n if (from === to) {\n return answers;\n }\n\n return answers.map((a) => {\n if (a.category === to) {\n if (categoryCount !== 0 && a.alternateResponses) {\n a.alternateResponses[alternateIndex] = (a.alternateResponses[alternateIndex] || []).filter(\n (resp) => resp !== choiceId,\n );\n }\n\n if (!a.alternateResponses) {\n a.alternateResponses = [];\n a.alternateResponses[alternateIndex] = [];\n }\n\n a.alternateResponses[alternateIndex].push(choiceId);\n }\n\n if (a.category === from && categoryCount !== 0 && a.alternateResponses && a.alternateResponses[alternateIndex]) {\n a.alternateResponses[alternateIndex] = a.alternateResponses[alternateIndex].filter((resp) => resp !== choiceId);\n }\n\n return a;\n });\n};\n\nexport const stillSelectable = (h, builtCategories) => {\n if (h.categoryCount > 0) {\n const count = countChosen(h, builtCategories);\n\n return count < h.categoryCount;\n } else {\n return true;\n }\n};\n\n/**\n * returns all choices with property 'correct' set to boolean\n * @param {string[]} possibleResponseChoices\n * @param {Object[]} builtCategoryChoices\n *\n * @returns {Object}, returns builtChoices: BuiltChoice[] and allChoicesAreCorrect: boolean\n * BuiltChoice = { id: choiceId, content: choiceContent, correct: boolean }\n */\nexport const buildChoices = (possibleResponseChoices, builtCategoryChoices) => {\n return builtCategoryChoices.reduce(\n (acc, builtChoice) => {\n // set correct value on each choice that was selected by user\n const index = acc.copyOfPossibleResponse.findIndex((cRC) => builtChoice && cRC === builtChoice.id);\n\n // if the choice exists in the correct response\n // set the correct: true\n if (index >= 0) {\n acc.builtChoices.push({\n ...builtChoice,\n correct: true,\n });\n acc.copyOfPossibleResponse = [\n ...acc.copyOfPossibleResponse.slice(0, index),\n ...acc.copyOfPossibleResponse.slice(index + 1),\n ];\n } else {\n acc.builtChoices.push({\n ...builtChoice,\n correct: false,\n });\n acc.allChoicesAreCorrect = false;\n }\n\n return acc;\n },\n {\n builtChoices: [],\n copyOfPossibleResponse: [...possibleResponseChoices],\n allChoicesAreCorrect: true,\n },\n );\n};\n\n/**\n * returns corrected answer using this possible correct response\n * @param {Object} possibleResponse, has form: { CategoryId: ChoiceId[] }\n * @param {Object[]} builtCategories\n *\n * @returns {Object}, returns builtCategories: BuiltCategory[] and correct: boolean\n * BuiltCategory = { id: categoryId, label: categoryLabel, correct: boolean, choices: BuiltChoice[] }\n * BuiltChoice = { id: choiceId, content: choiceContent, correct: boolean }\n */\nexport const getBuiltCategories = (possibleResponse, builtCategories) =>\n builtCategories.reduce(\n (acc, builtCategory) => {\n const possibleResponseChoices = possibleResponse[builtCategory.id] || []; // the correct choices for this category\n const builtCategoryChoices = builtCategory.choices || []; // the choices in the answer\n\n const { builtChoices, allChoicesAreCorrect } = buildChoices(possibleResponseChoices, builtCategoryChoices);\n const allChoicesAreInAnswer = builtCategoryChoices.length === possibleResponseChoices.length;\n\n acc.builtCategories.push({\n ...builtCategory,\n correct: allChoicesAreCorrect && allChoicesAreInAnswer,\n choices: builtChoices,\n });\n acc.correct = acc.correct && allChoicesAreCorrect && allChoicesAreInAnswer;\n\n return acc;\n },\n { builtCategories: [], correct: true },\n );\n\n/**\n * returns all the possible responses by combining the proper alternate responses\n * @param {Object[]} correctResponse\n *\n * @returns {Object[]}, returns Response[]\n * Response = { CategoryId: ChoiceId[] },\n */\nexport const getAllPossibleResponses = (correctResponse) => {\n if (!correctResponse) {\n return [];\n }\n\n return correctResponse.reduce((acc, cR) => {\n // main response\n if (acc[0]) {\n acc[0][cR.category] = cR.choices;\n } else {\n acc.push({ [cR.category]: cR.choices });\n }\n\n // alternate responses\n if (cR.alternateResponses) {\n cR.alternateResponses.forEach((aR, index) => {\n if (acc[index + 1]) {\n acc[index + 1][cR.category] = aR;\n } else {\n acc.push({ [cR.category]: aR });\n }\n });\n }\n\n return acc;\n }, []);\n};\n\n/**\n * build the categories to be displayed, where each category has its own list of choices\n * @param {Object[]} categories\n * @param {{id:string}[]} choices\n * @param {{category: string, choices:string[]}[]} answers\n *\n * @returns {Object[]}, returns BuiltCategory[]\n * BuiltCategory = { id: categoryId, label: categoryLabel, choices: BuiltChoice[]},\n * BuiltChoice = { id: choiceId, content: choiceContent }\n */\nexport const buildCategories = (categories, choices, answers) => {\n categories = categories || [];\n answers = answers || [];\n choices = choices || [];\n\n return categories.map((category) => {\n const answer = answers.find((answer) => answer.category === category.id);\n const { choices: answerChoices = [] } = answer || {};\n\n return {\n ...category,\n choices: answerChoices.map((chId) => choices.find((ch) => ch.id === chId)),\n };\n });\n};\n\n/**\n * build the choice and category state\n * @param {Object[]} categories\n * @param {{id:string}[]} choices\n * @param {{category: string, choices:string[]}[]} answers\n *\n * @param correctResponse\n * @returns { categories: Category[], choices: Choice[], correct: boolean, bestResponse: Response }, where Response: { categoryId: choiceId[] }\n */\nexport const buildState = (categories, choices, answers, correctResponse) => {\n categories = categories || [];\n choices = choices || [];\n answers = answers || [];\n\n const allResponses = getAllPossibleResponses(correctResponse) || [];\n\n let builtCategories = buildCategories(categories, choices, answers);\n let bestResponse;\n let entirelyCorrect;\n\n // at least one defined correct response\n if (allResponses.length) {\n const builtData = allResponses.reduce(\n (acc, possibleResponse) => {\n // set correctness for each possible response\n const { builtCategories: categoriesWithChoices, correct } = getBuiltCategories(\n possibleResponse,\n builtCategories,\n );\n\n // if bestResponse not found yet OR no correct response found yet and this one is the correct one\n if (acc.bestResponse === null || (!acc.entirelyCorrect && correct)) {\n return {\n bestResponse: possibleResponse,\n builtCategories: categoriesWithChoices,\n entirelyCorrect: correct,\n };\n }\n\n return acc;\n },\n {\n bestResponse: null,\n builtCategories: [],\n entirelyCorrect: false,\n },\n );\n\n builtCategories = builtData.builtCategories;\n bestResponse = builtData.bestResponse;\n entirelyCorrect = builtData.entirelyCorrect;\n }\n\n const filteredChoices = choices.map((ch) => (stillSelectable(ch, builtCategories) ? ch : { empty: true }));\n\n return {\n choices: filteredChoices,\n categories: builtCategories,\n correct: entirelyCorrect,\n bestResponse,\n };\n};\n"],"names":["log","debug","getWeightingRules","scoring","weighting","enabled","rules","getPartialRulesForCategory","partial","categoryId","pr","find","category","score","categories","Promise","resolve","weightingRules","weights","map","c","r","id","points","weightTotal","reduce","total","withScore","w","correct","correctCount","choices","filter","h","length","rule","u","count","percent","correctChoices","weightedScore","sum","parseFloat","toFixed","details","weighted","FooTwo","limitChoices","choiceId","out","acc","foundCount","countInChoices","push","limitInArrays","arrays","limit","result","array","l","limitInArray","arr","stripped","v","ensureNoExtraChoicesInAnswer","answer","answerArray","choice","categoryCount","undefined","a","updatedArray","index","alternateResponses","ensureNoExtraChoicesInAlternate","alternatePair","forEach","alternate","recreatedAlternate","Object","keys","k","limitAlternate","item","countInAnswer","countChosen","Array","isArray","removeCategory","answers","removeAllChoices","cloned","clone","remove","rearrangeChoices","indexFrom","indexTo","splice","verifyAllowMultiplePlacements","currentValue","foundIndex","findIndex","removeChoiceFromCategory","choiceIndex","removeChoiceFromAlternate","altIndex","newAlternates","altArray","idx","moveChoiceToCategory","from","to","moveChoiceToAlternate","alternateIndex","resp","stillSelectable","builtCategories","buildChoices","possibleResponseChoices","builtCategoryChoices","builtChoice","copyOfPossibleResponse","cRC","builtChoices","slice","allChoicesAreCorrect","getBuiltCategories","possibleResponse","builtCategory","allChoicesAreInAnswer","getAllPossibleResponses","correctResponse","cR","aR","buildCategories","answerChoices","chId","ch","buildState","allResponses","bestResponse","entirelyCorrect","builtData","categoriesWithChoices","filteredChoices","empty"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,MAAMA,KAAG,GAAGC,KAAK,CAAC,6BAAD,CAAjB;;AAEA,MAAMC,iBAAiB,GAAIC,OAAD,IAAa;AACrC,EAAA,IAAI,CAACA,OAAD,IAAY,CAACA,OAAO,CAACC,SAAzB,EAAoC;AAClC,IAAA,OAAO,EAAP;AACD,EAAA,CAFD,MAEO;AACL,IAAA,IAAI,CAACD,OAAO,CAACC,SAAR,CAAkBC,OAAvB,EAAgC;AAC9B,MAAA,OAAO,EAAP;AACD,IAAA,CAFD,MAEO;AACL,MAAA,MAAMC,KAAK,GAAGH,OAAO,CAACC,SAAR,GAAoBD,OAAO,CAACC,SAAR,CAAkBE,KAAlB,IAA2B,EAA/C,GAAoD,EAAlE;AAEA,MAAA,OAAOA,KAAP;AACD,IAAA;AACF,EAAA;AACF,CAZD;;AAcA,MAAMC,0BAA0B,GAAG,CAACC,OAAD,EAAUC,UAAV,KAAyB;AAC1DT,EAAAA,KAAG,CAAC,WAAD,EAAcQ,OAAd,CAAH;;AAEA,EAAA,IAAI,CAACA,OAAD,IAAY,CAACA,OAAO,CAACH,OAAzB,EAAkC;AAChC,IAAA;AACD,EAAA,CAFD,MAEO;AACL,IAAA,MAAMK,EAAE,GAAGF,OAAO,CAACF,KAAR,CAAcK,IAAd,CAAoBD,EAAD,IAAQA,EAAE,CAACE,QAAH,KAAgBH,UAA3C,CAAX;AAEA,IAAA,OAAOC,EAAE,GAAGA,EAAE,CAACJ,KAAH,IAAY,EAAf,GAAoB,EAA7B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AA8B,CAAC1F,GAAG,CAAC2F,eAAL,IAAwBhH,OAA1D,EAAoE;AAClE,QAAA,OAAO;AACL+G,UAAAA,YAAY,EAAEb,gBADT;AAELX,UAAAA,eAAe,EAAE2B,qBAFZ;AAGLF,UAAAA,eAAe,EAAEhH;AAHZ,SAAP;AAKD,MAAA;;AAED,MAAA,OAAOqB,GAAP;AACD,IAAA,CAlBe,EAmBhB;AACE0F,MAAAA,YAAY,EAAE,IADhB;AAEExB,MAAAA,eAAe,EAAE,EAFnB;AAGEyB,MAAAA,eAAe,EAAE;AAHnB,KAnBgB,CAAlB;AA0BAzB,IAAAA,eAAe,GAAG0B,SAAS,CAAC1B,eAA5B;AACAwB,IAAAA,YAAY,GAAGE,SAAS,CAACF,YAAzB;AACAC,IAAAA,eAAe,GAAGC,SAAS,CAACD,eAA5B;AACD,EAAA;;AAED,EAAA,MAAMG,eAAe,GAAGjH,OAAO,CAACZ,GAAR,CAAasH,EAAD,IAAStB,eAAe,CAACsB,EAAD,EAAKrB,eAAL,CAAf,GAAuCqB,EAAvC,GAA4C;AAAEQ,IAAAA,KAAK,EAAE;AAAT,GAAjE,CAAxB;AAEA,EAAA,OAAO;AACLlH,IAAAA,OAAO,EAAEiH,eADJ;AAELlI,IAAAA,UAAU,EAAEsG,eAFP;AAGLvF,IAAAA,OAAO,EAAEgH,eAHJ;AAILD,IAAAA;AAJK,GAAP;AAMD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/categorize",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"scripts": {},
|
|
15
15
|
"author": "",
|
|
16
16
|
"license": "ISC",
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "3b10dbe1c14708ccf9a9e8af8f1eafec6ed7dd2d",
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
20
|
"import": "./esm/index.js",
|