Commented all related to shuffle
This commit is contained in:
@@ -20,7 +20,7 @@ const FillBlanks: React.FC<FillBlanksExercise & CommonProps> = ({
|
||||
onNext,
|
||||
onBack,
|
||||
}) => {
|
||||
const { shuffleMaps } = useExamStore((state) => state);
|
||||
//const { shuffleMaps } = useExamStore((state) => state);
|
||||
const [answers, setAnswers] = useState<{ id: string; solution: string }[]>(userSolutions);
|
||||
const hasExamEnded = useExamStore((state) => state.hasExamEnded);
|
||||
|
||||
@@ -62,7 +62,7 @@ const FillBlanks: React.FC<FillBlanksExercise & CommonProps> = ({
|
||||
return solution.toLowerCase() === option.toLowerCase();
|
||||
} else if ('letter' in option) {
|
||||
return solution.toLowerCase() === option.word.toLowerCase();
|
||||
} else if ('options' in option) {
|
||||
} /*else if ('options' in option) {
|
||||
if (shuffleMaps.length !== 0) {
|
||||
const shuffleMap = shuffleMaps.find((map) => map.id == x.id)
|
||||
if (!shuffleMap) {
|
||||
@@ -73,7 +73,7 @@ const FillBlanks: React.FC<FillBlanksExercise & CommonProps> = ({
|
||||
}
|
||||
|
||||
return solution.toLowerCase() === (option.options[x.solution as keyof typeof option.options] || '').toLowerCase();
|
||||
}
|
||||
}*/
|
||||
return false;
|
||||
}).length;
|
||||
|
||||
@@ -129,7 +129,7 @@ const FillBlanks: React.FC<FillBlanksExercise & CommonProps> = ({
|
||||
setAnswers((prev) => [...prev.filter((x) => x.id !== id), { id: id, solution: value }]);
|
||||
}
|
||||
|
||||
const getShuffles = () => {
|
||||
/*const getShuffles = () => {
|
||||
let shuffle = {};
|
||||
if (shuffleMaps.length !== 0) {
|
||||
shuffle = {
|
||||
@@ -139,7 +139,7 @@ const FillBlanks: React.FC<FillBlanksExercise & CommonProps> = ({
|
||||
}
|
||||
}
|
||||
return shuffle;
|
||||
}
|
||||
}*/
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -166,7 +166,7 @@ const FillBlanks: React.FC<FillBlanksExercise & CommonProps> = ({
|
||||
<div className="bg-mti-gray-smoke rounded-xl px-5 py-6 flex flex-col gap-4">
|
||||
<span className="font-medium text-mti-purple-dark">Options</span>
|
||||
<div className="flex gap-4 flex-wrap">
|
||||
{currentMCSelection.selection?.options && Object.entries(currentMCSelection.selection.options).map(([key, value]) => {
|
||||
{currentMCSelection.selection?.options && Object.entries(currentMCSelection.selection.options).sort((a, b) => a[0].localeCompare(b[0])).map(([key, value]) => {
|
||||
return <button
|
||||
className={clsx(
|
||||
"border border-mti-purple-light rounded-full px-3 py-0.5 transition ease-in-out duration-300",
|
||||
@@ -212,14 +212,14 @@ const FillBlanks: React.FC<FillBlanksExercise & CommonProps> = ({
|
||||
<Button
|
||||
color="purple"
|
||||
variant="outline"
|
||||
onClick={() => onBack({ exercise: id, solutions: answers, score: calculateScore(), type, ...getShuffles() })}
|
||||
onClick={() => onBack({ exercise: id, solutions: answers, score: calculateScore(), type, })}//...getShuffles() })}
|
||||
className="max-w-[200px] w-full">
|
||||
Back
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
color="purple"
|
||||
onClick={() => onNext({ exercise: id, solutions: answers, score: calculateScore(), type, ...getShuffles() })}
|
||||
onClick={() => onNext({ exercise: id, solutions: answers, score: calculateScore(), type, })}//...getShuffles() })}
|
||||
className="max-w-[200px] self-end w-full">
|
||||
Next
|
||||
</Button>
|
||||
|
||||
@@ -76,7 +76,7 @@ function Question({
|
||||
export default function MultipleChoice({ id, prompt, type, questions, userSolutions, onNext, onBack }: MultipleChoiceExercise & CommonProps) {
|
||||
const [answers, setAnswers] = useState<{ question: string; option: string }[]>(userSolutions);
|
||||
|
||||
const { shuffleMaps } = useExamStore((state) => state);
|
||||
//const { shuffleMaps } = useExamStore((state) => state);
|
||||
const { questionIndex, setQuestionIndex } = useExamStore((state) => state);
|
||||
const { userSolutions: storeUserSolutions, setUserSolutions } = useExamStore((state) => state);
|
||||
const hasExamEnded = useExamStore((state) => state.hasExamEnded);
|
||||
@@ -109,12 +109,12 @@ export default function MultipleChoice({ id, prompt, type, questions, userSoluti
|
||||
});
|
||||
|
||||
let isSolutionCorrect;
|
||||
if (shuffleMaps.length == 0) {
|
||||
isSolutionCorrect = matchingQuestion?.solution === x.option;
|
||||
} else {
|
||||
const shuffleMap = shuffleMaps.find((map) => map.id == x.question)
|
||||
isSolutionCorrect = shuffleMap?.map[x.option] == matchingQuestion?.solution;
|
||||
}
|
||||
//if (shuffleMaps.length == 0) {
|
||||
isSolutionCorrect = matchingQuestion?.solution === x.option;
|
||||
//} else {
|
||||
// const shuffleMap = shuffleMaps.find((map) => map.id == x.question)
|
||||
// isSolutionCorrect = shuffleMap?.map[x.option] == matchingQuestion?.solution;
|
||||
//}
|
||||
return isSolutionCorrect || false;
|
||||
}).length;
|
||||
const missing = total - correct;
|
||||
@@ -122,7 +122,7 @@ export default function MultipleChoice({ id, prompt, type, questions, userSoluti
|
||||
return { total, correct, missing };
|
||||
};
|
||||
|
||||
const getShuffles = () => {
|
||||
/*const getShuffles = () => {
|
||||
let shuffle = {};
|
||||
if (shuffleMaps.length !== 0) {
|
||||
shuffle = {
|
||||
@@ -132,11 +132,11 @@ export default function MultipleChoice({ id, prompt, type, questions, userSoluti
|
||||
}
|
||||
}
|
||||
return shuffle;
|
||||
}
|
||||
}*/
|
||||
|
||||
const next = () => {
|
||||
if (questionIndex === questions.length - 1) {
|
||||
onNext({ exercise: id, solutions: answers, score: calculateScore(), type, ...getShuffles() });
|
||||
onNext({ exercise: id, solutions: answers, score: calculateScore(), type, });//...getShuffles() });
|
||||
} else {
|
||||
setQuestionIndex(questionIndex + 1);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ export default function MultipleChoice({ id, prompt, type, questions, userSoluti
|
||||
|
||||
const back = () => {
|
||||
if (questionIndex === 0) {
|
||||
onBack({ exercise: id, solutions: answers, score: calculateScore(), type, ...getShuffles() });
|
||||
onBack({ exercise: id, solutions: answers, score: calculateScore(), type, });// ...getShuffles() });
|
||||
} else {
|
||||
setQuestionIndex(questionIndex - 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user