Réponse à une question non enregistrée lorsque Étudiant reviens en arrière dans le quiz

Fixes #200
This commit is contained in:
JubaAzul 2025-03-07 13:39:56 -05:00
parent 1c2d4134af
commit ec2de888ec
3 changed files with 5 additions and 7 deletions

View file

@ -11,11 +11,7 @@ const mockGiftQuestions = parse(
`::Question:: Sample Question {=Option A ~Option B}`); `::Question:: Sample Question {=Option A ~Option B}`);
describe('TeacherModeQuiz', () => { describe('TeacherModeQuiz', () => {
it ('renders the initial question as MultipleChoiceQuestion', () => {
expect(mockGiftQuestions[0].type).toBe('MC');
});
const mockQuestion = mockGiftQuestions[0] as MultipleChoiceQuestion; const mockQuestion = mockGiftQuestions[0] as MultipleChoiceQuestion;
mockQuestion.id = '1'; mockQuestion.id = '1';

View file

@ -20,7 +20,7 @@ const TeacherModeQuiz: React.FC<TeacherModeQuizProps> = ({
}) => { }) => {
const [isAnswerSubmitted, setIsAnswerSubmitted] = useState(false); const [isAnswerSubmitted, setIsAnswerSubmitted] = useState(false);
const [isFeedbackDialogOpen, setIsFeedbackDialogOpen] = useState(false); const [isFeedbackDialogOpen, setIsFeedbackDialogOpen] = useState(false);
const [answer, setAnswer] = useState<string | number | boolean>(''); const [answer, setAnswer] = useState<string | number | boolean>();
useEffect(() => { useEffect(() => {
@ -28,7 +28,8 @@ const TeacherModeQuiz: React.FC<TeacherModeQuizProps> = ({
handleFeedbackDialogClose(); handleFeedbackDialogClose();
setIsAnswerSubmitted(false); setIsAnswerSubmitted(false);
setAnswer(JSON.parse(localStorage.getItem(`Answer${questionInfos.question.id}`)||'null')); setAnswer(JSON.parse(localStorage.getItem(`Answer${questionInfos.question.id}`)||'null'));
if (typeof answer !== "object") { console.log("LA REP",typeof answer);
if (typeof answer !== "object" && typeof answer !== "undefined") {
setIsAnswerSubmitted(true); setIsAnswerSubmitted(true);
setIsFeedbackDialogOpen(true); setIsFeedbackDialogOpen(true);
} }

View file

@ -2498,6 +2498,7 @@
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
"integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"cross-spawn": "^7.0.1" "cross-spawn": "^7.0.1"
}, },