@pie-element/multiple-choice 11.0.1 → 11.0.2-esm.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/configure/package.json +4 -4
- package/esm/configure.css +847 -0
- package/esm/configure.js +118 -15741
- package/esm/configure.js.map +1 -1
- package/esm/controller.css +847 -0
- package/esm/controller.js +102 -169
- package/esm/controller.js.map +1 -1
- package/esm/element.css +847 -0
- package/esm/element.js +1408 -12564
- package/esm/element.js.map +1 -1
- package/esm/print.css +847 -0
- package/esm/print.js +1385 -12541
- package/esm/print.js.map +1 -1
- package/module/controller.js +84 -81
- package/module/element.js +1 -1
- package/module/index.html +1 -1
- package/module/manifest.json +1 -1
- package/module/print.html +1 -1
- package/module/print.js +1 -1
- package/package.json +4 -4
package/module/controller.js
CHANGED
|
@@ -2541,26 +2541,6 @@ var defaults = {
|
|
|
2541
2541
|
keyboardEventsEnabled: false,
|
|
2542
2542
|
};
|
|
2543
2543
|
|
|
2544
|
-
const enabled = (config, env, defaultValue) => {
|
|
2545
|
-
// if model.partialScoring = false
|
|
2546
|
-
// - if env.partialScoring = false || env.partialScoring = true => use dichotomous scoring
|
|
2547
|
-
// else if model.partialScoring = true || undefined
|
|
2548
|
-
// - if env.partialScoring = false, use dichotomous scoring
|
|
2549
|
-
// - else if env.partialScoring = true, use partial scoring
|
|
2550
|
-
config = config || {};
|
|
2551
|
-
env = env || {};
|
|
2552
|
-
|
|
2553
|
-
if (config.partialScoring === false) {
|
|
2554
|
-
return false;
|
|
2555
|
-
}
|
|
2556
|
-
|
|
2557
|
-
if (env.partialScoring === false) {
|
|
2558
|
-
return false;
|
|
2559
|
-
}
|
|
2560
|
-
|
|
2561
|
-
return typeof defaultValue === 'boolean' ? defaultValue : true;
|
|
2562
|
-
};
|
|
2563
|
-
|
|
2564
2544
|
var baseGetTag = _baseGetTag,
|
|
2565
2545
|
isObjectLike = isObjectLike_1;
|
|
2566
2546
|
|
|
@@ -3127,67 +3107,90 @@ function shuffle(collection) {
|
|
|
3127
3107
|
|
|
3128
3108
|
var shuffle_1 = shuffle;
|
|
3129
3109
|
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3110
|
+
var enabled = (config, env, defaultValue) => {
|
|
3111
|
+
// if model.partialScoring = false
|
|
3112
|
+
// - if env.partialScoring = false || env.partialScoring = true => use dichotomous scoring
|
|
3113
|
+
// else if model.partialScoring = true || undefined
|
|
3114
|
+
// - if env.partialScoring = false, use dichotomous scoring
|
|
3115
|
+
// - else if env.partialScoring = true, use partial scoring
|
|
3116
|
+
config = config || {};
|
|
3117
|
+
env = env || {};
|
|
3136
3118
|
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
return arr.filter((v) => v !== null && v !== undefined);
|
|
3119
|
+
if (config.partialScoring === false) {
|
|
3120
|
+
return false;
|
|
3140
3121
|
}
|
|
3141
|
-
|
|
3122
|
+
|
|
3123
|
+
if (env.partialScoring === false) {
|
|
3124
|
+
return false;
|
|
3125
|
+
}
|
|
3126
|
+
|
|
3127
|
+
return typeof defaultValue === 'boolean' ? defaultValue : true;
|
|
3142
3128
|
};
|
|
3143
3129
|
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3130
|
+
var partialScoring = /*#__PURE__*/Object.freeze({
|
|
3131
|
+
__proto__: null,
|
|
3132
|
+
enabled: enabled
|
|
3133
|
+
});
|
|
3148
3134
|
|
|
3149
|
-
|
|
3135
|
+
var lg = n => console[n].bind(console, 'controller-utils:');
|
|
3150
3136
|
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3137
|
+
var debug = lg('debug');
|
|
3138
|
+
var log = lg('log');
|
|
3139
|
+
var warn = lg('warn');
|
|
3140
|
+
var error = lg('error');
|
|
3141
|
+
var compact = arr => {
|
|
3142
|
+
if (Array.isArray(arr)) {
|
|
3143
|
+
return arr.filter(v => v !== null && v !== undefined);
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
return arr;
|
|
3147
|
+
};
|
|
3148
|
+
var getShuffledChoices = (choices, session, updateSession, choiceKey) => new Promise(resolve => {
|
|
3149
|
+
var _session$data;
|
|
3150
|
+
|
|
3151
|
+
log('updateSession type: ', typeof updateSession);
|
|
3152
|
+
log('session: ', session);
|
|
3153
|
+
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) || []);
|
|
3154
|
+
|
|
3155
|
+
if (!session) {
|
|
3156
|
+
// eslint-disable-next-line quotes
|
|
3157
|
+
warn("unable to save shuffled choices because there's no session.");
|
|
3158
|
+
resolve(undefined);
|
|
3159
|
+
} else if (!isEmpty_1(currentShuffled)) {
|
|
3160
|
+
var _session$data2;
|
|
3161
|
+
|
|
3162
|
+
debug('use shuffledValues to sort the choices...', (_session$data2 = session.data) === null || _session$data2 === void 0 ? void 0 : _session$data2.shuffledValues);
|
|
3163
|
+
resolve(compact(currentShuffled.map(v => choices.find(c => c[choiceKey] === v))));
|
|
3164
|
+
} else {
|
|
3165
|
+
var shuffledChoices = shuffle_1(choices);
|
|
3166
|
+
|
|
3167
|
+
if (updateSession && typeof updateSession === 'function') {
|
|
3168
|
+
try {
|
|
3169
|
+
//Note: session.id refers to the id of the element within a session
|
|
3170
|
+
var shuffledValues = compact(shuffledChoices.map(c => c[choiceKey]));
|
|
3171
|
+
log('try to save shuffledValues to session...', shuffledValues);
|
|
3172
|
+
log('call updateSession... ', session.id, session.element);
|
|
3173
|
+
|
|
3174
|
+
if (isEmpty_1(shuffledValues)) {
|
|
3175
|
+
error("shuffledValues is an empty array? - refusing to call updateSession: shuffledChoices: ".concat(JSON.stringify(shuffledChoices), ", key: ").concat(choiceKey));
|
|
3176
|
+
} else {
|
|
3177
|
+
updateSession(session.id, session.element, {
|
|
3178
|
+
shuffledValues
|
|
3179
|
+
}).catch(e => // eslint-disable-next-line no-console
|
|
3180
|
+
console.error('update session failed for: ', session.id, e));
|
|
3182
3181
|
}
|
|
3183
|
-
}
|
|
3184
|
-
warn('unable to save shuffled
|
|
3182
|
+
} catch (e) {
|
|
3183
|
+
warn('unable to save shuffled order for choices');
|
|
3184
|
+
error(e);
|
|
3185
3185
|
}
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
}
|
|
3189
|
-
|
|
3186
|
+
} else {
|
|
3187
|
+
warn('unable to save shuffled choices, shuffle will happen every time.');
|
|
3188
|
+
} //save this shuffle to the session for later retrieval
|
|
3189
|
+
|
|
3190
3190
|
|
|
3191
|
+
resolve(shuffledChoices);
|
|
3192
|
+
}
|
|
3193
|
+
});
|
|
3191
3194
|
/**
|
|
3192
3195
|
* If we return:
|
|
3193
3196
|
* - true - that means that the order of the choices will be ordinal (as is created in the configure item)
|
|
@@ -3198,7 +3201,8 @@ const getShuffledChoices = (choices, session, updateSession, choiceKey) =>
|
|
|
3198
3201
|
* @param env - env to check if we should lock order
|
|
3199
3202
|
* @returns {boolean}
|
|
3200
3203
|
*/
|
|
3201
|
-
|
|
3204
|
+
|
|
3205
|
+
var lockChoices = (model, session, env) => {
|
|
3202
3206
|
if (model.lockChoiceOrder) {
|
|
3203
3207
|
return true;
|
|
3204
3208
|
}
|
|
@@ -3209,21 +3213,20 @@ const lockChoices = (model, session, env) => {
|
|
|
3209
3213
|
return true;
|
|
3210
3214
|
}
|
|
3211
3215
|
|
|
3212
|
-
|
|
3216
|
+
var role = get_1(env, 'role', 'student');
|
|
3213
3217
|
|
|
3214
3218
|
if (role === 'instructor') {
|
|
3215
3219
|
// TODO: .. in the future the instructor can toggle between ordinal and shuffled here, so keeping this code until then
|
|
3216
|
-
/*const alreadyShuffled = hasShuffledValues(session);
|
|
3217
3220
|
|
|
3218
|
-
|
|
3221
|
+
/*const alreadyShuffled = hasShuffledValues(session);
|
|
3222
|
+
if (alreadyShuffled) {
|
|
3219
3223
|
return false;
|
|
3220
3224
|
}
|
|
3221
|
-
|
|
3222
|
-
return true;*/
|
|
3225
|
+
return true;*/
|
|
3223
3226
|
return true;
|
|
3224
|
-
}
|
|
3227
|
+
} // here it's a student, so don't lock and it will shuffle if needs be
|
|
3228
|
+
|
|
3225
3229
|
|
|
3226
|
-
// here it's a student, so don't lock and it will shuffle if needs be
|
|
3227
3230
|
return false;
|
|
3228
3231
|
};
|
|
3229
3232
|
|
|
@@ -3379,7 +3382,7 @@ function outcome(model, session, env) {
|
|
|
3379
3382
|
if (!session || isEmpty_1(session)) {
|
|
3380
3383
|
resolve({ score: 0, empty: true });
|
|
3381
3384
|
} else {
|
|
3382
|
-
const partialScoringEnabled = enabled(model, env) && model.choiceMode !== 'radio';
|
|
3385
|
+
const partialScoringEnabled = partialScoring.enabled(model, env) && model.choiceMode !== 'radio';
|
|
3383
3386
|
const score = getScore(model, session);
|
|
3384
3387
|
|
|
3385
3388
|
resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: false });
|