@pie-element/categorize 11.0.5-esm.1 → 11.2.0-mui-update.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/configure/CHANGELOG.md +74 -0
  3. package/configure/lib/defaults.js +2 -5
  4. package/configure/lib/defaults.js.map +1 -1
  5. package/configure/lib/design/builder.js +15 -33
  6. package/configure/lib/design/builder.js.map +1 -1
  7. package/configure/lib/design/buttons.js +44 -95
  8. package/configure/lib/design/buttons.js.map +1 -1
  9. package/configure/lib/design/categories/RowLabel.js +32 -45
  10. package/configure/lib/design/categories/RowLabel.js.map +1 -1
  11. package/configure/lib/design/categories/alternateResponses.js +102 -251
  12. package/configure/lib/design/categories/alternateResponses.js.map +1 -1
  13. package/configure/lib/design/categories/category.js +138 -208
  14. package/configure/lib/design/categories/category.js.map +1 -1
  15. package/configure/lib/design/categories/choice-preview.js +59 -126
  16. package/configure/lib/design/categories/choice-preview.js.map +1 -1
  17. package/configure/lib/design/categories/droppable-placeholder.js +76 -165
  18. package/configure/lib/design/categories/droppable-placeholder.js.map +1 -1
  19. package/configure/lib/design/categories/index.js +199 -384
  20. package/configure/lib/design/categories/index.js.map +1 -1
  21. package/configure/lib/design/choices/choice.js +160 -263
  22. package/configure/lib/design/choices/choice.js.map +1 -1
  23. package/configure/lib/design/choices/config.js +46 -98
  24. package/configure/lib/design/choices/config.js.map +1 -1
  25. package/configure/lib/design/choices/index.js +152 -236
  26. package/configure/lib/design/choices/index.js.map +1 -1
  27. package/configure/lib/design/header.js +62 -111
  28. package/configure/lib/design/header.js.map +1 -1
  29. package/configure/lib/design/index.js +632 -476
  30. package/configure/lib/design/index.js.map +1 -1
  31. package/configure/lib/design/input-header.js +97 -149
  32. package/configure/lib/design/input-header.js.map +1 -1
  33. package/configure/lib/design/utils.js +4 -15
  34. package/configure/lib/design/utils.js.map +1 -1
  35. package/configure/lib/index.js +120 -183
  36. package/configure/lib/index.js.map +1 -1
  37. package/configure/lib/main.js +31 -74
  38. package/configure/lib/main.js.map +1 -1
  39. package/configure/lib/utils.js +22 -32
  40. package/configure/lib/utils.js.map +1 -1
  41. package/configure/package.json +15 -14
  42. package/controller/CHANGELOG.md +62 -0
  43. package/controller/lib/defaults.js +2 -5
  44. package/controller/lib/defaults.js.map +1 -1
  45. package/controller/lib/index.js +238 -315
  46. package/controller/lib/index.js.map +1 -1
  47. package/controller/lib/utils.js +40 -31
  48. package/controller/lib/utils.js.map +1 -1
  49. package/controller/package.json +5 -5
  50. package/lib/categorize/categories.js +110 -164
  51. package/lib/categorize/categories.js.map +1 -1
  52. package/lib/categorize/category.js +72 -122
  53. package/lib/categorize/category.js.map +1 -1
  54. package/lib/categorize/choice.js +116 -245
  55. package/lib/categorize/choice.js.map +1 -1
  56. package/lib/categorize/choices.js +66 -131
  57. package/lib/categorize/choices.js.map +1 -1
  58. package/lib/categorize/droppable-placeholder.js +49 -103
  59. package/lib/categorize/droppable-placeholder.js.map +1 -1
  60. package/lib/categorize/grid-content.js +39 -87
  61. package/lib/categorize/grid-content.js.map +1 -1
  62. package/lib/categorize/index.js +341 -316
  63. package/lib/categorize/index.js.map +1 -1
  64. package/lib/index.js +286 -271
  65. package/lib/index.js.map +1 -1
  66. package/package.json +17 -31
  67. package/LICENSE.md +0 -5
  68. package/esm/configure.js +0 -5025
  69. package/esm/configure.js.map +0 -1
  70. package/esm/controller.js +0 -456
  71. package/esm/controller.js.map +0 -1
  72. package/esm/element.js +0 -3118
  73. package/esm/element.js.map +0 -1
  74. package/module/configure.js +0 -1
  75. package/module/controller.js +0 -6076
  76. package/module/demo.js +0 -382
  77. package/module/element.js +0 -1
  78. package/module/index.html +0 -21
  79. package/module/manifest.json +0 -22
  80. package/module/print-demo.js +0 -420
  81. package/module/print.html +0 -18
