feat: add substract with image reference
This commit is contained in:
@@ -5,6 +5,9 @@ from app.problems.grade_1.join_corresponding_sums import join_corresponding_sums
|
||||
from app.problems.grade_1.join_pictures_with_quantity import (
|
||||
join_pictures_with_quantity,
|
||||
)
|
||||
from app.problems.grade_1.subtract_with_image_reference import (
|
||||
subtract_with_image_reference,
|
||||
)
|
||||
from app.problems.grade_1.sum_with_image_reference import sum_with_image_reference
|
||||
from app.problems.grade_1.where_are_more_items import where_are_more_items
|
||||
|
||||
@@ -12,6 +15,7 @@ __all__ = [
|
||||
"compose_and_decompose_numbers",
|
||||
"join_corresponding_sums",
|
||||
"join_pictures_with_quantity",
|
||||
"subtract_with_image_reference",
|
||||
"sum_with_image_reference",
|
||||
"where_are_more_items",
|
||||
]
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 328 KiB |
49
app/problems/grade_1/subtract_with_image_reference.py
Normal file
49
app/problems/grade_1/subtract_with_image_reference.py
Normal file
@@ -0,0 +1,49 @@
|
||||
from app.schemas.grade_1.subtract_with_image_reference import (
|
||||
FigureGroup,
|
||||
PictureAsset,
|
||||
SubtractWithImageReferenceProblem,
|
||||
SubtractionEquation,
|
||||
)
|
||||
|
||||
|
||||
def subtract_with_image_reference(
|
||||
object_name: str,
|
||||
initial_quantity: int,
|
||||
removed_quantity: int,
|
||||
figure: dict,
|
||||
actor_name: str = "Diego",
|
||||
) -> dict:
|
||||
"""Generate a subtraction story problem with remaining and removed groups."""
|
||||
if removed_quantity > initial_quantity:
|
||||
raise ValueError("removed_quantity must be less than or equal to initial_quantity")
|
||||
|
||||
selected_figure = PictureAsset.model_validate(figure)
|
||||
remaining_quantity = initial_quantity - removed_quantity
|
||||
question = (
|
||||
f"Hay {initial_quantity} {object_name}. "
|
||||
f"{actor_name} sacó {removed_quantity} {object_name}. "
|
||||
f"¿Cuántos {object_name} quedan?"
|
||||
)
|
||||
problem = SubtractWithImageReferenceProblem(
|
||||
question=question,
|
||||
object_name=object_name,
|
||||
actor_name=actor_name,
|
||||
figure=selected_figure,
|
||||
remaining_group=FigureGroup(
|
||||
label="quedan",
|
||||
quantity=remaining_quantity,
|
||||
picture=selected_figure,
|
||||
),
|
||||
subtracted_group=FigureGroup(
|
||||
label="sacó",
|
||||
quantity=removed_quantity,
|
||||
picture=selected_figure,
|
||||
),
|
||||
equation=SubtractionEquation(
|
||||
initial_quantity=initial_quantity,
|
||||
removed_quantity=removed_quantity,
|
||||
remaining_quantity=remaining_quantity,
|
||||
),
|
||||
)
|
||||
|
||||
return problem.model_dump()
|
||||
Reference in New Issue
Block a user