mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Confusion avec la navigation dans les questions à rythme de l'enseignant
Fixes #145
This commit is contained in:
parent
3e9152fa5c
commit
22f988f2ad
2 changed files with 21 additions and 12 deletions
|
|
@ -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 = () => {
|
|||
</div>
|
||||
|
||||
{quizMode === 'teacher' && (
|
||||
<div className="questionNavigationButtons" style={{ display: 'flex', justifyContent: 'center' }}>
|
||||
<div className="previousQuestionButton">
|
||||
<Button onClick={previousQuestion}
|
||||
variant="contained"
|
||||
disabled={Number(currentQuestion?.question.id) <= 1}>
|
||||
Question précedente
|
||||
</Button>
|
||||
</div>
|
||||
<div className="nextQuestionButton">
|
||||
<Button onClick={nextQuestion} variant="contained" >
|
||||
<Button onClick={nextQuestion}
|
||||
variant="contained"
|
||||
disabled={Number(currentQuestion?.question.id) >=quizQuestions.length}
|
||||
>
|
||||
Prochaine question
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
)}
|
||||
</div> )}
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue