diff --git a/flask_app/app/services/test_access.py b/flask_app/app/services/test_access.py index 74362ed..95d7954 100644 --- a/flask_app/app/services/test_access.py +++ b/flask_app/app/services/test_access.py @@ -6,7 +6,7 @@ from dataclasses import dataclass from sqlalchemy import exists, select from ..db import get_session -from ..models import Test, TestAssignment, TestAssignmentTarget, TestVersion, User +from ..models import Test, TestAssignment, TestAssignmentTarget, TestAttempt, TestVersion, User def is_test_author(created_by, user_id) -> bool: @@ -57,7 +57,12 @@ def user_has_test_access(user_id: str, test_id: str) -> AccessResult: def list_visible_tests(user_id: str) -> list[dict]: """В dev-режиме возвращает все активные тесты независимо от назначения.""" + import uuid as _uuid session = get_session() + try: + uid = _uuid.UUID(user_id) + except (ValueError, AttributeError): + uid = None rows = ( session.query(Test, TestVersion, User) @@ -80,6 +85,16 @@ def list_visible_tests(user_id: str) -> list[dict]: 'version': tv.version, 'created_by': str(t.created_by) if t.created_by else None, 'author_full_name': u.full_name if u else '—', + 'has_in_progress_attempt': bool( + uid and session.query( + exists().where( + TestAttempt.user_id == uid, + TestAttempt.status == 'in_progress', + TestAttempt.test_version_id == TestVersion.id, + TestVersion.test_id == t.id, + ) + ).scalar() + ), } for t, tv, u in rows ] diff --git a/flask_app/app/static/css/app.css b/flask_app/app/static/css/app.css index 92ceaa4..49adf4b 100644 --- a/flask_app/app/static/css/app.css +++ b/flask_app/app/static/css/app.css @@ -348,7 +348,6 @@ body.ui-legacy .list-row__side { align-items: center; padding: 0.5rem 0.9rem 0.5rem 0; flex-shrink: 0; - border-left: 1px solid color-mix(in srgb, var(--outline-variant) 35%, transparent); } body.ui-legacy .list-row--hidden { diff --git a/flask_app/app/templates/tests/list.html b/flask_app/app/templates/tests/list.html index 14711f2..3b04dbc 100644 --- a/flask_app/app/templates/tests/list.html +++ b/flask_app/app/templates/tests/list.html @@ -25,7 +25,9 @@
- +
{% endfor %} @@ -49,7 +51,9 @@
- +
{% endfor %} @@ -199,7 +203,8 @@ const testId = btn.dataset.testId; if (!testId) return; btn.disabled = true; - btn.textContent = 'Продолжить…'; + const oldText = (btn.textContent || '').trim() || 'Пройти'; + btn.textContent = `${oldText}…`; try { const r = await fetch(`/api/tests/${testId}/attempts/start`, { method: 'POST',