Merged develop into ENCOA-83_MasterStatistical
This commit is contained in:
@@ -50,10 +50,10 @@ export default function Level({ exam, showSolutions = false, onFinish, editing =
|
||||
const [contextWordLine, setContextWordLine] = useState<number | undefined>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
if (showSolutions && exerciseIndex && userSolutions[exerciseIndex].shuffleMaps) {
|
||||
if (showSolutions && exerciseIndex && exam.shuffle && userSolutions[exerciseIndex].shuffleMaps) {
|
||||
setShuffleMaps(userSolutions[exerciseIndex].shuffleMaps as ShuffleMap[])
|
||||
}
|
||||
}, [showSolutions, exerciseIndex, setShuffleMaps, userSolutions])
|
||||
}, [showSolutions, exerciseIndex, setShuffleMaps, userSolutions, exam.shuffle])
|
||||
|
||||
useEffect(() => {
|
||||
if (hasExamEnded && exerciseIndex === -1) {
|
||||
@@ -71,7 +71,7 @@ export default function Level({ exam, showSolutions = false, onFinish, editing =
|
||||
};
|
||||
|
||||
if (exam.shuffle && exercise.type === "multipleChoice" && !showSolutions) {
|
||||
console.log("Shuffling");
|
||||
console.log("Shuffling MC ");
|
||||
const exerciseShuffles = userSolutions[exerciseIndex].shuffleMaps;
|
||||
if (exerciseShuffles && exerciseShuffles.length == 0) {
|
||||
const newShuffleMaps: ShuffleMap[] = [];
|
||||
@@ -100,7 +100,7 @@ export default function Level({ exam, showSolutions = false, onFinish, editing =
|
||||
|
||||
setShuffleMaps(newShuffleMaps);
|
||||
} else {
|
||||
console.log("retrieving shuffles");
|
||||
console.log("retrieving MC shuffles");
|
||||
exercise.questions = exercise.questions.map(question => {
|
||||
const questionShuffleMap = shuffleMaps.find(map => map.id === question.id);
|
||||
if (questionShuffleMap) {
|
||||
@@ -116,7 +116,7 @@ export default function Level({ exam, showSolutions = false, onFinish, editing =
|
||||
} else if (exam.shuffle && exercise.type === "fillBlanks" && typeCheckWordsMC(exercise.words) && !showSolutions) {
|
||||
if (shuffleMaps.length === 0 && !showSolutions) {
|
||||
const newShuffleMaps: ShuffleMap[] = [];
|
||||
|
||||
console.log("Shuffling Words");
|
||||
exercise.words = exercise.words.map(word => {
|
||||
if ('options' in word) {
|
||||
const options = { ...word.options };
|
||||
@@ -141,8 +141,28 @@ export default function Level({ exam, showSolutions = false, onFinish, editing =
|
||||
});
|
||||
|
||||
setShuffleMaps(newShuffleMaps);
|
||||
} else {
|
||||
console.log("Retrieving Words shuffle");
|
||||
exercise.words = exercise.words.map(word => {
|
||||
if ('options' in word) {
|
||||
const shuffleMap = shuffleMaps.find(map => map.id === word.id);
|
||||
if (shuffleMap) {
|
||||
const options = { ...word.options };
|
||||
const shuffledOptions = Object.keys(options).reduce((acc, key) => {
|
||||
const shuffledKey = shuffleMap.map[key as keyof typeof options];
|
||||
acc[shuffledKey as keyof typeof options] = options[key as keyof typeof options];
|
||||
return acc;
|
||||
}, {} as { [key in keyof typeof options]: string });
|
||||
|
||||
return { ...word, options: shuffledOptions };
|
||||
}
|
||||
}
|
||||
return word;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
console.log(exercise);
|
||||
return exercise;
|
||||
};
|
||||
|
||||
@@ -338,12 +358,12 @@ export default function Level({ exam, showSolutions = false, onFinish, editing =
|
||||
|
||||
return {
|
||||
blankQuestions: !allSolutionsCorrectLength,
|
||||
finishingWhat: "part",
|
||||
onClose: partIndex !== exam.parts.length - 1 ? (
|
||||
finishingWhat: "part",
|
||||
onClose: partIndex !== exam.parts.length - 1 ? (
|
||||
function (x: boolean | undefined) { if (x) { setShowQuestionsModal(false); nextExercise(); } else { setShowQuestionsModal(false) } }
|
||||
) : function (x: boolean | undefined) { if (x) { setShowQuestionsModal(false); onFinish(userSolutions); } else { setShowQuestionsModal(false) } }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user