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

@ -12,10 +12,6 @@ const mockGiftQuestions = parse(
describe('TeacherModeQuiz', () => {
it ('renders the initial question as MultipleChoiceQuestion', () => {
expect(mockGiftQuestions[0].type).toBe('MC');
});
const mockQuestion = mockGiftQuestions[0] as MultipleChoiceQuestion;
mockQuestion.id = '1';

View file

@ -20,7 +20,7 @@ const TeacherModeQuiz: React.FC<TeacherModeQuizProps> = ({
}) => {
const [isAnswerSubmitted, setIsAnswerSubmitted] = useState(false);
const [isFeedbackDialogOpen, setIsFeedbackDialogOpen] = useState(false);
const [answer, setAnswer] = useState<string | number | boolean>('');
const [answer, setAnswer] = useState<string | number | boolean>();
useEffect(() => {
@ -28,7 +28,8 @@ const TeacherModeQuiz: React.FC<TeacherModeQuizProps> = ({
handleFeedbackDialogClose();
setIsAnswerSubmitted(false);
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);
setIsFeedbackDialogOpen(true);
}

View file

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