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

View file

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

View file

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