From 9925b7f039c904348921dfb439221f4e2f0a3fc7 Mon Sep 17 00:00:00 2001 From: "C. Fuhrman" Date: Tue, 24 Sep 2024 19:56:47 -0400 Subject: [PATCH] =?UTF-8?q?Apr=C3=A8s=20r=C3=A9ponse=20par=20=C3=A9tudiant?= =?UTF-8?q?=20dans=20mode=20rythme=20de=20l'enseignant,=20=C3=A7a=20passe?= =?UTF-8?q?=20=C3=A0=20la=20question=20suivante=20(sans=20afficher=20r?= =?UTF-8?q?=C3=A9troaction)=20Fixes=20#86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TeacherModeQuiz/TeacherModeQuiz.test.tsx | 4 +- .../StudentModeQuiz/StudentModeQuiz.tsx | 1 - .../TeacherModeQuiz/TeacherModeQuiz.tsx | 49 ++++++++++++++----- .../pages/Teacher/ManageRoom/ManageRoom.tsx | 3 +- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/client/src/__tests__/pages/Student/TeacherModeQuiz/TeacherModeQuiz.test.tsx b/client/src/__tests__/pages/Student/TeacherModeQuiz/TeacherModeQuiz.test.tsx index a5cb1b9..8bc4b0f 100644 --- a/client/src/__tests__/pages/Student/TeacherModeQuiz/TeacherModeQuiz.test.tsx +++ b/client/src/__tests__/pages/Student/TeacherModeQuiz/TeacherModeQuiz.test.tsx @@ -39,7 +39,7 @@ describe('TeacherModeQuiz', () => { expect(screen.getByText('Répondre')).toBeInTheDocument(); }); - test('handles answer submission and displays wait text', () => { + test('handles answer submission and displays feedback', () => { act(() => { fireEvent.click(screen.getByText('Option A')); @@ -48,7 +48,7 @@ describe('TeacherModeQuiz', () => { fireEvent.click(screen.getByText('Répondre')); }); expect(mockSubmitAnswer).toHaveBeenCalledWith('Option A', '1'); - expect(screen.getByText('En attente pour la prochaine question...')).toBeInTheDocument(); + expect(screen.getByText('Votre réponse est "Option A".')).toBeInTheDocument(); }); test('handles disconnect button click', () => { diff --git a/client/src/components/StudentModeQuiz/StudentModeQuiz.tsx b/client/src/components/StudentModeQuiz/StudentModeQuiz.tsx index 0bbd065..1d4dbfe 100644 --- a/client/src/components/StudentModeQuiz/StudentModeQuiz.tsx +++ b/client/src/components/StudentModeQuiz/StudentModeQuiz.tsx @@ -66,7 +66,6 @@ const StudentModeQuiz: React.FC = ({ handleOnSubmitAnswer={handleOnSubmitAnswer} question={questionInfos.question} showAnswer={isAnswerSubmitted} - // imageUrl={imageUrl} />
diff --git a/client/src/components/TeacherModeQuiz/TeacherModeQuiz.tsx b/client/src/components/TeacherModeQuiz/TeacherModeQuiz.tsx index 948fee9..4c15cef 100644 --- a/client/src/components/TeacherModeQuiz/TeacherModeQuiz.tsx +++ b/client/src/components/TeacherModeQuiz/TeacherModeQuiz.tsx @@ -7,6 +7,7 @@ import '../../pages/Student/JoinRoom/joinRoom.css'; import { QuestionType } from '../../Types/QuestionType'; // import { QuestionService } from '../../services/QuestionService'; import DisconnectButton from '../../components/DisconnectButton/DisconnectButton'; +import { Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material'; interface TeacherModeQuizProps { questionInfos: QuestionType; @@ -20,7 +21,8 @@ const TeacherModeQuiz: React.FC = ({ disconnectWebSocket }) => { const [isAnswerSubmitted, setIsAnswerSubmitted] = useState(false); - // const [imageUrl, setImageUrl] = useState(''); + const [isFeedbackDialogOpen, setIsFeedbackDialogOpen] = useState(false); + const [feedbackMessage, setFeedbackMessage] = useState(''); useEffect(() => { setIsAnswerSubmitted(false); @@ -29,6 +31,12 @@ const TeacherModeQuiz: React.FC = ({ const handleOnSubmitAnswer = (answer: string | number | boolean) => { const idQuestion = questionInfos.question.id || '-1'; submitAnswer(answer, idQuestion); + setFeedbackMessage(`Votre réponse est "${answer.toString()}".`); + setIsFeedbackDialogOpen(true); + }; + + const handleFeedbackDialogClose = () => { + setIsFeedbackDialogOpen(false); setIsAnswerSubmitted(true); }; @@ -49,17 +57,36 @@ const TeacherModeQuiz: React.FC = ({
{isAnswerSubmitted ? ( -
- En attente pour la prochaine question... -
- ) : ( - + En attente pour la prochaine question... +
+ ) : ( + + )} + + + Rétroaction + + {feedbackMessage} + - )} - + + + + + + ); }; diff --git a/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx b/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx index e8d8bfc..68ef7bd 100644 --- a/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx +++ b/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx @@ -189,7 +189,8 @@ const ManageRoom: React.FC = () => { }; const launchQuiz = () => { - if (!socket || !roomName || quiz?.content.length === 0) { + if (!socket || !roomName || !quiz?.content || quiz?.content.length === 0) { + // TODO: This error happens when token expires! Need to handle it properly console.log('Error launching quiz. No socket, room name or no questions.'); return; }