mirror of
https://github.com/koloideal/Quizzi.git
synced 2026-06-10 18:35:28 +03:00
update
This commit is contained in:
@@ -41,7 +41,7 @@ class TestDAO:
|
||||
|
||||
async def get_all(self) -> list[DomainTest]:
|
||||
result = await self.session.execute(
|
||||
select(Test).order_by(Test.created_at.desc())
|
||||
select(Test).order_by(Test.is_active.desc(), Test.created_at.desc())
|
||||
)
|
||||
models = list(result.scalars().all())
|
||||
return [TestDTO(model).to_domain() for model in models]
|
||||
|
||||
@@ -63,6 +63,11 @@ class Test(Base):
|
||||
cascade="all, delete-orphan",
|
||||
order_by="Question.position"
|
||||
)
|
||||
|
||||
test_attempts: Mapped[list["TestAttempt"]] = relationship(
|
||||
back_populates="test",
|
||||
cascade="all, delete-orphan",
|
||||
)
|
||||
|
||||
|
||||
@final
|
||||
@@ -110,7 +115,7 @@ class TestAttempt(Base):
|
||||
is_passed: Mapped[bool] = mapped_column(default=False)
|
||||
|
||||
user: Mapped["User"] = relationship()
|
||||
test: Mapped["Test"] = relationship()
|
||||
test: Mapped["Test"] = relationship(back_populates="test_attempts")
|
||||
answers: Mapped[list["UserAnswer"]] = relationship(
|
||||
back_populates="attempt",
|
||||
cascade="all, delete-orphan"
|
||||
|
||||
Reference in New Issue
Block a user