import React from 'react'; import { Question } from 'gift-pegjs'; import TrueFalseQuestionDisplay from './TrueFalseQuestionDisplay/TrueFalseQuestionDisplay'; import MultipleChoiceQuestionDisplay from './MultipleChoiceQuestionDisplay/MultipleChoiceQuestionDisplay'; import NumericalQuestionDisplay from './NumericalQuestionDisplay/NumericalQuestionDisplay'; import ShortAnswerQuestionDisplay from './ShortAnswerQuestionDisplay/ShortAnswerQuestionDisplay'; // import useCheckMobileScreen from '../../services/useCheckMobileScreen'; interface QuestionProps { question: Question; handleOnSubmitAnswer?: (answer: string | number | boolean) => void; showAnswer?: boolean; } const QuestionDisplay: React.FC = ({ question, handleOnSubmitAnswer, showAnswer, }) => { // const isMobile = useCheckMobileScreen(); // const imgWidth = useMemo(() => { // return isMobile ? '100%' : '20%'; // }, [isMobile]); let questionTypeComponent = null; switch (question?.type) { case 'TF': questionTypeComponent = ( ); break; case 'MC': questionTypeComponent = ( ); break; case 'Numerical': if (question.choices) { if (!Array.isArray(question.choices)) { questionTypeComponent = ( ); } else { questionTypeComponent = ( // TODO fix NumericalQuestion (correctAnswers is borked) ); } } break; case 'Short': questionTypeComponent = ( ); break; } return (
{questionTypeComponent ? ( <> {questionTypeComponent} ) : (
Question de type inconnue
)}
); }; export default QuestionDisplay;