58 lines
1.3 KiB
Python
58 lines
1.3 KiB
Python
from pydantic import BaseModel, Field
|
|
from typing import List, Dict, Union, Optional
|
|
from uuid import uuid4, UUID
|
|
|
|
|
|
class Option(BaseModel):
|
|
id: str
|
|
text: str
|
|
|
|
|
|
class MultipleChoiceQuestion(BaseModel):
|
|
id: str
|
|
prompt: str
|
|
variant: str = "text"
|
|
solution: str
|
|
options: List[Option]
|
|
|
|
|
|
class MultipleChoiceExercise(BaseModel):
|
|
id: UUID = Field(default_factory=uuid4)
|
|
type: str = "multipleChoice"
|
|
prompt: str = "Select the appropriate option."
|
|
questions: List[MultipleChoiceQuestion]
|
|
userSolutions: List = Field(default_factory=list)
|
|
|
|
|
|
class FillBlanksWord(BaseModel):
|
|
id: str
|
|
options: Dict[str, str]
|
|
|
|
|
|
class FillBlanksSolution(BaseModel):
|
|
id: str
|
|
solution: str
|
|
|
|
|
|
class FillBlanksExercise(BaseModel):
|
|
id: UUID = Field(default_factory=uuid4)
|
|
type: str = "fillBlanks"
|
|
variant: str = "mc"
|
|
prompt: str = "Click a blank to select the appropriate word for it."
|
|
text: str
|
|
solutions: List[FillBlanksSolution]
|
|
words: List[FillBlanksWord]
|
|
userSolutions: List = Field(default_factory=list)
|
|
|
|
|
|
Exercise = Union[MultipleChoiceExercise, FillBlanksExercise]
|
|
|
|
|
|
class Part(BaseModel):
|
|
exercises: List[Exercise]
|
|
context: Optional[str] = Field(default=None)
|
|
|
|
|
|
class Exam(BaseModel):
|
|
parts: List[Part]
|