UI bugfixes with boss
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json as _json
|
||||
import random
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
@@ -79,6 +80,18 @@ def validate_and_normalize_draft(o: Any) -> dict:
|
||||
return {'title': title, 'description': description, 'questions': questions}
|
||||
|
||||
|
||||
def shuffle_options_in_questions(questions: list[dict] | None) -> None:
|
||||
"""Случайный порядок вариантов в каждом вопросе; isCorrect остаётся у соответствующего текста."""
|
||||
if not questions:
|
||||
return
|
||||
for q in questions:
|
||||
if not isinstance(q, dict):
|
||||
continue
|
||||
opts = q.get('options')
|
||||
if isinstance(opts, list) and len(opts) >= 2:
|
||||
random.shuffle(opts)
|
||||
|
||||
|
||||
def assert_draft_matches_shape(o: dict, shape: list[dict]) -> None:
|
||||
"""Проверяет, что число вопросов и вариантов = ровно как в shape."""
|
||||
qs = o.get('questions') if isinstance(o, dict) else None
|
||||
|
||||
Reference in New Issue
Block a user