@pie-lib/categorize 0.24.1-next.0 → 0.25.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.
- package/esm/index.js +673 -0
- package/esm/index.js.map +1 -0
- package/package.json +9 -2
package/esm/index.js
ADDED
|
@@ -0,0 +1,673 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import clone from 'lodash/clone';
|
|
3
|
+
import remove from 'lodash/remove';
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) {
|
|
6
|
+
if (key in obj) {
|
|
7
|
+
Object.defineProperty(obj, key, {
|
|
8
|
+
value: value,
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true
|
|
12
|
+
});
|
|
13
|
+
} else {
|
|
14
|
+
obj[key] = value;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return obj;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
|
|
22
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
+
var log$1 = debug('@pie-lib:categorize:scoring');
|
|
24
|
+
|
|
25
|
+
var getWeightingRules = scoring => {
|
|
26
|
+
if (!scoring || !scoring.weighting) {
|
|
27
|
+
return [];
|
|
28
|
+
} else {
|
|
29
|
+
if (!scoring.weighting.enabled) {
|
|
30
|
+
return [];
|
|
31
|
+
} else {
|
|
32
|
+
var rules = scoring.weighting ? scoring.weighting.rules || [] : [];
|
|
33
|
+
return rules;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var getPartialRulesForCategory = (partial, categoryId) => {
|
|
39
|
+
log$1('partial? ', partial);
|
|
40
|
+
|
|
41
|
+
if (!partial || !partial.enabled) {
|
|
42
|
+
return;
|
|
43
|
+
} else {
|
|
44
|
+
var pr = partial.rules.find(pr => pr.category === categoryId);
|
|
45
|
+
return pr ? pr.rules || [] : [];
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* Calculate score based on the categories model generated from `buildState` and the partial scoring rules.
|
|
51
|
+
* @param {*} categories - this is the categories that you get from `buildState`.
|
|
52
|
+
* @param {*} scoring - scoring config.
|
|
53
|
+
* @see ../index#buildState
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
var score = (categories, scoring) => new Promise(resolve => {
|
|
58
|
+
log$1('categories: ', categories, 'scoring: ', scoring);
|
|
59
|
+
var weightingRules = getWeightingRules(scoring);
|
|
60
|
+
var weights = categories.map(c => {
|
|
61
|
+
var r = weightingRules.find(r => r.category === c.id) || {
|
|
62
|
+
points: 1
|
|
63
|
+
};
|
|
64
|
+
return _objectSpread$1(_objectSpread$1({}, r), {}, {
|
|
65
|
+
category: c.id
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
log$1('weights: ', weights);
|
|
69
|
+
var weightTotal = categories.reduce((total, c) => {
|
|
70
|
+
var r = weights.find(r => r.category === c.id);
|
|
71
|
+
return total += r.points;
|
|
72
|
+
}, 0);
|
|
73
|
+
log$1('total: ', weightTotal);
|
|
74
|
+
var withScore = categories.map(c => {
|
|
75
|
+
var w = weights.find(r => r.category === c.id).points;
|
|
76
|
+
log$1('category: ', c);
|
|
77
|
+
|
|
78
|
+
if (c.correct === true) {
|
|
79
|
+
return {
|
|
80
|
+
category: c.id,
|
|
81
|
+
score: w,
|
|
82
|
+
points: w
|
|
83
|
+
};
|
|
84
|
+
} else {
|
|
85
|
+
var rules = getPartialRulesForCategory(scoring.partial, c.id);
|
|
86
|
+
log$1('partial rules for category: ', rules);
|
|
87
|
+
|
|
88
|
+
if (!rules) {
|
|
89
|
+
return {
|
|
90
|
+
category: c.id,
|
|
91
|
+
score: 0,
|
|
92
|
+
points: w
|
|
93
|
+
};
|
|
94
|
+
} else {
|
|
95
|
+
var correctCount = (c.choices || []).filter(h => h.correct).length;
|
|
96
|
+
log$1('correctCount: ', correctCount);
|
|
97
|
+
var rule = rules.find(u => u.count === correctCount);
|
|
98
|
+
log$1('rule: ', rule);
|
|
99
|
+
rule = rule || {
|
|
100
|
+
percent: 0,
|
|
101
|
+
count: correctCount
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
var _score = w * (rule.percent / 100);
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
category: c.id,
|
|
108
|
+
score: _score,
|
|
109
|
+
points: w,
|
|
110
|
+
partial: {
|
|
111
|
+
correctChoices: correctCount,
|
|
112
|
+
rule: rule
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
var weightedScore = withScore.reduce((sum, c) => {
|
|
119
|
+
return sum += c.score;
|
|
120
|
+
}, 0);
|
|
121
|
+
log$1('weightedScore: ', weightedScore);
|
|
122
|
+
var score = parseFloat((weightedScore / weightTotal).toFixed(2), 10);
|
|
123
|
+
resolve({
|
|
124
|
+
score,
|
|
125
|
+
details: {
|
|
126
|
+
weighted: {
|
|
127
|
+
total: weightTotal,
|
|
128
|
+
score: weightedScore
|
|
129
|
+
},
|
|
130
|
+
categories: withScore
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
136
|
+
|
|
137
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
138
|
+
var FooTwo = 'foo-two';
|
|
139
|
+
var log = debug('@pie-lib:categorize');
|
|
140
|
+
var limitChoices = (choiceId, count, choices) => {
|
|
141
|
+
var out = choices.reduce((acc, id) => {
|
|
142
|
+
var foundCount = countInChoices(choiceId, acc.choices);
|
|
143
|
+
|
|
144
|
+
if (id !== choiceId || foundCount < count) {
|
|
145
|
+
acc.choices.push(id);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return acc;
|
|
149
|
+
}, {
|
|
150
|
+
choices: []
|
|
151
|
+
});
|
|
152
|
+
return out.choices;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Limit in an array of arrays.
|
|
156
|
+
* So for an array with [[1,1],[1,1]] if you call limitInArray(1, arr, 3) you'll get: [[1,1], [1]]
|
|
157
|
+
* @param {*} id
|
|
158
|
+
* @param {*} arrays
|
|
159
|
+
* @param {*} limit
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
var limitInArrays = (id, arrays, limit) => {
|
|
163
|
+
arrays = arrays || [];
|
|
164
|
+
var result = arrays.reduce((acc, array) => {
|
|
165
|
+
var l = limit - acc.count;
|
|
166
|
+
var result = limitInArray(id, array, l);
|
|
167
|
+
acc.out.push(result.array);
|
|
168
|
+
acc.count = acc.count + (result.count || 0);
|
|
169
|
+
return acc;
|
|
170
|
+
}, {
|
|
171
|
+
out: [],
|
|
172
|
+
count: 0
|
|
173
|
+
});
|
|
174
|
+
return result.out;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Limit the id in the array to the limit set.
|
|
178
|
+
* So for an array with [1,1,1,1] if you call limitInArray(1, arr, 2) you'll get: [1,1]
|
|
179
|
+
* @param {string} id
|
|
180
|
+
* @param {string[]} arr
|
|
181
|
+
* @param {number} limit
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
var limitInArray = (id, arr, limit) => {
|
|
185
|
+
arr = arr || [];
|
|
186
|
+
|
|
187
|
+
if (limit === 0) {
|
|
188
|
+
var stripped = arr.filter(v => v !== id);
|
|
189
|
+
return {
|
|
190
|
+
array: stripped,
|
|
191
|
+
count: arr.length - stripped.length
|
|
192
|
+
};
|
|
193
|
+
} else {
|
|
194
|
+
var result = arr.reduce((acc, v) => {
|
|
195
|
+
if (v === id) {
|
|
196
|
+
if (acc.count < limit) {
|
|
197
|
+
acc.count += 1;
|
|
198
|
+
acc.out.push(v);
|
|
199
|
+
}
|
|
200
|
+
} else {
|
|
201
|
+
acc.out.push(v);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return acc;
|
|
205
|
+
}, {
|
|
206
|
+
out: [],
|
|
207
|
+
count: 0
|
|
208
|
+
});
|
|
209
|
+
return {
|
|
210
|
+
array: result.out,
|
|
211
|
+
count: result.count
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* Ensure that there are no extra choices in answer, if a choice.categoryCount is > 0.
|
|
217
|
+
* @param {{category: string, choices: string[]}[]} answer
|
|
218
|
+
* @param {{id:string,categoryCount:number}} choices
|
|
219
|
+
*/
|
|
220
|
+
|
|
221
|
+
var ensureNoExtraChoicesInAnswer = (answer, choices) => {
|
|
222
|
+
choices = choices || [];
|
|
223
|
+
var out = choices.reduce((answerArray, choice) => {
|
|
224
|
+
log('choice: ----> ', choice.id, 'categoryCount: ', choice.categoryCount);
|
|
225
|
+
|
|
226
|
+
if (choice.categoryCount === undefined || choice.categoryCount === 0) {
|
|
227
|
+
return answerArray;
|
|
228
|
+
} else {
|
|
229
|
+
var _choices = answerArray.map(a => a.choices);
|
|
230
|
+
|
|
231
|
+
var result = limitInArrays(choice.id, _choices, choice.categoryCount);
|
|
232
|
+
var updatedArray = result.map((r, index) => {
|
|
233
|
+
return {
|
|
234
|
+
category: answerArray[index].category,
|
|
235
|
+
alternateResponses: answerArray[index].alternateResponses,
|
|
236
|
+
choices: r
|
|
237
|
+
};
|
|
238
|
+
});
|
|
239
|
+
return updatedArray;
|
|
240
|
+
}
|
|
241
|
+
}, answer);
|
|
242
|
+
return out;
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Ensure that there are no extra choices in alternate responses, if a choice.categoryCount is > 0.
|
|
246
|
+
* @param {{category: string, choices: string[]}[]} answer
|
|
247
|
+
* @param {{id:string,categoryCount:number}} choices
|
|
248
|
+
*/
|
|
249
|
+
|
|
250
|
+
var ensureNoExtraChoicesInAlternate = (answer, choices) => {
|
|
251
|
+
choices = choices || [];
|
|
252
|
+
var out = choices.reduce((answerArray, choice) => {
|
|
253
|
+
log('choice: ----> ', choice.id, 'categoryCount: ', choice.categoryCount);
|
|
254
|
+
|
|
255
|
+
if (choice.categoryCount === undefined || choice.categoryCount === 0) {
|
|
256
|
+
return answerArray;
|
|
257
|
+
} else {
|
|
258
|
+
var alternatePair = {};
|
|
259
|
+
answerArray.forEach(answer => (answer.alternateResponses || []).forEach((alternate, index) => {
|
|
260
|
+
if (index in alternatePair) {
|
|
261
|
+
alternatePair[index].push(alternate);
|
|
262
|
+
} else {
|
|
263
|
+
alternatePair[index] = [];
|
|
264
|
+
alternatePair[index].push(alternate);
|
|
265
|
+
}
|
|
266
|
+
}));
|
|
267
|
+
var recreatedAlternate = [];
|
|
268
|
+
Object.keys(alternatePair).forEach(k => {
|
|
269
|
+
var limitAlternate = limitInArrays(choice.id, alternatePair[k], choice.categoryCount);
|
|
270
|
+
alternatePair[k] = limitAlternate;
|
|
271
|
+
alternatePair[k].forEach((item, index) => {
|
|
272
|
+
if (!recreatedAlternate[index]) {
|
|
273
|
+
recreatedAlternate[index] = [];
|
|
274
|
+
recreatedAlternate[index].push(item);
|
|
275
|
+
} else {
|
|
276
|
+
recreatedAlternate[index].push(item);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
var updatedArray = answerArray.map((answer, index) => {
|
|
281
|
+
return {
|
|
282
|
+
category: answer.category,
|
|
283
|
+
alternateResponses: recreatedAlternate[index] || answer.alternateResponses,
|
|
284
|
+
choices: answer.choices
|
|
285
|
+
};
|
|
286
|
+
});
|
|
287
|
+
return updatedArray;
|
|
288
|
+
}
|
|
289
|
+
}, answer);
|
|
290
|
+
return out;
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* Count the number of choice ids in a given answer array
|
|
294
|
+
* @param {string} choiceId
|
|
295
|
+
* @param {{category: string, choices: string[]}[]} answer
|
|
296
|
+
*/
|
|
297
|
+
|
|
298
|
+
var countInAnswer = (choiceId, answer) => {
|
|
299
|
+
var out = answer.reduce((acc, a) => acc + countInChoices(choiceId, a.choices), 0);
|
|
300
|
+
log('[countInAnswer] choiceId:', choiceId, answer);
|
|
301
|
+
return out;
|
|
302
|
+
};
|
|
303
|
+
var countInChoices = (choiceId, choices) => (choices || []).filter(c => c === choiceId).length;
|
|
304
|
+
/**
|
|
305
|
+
* Count the number of times a choice has been selected in categories.
|
|
306
|
+
* @param {*} choice
|
|
307
|
+
* @param {*} categories
|
|
308
|
+
*/
|
|
309
|
+
|
|
310
|
+
var countChosen = (choice, categories) => {
|
|
311
|
+
if (!choice || !choice.id) {
|
|
312
|
+
return 0;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (!Array.isArray(categories)) {
|
|
316
|
+
return 0;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return categories.reduce((acc, c) => {
|
|
320
|
+
var count = (c.choices || []).filter(h => h && h.id === choice.id).length;
|
|
321
|
+
return acc + count;
|
|
322
|
+
}, 0);
|
|
323
|
+
};
|
|
324
|
+
/**
|
|
325
|
+
* @param {string?} categoryId
|
|
326
|
+
* @param {{category:string, choices: string[]}} answers
|
|
327
|
+
*/
|
|
328
|
+
|
|
329
|
+
var removeCategory = (categoryId, answers) => answers.filter(a => a.category !== categoryId);
|
|
330
|
+
/**
|
|
331
|
+
* @param {string} choiceId
|
|
332
|
+
* @param {{category:string, choices: string[]}} answers
|
|
333
|
+
* @param {string?} categoryId - optional categegory id
|
|
334
|
+
*/
|
|
335
|
+
|
|
336
|
+
var removeAllChoices = (choiceId, answers, categoryId) => {
|
|
337
|
+
return answers.map(a => {
|
|
338
|
+
if (!categoryId || a.category === categoryId) {
|
|
339
|
+
var cloned = clone(a.choices);
|
|
340
|
+
remove(cloned, v => v === choiceId);
|
|
341
|
+
return _objectSpread(_objectSpread({}, a), {}, {
|
|
342
|
+
choices: cloned
|
|
343
|
+
});
|
|
344
|
+
} else {
|
|
345
|
+
return a;
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
var rearrangeChoices = (choices, indexFrom, indexTo) => {
|
|
350
|
+
if (choices.length === 0) {
|
|
351
|
+
return choices;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
choices.splice(indexFrom, 1, choices.splice(indexTo, 1, choices[indexFrom])[0]);
|
|
355
|
+
return choices;
|
|
356
|
+
};
|
|
357
|
+
var verifyAllowMultiplePlacements = (choice, categoryId, answers) => {
|
|
358
|
+
return answers.map(a => {
|
|
359
|
+
if (a.category !== categoryId) {
|
|
360
|
+
a.choices = (a.choices || []).filter(c => c !== choice.id);
|
|
361
|
+
return a;
|
|
362
|
+
} else {
|
|
363
|
+
a.choices = a.choices.reduce((acc, currentValue) => {
|
|
364
|
+
if (currentValue.id === choice.id) {
|
|
365
|
+
var foundIndex = acc.findIndex(c => c.id === choice.id);
|
|
366
|
+
|
|
367
|
+
if (foundIndex === -1) {
|
|
368
|
+
acc.push(currentValue);
|
|
369
|
+
}
|
|
370
|
+
} else {
|
|
371
|
+
acc.push(currentValue);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return acc;
|
|
375
|
+
}, []);
|
|
376
|
+
return a;
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
};
|
|
380
|
+
var removeChoiceFromCategory = (choiceId, categoryId, choiceIndex, answers) => {
|
|
381
|
+
log('[removeChoiceFromCategory] choiceIndex:', choiceIndex);
|
|
382
|
+
return answers.map(a => {
|
|
383
|
+
if (a.category === categoryId) {
|
|
384
|
+
var cloned = clone(a.choices);
|
|
385
|
+
var index = cloned.findIndex((v, index) => {
|
|
386
|
+
return v === choiceId && index >= choiceIndex;
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
if (index !== -1) {
|
|
390
|
+
cloned.splice(index, 1);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return _objectSpread(_objectSpread({}, a), {}, {
|
|
394
|
+
choices: cloned
|
|
395
|
+
});
|
|
396
|
+
} else {
|
|
397
|
+
return a;
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
};
|
|
401
|
+
var removeChoiceFromAlternate = (choiceId, categoryId, choiceIndex, altIndex, answers) => {
|
|
402
|
+
return (answers || []).map(a => {
|
|
403
|
+
if ((a === null || a === void 0 ? void 0 : a.category) === categoryId) {
|
|
404
|
+
var newAlternates = ((a === null || a === void 0 ? void 0 : a.alternateResponses) || []).map((altArray, idx) => {
|
|
405
|
+
if (idx === altIndex) {
|
|
406
|
+
(altArray || []).splice(choiceIndex, 1);
|
|
407
|
+
return altArray;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return altArray;
|
|
411
|
+
});
|
|
412
|
+
return _objectSpread(_objectSpread({}, a), {}, {
|
|
413
|
+
alternateResponses: newAlternates
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return a;
|
|
418
|
+
});
|
|
419
|
+
};
|
|
420
|
+
var moveChoiceToCategory = (choiceId, from, to, choiceIndex, answers) => {
|
|
421
|
+
log('[moveChoiceToCategory] choice: ', choiceId, 'from: ', from, 'to: ', to, 'answers: ', answers);
|
|
422
|
+
|
|
423
|
+
if (from === to) {
|
|
424
|
+
return answers;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
if (from) {
|
|
428
|
+
answers = removeChoiceFromCategory(choiceId, from, choiceIndex, answers);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
var index = answers.findIndex(a => a.category === to);
|
|
432
|
+
|
|
433
|
+
if (index === -1) {
|
|
434
|
+
answers.push({
|
|
435
|
+
category: to,
|
|
436
|
+
choices: [choiceId]
|
|
437
|
+
});
|
|
438
|
+
return answers;
|
|
439
|
+
} else {
|
|
440
|
+
return answers.map(a => {
|
|
441
|
+
if (a.category === to) {
|
|
442
|
+
a.choices = a.choices || [];
|
|
443
|
+
a.choices.push(choiceId);
|
|
444
|
+
return a;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
return a;
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
var moveChoiceToAlternate = (choiceId, from, to, choiceIndex, answers, alternateIndex, categoryCount) => {
|
|
452
|
+
log('[moveChoiceToAlternate] choice: ', choiceId, 'from: ', from, 'to: ', to, 'answers: ', answers, 'chocieIndex: ', choiceIndex);
|
|
453
|
+
|
|
454
|
+
if (from === to) {
|
|
455
|
+
return answers;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
return answers.map(a => {
|
|
459
|
+
if (a.category === to) {
|
|
460
|
+
if (categoryCount !== 0 && a.alternateResponses) {
|
|
461
|
+
a.alternateResponses[alternateIndex] = (a.alternateResponses[alternateIndex] || []).filter(resp => resp !== choiceId);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
if (!a.alternateResponses) {
|
|
465
|
+
a.alternateResponses = [];
|
|
466
|
+
a.alternateResponses[alternateIndex] = [];
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
a.alternateResponses[alternateIndex].push(choiceId);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (a.category === from && categoryCount !== 0 && a.alternateResponses && a.alternateResponses[alternateIndex]) {
|
|
473
|
+
a.alternateResponses[alternateIndex] = a.alternateResponses[alternateIndex].filter(resp => resp !== choiceId);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return a;
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
var stillSelectable = (h, builtCategories) => {
|
|
480
|
+
if (h.categoryCount > 0) {
|
|
481
|
+
var count = countChosen(h, builtCategories);
|
|
482
|
+
return count < h.categoryCount;
|
|
483
|
+
} else {
|
|
484
|
+
return true;
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
/**
|
|
488
|
+
* returns all choices with property 'correct' set to boolean
|
|
489
|
+
* @param {string[]} possibleResponseChoices
|
|
490
|
+
* @param {Object[]} builtCategoryChoices
|
|
491
|
+
*
|
|
492
|
+
* @returns {Object}, returns builtChoices: BuiltChoice[] and allChoicesAreCorrect: boolean
|
|
493
|
+
* BuiltChoice = { id: choiceId, content: choiceContent, correct: boolean }
|
|
494
|
+
*/
|
|
495
|
+
|
|
496
|
+
var buildChoices = (possibleResponseChoices, builtCategoryChoices) => {
|
|
497
|
+
return builtCategoryChoices.reduce((acc, builtChoice) => {
|
|
498
|
+
// set correct value on each choice that was selected by user
|
|
499
|
+
var index = acc.copyOfPossibleResponse.findIndex(cRC => builtChoice && cRC === builtChoice.id); // if the choice exists in the correct response
|
|
500
|
+
// set the correct: true
|
|
501
|
+
|
|
502
|
+
if (index >= 0) {
|
|
503
|
+
acc.builtChoices.push(_objectSpread(_objectSpread({}, builtChoice), {}, {
|
|
504
|
+
correct: true
|
|
505
|
+
}));
|
|
506
|
+
acc.copyOfPossibleResponse = [...acc.copyOfPossibleResponse.slice(0, index), ...acc.copyOfPossibleResponse.slice(index + 1)];
|
|
507
|
+
} else {
|
|
508
|
+
acc.builtChoices.push(_objectSpread(_objectSpread({}, builtChoice), {}, {
|
|
509
|
+
correct: false
|
|
510
|
+
}));
|
|
511
|
+
acc.allChoicesAreCorrect = false;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
return acc;
|
|
515
|
+
}, {
|
|
516
|
+
builtChoices: [],
|
|
517
|
+
copyOfPossibleResponse: [...possibleResponseChoices],
|
|
518
|
+
allChoicesAreCorrect: true
|
|
519
|
+
});
|
|
520
|
+
};
|
|
521
|
+
/**
|
|
522
|
+
* returns corrected answer using this possible correct response
|
|
523
|
+
* @param {Object} possibleResponse, has form: { CategoryId: ChoiceId[] }
|
|
524
|
+
* @param {Object[]} builtCategories
|
|
525
|
+
*
|
|
526
|
+
* @returns {Object}, returns builtCategories: BuiltCategory[] and correct: boolean
|
|
527
|
+
* BuiltCategory = { id: categoryId, label: categoryLabel, correct: boolean, choices: BuiltChoice[] }
|
|
528
|
+
* BuiltChoice = { id: choiceId, content: choiceContent, correct: boolean }
|
|
529
|
+
*/
|
|
530
|
+
|
|
531
|
+
var getBuiltCategories = (possibleResponse, builtCategories) => builtCategories.reduce((acc, builtCategory) => {
|
|
532
|
+
var possibleResponseChoices = possibleResponse[builtCategory.id] || []; // the correct choices for this category
|
|
533
|
+
|
|
534
|
+
var builtCategoryChoices = builtCategory.choices || []; // the choices in the answer
|
|
535
|
+
|
|
536
|
+
var {
|
|
537
|
+
builtChoices,
|
|
538
|
+
allChoicesAreCorrect
|
|
539
|
+
} = buildChoices(possibleResponseChoices, builtCategoryChoices);
|
|
540
|
+
var allChoicesAreInAnswer = builtCategoryChoices.length === possibleResponseChoices.length;
|
|
541
|
+
acc.builtCategories.push(_objectSpread(_objectSpread({}, builtCategory), {}, {
|
|
542
|
+
correct: allChoicesAreCorrect && allChoicesAreInAnswer,
|
|
543
|
+
choices: builtChoices
|
|
544
|
+
}));
|
|
545
|
+
acc.correct = acc.correct && allChoicesAreCorrect && allChoicesAreInAnswer;
|
|
546
|
+
return acc;
|
|
547
|
+
}, {
|
|
548
|
+
builtCategories: [],
|
|
549
|
+
correct: true
|
|
550
|
+
});
|
|
551
|
+
/**
|
|
552
|
+
* returns all the possible responses by combining the proper alternate responses
|
|
553
|
+
* @param {Object[]} correctResponse
|
|
554
|
+
*
|
|
555
|
+
* @returns {Object[]}, returns Response[]
|
|
556
|
+
* Response = { CategoryId: ChoiceId[] },
|
|
557
|
+
*/
|
|
558
|
+
|
|
559
|
+
var getAllPossibleResponses = correctResponse => {
|
|
560
|
+
if (!correctResponse) {
|
|
561
|
+
return [];
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
return correctResponse.reduce((acc, cR) => {
|
|
565
|
+
// main response
|
|
566
|
+
if (acc[0]) {
|
|
567
|
+
acc[0][cR.category] = cR.choices;
|
|
568
|
+
} else {
|
|
569
|
+
acc.push({
|
|
570
|
+
[cR.category]: cR.choices
|
|
571
|
+
});
|
|
572
|
+
} // alternate responses
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
if (cR.alternateResponses) {
|
|
576
|
+
cR.alternateResponses.forEach((aR, index) => {
|
|
577
|
+
if (acc[index + 1]) {
|
|
578
|
+
acc[index + 1][cR.category] = aR;
|
|
579
|
+
} else {
|
|
580
|
+
acc.push({
|
|
581
|
+
[cR.category]: aR
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
return acc;
|
|
588
|
+
}, []);
|
|
589
|
+
};
|
|
590
|
+
/**
|
|
591
|
+
* build the categories to be displayed, where each category has its own list of choices
|
|
592
|
+
* @param {Object[]} categories
|
|
593
|
+
* @param {{id:string}[]} choices
|
|
594
|
+
* @param {{category: string, choices:string[]}[]} answers
|
|
595
|
+
*
|
|
596
|
+
* @returns {Object[]}, returns BuiltCategory[]
|
|
597
|
+
* BuiltCategory = { id: categoryId, label: categoryLabel, choices: BuiltChoice[]},
|
|
598
|
+
* BuiltChoice = { id: choiceId, content: choiceContent }
|
|
599
|
+
*/
|
|
600
|
+
|
|
601
|
+
var buildCategories = (categories, choices, answers) => {
|
|
602
|
+
categories = categories || [];
|
|
603
|
+
answers = answers || [];
|
|
604
|
+
choices = choices || [];
|
|
605
|
+
return categories.map(category => {
|
|
606
|
+
var answer = answers.find(answer => answer.category === category.id);
|
|
607
|
+
var {
|
|
608
|
+
choices: answerChoices = []
|
|
609
|
+
} = answer || {};
|
|
610
|
+
return _objectSpread(_objectSpread({}, category), {}, {
|
|
611
|
+
choices: answerChoices.map(chId => choices.find(ch => ch.id === chId))
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
};
|
|
615
|
+
/**
|
|
616
|
+
* build the choice and category state
|
|
617
|
+
* @param {Object[]} categories
|
|
618
|
+
* @param {{id:string}[]} choices
|
|
619
|
+
* @param {{category: string, choices:string[]}[]} answers
|
|
620
|
+
*
|
|
621
|
+
* @param correctResponse
|
|
622
|
+
* @returns { categories: Category[], choices: Choice[], correct: boolean, bestResponse: Response }, where Response: { categoryId: choiceId[] }
|
|
623
|
+
*/
|
|
624
|
+
|
|
625
|
+
var buildState = (categories, choices, answers, correctResponse) => {
|
|
626
|
+
categories = categories || [];
|
|
627
|
+
choices = choices || [];
|
|
628
|
+
answers = answers || [];
|
|
629
|
+
var allResponses = getAllPossibleResponses(correctResponse) || [];
|
|
630
|
+
var builtCategories = buildCategories(categories, choices, answers);
|
|
631
|
+
var bestResponse;
|
|
632
|
+
var entirelyCorrect; // at least one defined correct response
|
|
633
|
+
|
|
634
|
+
if (allResponses.length) {
|
|
635
|
+
var builtData = allResponses.reduce((acc, possibleResponse) => {
|
|
636
|
+
// set correctness for each possible response
|
|
637
|
+
var {
|
|
638
|
+
builtCategories: categoriesWithChoices,
|
|
639
|
+
correct
|
|
640
|
+
} = getBuiltCategories(possibleResponse, builtCategories); // if bestResponse not found yet OR no correct response found yet and this one is the correct one
|
|
641
|
+
|
|
642
|
+
if (acc.bestResponse === null || !acc.entirelyCorrect && correct) {
|
|
643
|
+
return {
|
|
644
|
+
bestResponse: possibleResponse,
|
|
645
|
+
builtCategories: categoriesWithChoices,
|
|
646
|
+
entirelyCorrect: correct
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
return acc;
|
|
651
|
+
}, {
|
|
652
|
+
bestResponse: null,
|
|
653
|
+
builtCategories: [],
|
|
654
|
+
entirelyCorrect: false
|
|
655
|
+
});
|
|
656
|
+
builtCategories = builtData.builtCategories;
|
|
657
|
+
bestResponse = builtData.bestResponse;
|
|
658
|
+
entirelyCorrect = builtData.entirelyCorrect;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
var filteredChoices = choices.map(ch => stillSelectable(ch, builtCategories) ? ch : {
|
|
662
|
+
empty: true
|
|
663
|
+
});
|
|
664
|
+
return {
|
|
665
|
+
choices: filteredChoices,
|
|
666
|
+
categories: builtCategories,
|
|
667
|
+
correct: entirelyCorrect,
|
|
668
|
+
bestResponse
|
|
669
|
+
};
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
export { FooTwo, buildCategories, buildChoices, buildState, countChosen, countInAnswer, countInChoices, ensureNoExtraChoicesInAlternate, ensureNoExtraChoicesInAnswer, getAllPossibleResponses, getBuiltCategories, limitChoices, limitInArray, limitInArrays, moveChoiceToAlternate, moveChoiceToCategory, rearrangeChoices, removeAllChoices, removeCategory, removeChoiceFromAlternate, removeChoiceFromCategory, score, stillSelectable, verifyAllowMultiplePlacements };
|
|
673
|
+
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
ADDED
|
@@ -0,0 +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,iBAA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AAA,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,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]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/categorize",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -14,5 +14,12 @@
|
|
|
14
14
|
"scripts": {},
|
|
15
15
|
"author": "",
|
|
16
16
|
"license": "ISC",
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "d6cccc4cca72fde471ababc7dce4c6236f5cbc0a",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": "./esm/index.js",
|
|
21
|
+
"require": "./lib/index.js",
|
|
22
|
+
"default": "./esm/index.js"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
18
25
|
}
|