@pie-element/ebsr 9.4.1-next.41 → 9.4.1-next.42

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.
@@ -1,485 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.createDefaultModel = exports.createCorrectResponseSession = void 0;
9
- exports.model = model;
10
- exports.normalize = void 0;
11
- exports.outcome = outcome;
12
- exports.validate = void 0;
13
-
14
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
15
-
16
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
17
-
18
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
19
-
20
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
21
-
22
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
- var _defaults = _interopRequireDefault(require("./defaults"));
25
-
26
- var _controllerUtils = require("@pie-lib/pie-toolbox/controller-utils");
27
-
28
- var _utils = require("./utils");
29
-
30
- var _get = _interopRequireDefault(require("lodash/get"));
31
-
32
- var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
33
-
34
- var _translator = _interopRequireDefault(require("@pie-lib/pie-toolbox/translator"));
35
-
36
- var _excluded = ["partA", "partB"];
37
-
38
- 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; }
39
-
40
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(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; }
41
-
42
- var translator = _translator["default"].translator;
43
-
44
- var prepareChoice = function prepareChoice(model, env, defaultFeedback) {
45
- return function (choice) {
46
- var out = {
47
- label: choice.label,
48
- value: choice.value
49
- };
50
-
51
- if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
52
- out.rationale = model.rationaleEnabled ? choice.rationale : null;
53
- } else {
54
- out.rationale = null;
55
- }
56
-
57
- if (env.mode === 'evaluate') {
58
- out.correct = !!choice.correct;
59
-
60
- if (model.feedbackEnabled) {
61
- var feedbackType = choice.feedback && choice.feedback.type || 'none';
62
-
63
- if (feedbackType === 'default') {
64
- out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];
65
- } else if (feedbackType === 'custom') {
66
- out.feedback = choice.feedback.value;
67
- }
68
- }
69
- }
70
-
71
- return out;
72
- };
73
- };
74
-
75
- var parsePart = function parsePart(part, key, session, env) {
76
- var defaultFeedback = Object.assign({
77
- correct: 'Correct',
78
- incorrect: 'Incorrect'
79
- }, part.defaultFeedback);
80
- var choices = part.choices ? part.choices.map(prepareChoice(part, env, defaultFeedback)) : [];
81
- return _objectSpread(_objectSpread({}, part), {}, {
82
- choices: choices,
83
- disabled: env.mode !== 'gather',
84
- complete: {
85
- min: part.choices.filter(function (c) {
86
- return c.correct;
87
- }).length
88
- },
89
- responseCorrect: env.mode === 'evaluate' ? (0, _utils.isResponseCorrect)(part, key, session) : undefined
90
- });
91
- };
92
-
93
- var normalize = function normalize(_ref) {
94
- var _ref$partA = _ref.partA,
95
- partA = _ref$partA === void 0 ? {} : _ref$partA,
96
- _ref$partB = _ref.partB,
97
- partB = _ref$partB === void 0 ? {} : _ref$partB,
98
- question = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
99
- return _objectSpread(_objectSpread({
100
- partLabels: true,
101
- partLabelType: 'Letters'
102
- }, question), {}, {
103
- partA: _objectSpread(_objectSpread(_objectSpread({}, _defaults["default"].partA), {}, {
104
- rationaleEnabled: true,
105
- feedbackEnabled: false,
106
- promptEnabled: true,
107
- teacherInstructionsEnabled: true,
108
- studentInstructionsEnabled: true,
109
- gridColumns: '2'
110
- }, partA), {}, {
111
- choicesLayout: partA.choicesLayout || partA.verticalMode === false && 'horizontal' || 'vertical'
112
- }),
113
- partB: _objectSpread(_objectSpread(_objectSpread({}, _defaults["default"].partB), {}, {
114
- rationaleEnabled: true,
115
- promptEnabled: true,
116
- feedbackEnabled: false,
117
- teacherInstructionsEnabled: true,
118
- studentInstructionsEnabled: true,
119
- gridColumns: '2'
120
- }, partB), {}, {
121
- choicesLayout: partB.choicesLayout || partB.verticalMode === false && 'horizontal' || 'vertical'
122
- })
123
- });
124
- };
125
- /**
126
- *
127
- * @param {*} question
128
- * @param {*} session
129
- * @param {*} env
130
- * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
131
- */
132
-
133
-
134
- exports.normalize = normalize;
135
-
136
- function model(_x, _x2, _x3, _x4) {
137
- return _model.apply(this, arguments);
138
- }
139
-
140
- function _model() {
141
- _model = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(question, session, env, updateSession) {
142
- var normalizedQuestion, partA, partB, shuffledValues, us, partASession, partALockChoiceOrder, _ref8, partAChoices, _ref9, partBChoices, partBSession, partBLockChoiceOrder, language;
143
-
144
- return _regenerator["default"].wrap(function _callee$(_context) {
145
- while (1) {
146
- switch (_context.prev = _context.next) {
147
- case 0:
148
- normalizedQuestion = normalize(question);
149
- partA = parsePart(normalizedQuestion.partA, 'partA', session, env);
150
- partB = parsePart(normalizedQuestion.partB, 'partB', session, env);
151
- shuffledValues = {};
152
-
153
- us = function us(part) {
154
- return function (id, element, update) {
155
- return new Promise(function (resolve) {
156
- shuffledValues[part] = update.shuffledValues;
157
- resolve();
158
- });
159
- };
160
- };
161
-
162
- partASession = (0, _get["default"])(session, 'value.partA');
163
- partALockChoiceOrder = (0, _controllerUtils.lockChoices)(normalizedQuestion.partA, partASession, env);
164
- _ref8 = partA || {}, partAChoices = _ref8.choices;
165
- _ref9 = partB || {}, partBChoices = _ref9.choices;
166
-
167
- if (!(!partALockChoiceOrder && partAChoices && partAChoices.length)) {
168
- _context.next = 13;
169
- break;
170
- }
171
-
172
- _context.next = 12;
173
- return (0, _controllerUtils.getShuffledChoices)(partAChoices, {
174
- shuffledValues: (session.shuffledValues || {}).partA
175
- }, us('partA'), 'value');
176
-
177
- case 12:
178
- partA.choices = _context.sent;
179
-
180
- case 13:
181
- partBSession = (0, _get["default"])(session, 'value.partB');
182
- partBLockChoiceOrder = (0, _controllerUtils.lockChoices)(normalizedQuestion.partB, partBSession, env);
183
-
184
- if (!(!partBLockChoiceOrder && partBChoices && partBChoices.length)) {
185
- _context.next = 19;
186
- break;
187
- }
188
-
189
- _context.next = 18;
190
- return (0, _controllerUtils.getShuffledChoices)(partBChoices, {
191
- shuffledValues: (session.shuffledValues || {}).partB
192
- }, us('partB'), 'value');
193
-
194
- case 18:
195
- partB.choices = _context.sent;
196
-
197
- case 19:
198
- if (!(0, _isEmpty["default"])(shuffledValues)) {
199
- if (updateSession && typeof updateSession === 'function') {
200
- updateSession(session.id, session.element, {
201
- shuffledValues: shuffledValues
202
- })["catch"](function (e) {
203
- // eslint-disable-next-line no-console
204
- console.error('update session failed', e);
205
- });
206
- }
207
- }
208
-
209
- if (normalizedQuestion.partLabels) {
210
- language = normalizedQuestion.language;
211
- partA.partLabel = translator.t('ebsr.part', {
212
- lng: language,
213
- index: normalizedQuestion.partLabelType === 'Letters' ? 'A' : '1'
214
- });
215
- partB.partLabel = translator.t('ebsr.part', {
216
- lng: language,
217
- index: normalizedQuestion.partLabelType === 'Letters' ? 'B' : '2'
218
- });
219
- } else {
220
- partA.partLabel = undefined;
221
- partB.partLabel = undefined;
222
- }
223
-
224
- if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
225
- partA.teacherInstructions = normalizedQuestion.partA.teacherInstructionsEnabled ? normalizedQuestion.partA.teacherInstructions : null;
226
- partB.teacherInstructions = normalizedQuestion.partB.teacherInstructionsEnabled ? normalizedQuestion.partB.teacherInstructions : null;
227
- } else {
228
- partA.teacherInstructions = null;
229
- partB.teacherInstructions = null;
230
- }
231
-
232
- partA.prompt = normalizedQuestion.partA.promptEnabled ? normalizedQuestion.partA.prompt : null;
233
- partB.prompt = normalizedQuestion.partB.promptEnabled ? normalizedQuestion.partB.prompt : null;
234
- return _context.abrupt("return", new Promise(function (resolve) {
235
- resolve({
236
- disabled: env.mode !== 'gather',
237
- mode: env.mode,
238
- partA: partA,
239
- partB: partB
240
- });
241
- }));
242
-
243
- case 25:
244
- case "end":
245
- return _context.stop();
246
- }
247
- }
248
- }, _callee);
249
- }));
250
- return _model.apply(this, arguments);
251
- }
252
-
253
- var createDefaultModel = function createDefaultModel() {
254
- var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
255
- return new Promise(function (resolve) {
256
- resolve(_objectSpread(_objectSpread({}, _defaults["default"]), model));
257
- });
258
- };
259
-
260
- exports.createDefaultModel = createDefaultModel;
261
-
262
- var isCorrect = function isCorrect(c) {
263
- return c.correct === true;
264
- };
265
-
266
- var getScore = function getScore(config, sessionPart, key, partialScoringEnabled) {
267
- var _ref2 = config && config[key] || {},
268
- _ref2$choices = _ref2.choices,
269
- choices = _ref2$choices === void 0 ? [] : _ref2$choices;
270
-
271
- var maxScore = choices.length;
272
-
273
- var _ref3 = sessionPart || {},
274
- sessionPartValue = _ref3.value;
275
-
276
- var chosen = function chosen(c) {
277
- return !!(sessionPartValue || []).find(function (v) {
278
- return v === c.value;
279
- });
280
- };
281
-
282
- var correctAndNotChosen = function correctAndNotChosen(c) {
283
- return isCorrect(c) && !chosen(c);
284
- };
285
-
286
- var incorrectAndChosen = function incorrectAndChosen(c) {
287
- return !isCorrect(c) && chosen(c);
288
- };
289
-
290
- var correctChoices = choices.reduce(function (total, choice) {
291
- if (correctAndNotChosen(choice) || incorrectAndChosen(choice)) {
292
- return total - 1;
293
- } else {
294
- return total;
295
- }
296
- }, choices.length); // determine score for a part
297
-
298
- if (!partialScoringEnabled && correctChoices < maxScore) {
299
- return 0;
300
- }
301
-
302
- return parseFloat(maxScore ? (correctChoices / maxScore).toFixed(2) : 0);
303
- };
304
-
305
- function outcome(config, session, env) {
306
- return new Promise(function (resolve) {
307
- var _ref4 = session || {},
308
- value = _ref4.value;
309
-
310
- if (!session || !value) {
311
- resolve({
312
- score: 0,
313
- scoreA: 0,
314
- scoreB: 0,
315
- empty: true
316
- });
317
- }
318
-
319
- if (value) {
320
- var _ref5 = value || {},
321
- partA = _ref5.partA,
322
- partB = _ref5.partB;
323
-
324
- var partialScoringEnabled = _controllerUtils.partialScoring.enabled(config, env);
325
-
326
- var scoreA = getScore(config, partA, 'partA', partialScoringEnabled);
327
- var scoreB = getScore(config, partB, 'partB', partialScoringEnabled);
328
-
329
- if (!partialScoringEnabled) {
330
- // The EBSR item is worth 1 point
331
- // That point is awarded if and only if both parts are fully correct, otherwise no points are awarded
332
- resolve({
333
- score: scoreA === 1 && scoreB === 1 ? 1 : 0,
334
- scoreA: scoreA,
335
- scoreB: scoreB,
336
- max: 1
337
- });
338
- } else {
339
- // The EBSR item is worth 2 points
340
- if (scoreA === 1) {
341
- if (scoreB === 1) {
342
- // If Part A and Part B are both correct, 2 points are awarded
343
- resolve({
344
- score: 2,
345
- scoreA: scoreA,
346
- scoreB: scoreB,
347
- max: 2
348
- });
349
- } else {
350
- // If Part A is correct and part B is incorrect, 1 point is awarded
351
- resolve({
352
- score: 1,
353
- scoreA: scoreA,
354
- scoreB: scoreB,
355
- max: 2
356
- });
357
- }
358
- } else {
359
- // For all other combinations, no points are awarded
360
- resolve({
361
- score: 0,
362
- scoreA: scoreA,
363
- scoreB: scoreB,
364
- max: 2
365
- });
366
- }
367
- }
368
- }
369
- });
370
- }
371
-
372
- var returnPartCorrect = function returnPartCorrect(choices) {
373
- var answers = [];
374
- choices.forEach(function (i) {
375
- var correct = i.correct,
376
- value = i.value;
377
-
378
- if (correct) {
379
- answers.push(value);
380
- }
381
- });
382
- return answers;
383
- };
384
-
385
- var createCorrectResponseSession = function createCorrectResponseSession(question, env) {
386
- return new Promise(function (resolve) {
387
- if (env.mode !== 'evaluate' && env.role === 'instructor') {
388
- var partA = question.partA,
389
- partB = question.partB;
390
- var partACorrect = returnPartCorrect(partA.choices);
391
- var partBCorrect = returnPartCorrect(partB.choices);
392
- resolve({
393
- value: {
394
- partA: {
395
- id: 'partA',
396
- value: partACorrect
397
- },
398
- partB: {
399
- id: 'partB',
400
- value: partBCorrect
401
- }
402
- },
403
- id: '1'
404
- });
405
- } else {
406
- resolve(null);
407
- }
408
- });
409
- };
410
-
411
- exports.createCorrectResponseSession = createCorrectResponseSession;
412
-
413
- var validatePart = function validatePart() {
414
- var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
415
- var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
416
- var choices = model.choices;
417
- var _config$minAnswerChoi = config.minAnswerChoices,
418
- minAnswerChoices = _config$minAnswerChoi === void 0 ? 2 : _config$minAnswerChoi,
419
- maxAnswerChoices = config.maxAnswerChoices;
420
- var reversedChoices = (0, _toConsumableArray2["default"])(choices || []).reverse();
421
- var choicesErrors = {};
422
- var hasCorrectResponse = false;
423
- reversedChoices.forEach(function (choice, index) {
424
- var correct = choice.correct,
425
- value = choice.value,
426
- label = choice.label;
427
-
428
- if (correct) {
429
- hasCorrectResponse = true;
430
- }
431
-
432
- if (label === '' || label === '<div></div>') {
433
- choicesErrors[value] = 'Content should not be empty.';
434
- } else {
435
- var identicalAnswer = reversedChoices.slice(index + 1).some(function (c) {
436
- return c.label === label;
437
- });
438
-
439
- if (identicalAnswer) {
440
- choicesErrors[value] = 'Content should be unique.';
441
- }
442
- }
443
- });
444
- var errors = {};
445
- var nbOfChoices = (choices || []).length;
446
-
447
- if (nbOfChoices < minAnswerChoices) {
448
- errors.answerChoicesError = "There should be at least ".concat(minAnswerChoices, " choices defined.");
449
- } else if (nbOfChoices > maxAnswerChoices) {
450
- errors.answerChoicesError = "No more than ".concat(maxAnswerChoices, " choices should be defined.");
451
- }
452
-
453
- if (!hasCorrectResponse) {
454
- errors.correctResponseError = 'No correct response defined.';
455
- }
456
-
457
- if (!(0, _isEmpty["default"])(choicesErrors)) {
458
- errors.choicesErrors = choicesErrors;
459
- }
460
-
461
- return errors;
462
- };
463
-
464
- var validate = function validate() {
465
- var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
466
- var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
467
-
468
- var _ref6 = model || {},
469
- partA = _ref6.partA,
470
- partB = _ref6.partB;
471
-
472
- var _ref7 = config || {},
473
- partAConfig = _ref7.partA,
474
- partBConfig = _ref7.partB;
475
-
476
- var partAErrors = validatePart(partA, partAConfig);
477
- var partBErrors = validatePart(partB, partBConfig);
478
- return {
479
- partA: partAErrors,
480
- partB: partBErrors
481
- };
482
- };
483
-
484
- exports.validate = validate;
485
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["translator","Translator","prepareChoice","model","env","defaultFeedback","choice","out","label","value","role","mode","rationale","rationaleEnabled","correct","feedbackEnabled","feedbackType","feedback","type","parsePart","part","key","session","Object","assign","incorrect","choices","map","disabled","complete","min","filter","c","length","responseCorrect","undefined","normalize","partA","partB","question","partLabels","partLabelType","defaults","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","gridColumns","choicesLayout","verticalMode","updateSession","normalizedQuestion","shuffledValues","us","id","element","update","Promise","resolve","partASession","partALockChoiceOrder","partAChoices","partBChoices","partBSession","partBLockChoiceOrder","e","console","error","language","partLabel","t","lng","index","teacherInstructions","prompt","createDefaultModel","isCorrect","getScore","config","sessionPart","partialScoringEnabled","maxScore","sessionPartValue","chosen","find","v","correctAndNotChosen","incorrectAndChosen","correctChoices","reduce","total","parseFloat","toFixed","outcome","score","scoreA","scoreB","empty","partialScoring","enabled","max","returnPartCorrect","answers","forEach","i","push","createCorrectResponseSession","partACorrect","partBCorrect","validatePart","minAnswerChoices","maxAnswerChoices","reversedChoices","reverse","choicesErrors","hasCorrectResponse","identicalAnswer","slice","some","errors","nbOfChoices","answerChoicesError","correctResponseError","validate","partAConfig","partBConfig","partAErrors","partBErrors"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;;AAEA,IAAME,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAAQC,GAAR,EAAaC,eAAb;AAAA,SAAiC,UAACC,MAAD,EAAY;AACjE,QAAMC,GAAG,GAAG;AACVC,MAAAA,KAAK,EAAEF,MAAM,CAACE,KADJ;AAEVC,MAAAA,KAAK,EAAEH,MAAM,CAACG;AAFJ,KAAZ;;AAKA,QAAIL,GAAG,CAACM,IAAJ,KAAa,YAAb,KAA8BN,GAAG,CAACO,IAAJ,KAAa,MAAb,IAAuBP,GAAG,CAACO,IAAJ,KAAa,UAAlE,CAAJ,EAAmF;AACjFJ,MAAAA,GAAG,CAACK,SAAJ,GAAgBT,KAAK,CAACU,gBAAN,GAAyBP,MAAM,CAACM,SAAhC,GAA4C,IAA5D;AACD,KAFD,MAEO;AACLL,MAAAA,GAAG,CAACK,SAAJ,GAAgB,IAAhB;AACD;;AAED,QAAIR,GAAG,CAACO,IAAJ,KAAa,UAAjB,EAA6B;AAC3BJ,MAAAA,GAAG,CAACO,OAAJ,GAAc,CAAC,CAACR,MAAM,CAACQ,OAAvB;;AAEA,UAAIX,KAAK,CAACY,eAAV,EAA2B;AACzB,YAAMC,YAAY,GAAIV,MAAM,CAACW,QAAP,IAAm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defaults';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/pie-toolbox/controller-utils';\nimport { isResponseCorrect } from './utils';\nimport get from 'lodash/get';\nimport isEmpty from 'lodash/isEmpty';\nimport Translator from '@pie-lib/pie-toolbox/translator';\n\nconst { translator } = Translator;\n\nconst prepareChoice = (model, env, defaultFeedback) => (choice) => {\n const out = {\n label: choice.label,\n value: choice.value,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = model.rationaleEnabled ? choice.rationale : null;\n } else {\n out.rationale = null;\n }\n\n if (env.mode === 'evaluate') {\n out.correct = !!choice.correct;\n\n if (model.feedbackEnabled) {\n const feedbackType = (choice.feedback && choice.feedback.type) || 'none';\n\n if (feedbackType === 'default') {\n out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];\n } else if (feedbackType === 'custom') {\n out.feedback = choice.feedback.value;\n }\n }\n }\n\n return out;\n};\n\nconst parsePart = (part, key, session, env) => {\n const defaultFeedback = Object.assign({ correct: 'Correct', incorrect: 'Incorrect' }, part.defaultFeedback);\n\n let choices = part.choices ? part.choices.map(prepareChoice(part, env, defaultFeedback)) : [];\n\n return {\n ...part,\n choices,\n disabled: env.mode !== 'gather',\n complete: {\n min: part.choices.filter((c) => c.correct).length,\n },\n responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(part, key, session) : undefined,\n };\n};\n\nexport const normalize = ({ partA = {}, partB = {}, ...question }) => ({\n partLabels: true,\n partLabelType: 'Letters',\n ...question,\n partA: {\n ...defaults.partA,\n rationaleEnabled: true,\n feedbackEnabled: false,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n gridColumns: '2',\n ...partA,\n choicesLayout: partA.choicesLayout || (partA.verticalMode === false && 'horizontal') || 'vertical',\n },\n partB: {\n ...defaults.partB,\n rationaleEnabled: true,\n promptEnabled: true,\n feedbackEnabled: false,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n gridColumns: '2',\n ...partB,\n choicesLayout: partB.choicesLayout || (partB.verticalMode === false && 'horizontal') || 'vertical',\n },\n});\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 async function model(question, session, env, updateSession) {\n const normalizedQuestion = normalize(question);\n const partA = parsePart(normalizedQuestion.partA, 'partA', session, env);\n const partB = parsePart(normalizedQuestion.partB, 'partB', session, env);\n\n const shuffledValues = {};\n\n const us = (part) => (id, element, update) =>\n new Promise((resolve) => {\n shuffledValues[part] = update.shuffledValues;\n resolve();\n });\n\n const partASession = get(session, 'value.partA');\n const partALockChoiceOrder = lockChoices(normalizedQuestion.partA, partASession, env);\n\n const { choices: partAChoices } = partA || {};\n const { choices: partBChoices } = partB || {};\n\n if (!partALockChoiceOrder && partAChoices && partAChoices.length) {\n partA.choices = await getShuffledChoices(\n partAChoices,\n { shuffledValues: (session.shuffledValues || {}).partA },\n us('partA'),\n 'value',\n );\n }\n\n const partBSession = get(session, 'value.partB');\n const partBLockChoiceOrder = lockChoices(normalizedQuestion.partB, partBSession, env);\n\n if (!partBLockChoiceOrder && partBChoices && partBChoices.length) {\n partB.choices = await getShuffledChoices(\n partBChoices,\n { shuffledValues: (session.shuffledValues || {}).partB },\n us('partB'),\n 'value',\n );\n }\n\n if (!isEmpty(shuffledValues)) {\n if (updateSession && typeof updateSession === 'function') {\n updateSession(session.id, session.element, {\n shuffledValues,\n }).catch((e) => {\n // eslint-disable-next-line no-console\n console.error('update session failed', e);\n });\n }\n }\n\n if (normalizedQuestion.partLabels) {\n const language = normalizedQuestion.language;\n partA.partLabel = translator.t('ebsr.part', {lng: language, index: normalizedQuestion.partLabelType === 'Letters' ? 'A' : '1'});\n partB.partLabel = translator.t('ebsr.part', {lng: language, index: normalizedQuestion.partLabelType === 'Letters' ? 'B' : '2'});\n } else {\n partA.partLabel = undefined;\n partB.partLabel = undefined;\n }\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n partA.teacherInstructions = normalizedQuestion.partA.teacherInstructionsEnabled\n ? normalizedQuestion.partA.teacherInstructions\n : null;\n partB.teacherInstructions = normalizedQuestion.partB.teacherInstructionsEnabled\n ? normalizedQuestion.partB.teacherInstructions\n : null;\n } else {\n partA.teacherInstructions = null;\n partB.teacherInstructions = null;\n }\n\n partA.prompt = normalizedQuestion.partA.promptEnabled ? normalizedQuestion.partA.prompt : null;\n partB.prompt = normalizedQuestion.partB.promptEnabled ? normalizedQuestion.partB.prompt : null;\n\n return new Promise((resolve) => {\n resolve({\n disabled: env.mode !== 'gather',\n mode: env.mode,\n partA,\n partB,\n });\n });\n}\n\nexport const createDefaultModel = (model = {}) =>\n new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n\nconst isCorrect = (c) => c.correct === true;\n\nconst getScore = (config, sessionPart, key, partialScoringEnabled) => {\n const { choices = [] } = (config && config[key]) || {};\n const maxScore = choices.length;\n const { value: sessionPartValue } = sessionPart || {};\n\n const chosen = (c) => !!(sessionPartValue || []).find((v) => v === c.value);\n const correctAndNotChosen = (c) => isCorrect(c) && !chosen(c);\n const incorrectAndChosen = (c) => !isCorrect(c) && chosen(c);\n const correctChoices = choices.reduce((total, choice) => {\n if (correctAndNotChosen(choice) || incorrectAndChosen(choice)) {\n return total - 1;\n } else {\n return total;\n }\n }, choices.length);\n\n // determine score for a part\n if (!partialScoringEnabled && correctChoices < maxScore) {\n return 0;\n }\n\n return parseFloat(maxScore ? (correctChoices / maxScore).toFixed(2) : 0);\n};\n\nexport function outcome(config, session, env) {\n return new Promise((resolve) => {\n const { value } = session || {};\n\n if (!session || !value) {\n resolve({ score: 0, scoreA: 0, scoreB: 0, empty: true });\n }\n\n if (value) {\n const { partA, partB } = value || {};\n\n const partialScoringEnabled = partialScoring.enabled(config, env);\n\n const scoreA = getScore(config, partA, 'partA', partialScoringEnabled);\n const scoreB = getScore(config, partB, 'partB', partialScoringEnabled);\n\n if (!partialScoringEnabled) {\n // The EBSR item is worth 1 point\n // That point is awarded if and only if both parts are fully correct, otherwise no points are awarded\n resolve({ score: scoreA === 1 && scoreB === 1 ? 1 : 0, scoreA, scoreB, max: 1 });\n } else {\n // The EBSR item is worth 2 points\n if (scoreA === 1) {\n if (scoreB === 1) {\n // If Part A and Part B are both correct, 2 points are awarded\n resolve({ score: 2, scoreA, scoreB, max: 2 });\n } else {\n // If Part A is correct and part B is incorrect, 1 point is awarded\n resolve({ score: 1, scoreA, scoreB, max: 2 });\n }\n } else {\n // For all other combinations, no points are awarded\n resolve({ score: 0, scoreA, scoreB, max: 2 });\n }\n }\n }\n });\n}\n\nconst returnPartCorrect = (choices) => {\n let answers = [];\n\n choices.forEach((i) => {\n const { correct, value } = i;\n if (correct) {\n answers.push(value);\n }\n });\n return answers;\n};\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n const { partA, partB } = question;\n\n const partACorrect = returnPartCorrect(partA.choices);\n const partBCorrect = returnPartCorrect(partB.choices);\n\n resolve({\n value: {\n partA: {\n id: 'partA',\n value: partACorrect,\n },\n partB: {\n id: 'partB',\n value: partBCorrect,\n },\n },\n id: '1',\n });\n } else {\n resolve(null);\n }\n });\n};\n\nconst validatePart = (model = {}, config = {}) => {\n const { choices } = model;\n const { minAnswerChoices = 2, maxAnswerChoices } = config;\n const reversedChoices = [...(choices || [])].reverse();\n const choicesErrors = {};\n let hasCorrectResponse = false;\n\n reversedChoices.forEach((choice, index) => {\n const { correct, value, label } = choice;\n\n if (correct) {\n hasCorrectResponse = true;\n }\n\n if (label === '' || label === '<div></div>') {\n choicesErrors[value] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[value] = 'Content should be unique.';\n }\n }\n });\n\n const errors = {};\n const nbOfChoices = (choices || []).length;\n\n if (nbOfChoices < minAnswerChoices) {\n errors.answerChoicesError = `There should be at least ${minAnswerChoices} choices defined.`;\n } else if (nbOfChoices > maxAnswerChoices) {\n errors.answerChoicesError = `No more than ${maxAnswerChoices} choices should be defined.`;\n }\n\n if (!hasCorrectResponse) {\n errors.correctResponseError = 'No correct response defined.';\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choicesErrors = choicesErrors;\n }\n\n return errors;\n};\n\nexport const validate = (model = {}, config = {}) => {\n const { partA, partB } = model || {};\n const { partA: partAConfig, partB: partBConfig } = config || {};\n\n const partAErrors = validatePart(partA, partAConfig);\n const partBErrors = validatePart(partB, partBConfig);\n\n return { partA: partAErrors, partB: partBErrors };\n};\n"],"file":"index.js"}
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.isResponseCorrect = exports.getCorrectResponse = void 0;
9
-
10
- var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
11
-
12
- var getCorrectResponse = function getCorrectResponse(choices) {
13
- return choices && choices.filter(function (c) {
14
- return c.correct;
15
- }).map(function (c) {
16
- return c.value;
17
- }).sort();
18
- };
19
-
20
- exports.getCorrectResponse = getCorrectResponse;
21
-
22
- var isResponseCorrect = function isResponseCorrect(question, key, session) {
23
- var correctResponse = getCorrectResponse(question.choices);
24
-
25
- if (session && session.value) {
26
- return (0, _isEqual["default"])((session.value[key].value || []).sort(), correctResponse);
27
- }
28
-
29
- return false;
30
- };
31
-
32
- exports.isResponseCorrect = isResponseCorrect;
33
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils.js"],"names":["getCorrectResponse","choices","filter","c","correct","map","value","sort","isResponseCorrect","question","key","session","correctResponse"],"mappings":";;;;;;;;;AAAA;;AAEO,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,OAAD;AAAA,SAChCA,OAAO,IACPA,OAAO,CACJC,MADH,CACU,UAACC,CAAD;AAAA,WAAOA,CAAC,CAACC,OAAT;AAAA,GADV,EAEGC,GAFH,CAEO,UAACF,CAAD;AAAA,WAAOA,CAAC,CAACG,KAAT;AAAA,GAFP,EAGGC,IAHH,EAFgC;AAAA,CAA3B;;;;AAOA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,QAAD,EAAWC,GAAX,EAAgBC,OAAhB,EAA4B;AAC3D,MAAIC,eAAe,GAAGZ,kBAAkB,CAACS,QAAQ,CAACR,OAAV,CAAxC;;AAEA,MAAIU,OAAO,IAAIA,OAAO,CAACL,KAAvB,EAA8B;AAC5B,WAAO,yBAAQ,CAACK,OAAO,CAACL,KAAR,CAAcI,GAAd,EAAmBJ,KAAnB,IAA4B,EAA7B,EAAiCC,IAAjC,EAAR,EAAiDK,eAAjD,CAAP;AACD;;AAED,SAAO,KAAP;AACD,CARM","sourcesContent":["import isEqual from 'lodash/isEqual';\n\nexport const getCorrectResponse = (choices) =>\n choices &&\n choices\n .filter((c) => c.correct)\n .map((c) => c.value)\n .sort();\n\nexport const isResponseCorrect = (question, key, session) => {\n let correctResponse = getCorrectResponse(question.choices);\n\n if (session && session.value) {\n return isEqual((session.value[key].value || []).sort(), correctResponse);\n }\n\n return false;\n};\n"],"file":"utils.js"}