from enum import Enum from pydantic import BaseModel, Field from typing import List, Union, Optional from uuid import uuid4, UUID class WriteBlanksSolution(BaseModel): id: str solution: List[str] class WriteBlanksExercise(BaseModel): id: UUID = Field(default_factory=uuid4) type: str = "writeBlanks" maxWords: int solutions: List[WriteBlanksSolution] text: str prompt: str class MatchSentencesOption(BaseModel): id: str sentence: str class MatchSentencesSentence(MatchSentencesOption): solution: str class MatchSentencesVariant(str, Enum): HEADING = "heading" IDEAMATCH = "ideaMatch" class MCOption(BaseModel): id: str text: str class MCQuestion(BaseModel): id: str prompt: str options: List[MCOption] solution: str variant: Optional[str] = None class MultipleChoice(BaseModel): questions: List[MCQuestion] type: str prompt: str class MatchSentencesExercise(BaseModel): options: List[MatchSentencesOption] sentences: List[MatchSentencesSentence] type: str = "matchSentences" variant: MatchSentencesVariant prompt: str class TrueFalseSolution(str, Enum): TRUE = "true" FALSE = "false" NOT_GIVEN = "not_given" class TrueFalseQuestions(BaseModel): prompt: str solution: TrueFalseSolution id: str class TrueFalseExercise(BaseModel): id: UUID = Field(default_factory=uuid4) questions: List[TrueFalseQuestions] type: str = "trueFalse" prompt: str = "Do the following statements agree with the information given in the Reading Passage?" class FillBlanksSolution(BaseModel): id: str solution: str class FillBlanksWord(BaseModel): letter: str word: str class FillBlanksExercise(BaseModel): id: UUID = Field(default_factory=uuid4) solutions: List[FillBlanksSolution] text: str type: str = "fillBlanks" words: List[FillBlanksWord] allowRepetition: bool = False prompt: str Exercise = Union[FillBlanksExercise, TrueFalseExercise, MatchSentencesExercise, WriteBlanksExercise, MultipleChoice] class Context(BaseModel): title: str content: str class Part(BaseModel): exercises: List[Exercise] text: Context class Exam(BaseModel): id: UUID = Field(default_factory=uuid4) module: str = "reading" minTimer: int isDiagnostic: bool = False parts: List[Part]