import React, { useState, useEffect } from 'react'; import { useParams } from 'react-router-dom'; import { useExercise } from '../hooks/useExercises'; import { Container, Row, Col, ListGroup, Button, Modal, Alert, OverlayTrigger, Popover } from 'react-bootstrap'; import MultipleChoiceQuestion from './components/MultipleChoiceQuestion'; import TrueFalseQuestion from './components/TrueFalseQuestion'; import MatchingPairsQuestion from './components/MatchingPairsQuestion'; import Skeleton from 'react-loading-skeleton'; import ilustration from '../../../../assets/images/illustration/submitExercise.png'; const Exercise = () => { const [showModal, setShowModal] = useState(false); const [showAlert, setShowAlert] = useState(false); const { topic, level } = useParams(); const { questions, currentQuestion, currentQuestionIndex, setCurrentQuestionIndex, answers, isLoading, error, handleAnswer, nextQuestion, prevQuestion, handleSubmit, handleConfirmSubmit } = useExercise(topic, level); const handleSubmitWrapper = () => { if (handleSubmit()) { setShowModal(true); } else { setShowAlert(true); } }; const handleCloseModal = () => setShowModal(false); const renderQuestion = () => { switch (currentQuestion.QUESTION_TYPE) { case 'MCQ': return ( ); case 'TFQ': return ( ); case 'MPQ': return ( ); default: return

Unknown question type.

; } }; const popover = ( Tips
  • Click the left arrow key to go to the previous question
  • Click the right arrow key to go to the next question
); if (isLoading) { return (
); } if (error) return

Error loading questions.

; return (

Pretest

{questions.map((q, index) => ( setCurrentQuestionIndex(index)} className={`border-0 rounded-3 number-label ${answers[index] !== null ? 'answered fw-bold' : ''}`} style={{ cursor: 'pointer' }} > {index+1} ))}
{`Questions ${currentQuestionIndex + 1} of ${questions.length}`}
{renderQuestion()}
setShowAlert(false)} dismissible> ATTENTION! Please answer all questions before submitting. {/* Confirmation

Are you sure you want to submit your answer?

*/}

Proceed with Submission?

Confirm submission? There's no going back.

); }; export default Exercise;