Changes to endpoints so they allow to only get context and then the exercises as well as tidying up a bit
This commit is contained in:
0
app/dtos/exams/__init__.py
Normal file
0
app/dtos/exams/__init__.py
Normal file
110
app/dtos/exams/reading.py
Normal file
110
app/dtos/exams/reading.py
Normal file
@@ -0,0 +1,110 @@
|
||||
from enum import Enum
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import List, Union
|
||||
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
|
||||
|
||||
@property
|
||||
def prompt(self) -> str:
|
||||
return f"Choose no more than {self.maxWords} words and/or a number from the passage for each answer."
|
||||
|
||||
|
||||
class MatchSentencesOption(BaseModel):
|
||||
id: str
|
||||
sentence: str
|
||||
|
||||
class MatchSentencesSentence(MatchSentencesOption):
|
||||
solution: str
|
||||
|
||||
class MatchSentencesVariant(str, Enum):
|
||||
HEADING = "heading"
|
||||
IDEAMATCH = "ideaMatch"
|
||||
|
||||
|
||||
class MatchSentencesExercise(BaseModel):
|
||||
options: List[MatchSentencesOption]
|
||||
sentences: List[MatchSentencesSentence]
|
||||
type: str = "matchSentences"
|
||||
variant: MatchSentencesVariant
|
||||
|
||||
@property
|
||||
def prompt(self) -> str:
|
||||
return (
|
||||
"Choose the correct heading for paragraphs from the list of headings below."
|
||||
if self.variant == MatchSentencesVariant.HEADING else
|
||||
"Choose the correct author for the ideas/opinions from the list of authors below."
|
||||
)
|
||||
|
||||
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
|
||||
|
||||
@property
|
||||
def prompt(self) -> str:
|
||||
prompt = "Complete the summary below. Write the letter of the corresponding word(s) for it."
|
||||
|
||||
return (
|
||||
f"{prompt}"
|
||||
if len(self.solutions) == len(self.words) else
|
||||
f"{prompt}\\nThere are more words than spaces so you will not use them all."
|
||||
)
|
||||
|
||||
Exercise = Union[FillBlanksExercise, TrueFalseExercise, MatchSentencesExercise, WriteBlanksExercise]
|
||||
|
||||
|
||||
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]
|
||||
19
app/dtos/level.py
Normal file
19
app/dtos/level.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.configs.constants import LevelExerciseType
|
||||
|
||||
|
||||
class LevelExercises(BaseModel):
|
||||
type: LevelExerciseType
|
||||
quantity: int
|
||||
text_size: Optional[int]
|
||||
sa_qty: Optional[int]
|
||||
mc_qty: Optional[int]
|
||||
topic: Optional[str]
|
||||
|
||||
class LevelExercisesDTO(BaseModel):
|
||||
text: str
|
||||
exercises: List[LevelExercises]
|
||||
difficulty: Optional[str]
|
||||
@@ -1,10 +1,10 @@
|
||||
import random
|
||||
import uuid
|
||||
from typing import List, Dict
|
||||
from typing import List, Dict, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.configs.constants import MinTimers, EducationalContent
|
||||
from app.configs.constants import MinTimers, EducationalContent, ListeningExerciseType
|
||||
|
||||
|
||||
class SaveListeningDTO(BaseModel):
|
||||
@@ -12,3 +12,13 @@ class SaveListeningDTO(BaseModel):
|
||||
minTimer: int = MinTimers.LISTENING_MIN_TIMER_DEFAULT
|
||||
difficulty: str = random.choice(EducationalContent.DIFFICULTIES)
|
||||
id: str = str(uuid.uuid4())
|
||||
|
||||
|
||||
class ListeningExercises(BaseModel):
|
||||
type: ListeningExerciseType
|
||||
quantity: int
|
||||
|
||||
class GenerateListeningExercises(BaseModel):
|
||||
text: str
|
||||
exercises: List[ListeningExercises]
|
||||
difficulty: Optional[str]
|
||||
|
||||
17
app/dtos/reading.py
Normal file
17
app/dtos/reading.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import random
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.configs.constants import ReadingExerciseType, EducationalContent
|
||||
|
||||
class ReadingExercise(BaseModel):
|
||||
type: ReadingExerciseType
|
||||
quantity: int
|
||||
num_random_words: Optional[int] = Field(1)
|
||||
max_words: Optional[int] = Field(3)
|
||||
|
||||
class ReadingDTO(BaseModel):
|
||||
text: str = Field(...)
|
||||
exercises: List[ReadingExercise] = Field(...)
|
||||
difficulty: str = Field(random.choice(EducationalContent.DIFFICULTIES))
|
||||
@@ -3,7 +3,7 @@ from typing import List, Dict
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.configs.constants import MinTimers, AvatarEnum
|
||||
from app.configs.constants import MinTimers, ELAIAvatars
|
||||
|
||||
|
||||
class SaveSpeakingDTO(BaseModel):
|
||||
@@ -21,14 +21,14 @@ class GradeSpeakingAnswersDTO(BaseModel):
|
||||
|
||||
|
||||
class GenerateVideo1DTO(BaseModel):
|
||||
avatar: str = (random.choice(list(AvatarEnum))).value
|
||||
avatar: str = (random.choice(list(ELAIAvatars))).name
|
||||
questions: List[str]
|
||||
first_topic: str
|
||||
second_topic: str
|
||||
|
||||
|
||||
class GenerateVideo2DTO(BaseModel):
|
||||
avatar: str = (random.choice(list(AvatarEnum))).value
|
||||
avatar: str = (random.choice(list(ELAIAvatars))).name
|
||||
prompts: List[str] = []
|
||||
suffix: str = ""
|
||||
question: str
|
||||
@@ -36,7 +36,7 @@ class GenerateVideo2DTO(BaseModel):
|
||||
|
||||
|
||||
class GenerateVideo3DTO(BaseModel):
|
||||
avatar: str = (random.choice(list(AvatarEnum))).value
|
||||
avatar: str = (random.choice(list(ELAIAvatars))).name
|
||||
questions: List[str]
|
||||
topic: str
|
||||
|
||||
|
||||
Reference in New Issue
Block a user