Added title to the exam generate

This commit is contained in:
Joao Ramos
2024-08-06 19:24:43 +01:00
parent cf64a91651
commit 95c3f89911
7 changed files with 94 additions and 19 deletions

View File

@@ -230,7 +230,11 @@ const TaskTab = ({section, setSection}: {section: LevelSection; setSection: (sec
);
};
const LevelGeneration = () => {
interface Props {
id: string;
}
const LevelGeneration = ({ id } : Props) => {
const [generatedExam, setGeneratedExam] = useState<LevelExam>();
const [isLoading, setIsLoading] = useState(false);
const [resultingExam, setResultingExam] = useState<LevelExam>();
@@ -420,10 +424,16 @@ const LevelGeneration = () => {
return;
}
if(!id) {
toast.error("Please insert a title before submitting");
return;
}
setIsLoading(true);
const exam = {
...generatedExam,
id,
parts: generatedExam.parts.map((p, i) => ({...p, exercises: parts[i].part!.exercises})),
};