Amélioration de beaucoup de features

This commit is contained in:
JubaAzul 2025-03-07 12:20:39 -05:00
parent f8dd95f651
commit 6a340556e2
3 changed files with 6 additions and 8 deletions

View file

@ -4,13 +4,11 @@ import { render, fireEvent, act } from '@testing-library/react';
import { screen } from '@testing-library/dom';
import '@testing-library/jest-dom';
import { MultipleChoiceQuestion, parse } from 'gift-pegjs';
import TeacherModeQuiz from 'src/components/TeacherModeQuiz/TeacherModeQuiz';
import { MemoryRouter } from 'react-router-dom';
// import { mock } from 'node:test';
const mockGiftQuestions = parse(
`::Sample Question:: Sample Question {=Option A ~Option B}`);
`::Question:: Sample Question {=Option A ~Option B}`);
describe('TeacherModeQuiz', () => {
@ -36,6 +34,7 @@ describe('TeacherModeQuiz', () => {
});
test('renders the initial question', () => {
expect(screen.getByText('Question 1')).toBeInTheDocument();
expect(screen.getByText('Sample Question')).toBeInTheDocument();
expect(screen.getByText('Option A')).toBeInTheDocument();
@ -53,7 +52,6 @@ describe('TeacherModeQuiz', () => {
fireEvent.click(screen.getByText('Répondre'));
});
expect(mockSubmitAnswer).toHaveBeenCalledWith('Option A', 1);
expect(screen.getByText('Votre réponse est:')).toBeInTheDocument();
});
test('handles disconnect button click', () => {

View file

@ -33,8 +33,8 @@ const MultipleChoiceQuestionDisplay: React.FC<Props> = (props) => {
};
const alpha = Array.from(Array(26)).map((_e, i) => i + 65);
const alphabet = alpha.map((x) => String.fromCharCode(x));
return (
<div className="question-container">
<div className="question content">
<div dangerouslySetInnerHTML={{ __html: FormattedTextTemplate(question.formattedStem) }} />
@ -43,7 +43,6 @@ const MultipleChoiceQuestionDisplay: React.FC<Props> = (props) => {
{question.choices.map((choice, i) => {
const selected = answer === choice.formattedText.text ? 'selected' : '';
console.log("dsa", selected)
return (
<div key={choice.formattedText.text + i} className="choice-container">
<Button
@ -81,7 +80,7 @@ const MultipleChoiceQuestionDisplay: React.FC<Props> = (props) => {
onClick={() =>
answer !== "" && handleOnSubmitAnswer && handleOnSubmitAnswer(answer)
}
disabled={answer === ''}
disabled={answer === '' || answer === null}
>
Répondre

View file

@ -22,6 +22,7 @@ const TeacherModeQuiz: React.FC<TeacherModeQuizProps> = ({
const [isFeedbackDialogOpen, setIsFeedbackDialogOpen] = useState(false);
const [answer, setAnswer] = useState<string | number | boolean>('');
console.log("Answer" , answer);
useEffect(() => {