Дорабоки интерфейса системы тестирования. Раздел 1 Шапка+Верхний brick

This commit is contained in:
Константин Лебединский
2026-04-29 14:55:43 +05:00
parent 1c4dacbc85
commit eff3fda5b0
34 changed files with 3339 additions and 576 deletions
+10
View File
@@ -10,6 +10,7 @@ from sqlalchemy import text
from ..db import get_engine
from ..messages import RU
from .test_access import is_test_author
from .test_chain import has_any_attempt_for_test
class HttpError(Exception):
@@ -81,7 +82,13 @@ def get_editor_content(user_id: str, test_id: str) -> dict:
if not tv:
raise HttpError(400, 'Нет активной версии теста.')
version_id = tv['id']
version_count_row = conn.execute(
text('SELECT COUNT(*) AS n FROM test_versions WHERE test_id = :id'),
{'id': test_id},
).mappings().first()
version_count = int(version_count_row['n'] or 0)
questions = load_questions_for_version(conn, version_id, include_correct=True)
has_attempts = has_any_attempt_for_test(conn, test_id)
return {
'test': {
@@ -89,6 +96,9 @@ def get_editor_content(user_id: str, test_id: str) -> dict:
'title': tr['title'],
'description': tr['description'],
'passingThreshold': tr['passing_threshold'],
'hasAttempts': bool(has_attempts),
'versionCount': version_count,
'hasForkRisk': bool(has_attempts) or version_count > 1,
},
'activeVersionId': str(version_id),
'questions': questions,