ENCOA-295

This commit is contained in:
Carlos-Mesquita
2024-12-26 12:31:22 +00:00
parent 09d6242360
commit 9bfad2d47f
13 changed files with 170 additions and 38 deletions

View File

@@ -1,5 +1,5 @@
import random
from typing import Optional
from typing import Optional, List
from dependency_injector.wiring import inject, Provide
from fastapi import APIRouter, Path, Query, Depends
@@ -59,7 +59,7 @@ async def get_speaking_task(
topic: Optional[str] = Query(None),
first_topic: Optional[str] = Query(None),
second_topic: Optional[str] = Query(None),
difficulty: str = Query(default=random.choice(EducationalContent.DIFFICULTIES)),
difficulty: Optional[str] = None,
speaking_controller: ISpeakingController = Depends(Provide[controller])
):
if not second_topic:
@@ -67,5 +67,8 @@ async def get_speaking_task(
else:
topic_or_first_topic = first_topic if first_topic else random.choice(EducationalContent.MTI_TOPICS)
if not difficulty:
difficulty = random.choice(random.choice(EducationalContent.DIFFICULTIES))
second_topic = second_topic if second_topic else random.choice(EducationalContent.MTI_TOPICS)
return await speaking_controller.get_speaking_part(task, topic_or_first_topic, second_topic, difficulty)