🎨 black
This commit is contained in:
@@ -53,6 +53,7 @@ async def _download_image(url: str) -> bytes:
|
||||
# data = await resp.json()
|
||||
# return data["data"]["id"]
|
||||
|
||||
|
||||
async def import_quiz(quiz_id: str, user: User) -> Quiz | str:
|
||||
"""
|
||||
Imports a quiz from Kahoot.
|
||||
@@ -78,8 +79,21 @@ async def import_quiz(quiz_id: str, user: User) -> Quiz | str:
|
||||
for a in q.choices:
|
||||
answers.append((QuizAnswer(right=a.correct, answer=html.unescape(a.answer))))
|
||||
quiz_questions.append(
|
||||
QuizQuestion(question=q.question, answers=answers, time=str(q.time / 1000), image=image).dict())
|
||||
quiz_data = Quiz(id=quiz_id, public=False, title=quiz.kahoot.title, description=quiz.kahoot.description,
|
||||
created_at=datetime.now(), updated_at=datetime.now(), user_id=user.id,
|
||||
questions=json.dumps(quiz_questions))
|
||||
QuizQuestion(
|
||||
question=q.question,
|
||||
answers=answers,
|
||||
time=str(q.time / 1000),
|
||||
image=image,
|
||||
).dict()
|
||||
)
|
||||
quiz_data = Quiz(
|
||||
id=quiz_id,
|
||||
public=False,
|
||||
title=quiz.kahoot.title,
|
||||
description=quiz.kahoot.description,
|
||||
created_at=datetime.now(),
|
||||
updated_at=datetime.now(),
|
||||
user_id=user.id,
|
||||
questions=json.dumps(quiz_questions),
|
||||
)
|
||||
return await quiz_data.save()
|
||||
|
||||
Reference in New Issue
Block a user