refactor: implement core and server dir to split the library and endpoints for testing
This commit is contained in:
0
math_problems_structure/core/schemas/__init__.py
Normal file
0
math_problems_structure/core/schemas/__init__.py
Normal file
39
math_problems_structure/core/schemas/grade_1/__init__.py
Normal file
39
math_problems_structure/core/schemas/grade_1/__init__.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from math_problems_structure.core.schemas.grade_1.compose_and_decompose_numbers import (
|
||||
ComposeAndDecomposeNumbersProblem,
|
||||
ComposeAndDecomposeNumbersRequest,
|
||||
)
|
||||
from math_problems_structure.core.schemas.grade_1.join_corresponding_sums import (
|
||||
JoinCorrespondingSumsProblem,
|
||||
JoinCorrespondingSumsRequest,
|
||||
)
|
||||
from math_problems_structure.core.schemas.grade_1.join_pictures_with_quantity import (
|
||||
JoinPicturesWithQuantityProblem,
|
||||
JoinPicturesWithQuantityRequest,
|
||||
)
|
||||
from math_problems_structure.core.schemas.grade_1.subtract_with_image_reference import (
|
||||
SubtractWithImageReferenceProblem,
|
||||
SubtractWithImageReferenceRequest,
|
||||
)
|
||||
from math_problems_structure.core.schemas.grade_1.sum_with_image_reference import (
|
||||
SumWithImageReferenceProblem,
|
||||
SumWithImageReferenceRequest,
|
||||
)
|
||||
from math_problems_structure.core.schemas.grade_1.where_are_more_items import (
|
||||
WhereAreMoreItemsProblem,
|
||||
WhereAreMoreItemsRequest,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"ComposeAndDecomposeNumbersProblem",
|
||||
"ComposeAndDecomposeNumbersRequest",
|
||||
"JoinCorrespondingSumsProblem",
|
||||
"JoinCorrespondingSumsRequest",
|
||||
"JoinPicturesWithQuantityProblem",
|
||||
"JoinPicturesWithQuantityRequest",
|
||||
"SubtractWithImageReferenceProblem",
|
||||
"SubtractWithImageReferenceRequest",
|
||||
"SumWithImageReferenceProblem",
|
||||
"SumWithImageReferenceRequest",
|
||||
"WhereAreMoreItemsProblem",
|
||||
"WhereAreMoreItemsRequest",
|
||||
]
|
||||
@@ -0,0 +1,30 @@
|
||||
from pydantic import BaseModel, Field, PositiveInt
|
||||
|
||||
|
||||
class PictureAsset(BaseModel):
|
||||
id: str = Field(min_length=1)
|
||||
name: str = Field(min_length=1)
|
||||
image_path: str = Field(min_length=1)
|
||||
|
||||
|
||||
class DecompositionRow(BaseModel):
|
||||
position: PositiveInt
|
||||
whole: PositiveInt
|
||||
first_part: PositiveInt
|
||||
second_part: PositiveInt
|
||||
picture: PictureAsset
|
||||
has_answer_boxes: bool = True
|
||||
|
||||
|
||||
class ComposeAndDecomposeNumbersProblem(BaseModel):
|
||||
instructions: str = "Compón y descompón el número."
|
||||
whole: PositiveInt
|
||||
picture: PictureAsset
|
||||
rows: list[DecompositionRow]
|
||||
|
||||
|
||||
class ComposeAndDecomposeNumbersRequest(BaseModel):
|
||||
picture: PictureAsset
|
||||
whole: PositiveInt = 10
|
||||
randomize_rows: bool = False
|
||||
seed: int | None = None
|
||||
@@ -0,0 +1,32 @@
|
||||
from pydantic import BaseModel, Field, PositiveInt
|
||||
|
||||
|
||||
class AdditionExpression(BaseModel):
|
||||
position: PositiveInt
|
||||
first_addend: PositiveInt
|
||||
second_addend: PositiveInt
|
||||
total: PositiveInt
|
||||
match_id: str = Field(min_length=1)
|
||||
|
||||
|
||||
class SumConnection(BaseModel):
|
||||
match_id: str = Field(min_length=1)
|
||||
total: PositiveInt
|
||||
left_position: PositiveInt
|
||||
right_position: PositiveInt
|
||||
|
||||
|
||||
class JoinCorrespondingSumsProblem(BaseModel):
|
||||
instructions: str = "Conecta."
|
||||
left_expressions: list[AdditionExpression]
|
||||
right_expressions: list[AdditionExpression]
|
||||
answer_key: list[SumConnection]
|
||||
|
||||
|
||||
class JoinCorrespondingSumsRequest(BaseModel):
|
||||
pair_count: PositiveInt = 3
|
||||
min_sum: PositiveInt = 2
|
||||
max_sum: PositiveInt = 10
|
||||
min_addend: PositiveInt = 1
|
||||
max_addend: PositiveInt = 9
|
||||
seed: int | None = None
|
||||
@@ -0,0 +1,35 @@
|
||||
from pydantic import BaseModel, Field, PositiveInt
|
||||
|
||||
|
||||
class PictureAsset(BaseModel):
|
||||
id: str = Field(min_length=1)
|
||||
name: str = Field(min_length=1)
|
||||
image_path: str = Field(min_length=1)
|
||||
|
||||
|
||||
class PictureContainer(BaseModel):
|
||||
position: PositiveInt
|
||||
quantity: PositiveInt
|
||||
picture: PictureAsset
|
||||
|
||||
|
||||
class NumberCard(BaseModel):
|
||||
position: PositiveInt
|
||||
value: PositiveInt
|
||||
shows_blocks: bool = True
|
||||
has_answer_box: bool = True
|
||||
|
||||
|
||||
class JoinPicturesWithQuantityProblem(BaseModel):
|
||||
instructions: str = "Cuenta las imágenes y une cada grupo con el número correcto."
|
||||
left_containers: list[PictureContainer]
|
||||
number_cards: list[NumberCard]
|
||||
right_containers: list[PictureContainer]
|
||||
|
||||
|
||||
class JoinPicturesWithQuantityRequest(BaseModel):
|
||||
available_pictures: list[PictureAsset] = Field(min_length=1)
|
||||
container_count_per_side: PositiveInt = 5
|
||||
min_quantity: PositiveInt = 1
|
||||
max_quantity: PositiveInt = 10
|
||||
seed: int | None = None
|
||||
@@ -0,0 +1,40 @@
|
||||
from pydantic import BaseModel, Field, NonNegativeInt, PositiveInt
|
||||
|
||||
|
||||
class PictureAsset(BaseModel):
|
||||
id: str = Field(min_length=1)
|
||||
name: str = Field(min_length=1)
|
||||
image_path: str = Field(min_length=1)
|
||||
|
||||
|
||||
class SubtractionEquation(BaseModel):
|
||||
initial_quantity: PositiveInt
|
||||
removed_quantity: PositiveInt
|
||||
remaining_quantity: NonNegativeInt
|
||||
symbol: str = "-"
|
||||
equals_symbol: str = "="
|
||||
|
||||
|
||||
class FigureGroup(BaseModel):
|
||||
label: str = Field(min_length=1)
|
||||
quantity: NonNegativeInt
|
||||
picture: PictureAsset
|
||||
|
||||
|
||||
class SubtractWithImageReferenceProblem(BaseModel):
|
||||
title: str = "¿Cuántos quedan?"
|
||||
question: str
|
||||
object_name: str = Field(min_length=1)
|
||||
actor_name: str = Field(min_length=1)
|
||||
figure: PictureAsset
|
||||
remaining_group: FigureGroup
|
||||
subtracted_group: FigureGroup
|
||||
equation: SubtractionEquation
|
||||
|
||||
|
||||
class SubtractWithImageReferenceRequest(BaseModel):
|
||||
object_name: str = Field(min_length=1)
|
||||
initial_quantity: PositiveInt
|
||||
removed_quantity: PositiveInt
|
||||
figure: PictureAsset
|
||||
actor_name: str = Field(default="Diego", min_length=1)
|
||||
@@ -0,0 +1,51 @@
|
||||
from pydantic import BaseModel, Field, PositiveInt
|
||||
|
||||
|
||||
class PictureAsset(BaseModel):
|
||||
id: str = Field(min_length=1)
|
||||
name: str = Field(min_length=1)
|
||||
image_path: str = Field(min_length=1)
|
||||
|
||||
|
||||
class AddendGroup(BaseModel):
|
||||
quantity: PositiveInt
|
||||
description: str = Field(min_length=1)
|
||||
|
||||
|
||||
class FigureGroup(BaseModel):
|
||||
quantity: PositiveInt
|
||||
description: str = Field(min_length=1)
|
||||
picture: PictureAsset
|
||||
|
||||
|
||||
class ImageOption(BaseModel):
|
||||
position: PositiveInt
|
||||
quantity: PositiveInt
|
||||
first_group: FigureGroup
|
||||
second_group: FigureGroup
|
||||
is_correct: bool
|
||||
has_answer_box: bool = True
|
||||
|
||||
|
||||
class SumWithImageReferenceProblem(BaseModel):
|
||||
question: str
|
||||
instructions: str = "Escoge la imagen en la próxima página."
|
||||
first_group: AddendGroup
|
||||
second_group: AddendGroup
|
||||
common_object: str = Field(min_length=1)
|
||||
total: PositiveInt
|
||||
options: list[ImageOption]
|
||||
|
||||
|
||||
class SumWithImageReferenceRequest(BaseModel):
|
||||
first_quantity: PositiveInt
|
||||
second_quantity: PositiveInt
|
||||
first_description: str = Field(min_length=1)
|
||||
second_description: str = Field(min_length=1)
|
||||
common_object: str = Field(min_length=1)
|
||||
first_picture: PictureAsset
|
||||
second_picture: PictureAsset
|
||||
option_count: PositiveInt = 3
|
||||
min_option_quantity: PositiveInt = 1
|
||||
max_option_quantity: PositiveInt = 20
|
||||
seed: int | None = None
|
||||
@@ -0,0 +1,36 @@
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, Field, PositiveInt
|
||||
|
||||
|
||||
class PictureAsset(BaseModel):
|
||||
id: str = Field(min_length=1)
|
||||
name: str = Field(min_length=1)
|
||||
image_path: str = Field(min_length=1)
|
||||
|
||||
|
||||
class ItemGroup(BaseModel):
|
||||
side: Literal["left", "right"]
|
||||
picture: PictureAsset
|
||||
quantity: PositiveInt
|
||||
|
||||
|
||||
class MoreItemsComparison(BaseModel):
|
||||
position: PositiveInt
|
||||
left_group: ItemGroup
|
||||
right_group: ItemGroup
|
||||
answer_side: Literal["left", "right"]
|
||||
has_answer_box: bool = True
|
||||
|
||||
|
||||
class WhereAreMoreItemsProblem(BaseModel):
|
||||
instructions: str = "Marca dónde hay más."
|
||||
comparisons: list[MoreItemsComparison]
|
||||
|
||||
|
||||
class WhereAreMoreItemsRequest(BaseModel):
|
||||
available_pictures: list[PictureAsset] = Field(min_length=1)
|
||||
comparison_count: PositiveInt = 3
|
||||
min_quantity: PositiveInt = 1
|
||||
max_quantity: PositiveInt = 10
|
||||
seed: int | None = None
|
||||
Reference in New Issue
Block a user