ENCOA-255 gpt was grouping parts by sections and the reading passages were not updated with text.content instead of the old context field

This commit is contained in:
Carlos-Mesquita
2024-12-03 11:57:42 +00:00
parent 1603fa4ee6
commit 4e05c4d913
4 changed files with 37 additions and 37 deletions

View File

@@ -5,7 +5,7 @@ from pydantic import ValidationError
from app.dtos.exams.level import (
MultipleChoiceExercise,
FillBlanksExercise,
Part, Exam
Part, Exam, Text
)
from app.dtos.sheet import Sheet, Option, MultipleChoiceQuestion, FillBlanksWord
@@ -17,7 +17,7 @@ class LevelMapper:
parts = []
for part in response['parts']:
part_exercises = part['exercises']
context = part.get('context', None)
text = part.get('text', None)
exercises = []
for exercise in part_exercises:
@@ -32,8 +32,13 @@ class LevelMapper:
exercises.append(exercise_model)
part_kwargs = {"exercises": exercises}
if context is not None:
part_kwargs["context"] = context
if text is not None and text.get('content', None):
title = text.get('title', 'Untitled')
if title == '':
title = 'Untitled'
part_kwargs["text"] = Text(title=title, content=text['content'])
else:
part_kwargs["text"] = None
part_model = Part(**part_kwargs)
parts.append(part_model)