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