🚨 Removed comments
This commit is contained in:
@@ -20,7 +20,6 @@ from classquiz.db.models import User, TokenData
|
||||
|
||||
settings = settings()
|
||||
|
||||
# pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
||||
pwd_context = argon2
|
||||
ALGORITHM = "HS256"
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES = settings.access_token_expire_minutes
|
||||
|
||||
@@ -98,10 +98,6 @@ class _Crop(BaseModel):
|
||||
circular: bool
|
||||
|
||||
|
||||
# class _Language(Enum):
|
||||
# EN_US = "en-US"
|
||||
|
||||
|
||||
class _LanguageInfo(BaseModel):
|
||||
language: str
|
||||
lastUpdatedOn: int
|
||||
|
||||
@@ -19,42 +19,6 @@ async def _download_image(url: str) -> bytes:
|
||||
return await resp.read()
|
||||
|
||||
|
||||
# async def _upload_to_imgur(image: bytes, album_id: str | None) -> str:
|
||||
# """
|
||||
# Uploads an image to Imgur.
|
||||
# :param image: The image to upload.
|
||||
# :return: The URL of the image on Imgur.
|
||||
# """
|
||||
#
|
||||
# formdata = FormData()
|
||||
# formdata.add_field('image', image, filename='image.png')
|
||||
# if album_id:
|
||||
# formdata.add_field('album', album_id)
|
||||
# async with ClientSession(headers={"Authorization": f"Client-ID {settings.imgur_client_id}"}) as session:
|
||||
# print(settings.imgur_client_id)
|
||||
# async with session.post("https://api.imgur.com/3/image", data=image) as resp:
|
||||
# data = await resp.json()
|
||||
# print(resp.headers)
|
||||
# try:
|
||||
# return data["data"]["link"]
|
||||
# except KeyError:
|
||||
# raise Exception(data)
|
||||
#
|
||||
#
|
||||
# async def _generate_imgur_album(quiz_id: str) -> str:
|
||||
# # """
|
||||
# # Generates an album on Imgur.
|
||||
# # :param quiz_id: The ID of the quiz.
|
||||
# # :return: The URL of the album on Imgur.
|
||||
# # """
|
||||
# formdata = FormData()
|
||||
# formdata.add_field('title', quiz_id)
|
||||
# async with ClientSession(headers={"Authorization": f"Client-ID {settings.imgur_client_id}"}) as session:
|
||||
# async with session.post("https://api.imgur.com/3/album", data={"title": "Quiz: " + quiz_id}, ) as resp:
|
||||
# data = await resp.json()
|
||||
# return data["data"]["id"]
|
||||
|
||||
|
||||
async def import_quiz(quiz_id: str, user: User) -> Quiz | str:
|
||||
"""
|
||||
Imports a quiz from Kahoot.
|
||||
@@ -76,7 +40,6 @@ async def import_quiz(quiz_id: str, user: User) -> Quiz | str:
|
||||
image_name = f"{quiz_id}--{uuid.uuid4()}"
|
||||
image = await storage.upload(file_name=image_name, file_data=image_bytes)
|
||||
image = f"{settings.root_address}/api/v1/storage/download/{image_name}"
|
||||
# image = q.image
|
||||
for a in q.choices:
|
||||
answers.append((QuizAnswer(right=a.correct, answer=html.unescape(a.answer))))
|
||||
quiz_questions.append(
|
||||
|
||||
@@ -34,6 +34,4 @@ async def search(
|
||||
async with session.get(
|
||||
f"https://create.kahoot.it/rest/kahoots/?query={query}&limit={limit}&cursor={cursor}&searchCluster={search_cluster}&includeExtendedCounters=false&inventoryItemId={inventory_item_id}" # noqa : E501
|
||||
) as response:
|
||||
# print(
|
||||
# f"https://create.kahoot.it/rest/kahoots/?query={query}&limit={limit}&cursor={cursor}&searchCluster={search_cluster}&includeExtendedCounters=false&inventoryItemId={inventory_item_id}")
|
||||
return _Response(**await response.json())
|
||||
|
||||
@@ -39,7 +39,6 @@ async def join_game(sid, data):
|
||||
await sio.emit("joined_game", redis_res, room=sid)
|
||||
redis_res = await redis.get(f"game_session:{data['game_pin']}")
|
||||
redis_res = json.loads(redis_res)
|
||||
# print(redis_res)
|
||||
redis_res["players"].append({"username": data["username"], "sid": sid})
|
||||
await redis.set(
|
||||
f"game_session:{data['game_pin']}",
|
||||
@@ -63,9 +62,7 @@ async def join_game(sid, data):
|
||||
|
||||
@sio.event
|
||||
async def start_game(sid, _data):
|
||||
# print(sid, data, "START_GAME")
|
||||
session = await sio.get_session(sid)
|
||||
# print(session)
|
||||
if session["admin"]:
|
||||
await sio.emit("start_game", room=session["game_pin"])
|
||||
|
||||
@@ -114,10 +111,7 @@ async def set_question_number(sid, data):
|
||||
@sio.event
|
||||
async def submit_answer(sid, data):
|
||||
session = await sio.get_session(sid)
|
||||
# redis_res = await redis.get(f"game_session:{session['game_pin']}")
|
||||
# game_session = GameSession(**json.loads(redis_res))
|
||||
game_data = PlayGame(**json.loads(await redis.get(f"game:{session['game_pin']}")))
|
||||
# print(game_session)
|
||||
answer_right = False
|
||||
for answer in game_data.questions[int(data["question_index"])].answers:
|
||||
if answer.answer == data["answer"] and answer.right:
|
||||
|
||||
Reference in New Issue
Block a user