From 3e9152fa5c8149457ebe96ba4d6e5a6b628ba9bc Mon Sep 17 00:00:00 2001 From: JubaAzul <118773284+JubaAzul@users.noreply.github.com> Date: Tue, 21 Jan 2025 15:35:07 -0500 Subject: [PATCH 1/3] =?UTF-8?q?Confusion=20avec=20la=20navigation=20dans?= =?UTF-8?q?=20les=20questions=20=C3=A0=20rythme=20de=20l'enseignant=20Fixe?= =?UTF-8?q?s=20#145?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MultipleChoiceQuestion.tsx | 4 +++ .../StudentModeQuiz/StudentModeQuiz.tsx | 27 +++++++++---------- .../pages/Teacher/ManageRoom/ManageRoom.tsx | 23 ++++++++-------- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/client/src/components/Questions/MultipleChoiceQuestion/MultipleChoiceQuestion.tsx b/client/src/components/Questions/MultipleChoiceQuestion/MultipleChoiceQuestion.tsx index 4957d11..32f451a 100644 --- a/client/src/components/Questions/MultipleChoiceQuestion/MultipleChoiceQuestion.tsx +++ b/client/src/components/Questions/MultipleChoiceQuestion/MultipleChoiceQuestion.tsx @@ -23,6 +23,7 @@ interface Props { } const MultipleChoiceQuestion: React.FC = (props) => { + const { questionStem: questionContent, choices, showAnswer, handleOnSubmitAnswer, globalFeedback } = props; const [answer, setAnswer] = useState(); @@ -73,7 +74,9 @@ const MultipleChoiceQuestion: React.FC = (props) => { {globalFeedback && showAnswer && (
{globalFeedback}
)} + {!showAnswer && handleOnSubmitAnswer && ( + )} diff --git a/client/src/components/StudentModeQuiz/StudentModeQuiz.tsx b/client/src/components/StudentModeQuiz/StudentModeQuiz.tsx index 6b8db94..15d6fba 100644 --- a/client/src/components/StudentModeQuiz/StudentModeQuiz.tsx +++ b/client/src/components/StudentModeQuiz/StudentModeQuiz.tsx @@ -1,13 +1,12 @@ // StudentModeQuiz.tsx import React, { useEffect, useState } from 'react'; import QuestionComponent from '../Questions/Question'; - import '../../pages/Student/JoinRoom/joinRoom.css'; import { QuestionType } from '../../Types/QuestionType'; // import { QuestionService } from '../../services/QuestionService'; import { Button } from '@mui/material'; -import QuestionNavigation from '../QuestionNavigation/QuestionNavigation'; -import { ChevronLeft, ChevronRight } from '@mui/icons-material'; +//import QuestionNavigation from '../QuestionNavigation/QuestionNavigation'; +//import { ChevronLeft, ChevronRight } from '@mui/icons-material'; import DisconnectButton from 'src/components/DisconnectButton/DisconnectButton'; interface StudentModeQuizProps { @@ -25,10 +24,10 @@ const StudentModeQuiz: React.FC = ({ const [isAnswerSubmitted, setIsAnswerSubmitted] = useState(false); // const [imageUrl, setImageUrl] = useState(''); - const previousQuestion = () => { - setQuestion(questions[Number(questionInfos.question?.id) - 2]); - setIsAnswerSubmitted(false); - }; + // const previousQuestion = () => { + // setQuestion(questions[Number(questionInfos.question?.id) - 2]); + // setIsAnswerSubmitted(false); + // }; useEffect(() => {}, [questionInfos]); @@ -55,12 +54,12 @@ const StudentModeQuiz: React.FC = ({
- + /> */}
= ({ />
- + */}
-
-
+ ); }; diff --git a/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx b/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx index 30add4e..7f1d744 100644 --- a/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx +++ b/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx @@ -17,7 +17,7 @@ import LoadingCircle from 'src/components/LoadingCircle/LoadingCircle'; import { Refresh, Error } from '@mui/icons-material'; import StudentWaitPage from 'src/components/StudentWaitPage/StudentWaitPage'; import DisconnectButton from 'src/components/DisconnectButton/DisconnectButton'; -import QuestionNavigation from 'src/components/QuestionNavigation/QuestionNavigation'; +//import QuestionNavigation from 'src/components/QuestionNavigation/QuestionNavigation'; import Question from 'src/components/Questions/Question'; import ApiService from '../../../services/ApiService'; @@ -261,16 +261,16 @@ const ManageRoom: React.FC = () => { webSocketService.nextQuestion(roomName, quizQuestions[nextQuestionIndex]); }; - const previousQuestion = () => { - if (!quizQuestions || !currentQuestion || !quiz?.content) return; + // const previousQuestion = () => { + // if (!quizQuestions || !currentQuestion || !quiz?.content) return; - const prevQuestionIndex = Number(currentQuestion?.question.id) - 2; // -2 because question.id starts at index 1 + // const prevQuestionIndex = Number(currentQuestion?.question.id) - 2; // -2 because question.id starts at index 1 - if (prevQuestionIndex === undefined || prevQuestionIndex < 0) return; + // if (prevQuestionIndex === undefined || prevQuestionIndex < 0) return; - setCurrentQuestion(quizQuestions[prevQuestionIndex]); - webSocketService.nextQuestion(roomName, quizQuestions[prevQuestionIndex]); - }; + // setCurrentQuestion(quizQuestions[prevQuestionIndex]); + // webSocketService.nextQuestion(roomName, quizQuestions[prevQuestionIndex]); + // }; const initializeQuizQuestion = () => { const quizQuestionArray = quiz?.content; @@ -461,12 +461,12 @@ const ManageRoom: React.FC = () => { {quizMode === 'teacher' && (
- + /> */}
)} @@ -494,10 +494,11 @@ const ManageRoom: React.FC = () => { {quizMode === 'teacher' && (
-
+ )} From 22f988f2ad320921fa4f2b106f015a1b8856b18b Mon Sep 17 00:00:00 2001 From: JubaAzul <118773284+JubaAzul@users.noreply.github.com> Date: Wed, 22 Jan 2025 15:28:45 -0500 Subject: [PATCH 2/3] =?UTF-8?q?Confusion=20avec=20la=20navigation=20dans?= =?UTF-8?q?=20les=20questions=20=C3=A0=20rythme=20de=20l'enseignant=20Fixe?= =?UTF-8?q?s=20#145?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MultipleChoiceQuestion.tsx | 2 +- .../pages/Teacher/ManageRoom/ManageRoom.tsx | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/client/src/components/Questions/MultipleChoiceQuestion/MultipleChoiceQuestion.tsx b/client/src/components/Questions/MultipleChoiceQuestion/MultipleChoiceQuestion.tsx index 32f451a..9c18605 100644 --- a/client/src/components/Questions/MultipleChoiceQuestion/MultipleChoiceQuestion.tsx +++ b/client/src/components/Questions/MultipleChoiceQuestion/MultipleChoiceQuestion.tsx @@ -23,7 +23,7 @@ interface Props { } const MultipleChoiceQuestion: React.FC = (props) => { - + const { questionStem: questionContent, choices, showAnswer, handleOnSubmitAnswer, globalFeedback } = props; const [answer, setAnswer] = useState(); diff --git a/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx b/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx index 7f1d744..9bf2000 100644 --- a/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx +++ b/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx @@ -261,16 +261,15 @@ const ManageRoom: React.FC = () => { webSocketService.nextQuestion(roomName, quizQuestions[nextQuestionIndex]); }; - // const previousQuestion = () => { - // if (!quizQuestions || !currentQuestion || !quiz?.content) return; + const previousQuestion = () => { + if (!quizQuestions || !currentQuestion || !quiz?.content) return; - // const prevQuestionIndex = Number(currentQuestion?.question.id) - 2; // -2 because question.id starts at index 1 + const prevQuestionIndex = Number(currentQuestion?.question.id) - 2; // -2 because question.id starts at index 1 - // if (prevQuestionIndex === undefined || prevQuestionIndex < 0) return; - - // setCurrentQuestion(quizQuestions[prevQuestionIndex]); - // webSocketService.nextQuestion(roomName, quizQuestions[prevQuestionIndex]); - // }; + if (prevQuestionIndex === undefined || prevQuestionIndex < 0) return; + setCurrentQuestion(quizQuestions[prevQuestionIndex]); + webSocketService.nextQuestion(roomName, quizQuestions[prevQuestionIndex]); + }; const initializeQuizQuestion = () => { const quizQuestionArray = quiz?.content; @@ -493,13 +492,23 @@ const ManageRoom: React.FC = () => { {quizMode === 'teacher' && ( +
+
+ +
-
- - )} +
)} From 5018625693fd0de1cc24d993774b936396e3318f Mon Sep 17 00:00:00 2001 From: JubaAzul <118773284+JubaAzul@users.noreply.github.com> Date: Wed, 22 Jan 2025 16:06:23 -0500 Subject: [PATCH 3/3] Fix tests --- .../StudentModeQuiz/StudentModeQuiz.test.tsx | 16 ---------------- .../src/pages/Teacher/ManageRoom/ManageRoom.tsx | 2 +- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/client/src/__tests__/pages/Student/StudentModeQuiz/StudentModeQuiz.test.tsx b/client/src/__tests__/pages/Student/StudentModeQuiz/StudentModeQuiz.test.tsx index 379cf5e..85d4a7d 100644 --- a/client/src/__tests__/pages/Student/StudentModeQuiz/StudentModeQuiz.test.tsx +++ b/client/src/__tests__/pages/Student/StudentModeQuiz/StudentModeQuiz.test.tsx @@ -77,21 +77,5 @@ describe('StudentModeQuiz', () => { }); - test('navigates to the previous question', async () => { - - act(() => { - fireEvent.click(screen.getByText('Option A')); - }); - act(() => { - fireEvent.click(screen.getByText('Répondre')); - }); - act(() => { - fireEvent.click(screen.getByText('Question précédente')); - }); - - expect(screen.getByText('Sample Question 1')).toBeInTheDocument(); - expect(screen.getByText('Option B')).toBeInTheDocument(); - }); - }); diff --git a/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx b/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx index 9bf2000..95e8464 100644 --- a/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx +++ b/client/src/pages/Teacher/ManageRoom/ManageRoom.tsx @@ -497,7 +497,7 @@ const ManageRoom: React.FC = () => {