✨ Added info if quiz on kahoot is private
This commit is contained in:
@@ -14,17 +14,11 @@ class _Response(BaseModel):
|
||||
kahoot: _Kahoot
|
||||
|
||||
|
||||
async def get(game_id: str) -> _Response | None:
|
||||
async def get(game_id: str) -> _Response | int:
|
||||
async with ClientSession() as session, session.get(
|
||||
f"https://create.kahoot.it/rest/kahoots/{game_id}/card/?includeKahoot=true"
|
||||
) as response:
|
||||
if response.status == 200:
|
||||
return _Response(**await response.json())
|
||||
elif response.status == 404:
|
||||
return None
|
||||
elif response.status == 400:
|
||||
return None
|
||||
elif response.status == 403:
|
||||
return None
|
||||
else:
|
||||
raise Exception(f"Unexpected response status: {response.status}")
|
||||
return response.status
|
||||
|
||||
@@ -47,7 +47,7 @@ async def handle_image_upload(url: str, user: User) -> StorageItem:
|
||||
return file_obj
|
||||
|
||||
|
||||
async def import_quiz(quiz_id: str, user: User) -> Quiz | str:
|
||||
async def import_quiz(quiz_id: str, user: User) -> Quiz | int:
|
||||
"""
|
||||
Imports a quiz from Kahoot.
|
||||
:param user: The user object
|
||||
@@ -56,8 +56,8 @@ async def import_quiz(quiz_id: str, user: User) -> Quiz | str:
|
||||
"""
|
||||
kahoot_quiz_id = quiz_id
|
||||
quiz = await get_quiz(kahoot_quiz_id)
|
||||
if quiz is None:
|
||||
return "quiz not found"
|
||||
if type(quiz) is int:
|
||||
return quiz
|
||||
quiz_questions: list[dict] = []
|
||||
quiz_id = uuid.uuid4()
|
||||
meilisearch.delete_index(settings.meilisearch_index)
|
||||
|
||||
Reference in New Issue
Block a user