From 800575a79c350695a73ef3a3d6b6e271d35f8019 Mon Sep 17 00:00:00 2001 From: JubaAzul <118773284+JubaAzul@users.noreply.github.com> Date: Fri, 21 Mar 2025 18:59:02 -0400 Subject: [PATCH] =?UTF-8?q?Manque=20l'ajout=20des=20tests=20et=20l'afficha?= =?UTF-8?q?ge=20du=20feedback=20appropri=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NumericalQuestionDisplay.tsx | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/client/src/components/QuestionsDisplay/NumericalQuestionDisplay/NumericalQuestionDisplay.tsx b/client/src/components/QuestionsDisplay/NumericalQuestionDisplay/NumericalQuestionDisplay.tsx index f81c46a..c6ba7d2 100644 --- a/client/src/components/QuestionsDisplay/NumericalQuestionDisplay/NumericalQuestionDisplay.tsx +++ b/client/src/components/QuestionsDisplay/NumericalQuestionDisplay/NumericalQuestionDisplay.tsx @@ -137,21 +137,15 @@ const NumericalQuestionDisplay: React.FC = (props) => {
{answer}
{isMultpleAnswer && (() => { - const highestPriorityAnswer = correctAnswers - .filter((correctAnswer) => - isAnswerCorrect(answer as number, (correctAnswer as MultipleNumericalAnswer).answer) - ) // Filter answers that return true for isAnswerCorrect - .reduce((prev, current) => { - const prevWeight = (prev as MultipleNumericalAnswer).weight ?? -1; // Treat undefined as highest priority - const currentWeight = (current as MultipleNumericalAnswer).weight ?? -1; // Treat undefined as highest priority - - // Prioritize undefined weights - if (prevWeight === -1 && currentWeight !== -1) return prev; - if (currentWeight === -1 && prevWeight !== -1) return current; - - // Otherwise, return the one with the smallest weight - return currentWeight < prevWeight ? current : prev; - }); + const highestPriorityAnswer = correctAnswers.reduce((prev, current) => { + const prevWeight = (prev as MultipleNumericalAnswer).weight ?? -1; // Treat undefined as highest priority + const currentWeight = (current as MultipleNumericalAnswer).weight ?? -1; // Treat undefined as highest priority + + // Prioritize undefined weights, otherwise compare weights numerically + if (prevWeight === -1 && currentWeight !== -1) return prev; + if (currentWeight === -1 && prevWeight !== -1) return current; + return currentWeight > prevWeight ? current : prev; + }); return isAnswerCorrect(answer as number, (highestPriorityAnswer as MultipleNumericalAnswer).answer) && (