Further cleanup
This commit is contained in:
@@ -15,8 +15,8 @@ This library is also tested.
|
||||
```python
|
||||
from classquiz.kahoot_importer.get import get, _Response
|
||||
from asyncio import run
|
||||
# _Response ia a pydantic-object, so you have access to
|
||||
# .dict() or .json(exclude={"kahoot"})
|
||||
# _Response is a pydantic-object, so you have access to
|
||||
# .dict() or .model_dump_json(exclude={"kahoot"})
|
||||
|
||||
async def main():
|
||||
kahoot_quiz: _Response = await get("GAME_ID")
|
||||
@@ -31,7 +31,7 @@ run(main())
|
||||
from classquiz.kahoot_importer.search import search, _Response
|
||||
from asyncio import run
|
||||
# _Response ia a pydantic-object, so you have access to
|
||||
# .dict() or .json(exclude={"kahoot"})
|
||||
# .dict() or .model_dump_json(exclude={"kahoot"})
|
||||
|
||||
async def main():
|
||||
kahoot_quizzes: _Response = await search("QUERY")
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
|
||||
from typing import List, Any, Optional
|
||||
from typing import Any
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel
|
||||
@@ -33,10 +33,10 @@ class _LastEdit(BaseModel):
|
||||
|
||||
class _ImageMetadata(BaseModel):
|
||||
id: UUID | None = None
|
||||
content_type: Optional[str] = None
|
||||
width: Optional[int] = None
|
||||
height: Optional[int] = None
|
||||
resources: Optional[str] = None
|
||||
content_type: str | None = None
|
||||
width: int | None = None
|
||||
height: int | None = None
|
||||
resources: str | None = None
|
||||
|
||||
|
||||
class _SampleQuestion(BaseModel):
|
||||
@@ -48,11 +48,11 @@ class _SampleQuestion(BaseModel):
|
||||
|
||||
|
||||
class _Access(BaseModel):
|
||||
groupRead: List[Any | None]
|
||||
folderGroupIds: List[Any | None]
|
||||
groupRead: list[Any | None]
|
||||
folderGroupIds: list[Any | None]
|
||||
|
||||
|
||||
class _Card(BaseModel):
|
||||
class Card(BaseModel):
|
||||
type: str
|
||||
title: str
|
||||
description: str
|
||||
@@ -60,12 +60,12 @@ class _Card(BaseModel):
|
||||
cover: str | None = None
|
||||
coverMetadata: _CoverMetadata | dict[None, None] | None = None
|
||||
draftExists: bool
|
||||
inventoryItemIds: List[Any] = None
|
||||
inventoryItemIds: list[Any] | None = None
|
||||
number_of_questions: int
|
||||
creator: UUID
|
||||
creator_username: str
|
||||
creator_avatar: _CreatorAvatar | dict[None, None] | None = None
|
||||
badges: List[str]
|
||||
badges: list[str]
|
||||
visibility: int
|
||||
locked: bool
|
||||
writeProtection: bool
|
||||
@@ -76,11 +76,11 @@ class _Card(BaseModel):
|
||||
draft: bool
|
||||
combined: bool
|
||||
compatibility_level: int
|
||||
sample_questions: List[_SampleQuestion]
|
||||
sample_questions: list[_SampleQuestion]
|
||||
number_of_plays: int
|
||||
number_of_players: int
|
||||
total_favourites: int
|
||||
question_types: List[str]
|
||||
question_types: list[str]
|
||||
created: int
|
||||
modified: int
|
||||
access: _Access
|
||||
@@ -89,7 +89,7 @@ class _Card(BaseModel):
|
||||
|
||||
|
||||
class _Entity(BaseModel):
|
||||
card: _Card
|
||||
card: Card
|
||||
|
||||
|
||||
class _Origin(BaseModel):
|
||||
@@ -130,8 +130,8 @@ class _Video(BaseModel):
|
||||
startTime: float
|
||||
endTime: float
|
||||
service: str
|
||||
full_url: Optional[str] = None
|
||||
id: Optional[str] = None
|
||||
full_url: str | None = None
|
||||
id: str | None = None
|
||||
|
||||
|
||||
class _Question(BaseModel):
|
||||
@@ -140,17 +140,17 @@ class _Question(BaseModel):
|
||||
time: int
|
||||
points: bool
|
||||
pointsMultiplier: int
|
||||
choices: List[_Choice]
|
||||
choices: list[_Choice]
|
||||
image: str | None = None
|
||||
imageMetadata: _ImageMetadata | None = None
|
||||
resources: Optional[str] = None
|
||||
resources: str | None = None
|
||||
video: _Video
|
||||
questionFormat: int
|
||||
languageInfo: _LanguageInfo | None = None
|
||||
media: List[Any]
|
||||
media: list[Any]
|
||||
|
||||
|
||||
class _Kahoot(BaseModel):
|
||||
class Kahoot(BaseModel):
|
||||
uuid: UUID
|
||||
language: str
|
||||
creator: UUID
|
||||
@@ -161,20 +161,19 @@ class _Kahoot(BaseModel):
|
||||
visibility: int
|
||||
difficulty: int | None = None
|
||||
audience: str
|
||||
audience: str
|
||||
title: str
|
||||
description: str
|
||||
quizType: str
|
||||
tags: str | None | List[str] = None
|
||||
tags: str | None | list[str] = None
|
||||
cover: str | None = None
|
||||
coverMetadata: _CoverMetadata | dict[None, None] | None = None
|
||||
questions: List[_Question]
|
||||
questions: list[_Question]
|
||||
metadata: _Metadata
|
||||
parent: _Parent | None = None
|
||||
resources: str | None = None
|
||||
slug: str
|
||||
languageInfo: _LanguageInfo | None = None
|
||||
inventoryItemIds: List[Any]
|
||||
inventoryItemIds: list[Any]
|
||||
type: str
|
||||
created: int
|
||||
modified: int
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
from aiohttp import ClientSession
|
||||
from pydantic import BaseModel
|
||||
|
||||
from classquiz.kahoot_importer import _Card, _Kahoot
|
||||
from classquiz.kahoot_importer import Card, Kahoot
|
||||
|
||||
|
||||
class _Response(BaseModel):
|
||||
card: _Card
|
||||
kahoot: _Kahoot
|
||||
card: Card
|
||||
kahoot: Kahoot
|
||||
|
||||
|
||||
async def get(game_id: str) -> _Response | int:
|
||||
|
||||
@@ -58,7 +58,7 @@ async def import_quiz(quiz_id: str, user: User) -> Quiz | int:
|
||||
if type(quiz) is int:
|
||||
return quiz
|
||||
quiz_questions: list[dict] = []
|
||||
quiz_id = uuid.uuid4()
|
||||
new_quiz_id = uuid.uuid4()
|
||||
meilisearch.delete_index(settings.meilisearch_index)
|
||||
meilisearch.create_index(settings.meilisearch_index)
|
||||
uploaded_images: list[StorageItem] = []
|
||||
@@ -97,7 +97,7 @@ async def import_quiz(quiz_id: str, user: User) -> Quiz | int:
|
||||
if quiz.kahoot.description is None or quiz.kahoot.description == "":
|
||||
quiz.kahoot.description = "Description Missing!"
|
||||
quiz_data = Quiz(
|
||||
id=quiz_id,
|
||||
id=new_quiz_id,
|
||||
public=False,
|
||||
title=bleach.clean(quiz.kahoot.title, tags=ALLOWED_TAGS_FOR_QUIZ, strip=True),
|
||||
description=bleach.clean(quiz.kahoot.description, tags=ALLOWED_TAGS_FOR_QUIZ, strip=True),
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
|
||||
from typing import List
|
||||
|
||||
from aiohttp import ClientSession
|
||||
from pydantic import BaseModel
|
||||
|
||||
@@ -13,7 +11,7 @@ from classquiz.kahoot_importer import _Entity
|
||||
|
||||
# noqa : E501
|
||||
class _Response(BaseModel):
|
||||
entities: List[_Entity]
|
||||
entities: list[_Entity]
|
||||
totalHits: int
|
||||
cursor: int | None = None
|
||||
pageTimestamp: int
|
||||
@@ -28,7 +26,7 @@ async def search(
|
||||
) -> _Response:
|
||||
"""
|
||||
|
||||
:param inventory_item_id: I dkon't know
|
||||
:param inventory_item_id: I don't know
|
||||
:param search_cluster: Doesn't seeem to matter
|
||||
:param cursor: The position in the result-list (page)
|
||||
:param query: The search query
|
||||
|
||||
Reference in New Issue
Block a user