@pie-element/multiple-choice 9.19.3 → 9.19.5-next.83

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.
@@ -94,11 +94,11 @@ var _root = root$8;
94
94
  var root$7 = _root;
95
95
 
96
96
  /** Built-in value references. */
97
- var Symbol$5 = root$7.Symbol;
97
+ var Symbol$4 = root$7.Symbol;
98
98
 
99
- var _Symbol = Symbol$5;
99
+ var _Symbol = Symbol$4;
100
100
 
101
- var Symbol$4 = _Symbol;
101
+ var Symbol$3 = _Symbol;
102
102
 
103
103
  /** Used for built-in method references. */
104
104
  var objectProto$a = Object.prototype;
@@ -114,7 +114,7 @@ var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
114
114
  var nativeObjectToString$1 = objectProto$a.toString;
115
115
 
116
116
  /** Built-in value references. */
117
- var symToStringTag$1 = Symbol$4 ? Symbol$4.toStringTag : undefined;
117
+ var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : undefined;
118
118
 
119
119
  /**
120
120
  * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
@@ -169,7 +169,7 @@ function objectToString$1(value) {
169
169
 
170
170
  var _objectToString = objectToString$1;
171
171
 
172
- var Symbol$3 = _Symbol,
172
+ var Symbol$2 = _Symbol,
173
173
  getRawTag = _getRawTag,
174
174
  objectToString = _objectToString;
175
175
 
@@ -178,7 +178,7 @@ var nullTag = '[object Null]',
178
178
  undefinedTag = '[object Undefined]';
179
179
 
180
180
  /** Built-in value references. */
181
- var symToStringTag = Symbol$3 ? Symbol$3.toStringTag : undefined;
181
+ var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : undefined;
182
182
 
183
183
  /**
184
184
  * The base implementation of `getTag` without fallbacks for buggy environments.
@@ -442,15 +442,15 @@ var getNative$1 = _getNative,
442
442
  root$1 = _root;
443
443
 
444
444
  /* Built-in method references that are verified to be native. */
445
- var WeakMap$2 = getNative$1(root$1, 'WeakMap');
445
+ var WeakMap$1 = getNative$1(root$1, 'WeakMap');
446
446
 
447
- var _WeakMap = WeakMap$2;
447
+ var _WeakMap = WeakMap$1;
448
448
 
449
449
  var DataView = _DataView,
450
450
  Map$2 = _Map,
451
451
  Promise$1 = _Promise,
452
452
  Set = _Set,
453
- WeakMap$1 = _WeakMap,
453
+ WeakMap = _WeakMap,
454
454
  baseGetTag$3 = _baseGetTag,
455
455
  toSource = _toSource;
456
456
 
@@ -468,7 +468,7 @@ var dataViewCtorString = toSource(DataView),
468
468
  mapCtorString = toSource(Map$2),
469
469
  promiseCtorString = toSource(Promise$1),
470
470
  setCtorString = toSource(Set),
471
- weakMapCtorString = toSource(WeakMap$1);
471
+ weakMapCtorString = toSource(WeakMap);
472
472
 
473
473
  /**
474
474
  * Gets the `toStringTag` of `value`.
@@ -484,7 +484,7 @@ if ((DataView && getTag$2(new DataView(new ArrayBuffer(1))) != dataViewTag$2) ||
484
484
  (Map$2 && getTag$2(new Map$2) != mapTag$3) ||
485
485
  (Promise$1 && getTag$2(Promise$1.resolve()) != promiseTag) ||
486
486
  (Set && getTag$2(new Set) != setTag$3) ||
487
- (WeakMap$1 && getTag$2(new WeakMap$1) != weakMapTag$1)) {
487
+ (WeakMap && getTag$2(new WeakMap) != weakMapTag$1)) {
488
488
  getTag$2 = function(value) {
489
489
  var result = baseGetTag$3(value),
490
490
  Ctor = result == objectTag$2 ? value.constructor : undefined,
@@ -1870,7 +1870,7 @@ function setToArray$1(set) {
1870
1870
 
1871
1871
  var _setToArray = setToArray$1;
1872
1872
 
1873
- var Symbol$2 = _Symbol,
1873
+ var Symbol$1 = _Symbol,
1874
1874
  Uint8Array = _Uint8Array,
1875
1875
  eq = eq_1,
1876
1876
  equalArrays$1 = _equalArrays,
@@ -1896,7 +1896,7 @@ var arrayBufferTag = '[object ArrayBuffer]',
1896
1896
  dataViewTag = '[object DataView]';
1897
1897
 
1898
1898
  /** Used to convert symbols to primitives and strings. */
