Manque l'ajout des tests et l'affichage du feedback approprié

This commit is contained in:
JubaAzul 2025-03-21 18:59:02 -04:00
parent 459b30f63c
commit 800575a79c

View file

@ -137,21 +137,15 @@ const NumericalQuestionDisplay: React.FC<Props> = (props) => {
<span> <span>
<div className="accepted-answers">{answer}</div> <div className="accepted-answers">{answer}</div>
{isMultpleAnswer && (() => { {isMultpleAnswer && (() => {
const highestPriorityAnswer = correctAnswers const highestPriorityAnswer = correctAnswers.reduce((prev, current) => {
.filter((correctAnswer) => const prevWeight = (prev as MultipleNumericalAnswer).weight ?? -1; // Treat undefined as highest priority
isAnswerCorrect(answer as number, (correctAnswer as MultipleNumericalAnswer).answer) const currentWeight = (current as MultipleNumericalAnswer).weight ?? -1; // Treat undefined as highest priority
) // Filter answers that return true for isAnswerCorrect
.reduce((prev, current) => { // Prioritize undefined weights, otherwise compare weights numerically
const prevWeight = (prev as MultipleNumericalAnswer).weight ?? -1; // Treat undefined as highest priority if (prevWeight === -1 && currentWeight !== -1) return prev;
const currentWeight = (current as MultipleNumericalAnswer).weight ?? -1; // Treat undefined as highest priority if (currentWeight === -1 && prevWeight !== -1) return current;
return currentWeight > prevWeight ? current : prev;
// 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;
});
return isAnswerCorrect(answer as number, (highestPriorityAnswer as MultipleNumericalAnswer).answer) && ( return isAnswerCorrect(answer as number, (highestPriorityAnswer as MultipleNumericalAnswer).answer) && (
<div> <div>