From 60ad2df67d386ca322cc7fb647247db1c84545d6 Mon Sep 17 00:00:00 2001 From: JubaAzul <118773284+JubaAzul@users.noreply.github.com> Date: Tue, 4 Mar 2025 16:49:12 -0500 Subject: [PATCH] =?UTF-8?q?R=C3=A9ponse=20=C3=A0=20une=20question=20non=20?= =?UTF-8?q?enregistr=C3=A9e=20lorsque=20=C3=89tudiant=20reviens=20en=20arr?= =?UTF-8?q?i=C3=A8re=20dans=20le=20quiz=20Fixes=20#200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MultipleChoiceQuestionDisplay.tsx | 17 ++++++----- .../QuestionsDisplay/QuestionDisplay.tsx | 4 +++ .../TrueFalseQuestionDisplay.tsx | 28 +++++++++++++------ .../StudentModeQuiz/StudentModeQuiz.tsx | 3 +- .../TeacherModeQuiz/TeacherModeQuiz.tsx | 11 ++++++-- 5 files changed, 40 insertions(+), 23 deletions(-) diff --git a/client/src/components/QuestionsDisplay/MultipleChoiceQuestionDisplay/MultipleChoiceQuestionDisplay.tsx b/client/src/components/QuestionsDisplay/MultipleChoiceQuestionDisplay/MultipleChoiceQuestionDisplay.tsx index e5e7b6b..790848f 100644 --- a/client/src/components/QuestionsDisplay/MultipleChoiceQuestionDisplay/MultipleChoiceQuestionDisplay.tsx +++ b/client/src/components/QuestionsDisplay/MultipleChoiceQuestionDisplay/MultipleChoiceQuestionDisplay.tsx @@ -1,5 +1,5 @@ // MultipleChoiceQuestionDisplay.tsx -import React, { useEffect, useState } from 'react'; +import React, { useState } from 'react'; import '../questionStyle.css'; import { Button } from '@mui/material'; import { FormattedTextTemplate } from '../../GiftTemplate/templates/TextTypeTemplate'; @@ -7,22 +7,21 @@ import { MultipleChoiceQuestion } from 'gift-pegjs'; interface Props { question: MultipleChoiceQuestion; - handleOnSubmitAnswer?: (answer: string) => void; + handleOnSubmitAnswer?: (answer: string | number | boolean) => void; showAnswer?: boolean; + passedAnswer?: string | number | boolean; } const MultipleChoiceQuestionDisplay: React.FC = (props) => { - const { question, showAnswer, handleOnSubmitAnswer } = props; - const [answer, setAnswer] = useState(); + const { question, showAnswer, handleOnSubmitAnswer, passedAnswer } = props; + const [answer, setAnswer] = useState(passedAnswer || ''); - useEffect(() => { - setAnswer(undefined); - }, [question]); const handleOnClickAnswer = (choice: string) => { setAnswer(choice); }; + const alpha = Array.from(Array(26)).map((_e, i) => i + 65); const alphabet = alpha.map((x) => String.fromCharCode(x)); return ( @@ -67,9 +66,9 @@ const MultipleChoiceQuestionDisplay: React.FC = (props) => {