// ShortAnswerQuestion.tsx import React, { useState } from 'react'; import Latex from 'react-latex'; import '../questionStyle.css'; import { Button, TextField } from '@mui/material'; type Choices = { feedback: { format: string; text: string } | null; isCorrect: boolean; text: { format: string; text: string }; weigth?: number; }; interface Props { questionTitle: string; choices: Choices[]; globalFeedback?: string | undefined; handleOnSubmitAnswer?: (answer: string) => void; showAnswer?: boolean; } const ShortAnswerQuestion: React.FC = (props) => { const { questionTitle, choices, showAnswer, handleOnSubmitAnswer, globalFeedback } = props; const [answer, setAnswer] = useState(); return (
{questionTitle}
{showAnswer ? ( <>
{choices.map((choice) => (
{choice.text.text}
))}
{globalFeedback &&
{globalFeedback}
} ) : ( <>
{ setAnswer(e.target.value); }} disabled={showAnswer} inputProps={{ 'data-testid': 'text-input' }} />
{handleOnSubmitAnswer && ( )} )}
); }; export default ShortAnswerQuestion;