1899
- var symbolProto$1 = Symbol$2 ? Symbol$2.prototype : undefined,
1899
+ var symbolProto$1 = Symbol$1 ? Symbol$1.prototype : undefined,
1900
1900
  symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : undefined;
1901
1901
 
1902
1902
  /**
@@ -2533,37 +2533,15 @@ var defaults = {
2533
2533
  teacherInstructionsEnabled: true,
2534
2534
  toolbarEditorPosition: 'bottom',
2535
2535
  selectedAnswerBackgroundColor: 'initial',
2536
+ selectedAnswerStrokeColor: 'initial',
2537
+ selectedAnswerStrokeWidth: 'initial',
2538
+ hoverAnswerBackgroundColor: 'initial',
2539
+ hoverAnswerStrokeColor: 'initial',
2540
+ hoverAnswerStrokeWidth: 'initial',
2536
2541
  keyboardEventsEnabled: false,
2537
2542
  };
2538
2543
 
2539
- var controllerUtils$1 = {};
2540
-
2541
- var controllerUtils = {};
2542
-
2543
- var _typeof = {exports: {}};
2544
-
2545
- (function (module) {
2546
- function _typeof(obj) {
2547
- "@babel/helpers - typeof";
2548
-
2549
- return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
2550
- return typeof obj;
2551
- } : function (obj) {
2552
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
2553
- }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
2554
- }
2555
-
2556
- module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
2557
- }(_typeof));
2558
-
2559
- var partialScoring = {};
2560
-
2561
- Object.defineProperty(partialScoring, "__esModule", {
2562
- value: true
2563
- });
2564
- partialScoring.enabled = void 0;
2565
-
2566
- var enabled = function enabled(config, env, defaultValue) {
2544
+ const enabled = (config, env, defaultValue) => {
2567
2545
  // if model.partialScoring = false
2568
2546
  // - if env.partialScoring = false || env.partialScoring = true => use dichotomous scoring
2569
2547
  // else if model.partialScoring = true || undefined
@@ -2583,22 +2561,6 @@ var enabled = function enabled(config, env, defaultValue) {
2583
2561
  return typeof defaultValue === 'boolean' ? defaultValue : true;
2584
2562
  };
2585
2563
 
2586
- partialScoring.enabled = enabled;
2587
-
2588
- var persistence = {};
2589
-
2590
- var interopRequireDefault = {exports: {}};
2591
-
2592
- (function (module) {
2593
- function _interopRequireDefault(obj) {
2594
- return obj && obj.__esModule ? obj : {
2595
- "default": obj
2596
- };
2597
- }
2598
-
2599
- module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
2600
- }(interopRequireDefault));
2601
-
2602
2564
  var baseGetTag = _baseGetTag,
2603
2565
  isObjectLike = isObjectLike_1;
2604
2566
 
@@ -2811,7 +2773,7 @@ function arrayMap$2(array, iteratee) {
2811
2773
 
2812
2774
  var _arrayMap = arrayMap$2;
2813
2775
 
2814
- var Symbol$1 = _Symbol,
2776
+ var Symbol = _Symbol,
2815
2777
  arrayMap$1 = _arrayMap,
2816
2778
  isArray$2 = isArray_1,
2817
2779
  isSymbol$1 = isSymbol_1;
@@ -2820,7 +2782,7 @@ var Symbol$1 = _Symbol,
2820
2782
  var INFINITY$1 = 1 / 0;
2821
2783
 
2822
2784
  /** Used to convert symbols to primitives and strings. */
2823
- var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
2785
+ var symbolProto = Symbol ? Symbol.prototype : undefined,
2824
2786
  symbolToString = symbolProto ? symbolProto.toString : undefined;
2825
2787
 
