mirror of
https://github.com/koloideal/Quizzi.git
synced 2026-06-10 18:35:28 +03:00
Initial commit
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
from trudex.domain.schemas import Option as DomainOption
|
||||
from trudex.infrastructure.database.models import Option as OptionModel
|
||||
|
||||
|
||||
class OptionDTO:
|
||||
def __init__(self, model: OptionModel) -> None:
|
||||
self.model: OptionModel = model
|
||||
|
||||
def to_domain(self) -> DomainOption:
|
||||
return DomainOption(
|
||||
id=self.model.id,
|
||||
question_id=self.model.question_id,
|
||||
text=self.model.text,
|
||||
is_correct=self.model.is_correct,
|
||||
explanation=self.model.explanation,
|
||||
)
|
||||
@@ -0,0 +1,17 @@
|
||||
from trudex.domain.schemas import Question as DomainQuestion
|
||||
from trudex.infrastructure.database.models import Question as QuestionModel
|
||||
|
||||
|
||||
class QuestionDTO:
|
||||
def __init__(self, model: QuestionModel) -> None:
|
||||
self.model: QuestionModel = model
|
||||
|
||||
def to_domain(self) -> DomainQuestion:
|
||||
return DomainQuestion(
|
||||
id=self.model.id,
|
||||
test_id=self.model.test_id,
|
||||
text=self.model.text,
|
||||
position=self.model.position,
|
||||
question_type=self.model.question_type.value,
|
||||
tg_file_id=self.model.tg_file_id,
|
||||
)
|
||||
@@ -0,0 +1,18 @@
|
||||
from trudex.domain.schemas import Test as DomainTest
|
||||
from trudex.infrastructure.database.models import Test as TestModel
|
||||
|
||||
|
||||
class TestDTO:
|
||||
def __init__(self, model: TestModel) -> None:
|
||||
self.model: TestModel = model
|
||||
|
||||
def to_domain(self) -> DomainTest:
|
||||
return DomainTest(
|
||||
id=self.model.id,
|
||||
title=self.model.title,
|
||||
description=self.model.description,
|
||||
for_group=self.model.for_group,
|
||||
is_active=self.model.is_active,
|
||||
created_at=self.model.created_at,
|
||||
updated_at=self.model.updated_at,
|
||||
)
|
||||
Reference in New Issue
Block a user