package/esm/controller.js DELETED
@@ -1,456 +0,0 @@
1
- import isEmpty from 'lodash/isEmpty';
2
- import { buildState } from '@pie-lib/categorize';
3
- export { score } from '@pie-lib/categorize';
4
- import { getFeedbackForCorrectness } from '@pie-lib/feedback';
5
- import { partialScoring, lockChoices, getShuffledChoices } from '@pie-lib/controller-utils';
6
- import Translator from '@pie-lib/translator';
7
-
8
- function _extends() {
9
- _extends = Object.assign || function (target) {
10
- for (var i = 1; i < arguments.length; i++) {
11
- var source = arguments[i];
12
-
13
- for (var key in source) {
14
- if (Object.prototype.hasOwnProperty.call(source, key)) {
15
- target[key] = source[key];
16
- }
17
- }
18
- }
19
-
20
- return target;
21
- };
22
-
23
- return _extends.apply(this, arguments);
24
- }
25
-
26
- // used in configure too, for consistency modify it there too
27
- const multiplePlacements = {
28
- enabled: 'Yes',
29
- disabled: 'No',
30
- perChoice: 'Set Per Choice'
31
- }; // used to validate the config
32
-
33
- const isCorrectResponseDuplicated = (choices, alternate) => {
34
- if (choices.length < 1 || alternate.length < 1) {
35
- return -1;
36
- }
37
-
38
- const stringChoices = JSON.stringify(choices.sort());
39
- const stringAlternate = alternate.reduce((total, current) => current.length > 0 ? [...total, JSON.stringify(current.sort())] : total, []);
40
- const foundIndexDuplicate = stringAlternate.findIndex(alternate => alternate.length && alternate === stringChoices);
41
- return foundIndexDuplicate;
42
- };
43
- const isAlternateDuplicated = alternate => {
44
- if (alternate.length <= 1) {
45
- return -1;
46
- }
47
-
48
- const elementSet = new Set();
49
- const stringAlternate = alternate.reduce((total, current) => current.length > 0 ? [...total, JSON.stringify(current.sort())] : total, []);
50
-
51
- for (let i = 0; i < stringAlternate.length; i++) {
52
- if (elementSet.has(stringAlternate[i]) && stringAlternate[i]) {
53
- return i;
54
- }
55
-
56
- elementSet.add(stringAlternate[i]);
57
- }
58
-
59
- return -1;
60
- };
61
-
62
- var defaults = {
63
- allowMultiplePlacementsEnabled: multiplePlacements.enabled,
64
- alternates: [],
65
- categories: [],
66
- categoriesPerRow: 2,
67
- choices: [],
68
- choicesLabel: '',
69
- choicesPosition: 'below',
70
- correctResponse: [],
71
- feedbackEnabled: false,
72
- lockChoiceOrder: true,
73
- maxAnswerChoices: 6,
74
- maxChoicesPerCategory: 0,
75
- partialScoring: true,
76
- prompt: '',
77
- promptEnabled: true,
78
- rationale: '',
79
- rationaleEnabled: true,
80
- rowLabels: [''],
81
- studentInstructionsEnabled: true,
82
- teacherInstructions: '',
83
- teacherInstructionsEnabled: true,
84
- toolbarEditorPosition: 'bottom',
85
- minRowHeight: '80px'
86
- };
87
-
88
- const {
89
- translator
90
- } = Translator;
91
- const getPartialScore = (correctResponse, builtCategories) => {
92
- // in the resulted best scenario we make a sum with all the correct responses
93
- // and all the placements
94
- const {
95
- placements,
96
- score
97
- } = builtCategories.reduce((acc, {
98
- choices: _choices = []
99
- }) => ({
100
- placements: acc.placements + _choices.length,
101
- score: acc.score + _choices.filter(ch => ch.correct).length
102
- }), {
103
- placements: 0,
104
- score: 0
105
- }); // in the correct response, we make a sum of the max possible score
106
-
107
- const {
108
- maxScore
109
- } = correctResponse.reduce((acc, {
110
- choices
111
- }) => ({
112
- maxScore: acc.maxScore + choices.length
113
- }), {
114
- maxScore: 0
115
- }); // if there are any extra placements, we subtract from the obtained score
116
-
117
- const extraPlacements = placements > maxScore ? placements - maxScore : 0;
118
- const totalScore = (score - extraPlacements) / maxScore;
119
- return totalScore < 0 ? 0 : parseFloat(totalScore.toFixed(2));
120
- };
121
-
122
- const getAlternates = correctResponse => correctResponse.map(c => c.alternateResponses).filter(alternate => alternate);
123
-
124
- const getTotalScore = (question, session, env) => {
125
- if (!session) {
126
- return 0;
127
- }
128
-
129
- if (Object.keys(session).length === 0) {
130
- return 0;
131
- }
132
-
133
- const {
134
- categories,
135
- choices
136
- } = question || {};
137
- let {
138
- correctResponse
139
- } = question || {};
140
- let {
141
- answers
142
- } = session || {};
143
- answers = answers || [];
144
- correctResponse = correctResponse || []; // this function is used in pie-ui/categorize as well, in order to get the best scenario
145
- // so we get the best scenario and calculate the score
146
-
147
- const {
148
- categories: builtCategories,
149
- correct
150
- } = buildState(categories, choices, answers, correctResponse);
151
- const alternates = getAlternates(correctResponse);
152
- const enabled = partialScoring.enabled(question, env); // if there are any alternates, there will be no partial scoring!
153
-
154
- if (enabled && !alternates.length) {
155
- // we apply partial scoring
156
- return getPartialScore(correctResponse, builtCategories);
157
- } // else we apply dichotomous
158
-
159
-
160
- return correct ? 1 : 0;
161
- };
162
- const getCorrectness = (question, session, env) => {
163
- return new Promise(resolve => {
164
- if (env.mode === 'evaluate') {
165
- const score = getTotalScore(question, session, env);
166
-
167
- if (score === 1) {
168
- resolve('correct');
169
- } else if (score === 0) {
170
- resolve('incorrect');
171
- } else {
172
- resolve('partially-correct');
173
- }
174
- } else {
175
- resolve(undefined);
176
- }
177
- });
178
- };
179
- const createDefaultModel = (model = {}) => new Promise(resolve => {
180
- resolve(_extends({}, defaults, model));
181
- });
182
- const normalize = question => _extends({}, defaults, question);
183
- /**
184
- *
185
- * @param {*} question
186
- * @param {*} session
187
- * @param {*} env
188
- * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
189
- */
190
-
191
- const model = (question, session, env, updateSession) => new Promise(async resolve => {
192
- const normalizedQuestion = normalize(question);
193
- const answerCorrectness = await getCorrectness(normalizedQuestion, session, env);
194
- const {
195
- mode,
196
- role
197
- } = env || {};
198
- const {
199
- categories,
200
- categoriesPerRow,
201
- choicesLabel,
202
- choicesPosition,
203
- correctResponse,
204
- feedback,
205
- feedbackEnabled,
206
- promptEnabled,
207
- prompt,
208
- rowLabels,
209
- rationaleEnabled,
210
- rationale,
211
- teacherInstructionsEnabled,
212
- teacherInstructions,
213
- language,
214
- maxChoicesPerCategory,
215
- extraCSSRules,
216
- minRowHeight,
217
- fontSizeFactor,
218
- autoplayAudioEnabled,
219
- completeAudioEnabled,
220
- customAudioButton
221
- } = normalizedQuestion;
222
- let {
223
- choices,
224
- note
225
- } = normalizedQuestion;
226
- let fb;
227
- const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);
228
- const filteredCorrectResponse = correctResponse.map(response => {
229
- const filteredChoices = (response.choices || []).filter(choice => choice !== 'null');
230
- return _extends({}, response, {
231
- choices: filteredChoices
232
- });
233
- });
234
-
235
- if (mode === 'evaluate' && feedbackEnabled) {
236
- fb = await getFeedbackForCorrectness(answerCorrectness, feedback);
237
- }
238
-
239
- if (!lockChoiceOrder) {
240
- choices = await getShuffledChoices(choices, session, updateSession, 'id');
241
- }
242
-
243
- if (!note) {
244
- note = translator.t('common:commonCorrectAnswerWithAlternates', {
245
- lng: language
246
- });
247
- }
248
-
249
- const alternates = getAlternates(filteredCorrectResponse);
250
- const out = {
251
- categories: categories || [],
252
- categoriesPerRow: categoriesPerRow || 2,
253
- maxChoicesPerCategory,
254
- correctness: answerCorrectness,
255
- choices: choices || [],
256
- choicesLabel: choicesLabel || '',
257
- choicesPosition,
258
- disabled: mode !== 'gather',
259
- feedback: fb,
260
- lockChoiceOrder,
261
- prompt: promptEnabled ? prompt : null,
262
- rowLabels,
263
- note,
264
- env,
265
- showNote: alternates && alternates.length > 0,
266
- correctResponse: mode === 'evaluate' ? filteredCorrectResponse : undefined,
267
- language,
268
- extraCSSRules,
269
- fontSizeFactor,
270
- minRowHeight: minRowHeight,
271
- autoplayAudioEnabled,
272
- completeAudioEnabled,
273
- customAudioButton
274
- };
275
-
276
- if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
277
- out.rationale = rationaleEnabled ? rationale : null;
278
- out.teacherInstructions = teacherInstructionsEnabled ? teacherInstructions : null;
279
- } else {
280
- out.rationale = null;
281
- out.teacherInstructions = null;
282
- }
283
-
284
- resolve(out);
285
- });
286
- const outcome = (question, session, env) => {
287
- if (env.mode !== 'evaluate') {
288
- return Promise.reject(new Error('Can not call outcome when mode is not evaluate'));
289
- } else {
290
- return new Promise(resolve => {
291
- resolve({
292
- score: getTotalScore(question, session, env),
293
- empty: !session || isEmpty(session)
294
- });
295
- });
296
- }
297
- };
298
- const createCorrectResponseSession = (question, env) => {
299
- return new Promise(resolve => {
300
- const {
301
- mode,
302
- role
303
- } = env || {};
304
-
305
- if (mode !== 'evaluate' && role === 'instructor') {
306
- const {
307
- correctResponse
308
- } = question;
309
- resolve({
310
- answers: correctResponse,
311
- id: 1
312
- });
313
- } else {
314
- return resolve(null);
315
- }
316
- });
317
- }; // remove all html tags
318
-
319
- const getInnerText = html => (html || '').replaceAll(/<[^>]*>/g, ''); // remove all html tags except img, iframe and source tag for audio
320
-
321
-
322
- const getContent = html => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
323
-
324
- const validate = (model = {}, config = {}) => {
325
- const {
326
- categories,
327
- choices,
328
- correctResponse,
329
- maxAnswerChoices
330
- } = model;
331
- const {
332
- minChoices = 1,
333
- minCategories = 1,
334
- maxCategories = 12,
335
- maxLengthPerChoice = 300,
336
- maxLengthPerCategory = 150
337
- } = config;
338
- const reversedChoices = [...(choices || [])].reverse();
339
- const errors = {};
340
- const choicesErrors = {};
341
- const categoriesErrors = {};
342
- ['teacherInstructions', 'prompt', 'rationale'].forEach(field => {
343
- var _config$field;
344
-
345
- if ((_config$field = config[field]) != null && _config$field.required && !getContent(model[field])) {
346
- errors[field] = 'This field is required.';
347
- }
348
- });
349
- (categories || []).forEach(category => {
350
- const {
351
- id,
352
- label
353
- } = category;
354
-
355
- if (getInnerText(label).length > maxLengthPerCategory) {
356
- categoriesErrors[id] = `Category labels should be no more than ${maxLengthPerCategory} characters long.`;
357
- }
358
- });
359
- (reversedChoices || []).forEach((choice, index) => {
360
- const {
361
- id,
362
- content
363
- } = choice;
364
-
365
- if (getInnerText(content).length > maxLengthPerChoice) {
366
- choicesErrors[id] = `Tokens should be no more than ${maxLengthPerChoice} characters long.`;
367
- }
368
-
369
- if (!getContent(content)) {
370
- choicesErrors[id] = 'Tokens should not be empty.';
371
- } else {
372
- const identicalAnswer = reversedChoices.slice(index + 1).some(c => c.content === content);
373
-
374
- if (identicalAnswer) {
375
- choicesErrors[id] = 'Tokens content should be unique.';
376
- }
377
- }
378
- });
379
- const nbOfCategories = (categories || []).length;
380
- const nbOfChoices = (choices || []).length;
381
-
382
- if (nbOfCategories > maxCategories) {
383
- errors.categoriesError = `No more than ${maxCategories} categories should be defined.`;
384
- } else if (nbOfCategories < minCategories) {
385
- errors.categoriesError = `There should be at least ${minCategories} category defined.`;
386
- }
387
-
388
- if (nbOfChoices < minChoices) {
389
- errors.choicesError = `There should be at least ${minChoices} choices defined.`;
390
- } else if (nbOfChoices > maxAnswerChoices) {
391
- errors.choicesError = `No more than ${maxAnswerChoices} choices should be defined.`;
392
- }
393
-
394
- if (nbOfChoices && nbOfCategories) {
395
- let hasAssociations = false;
396
- (correctResponse || []).forEach(response => {
397
- const {
398
- choices = [],
399
- alternateResponses = []
400
- } = response;
401
-
402
- if (choices.length) {
403
- hasAssociations = true;
404
- } else {
405
- alternateResponses.forEach(alternate => {
406
- if ((alternate || []).length) {
407
- hasAssociations = true;
408
- }
409
- });
410
- }
411
- });
412
- let duplicateAlternateIndex = -1;
413
- let duplicateCategory = '';
414
- (correctResponse || []).forEach(response => {
415
- const {
416
- choices = [],
417
- alternateResponses = [],
418
- category
419
- } = response;
420
-
421
- if (duplicateAlternateIndex === -1) {
422
- duplicateAlternateIndex = isCorrectResponseDuplicated(choices, alternateResponses);
423
-
424
- if (duplicateAlternateIndex === -1) {
425
- duplicateAlternateIndex = isAlternateDuplicated(alternateResponses);
426
- }
427
-
428
- duplicateCategory = category;
429
- }
430
- });
431
-
432
- if (duplicateAlternateIndex > -1) {
433
- errors.duplicateAlternate = {
434
- index: duplicateAlternateIndex,
435
- category: duplicateCategory
436
- };
437
- }
438
-
439
- if (!hasAssociations) {
440
- errors.associationError = 'At least one token should be assigned to at least one category.';
441
- }
442
- }
443
-
444
- if (!isEmpty(choicesErrors)) {
445
- errors.choicesErrors = choicesErrors;
446
- }
447
-
448
- if (!isEmpty(categoriesErrors)) {
449
- errors.categoriesErrors = categoriesErrors;
450
- }
451
-
452
- return errors;
453
- };
454
-
455
- export { createCorrectResponseSession, createDefaultModel, getCorrectness, getPartialScore, getTotalScore, model, normalize, outcome, validate };
456
- //# sourceMappingURL=controller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"controller.js","sources":["../controller/src/utils.js","../controller/src/defaults.js","../controller/src/index.js"],"sourcesContent":["// used in configure too, for consistency modify it there too\nexport const multiplePlacements = { enabled: 'Yes', disabled: 'No', perChoice: 'Set Per Choice' };\n\n// used to validate the config\nexport const isCorrectResponseDuplicated = (choices,alternate) => {\n if (choices.length < 1 || alternate.length < 1){\n return -1;\n }\n\n const stringChoices = JSON.stringify(choices.sort());\n const stringAlternate = alternate.reduce((total, current) => current.length > 0 ? [...total, JSON.stringify(current.sort())] : total, []);\n const foundIndexDuplicate = stringAlternate.findIndex(alternate => alternate.length && alternate === stringChoices);\n\n return foundIndexDuplicate;\n};\n\nexport const isAlternateDuplicated = (alternate) => {\n if (alternate.length <= 1){\n return -1;\n }\n\n const elementSet = new Set();\n const stringAlternate = alternate.reduce((total, current) => current.length > 0 ? [...total, JSON.stringify(current.sort())] : total, []);\n\n for (let i = 0; i < stringAlternate.length; i++) {\n if (elementSet.has(stringAlternate[i]) && stringAlternate[i]) {\n return i;\n }\n\n elementSet.add(stringAlternate[i]);\n }\n\n return -1;\n};\n","import { multiplePlacements } from './utils';\n\nexport default {\n allowMultiplePlacementsEnabled: multiplePlacements.enabled,\n alternates: [],\n categories: [],\n categoriesPerRow: 2,\n choices: [],\n choicesLabel: '',\n choicesPosition: 'below',\n correctResponse: [],\n feedbackEnabled: false,\n lockChoiceOrder: true,\n maxAnswerChoices: 6,\n maxChoicesPerCategory: 0,\n partialScoring: true,\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n rowLabels: [''],\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n minRowHeight: '80px',\n};\n","import isEmpty from 'lodash/isEmpty';\nimport { buildState, score } from '@pie-lib/categorize';\nimport { getFeedbackForCorrectness } from '@pie-lib/feedback';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils';\nimport Translator from '@pie-lib/translator';\n\nconst { translator } = Translator;\nimport defaults from './defaults';\nimport { isAlternateDuplicated, isCorrectResponseDuplicated } from './utils';\n\n// eslint-disable-next-line no-console\n\nexport { score };\n\nexport const getPartialScore = (correctResponse, builtCategories) => {\n // in the resulted best scenario we make a sum with all the correct responses\n // and all the placements\n const { placements, score } = builtCategories.reduce(\n (acc, { choices = [] }) => ({\n placements: acc.placements + choices.length,\n score: acc.score + choices.filter((ch) => ch.correct).length,\n }),\n { placements: 0, score: 0 },\n );\n\n // in the correct response, we make a sum of the max possible score\n const { maxScore } = correctResponse.reduce(\n (acc, { choices }) => ({\n maxScore: acc.maxScore + choices.length,\n }),\n { maxScore: 0 },\n );\n\n // if there are any extra placements, we subtract from the obtained score\n const extraPlacements = placements > maxScore ? placements - maxScore : 0;\n const totalScore = (score - extraPlacements) / maxScore;\n\n return totalScore < 0 ? 0 : parseFloat(totalScore.toFixed(2));\n};\n\nconst getAlternates = (correctResponse) =>\n correctResponse.map((c) => c.alternateResponses).filter((alternate) => alternate);\n\nexport const getTotalScore = (question, session, env) => {\n if (!session) {\n return 0;\n }\n\n if (Object.keys(session).length === 0) {\n return 0;\n }\n const { categories, choices } = question || {};\n let { correctResponse } = question || {};\n let { answers } = session || {};\n answers = answers || [];\n correctResponse = correctResponse || [];\n\n // this function is used in pie-ui/categorize as well, in order to get the best scenario\n // so we get the best scenario and calculate the score\n const { categories: builtCategories, correct } = buildState(categories, choices, answers, correctResponse);\n\n const alternates = getAlternates(correctResponse);\n const enabled = partialScoring.enabled(question, env);\n\n // if there are any alternates, there will be no partial scoring!\n if (enabled && !alternates.length) {\n // we apply partial scoring\n return getPartialScore(correctResponse, builtCategories);\n }\n\n // else we apply dichotomous\n return correct ? 1 : 0;\n};\n\nexport const getCorrectness = (question, session, env) => {\n return new Promise((resolve) => {\n if (env.mode === 'evaluate') {\n const score = getTotalScore(question, session, env);\n if (score === 1) {\n resolve('correct');\n } else if (score === 0) {\n resolve('incorrect');\n } else {\n resolve('partially-correct');\n }\n } else {\n resolve(undefined);\n }\n });\n};\n\nexport const createDefaultModel = (model = {}) =>\n new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nexport const normalize = (question) => ({ ...defaults, ...question });\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport const model = (question, session, env, updateSession) =>\n new Promise(async (resolve) => {\n const normalizedQuestion = normalize(question);\n const answerCorrectness = await getCorrectness(normalizedQuestion, session, env);\n\n const { mode, role } = env || {};\n\n const {\n categories,\n categoriesPerRow,\n choicesLabel,\n choicesPosition,\n correctResponse,\n feedback,\n feedbackEnabled,\n promptEnabled,\n prompt,\n rowLabels,\n rationaleEnabled,\n rationale,\n teacherInstructionsEnabled,\n teacherInstructions,\n language,\n maxChoicesPerCategory,\n extraCSSRules,\n minRowHeight,\n fontSizeFactor,\n autoplayAudioEnabled,\n completeAudioEnabled,\n customAudioButton,\n } = normalizedQuestion;\n let { choices, note } = normalizedQuestion;\n let fb;\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n const filteredCorrectResponse = correctResponse.map((response) => {\n const filteredChoices = (response.choices || []).filter((choice) => choice !== 'null');\n return { ...response, choices: filteredChoices };\n });\n\n if (mode === 'evaluate' && feedbackEnabled) {\n fb = await getFeedbackForCorrectness(answerCorrectness, feedback);\n }\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session, updateSession, 'id');\n }\n\n if (!note) {\n note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: language });\n }\n\n const alternates = getAlternates(filteredCorrectResponse);\n const out = {\n categories: categories || [],\n categoriesPerRow: categoriesPerRow || 2,\n maxChoicesPerCategory,\n correctness: answerCorrectness,\n choices: choices || [],\n choicesLabel: choicesLabel || '',\n choicesPosition,\n disabled: mode !== 'gather',\n feedback: fb,\n lockChoiceOrder,\n prompt: promptEnabled ? prompt : null,\n rowLabels,\n note,\n env,\n showNote: alternates && alternates.length > 0,\n correctResponse: mode === 'evaluate' ? filteredCorrectResponse : undefined,\n language,\n extraCSSRules,\n fontSizeFactor,\n minRowHeight: minRowHeight,\n autoplayAudioEnabled,\n completeAudioEnabled,\n customAudioButton,\n };\n\n if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {\n out.rationale = rationaleEnabled ? rationale : null;\n out.teacherInstructions = teacherInstructionsEnabled ? teacherInstructions : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n resolve(out);\n });\n\nexport const outcome = (question, session, env) => {\n if (env.mode !== 'evaluate') {\n return Promise.reject(new Error('Can not call outcome when mode is not evaluate'));\n } else {\n return new Promise((resolve) => {\n resolve({\n score: getTotalScore(question, session, env),\n empty: !session || isEmpty(session),\n });\n });\n }\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n const { mode, role } = env || {};\n\n if (mode !== 'evaluate' && role === 'instructor') {\n const { correctResponse } = question;\n\n resolve({ answers: correctResponse, id: 1 });\n } else {\n return resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { categories, choices, correctResponse, maxAnswerChoices } = model;\n const {\n minChoices = 1,\n minCategories = 1,\n maxCategories = 12,\n maxLengthPerChoice = 300,\n maxLengthPerCategory = 150,\n } = config;\n const reversedChoices = [...(choices || [])].reverse();\n const errors = {};\n const choicesErrors = {};\n const categoriesErrors = {};\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n (categories || []).forEach((category) => {\n const { id, label } = category;\n\n if (getInnerText(label).length > maxLengthPerCategory) {\n categoriesErrors[id] = `Category labels should be no more than ${maxLengthPerCategory} characters long.`;\n }\n });\n\n (reversedChoices || []).forEach((choice, index) => {\n const { id, content } = choice;\n\n if (getInnerText(content).length > maxLengthPerChoice) {\n choicesErrors[id] = `Tokens should be no more than ${maxLengthPerChoice} characters long.`;\n }\n\n if (!getContent(content)) {\n choicesErrors[id] = 'Tokens should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.content === content);\n\n if (identicalAnswer) {\n choicesErrors[id] = 'Tokens content should be unique.';\n }\n }\n });\n\n const nbOfCategories = (categories || []).length;\n const nbOfChoices = (choices || []).length;\n\n if (nbOfCategories > maxCategories) {\n errors.categoriesError = `No more than ${maxCategories} categories should be defined.`;\n } else if (nbOfCategories < minCategories) {\n errors.categoriesError = `There should be at least ${minCategories} category defined.`;\n }\n\n if (nbOfChoices < minChoices) {\n errors.choicesError = `There should be at least ${minChoices} choices defined.`;\n } else if (nbOfChoices > maxAnswerChoices) {\n errors.choicesError = `No more than ${maxAnswerChoices} choices should be defined.`;\n }\n\n if (nbOfChoices && nbOfCategories) {\n let hasAssociations = false;\n\n (correctResponse || []).forEach((response) => {\n const { choices = [], alternateResponses = [] } = response;\n\n if (choices.length) {\n hasAssociations = true;\n } else {\n alternateResponses.forEach((alternate) => {\n if ((alternate || []).length) {\n hasAssociations = true;\n }\n });\n }\n });\n\n let duplicateAlternateIndex = -1;\n let duplicateCategory = '';\n (correctResponse || []).forEach((response) => {\n const { choices = [], alternateResponses = [], category } = response;\n\n if (duplicateAlternateIndex === -1) {\n duplicateAlternateIndex = isCorrectResponseDuplicated(choices, alternateResponses);\n\n if (duplicateAlternateIndex === -1) {\n duplicateAlternateIndex = isAlternateDuplicated(alternateResponses);\n }\n\n duplicateCategory = category;\n }\n });\n\n if (duplicateAlternateIndex > -1) {\n errors.duplicateAlternate = { index: duplicateAlternateIndex, category: duplicateCategory };\n }\n\n if (!hasAssociations) {\n errors.associationError = 'At least one token should be assigned to at least one category.';\n }\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choicesErrors = choicesErrors;\n }\n\n if (!isEmpty(categoriesErrors)) {\n errors.categoriesErrors = categoriesErrors;\n }\n\n return errors;\n};\n"],"names":["multiplePlacements","enabled","disabled","perChoice","isCorrectResponseDuplicated","choices","alternate","length","stringChoices","JSON","stringify","sort","stringAlternate","reduce","total","current","foundIndexDuplicate","findIndex","isAlternateDuplicated","elementSet","Set","i","has","add","allowMultiplePlacementsEnabled","alternates","categories","categoriesPerRow","choicesLabel","choicesPosition","correctResponse","feedbackEnabled","lockChoiceOrder","maxAnswerChoices","maxChoicesPerCategory","partialScoring","prompt","promptEnabled","rationale","rationaleEnabled","rowLabels","studentInstructionsEnabled","teacherInstructions","teacherInstructionsEnabled","toolbarEditorPosition","minRowHeight","translator","Translator","getPartialScore","builtCategories","placements","score","acc","filter","ch","correct","maxScore","extraPlacements","totalScore","parseFloat","toFixed","getAlternates","map","c","alternateResponses","getTotalScore","question","session","env","Object","keys","answers","buildState","getCorrectness","Promise","resolve","mode","undefined","createDefaultModel","model","defaults","normalize","updateSession","normalizedQuestion","answerCorrectness","role","feedback","language","extraCSSRules","fontSizeFactor","autoplayAudioEnabled","completeAudioEnabled","customAudioButton","note","fb","lockChoices","filteredCorrectResponse","response","filteredChoices","choice","getFeedbackForCorrectness","getShuffledChoices","t","lng","out","correctness","showNote","outcome","reject","Error","empty","isEmpty","createCorrectResponseSession","id","getInnerText","html","replaceAll","getContent","replace","validate","config","minChoices","minCategories","maxCategories","maxLengthPerChoice","maxLengthPerCategory","reversedChoices","reverse","errors","choicesErrors","categoriesErrors","forEach","field","required","category","label","index","content","identicalAnswer","slice","some","nbOfCategories","nbOfChoices","categoriesError","choicesError","hasAssociations","duplicateAlternateIndex","duplicateCategory","duplicateAlternate","associationError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACO,MAAMA,kBAAkB,GAAG;AAAEC,EAAAA,OAAO,EAA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