Added option to shuffle answers

This commit is contained in:
Mawoka
2023-07-04 10:48:02 +02:00
parent 06ecef24d5
commit ce5ffa4a80
2 changed files with 26 additions and 1 deletions
+6
View File
@@ -4,6 +4,7 @@
import json
import random
import re
import uuid
from datetime import datetime
@@ -80,6 +81,7 @@ async def start_quiz(
captcha_enabled: bool = True,
custom_field: str | None = None,
cqcs_enabled: bool = False,
randomize_answers: bool = False,
user: User = Depends(get_current_user),
):
try:
@@ -101,6 +103,10 @@ async def start_quiz(
game_pin = randint(100000, 999999)
game = await redis.get(f"game:{game_pin}")
if randomize_answers:
for question in quiz.questions:
random.shuffle(question["answers"])
game = PlayGame(
quiz_id=quiz_id,
game_pin=str(game_pin),