2826
2788
  /**
@@ -3165,86 +3127,54 @@ function shuffle(collection) {
3165
3127
 
3166
3128
  var shuffle_1 = shuffle;
3167
3129
 
3168
- var _interopRequireDefault = interopRequireDefault.exports;
3169
-
3170
- Object.defineProperty(persistence, "__esModule", {
3171
- value: true
3172
- });
3173
- persistence.lockChoices = persistence.getShuffledChoices = persistence.compact = void 0;
3174
-
3175
- var _typeof2 = _interopRequireDefault(_typeof.exports);
3176
-
3177
- var _get = _interopRequireDefault(get_1);
3178
-
3179
- var _shuffle = _interopRequireDefault(shuffle_1);
3180
-
3181
- var _isEmpty = _interopRequireDefault(isEmpty_1);
3182
-
3183
3130
  // eslint-disable-next-line no-console
3184
- var lg = function lg(n) {
3185
- return console[n].bind(console, 'controller-utils:');
3186
- };
3187
-
3188
- var debug = lg('debug');
3189
- var log = lg('log');
3190
- var warn = lg('warn');
3191
- var error = lg('error');
3131
+ const lg = (n) => console[n].bind(console, 'controller-utils:');
3132
+ const debug = lg('debug');
3133
+ const log = lg('log');
3134
+ const warn = lg('warn');
3135
+ const error = lg('error');
3192
3136
 
3193
- var compact = function compact(arr) {
3137
+ const compact = (arr) => {
3194
3138
  if (Array.isArray(arr)) {
3195
- return arr.filter(function (v) {
3196
- return v !== null && v !== undefined;
3197
- });
3139
+ return arr.filter((v) => v !== null && v !== undefined);
3198
3140
  }
3199
-
3200
3141
  return arr;
3201
3142
  };
3202
3143
 
3203
- persistence.compact = compact;
3204
-
3205
- var getShuffledChoices = function getShuffledChoices(choices, session, updateSession, choiceKey) {
3206
- return new Promise(function (resolve) {
3207
- var _session$data;
3208
-
3209
- log('updateSession type: ', (0, _typeof2["default"])(updateSession));
3144
+ const getShuffledChoices = (choices, session, updateSession, choiceKey) =>
3145
+ new Promise((resolve) => {
3146
+ log('updateSession type: ', typeof updateSession);
3210
3147
  log('session: ', session);
3211
- var currentShuffled = compact((session === null || session === void 0 ? void 0 : (_session$data = session.data) === null || _session$data === void 0 ? void 0 : _session$data.shuffledValues) || (session === null || session === void 0 ? void 0 : session.shuffledValues) || []);
3148
+
3149
+ const currentShuffled = compact(session?.data?.shuffledValues || session?.shuffledValues || []);
3212
3150
 
3213
3151
  if (!session) {
3214
3152
  // eslint-disable-next-line quotes
3215
3153
  warn("unable to save shuffled choices because there's no session.");
3216
3154
  resolve(undefined);
3217
- } else if (!(0, _isEmpty["default"])(currentShuffled)) {
3218
- var _session$data2;
3219
-
3220
- debug('use shuffledValues to sort the choices...', (_session$data2 = session.data) === null || _session$data2 === void 0 ? void 0 : _session$data2.shuffledValues);
3221
- resolve(compact(currentShuffled.map(function (v) {
3222
- return choices.find(function (c) {
3223
- return c[choiceKey] === v;
3224
- });
3225
- })));
3155
+ } else if (!isEmpty_1(currentShuffled)) {
3156
+ debug('use shuffledValues to sort the choices...', session.data?.shuffledValues);
3157
+ resolve(compact(currentShuffled.map((v) => choices.find((c) => c[choiceKey] === v))));
3226
3158
  } else {
3227
- var shuffledChoices = (0, _shuffle["default"])(choices);
3159
+ const shuffledChoices = shuffle_1(choices);
3228
3160
 
3229
3161
  if (updateSession && typeof updateSession === 'function') {
3230
3162
  try {
3231
3163
  //Note: session.id refers to the id of the element within a session
3232
- var shuffledValues = compact(shuffledChoices.map(function (c) {
3233
- return c[choiceKey];
3234
- }));
3164
+ const shuffledValues = compact(shuffledChoices.map((c) => c[choiceKey]));
3235
3165
  log('try to save shuffledValues to session...', shuffledValues);
3236
3166
  log('call updateSession... ', session.id, session.element);
3237
-
3238
- if ((0, _isEmpty["default"])(shuffledValues)) {
3239
- error("shuffledValues is an empty array? - refusing to call updateSession: shuffledChoices: ".concat(JSON.stringify(shuffledChoices), ", key: ").concat(choiceKey));
3167
+ if (isEmpty_1(shuffledValues)) {
3168
+ error(
3169
+ `shuffledValues is an empty array? - refusing to call updateSession: shuffledChoices: ${JSON.stringify(
3170
+ shuffledChoices,
3171
+ )}, key: ${choiceKey}`,
3172
+ );
3240
3173
  } else {
3241
- updateSession(session.id, session.element, {
3242
- shuffledValues: shuffledValues
3243
- })["catch"](function (e) {
3244
- return (// eslint-disable-next-line no-console
3245
- console.error('update session failed for: ', session.id, e)
3246
- );
3247
- });
3174
+ updateSession(session.id, session.element, { shuffledValues }).catch((e) =>
3175
+ // eslint-disable-next-line no-console
3176
+ console.error('update session failed for: ', session.id, e),
3177
+ );
3248
3178
  }
3249
3179
  } catch (e) {
3250
3180
  warn('unable to save shuffled order for choices');
@@ -3252,13 +3182,12 @@ var getShuffledChoices = function getShuffledChoices(choices, session, updateSes
3252
3182
  }
3253
3183
  } else {
3254
3184
  warn('unable to save shuffled choices, shuffle will happen every time.');
3255
- } //save this shuffle to the session for later retrieval
3256
-
3257
-
3185
+ }
3186
+ //save this shuffle to the session for later retrieval
3258
3187
  resolve(shuffledChoices);
3259
3188
  }
3260
3189
  });
3261
- };
3190
+
3262
3191
  /**
3263
3192
  * If we return:
3264
3193
  * - true - that means that the order of the choices will be ordinal (as is created in the configure item)
@@ -3269,101 +3198,35 @@ var getShuffledChoices = function getShuffledChoices(choices, session, updateSes
3269
3198
  * @param env - env to check if we should lock order
3270
3199
  * @returns {boolean}
3271
3200
  */
