✨ Stripping html-tags from kahoot-imports
This commit is contained in:
@@ -7,6 +7,7 @@ import json
|
|||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
import bleach
|
||||||
from aiohttp import ClientSession
|
from aiohttp import ClientSession
|
||||||
|
|
||||||
from classquiz.config import settings, storage, meilisearch
|
from classquiz.config import settings, storage, meilisearch
|
||||||
@@ -46,10 +47,13 @@ async def import_quiz(quiz_id: str, user: User) -> Quiz | str:
|
|||||||
image = await storage.upload(file_name=image_name, file_data=image_bytes)
|
image = await storage.upload(file_name=image_name, file_data=image_bytes)
|
||||||
image = f"{settings.root_address}/api/v1/storage/download/{image_name}"
|
image = f"{settings.root_address}/api/v1/storage/download/{image_name}"
|
||||||
for a in q.choices:
|
for a in q.choices:
|
||||||
answers.append((ABCDQuizAnswer(right=a.correct, answer=html.unescape(a.answer))))
|
answers.append(
|
||||||
|
(ABCDQuizAnswer(right=a.correct, answer=html.unescape(bleach.clean(a.answer, tags=[], strip=True))))
|
||||||
|
)
|
||||||
|
|
||||||
quiz_questions.append(
|
quiz_questions.append(
|
||||||
QuizQuestion(
|
QuizQuestion(
|
||||||
question=q.question,
|
question=html.unescape(bleach.clean(q.question, tags=[], strip=True)),
|
||||||
answers=answers,
|
answers=answers,
|
||||||
time=str(q.time / 1000),
|
time=str(q.time / 1000),
|
||||||
image=image,
|
image=image,
|
||||||
@@ -64,8 +68,8 @@ async def import_quiz(quiz_id: str, user: User) -> Quiz | str:
|
|||||||
quiz_data = Quiz(
|
quiz_data = Quiz(
|
||||||
id=quiz_id,
|
id=quiz_id,
|
||||||
public=True,
|
public=True,
|
||||||
title=quiz.kahoot.title,
|
title=html.unescape(bleach.clean(quiz.kahoot.title, tags=[], strip=True)),
|
||||||
description=quiz.kahoot.description,
|
description=html.unescape(bleach.clean(quiz.kahoot.description, tags=[], strip=True)),
|
||||||
created_at=datetime.now(),
|
created_at=datetime.now(),
|
||||||
updated_at=datetime.now(),
|
updated_at=datetime.now(),
|
||||||
user_id=user.id,
|
user_id=user.id,
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
modules={[Pagination, Keyboard, Navigation]}
|
modules={[Pagination, Keyboard, Navigation]}
|
||||||
>
|
>
|
||||||
<SwiperSlide>
|
<SwiperSlide>
|
||||||
<div class="grid grid-cols-6 h-full">
|
<div class="grid grid-cols-6 h-[25vh]">
|
||||||
<p
|
<p
|
||||||
style="writing-mode: vertical-lr"
|
style="writing-mode: vertical-lr"
|
||||||
class="text-center h-full text-xl p-2"
|
class="text-center h-full text-xl p-2"
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
quizzes_to_show = quizzes;
|
quizzes_to_show = quizzes;
|
||||||
quizzes_to_show = quizzes_to_show;
|
quizzes_to_show = quizzes_to_show;
|
||||||
} else {
|
} else {
|
||||||
const res = minisearch.search(search_term);
|
const res = minisearch.search(search_term, { prefix: true, fuzzy: 0.3 });
|
||||||
if (res.length === 0) {
|
if (res.length === 0) {
|
||||||
quizzes_to_show = [];
|
quizzes_to_show = [];
|
||||||
suggestions = minisearch.autoSuggest(search_term);
|
suggestions = minisearch.autoSuggest(search_term);
|
||||||
|
|||||||
Reference in New Issue
Block a user