@pie-element/multiple-choice 13.4.0 → 13.4.2-beta.2
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/CHANGELOG.md +32 -54
- package/configure/CHANGELOG.md +28 -40
- package/configure/lib/__tests__/root.test.js +279 -0
- package/configure/package.json +4 -4
- package/controller/CHANGELOG.md +36 -11
- package/controller/lib/__tests__/index.test.js +561 -0
- package/controller/lib/__tests__/utils.test.js +8 -0
- package/controller/package.json +1 -1
- package/docs/demo/pie.manifest.json +11 -0
- package/lib/__tests__/choice-input-test.js +49 -0
- package/lib/__tests__/choice-input.test.js +49 -0
- package/lib/__tests__/index-test.js +206 -0
- package/lib/__tests__/index.test.js +221 -0
- package/lib/__tests__/key-events-test.js +95 -0
- package/lib/__tests__/key-events.test.js +107 -0
- package/lib/__tests__/multiple-choice-test.js +101 -0
- package/lib/__tests__/multiple-choice.test.js +256 -0
- package/lib/__tests__/session-updater-test.js +70 -0
- package/lib/__tests__/session-updater.test.js +70 -0
- package/lib/choice.js +1 -8
- package/lib/choice.js.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/module/configure.js +1 -1
- package/module/controller.js +15 -12
- package/module/element.js +1 -1
- package/module/index.html +1 -1
- package/module/manifest.json +3 -3
- package/module/print.html +1 -1
- package/module/print.js +1 -1
- package/package.json +4 -4
package/module/controller.js
CHANGED
|
@@ -2722,10 +2722,6 @@ const getShuffledChoices = (choices, session, updateSession, choiceKey) =>
|
|
|
2722
2722
|
* - true - that means that the order of the choices will be ordinal (as is created in the configure item)
|
|
2723
2723
|
* - false - that means the getShuffledChoices above will be called and that in turn means that we either
|
|
2724
2724
|
* return the shuffled values on the session (if any exists) or we shuffle the choices
|
|
2725
|
-
*
|
|
2726
|
-
* Note: the role (student/instructor) is intentionally not considered here — instructor mode
|
|
2727
|
-
* will respect the same `lockChoiceOrder` value as students, instead of forcing the order to be locked.
|
|
2728
|
-
*
|
|
2729
2725
|
* @param model - model to check if we should lock order
|
|
2730
2726
|
* @param session - session to check if we should lock order
|
|
2731
2727
|
* @param env - env to check if we should lock order
|
|
@@ -2742,6 +2738,21 @@ const lockChoices = (model, session, env) => {
|
|
|
2742
2738
|
return true;
|
|
2743
2739
|
}
|
|
2744
2740
|
|
|
2741
|
+
const role = get(env, 'role', 'student');
|
|
2742
|
+
|
|
2743
|
+
if (role === 'instructor') {
|
|
2744
|
+
// TODO: .. in the future the instructor can toggle between ordinal and shuffled here, so keeping this code until then
|
|
2745
|
+
/*const alreadyShuffled = hasShuffledValues(session);
|
|
2746
|
+
|
|
2747
|
+
if (alreadyShuffled) {
|
|
2748
|
+
return false;
|
|
2749
|
+
}
|
|
2750
|
+
|
|
2751
|
+
return true;*/
|
|
2752
|
+
return true;
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
// here it's a student, so don't lock and it will shuffle if needs be
|
|
2745
2756
|
return false;
|
|
2746
2757
|
};
|
|
2747
2758
|
|
|
@@ -2985,14 +2996,12 @@ const validate = (model = {}, config = {}) => {
|
|
|
2985
2996
|
});
|
|
2986
2997
|
|
|
2987
2998
|
let hasCorrectResponse = false;
|
|
2988
|
-
let correctCount = 0;
|
|
2989
2999
|
|
|
2990
3000
|
reversedChoices.forEach((choice, index) => {
|
|
2991
3001
|
const { correct, value, label, rationale } = choice;
|
|
2992
3002
|
|
|
2993
3003
|
if (correct) {
|
|
2994
3004
|
hasCorrectResponse = true;
|
|
2995
|
-
correctCount++;
|
|
2996
3005
|
}
|
|
2997
3006
|
|
|
2998
3007
|
if (!getContent(label)) {
|
|
@@ -3020,12 +3029,6 @@ const validate = (model = {}, config = {}) => {
|
|
|
3020
3029
|
|
|
3021
3030
|
if (!hasCorrectResponse) {
|
|
3022
3031
|
errors.correctResponse = 'No correct response defined.';
|
|
3023
|
-
} else {
|
|
3024
|
-
const { maxSelections, choiceMode } = model;
|
|
3025
|
-
|
|
3026
|
-
if (choiceMode !== 'radio' && maxSelections != null && correctCount > maxSelections) {
|
|
3027
|
-
errors.correctResponse = `The number of correct answers (${correctCount}) exceeds max selections (${maxSelections}). Students won't be able to select all correct answers.`;
|
|
3028
|
-
}
|
|
3029
3032
|
}
|
|
3030
3033
|
|
|
3031
3034
|
if (!isEmpty(choicesErrors)) {
|