3272
-
3273
-
3274
- persistence.getShuffledChoices = getShuffledChoices;
3275
-
3276
- var lockChoices = function lockChoices(model, session, env) {
3201
+ const lockChoices = (model, session, env) => {
3277
3202
  if (model.lockChoiceOrder) {
3278
3203
  return true;
3279
3204
  }
3280
3205
 
3281
- log('lockChoiceOrder: ', (0, _get["default"])(env, ['@pie-element', 'lockChoiceOrder'], false));
3206
+ log('lockChoiceOrder: ', get_1(env, ['@pie-element', 'lockChoiceOrder'], false));
3282
3207
 
3283
- if ((0, _get["default"])(env, ['@pie-element', 'lockChoiceOrder'], false)) {
3208
+ if (get_1(env, ['@pie-element', 'lockChoiceOrder'], false)) {
3284
3209
  return true;
3285
3210
  }
3286
3211
 
3287
- var role = (0, _get["default"])(env, 'role', 'student');
3212
+ const role = get_1(env, 'role', 'student');
3288
3213
 
3289
3214
  if (role === 'instructor') {
3290
3215
  // TODO: .. in the future the instructor can toggle between ordinal and shuffled here, so keeping this code until then
3291
-
3292
3216
  /*const alreadyShuffled = hasShuffledValues(session);
3293
- if (alreadyShuffled) {
3217
+
3218
+ if (alreadyShuffled) {
3294
3219
  return false;
3295
3220
  }
3296
- return true;*/
3297
- return true;
3298
- } // here it's a student, so don't lock and it will shuffle if needs be
3299
3221
 
3222
+ return true;*/
3223
+ return true;
3224
+ }
3300
3225
 
3226
+ // here it's a student, so don't lock and it will shuffle if needs be
3301
3227
  return false;
3302
3228
  };
3303
3229
 
3304
- persistence.lockChoices = lockChoices;
3305
-
3306
- (function (exports) {
3307
-
3308
- var _typeof$1 = _typeof.exports;
3309
-
3310
- Object.defineProperty(exports, "__esModule", {
3311
- value: true
3312
- });
3313
- Object.defineProperty(exports, "getShuffledChoices", {
3314
- enumerable: true,
3315
- get: function get() {
3316
- return _persistence.getShuffledChoices;
3317
- }
3318
- });
3319
- Object.defineProperty(exports, "lockChoices", {
3320
- enumerable: true,
3321
- get: function get() {
3322
- return _persistence.lockChoices;
3323
- }
3324
- });
3325
- exports.partialScoring = void 0;
3326
-
3327
- var partialScoring$1 = _interopRequireWildcard(partialScoring);
3328
-
3329
- exports.partialScoring = partialScoring$1;
3330
-
3331
- var _persistence = persistence;
3332
-
3333
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
3334
-
3335
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof$1(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
3336
-
3337
- }(controllerUtils));
3338
-
3339
- (function (exports) {
3340
-
3341
- Object.defineProperty(exports, "__esModule", {
3342
- value: true
3343
- });
3344
- Object.defineProperty(exports, "getShuffledChoices", {
3345
- enumerable: true,
3346
- get: function get() {
3347
- return _controllerUtils.getShuffledChoices;
3348
- }
3349
- });
3350
- Object.defineProperty(exports, "lockChoices", {
3351
- enumerable: true,
3352
- get: function get() {
3353
- return _controllerUtils.lockChoices;
3354
- }
3355
- });
3356
- Object.defineProperty(exports, "partialScoring", {
3357
- enumerable: true,
3358
- get: function get() {
3359
- return _controllerUtils.partialScoring;
3360
- }
3361
- });
3362
-
3363
- var _controllerUtils = controllerUtils;
3364
-
3365
- }(controllerUtils$1));
3366
-
3367
3230
  /* eslint-disable no-console */
3368
3231
 
3369
3232
  const prepareChoice = (model, env, defaultFeedback) => (choice) => {
@@ -3429,10 +3292,10 @@ async function model(question, session, env, updateSession) {
3429
3292
 
3430
3293
  let choices = (normalizedQuestion.choices || []).map(prepareChoice(normalizedQuestion, env, defaultFeedback));
3431
3294
 
3432
- const lockChoiceOrder = controllerUtils$1.lockChoices(normalizedQuestion, session, env);
3295
+ const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);
3433
3296
 
3434
3297
  if (!lockChoiceOrder) {
3435
- choices = await controllerUtils$1.getShuffledChoices(choices, session, updateSession, 'value');
3298
+ choices = await getShuffledChoices(choices, session, updateSession, 'value');
3436
3299
  }
3437
3300
 
3438
3301
  const out = {
@@ -3450,6 +3313,11 @@ async function model(question, session, env, updateSession) {
3450
3313
  fontSizeFactor: normalizedQuestion.fontSizeFactor,
3451
3314
  isSelectionButtonBelow: normalizedQuestion.isSelectionButtonBelow,
3452
3315
  selectedAnswerBackgroundColor: normalizedQuestion.selectedAnswerBackgroundColor || 'initial',
3316
+ selectedAnswerStrokeColor: normalizedQuestion.selectedAnswerStrokeColor || 'initial',
3317
+ selectedAnswerStrokeWidth: normalizedQuestion.selectedAnswerStrokeWidth || 'initial',
3318
+ hoverAnswerBackgroundColor: normalizedQuestion.hoverAnswerBackgroundColor || 'initial',
3319
+ hoverAnswerStrokeColor: normalizedQuestion.hoverAnswerStrokeColor || 'initial',
3320
+ hoverAnswerStrokeWidth: normalizedQuestion.hoverAnswerStrokeWidth || 'initial',
3453
3321
  minSelections: normalizedQuestion.minSelections,
3454
3322
  maxSelections: normalizedQuestion.maxSelections,
3455
3323
  keyboardEventsEnabled: normalizedQuestion.keyboardEventsEnabled,
@@ -3511,7 +3379,7 @@ function outcome(model, session, env) {
3511
3379
  if (!session || isEmpty_1(session)) {
3512
3380
  resolve({ score: 0, empty: true });
3513
3381
  } else {
3514
- const partialScoringEnabled = controllerUtils$1.partialScoring.enabled(model, env) && model.choiceMode !== 'radio';
3382
+ const partialScoringEnabled = enabled(model, env) && model.choiceMode !== 'radio';
3515
3383
  const score = getScore(model, session);
3516
3384
 
3517
3385
  resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: false });