mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Manque l'ajout des tests et l'affichage du feedback approprié
This commit is contained in:
parent
459b30f63c
commit
800575a79c
1 changed files with 9 additions and 15 deletions
|
|
@ -137,20 +137,14 @@ 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) =>
|
|
||||||
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 prevWeight = (prev as MultipleNumericalAnswer).weight ?? -1; // Treat undefined as highest priority
|
||||||
const currentWeight = (current as MultipleNumericalAnswer).weight ?? -1; // Treat undefined as highest priority
|
const currentWeight = (current as MultipleNumericalAnswer).weight ?? -1; // Treat undefined as highest priority
|
||||||
|
|
||||||
// Prioritize undefined weights
|
// Prioritize undefined weights, otherwise compare weights numerically
|
||||||
if (prevWeight === -1 && currentWeight !== -1) return prev;
|
if (prevWeight === -1 && currentWeight !== -1) return prev;
|
||||||
if (currentWeight === -1 && prevWeight !== -1) return current;
|
if (currentWeight === -1 && prevWeight !== -1) return current;
|
||||||
|
return currentWeight > prevWeight ? current : prev;
|
||||||
// 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) && (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue