-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
106 additions
and
4 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import List | ||
|
||
from app.domain.core.Answer import Answer | ||
from app.domain.core.QuestionId import QuestionId | ||
from app.domain.core.enum.Action import Action | ||
from app.domain.core.enum.QuestionType import QuestionType | ||
|
||
|
||
class Question: | ||
|
||
def __init__( | ||
self, | ||
question_id: QuestionId, | ||
text: str, | ||
question_type: QuestionType, | ||
available_answers: List[Answer], | ||
selected_answer: List[Answer] = [], | ||
action_needed: Action = None, | ||
): | ||
self._id = question_id | ||
self._text = text | ||
self._type = question_type | ||
self._availableAnswers = available_answers | ||
self._selectedAnswer = selected_answer | ||
self._actionNeeded = action_needed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class QuestionId: | ||
|
||
def __init__(self, code: str): | ||
self._code = code | ||
|
||
@property | ||
def code(self): | ||
return self._code | ||
|
||
def __eq__(self, other): | ||
return self.code == other.code | ||
|
||
def __str__(self): | ||
return f"QuestionId(code={self.code})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from enum import Enum | ||
|
||
|
||
class Action(Enum): | ||
METRICS_CHECK = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from enum import Enum | ||
|
||
|
||
class QuestionType(Enum): | ||
BOOLEAN = 0 | ||
SINGLE_CHOICE = 1 | ||
MULTIPLE_CHOICE = 2 | ||
RATING = 3 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from typing import List | ||
|
||
from app.domain.core.Answer import Answer | ||
from app.domain.core.Question import Question | ||
from app.domain.core.QuestionId import QuestionId | ||
from app.domain.core.enum.Action import Action | ||
from app.domain.core.enum.QuestionType import QuestionType | ||
from app.domain.factories.AnswerFactory import AnswerFactory | ||
|
||
|
||
class QuestionFactory: | ||
|
||
def __init__(self): | ||
self._answer_factory = AnswerFactory() | ||
|
||
def create_question( | ||
self, | ||
question_id: QuestionId, | ||
text: str, | ||
question_type: QuestionType, | ||
available_answers: List[Answer], | ||
selected_answer: List[Answer], | ||
action_needed: Action, | ||
) -> Question: | ||
return Question( | ||
question_id, | ||
text, | ||
question_type, | ||
available_answers, | ||
selected_answer, | ||
action_needed, | ||
) | ||
|
||
def create_boolean_question( | ||
self, question_id: QuestionId, text: str, action_needed: Action = None | ||
) -> Question: | ||
available_answers: List[Answer] = [ | ||
self._answer_factory.create_boolean_answer(True), | ||
self._answer_factory.create_boolean_answer(False), | ||
] | ||
return Question( | ||
question_id, | ||
text, | ||
QuestionType.BOOLEAN, | ||
available_answers, | ||
[], | ||
action_needed, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import unittest | ||
|
||
from app.domain.core.Question import Question | ||
from app.domain.factories.QuestionFactory import QuestionFactory | ||
|
||
|
||
class TestQuestion(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.question = Question("What is your name?") | ||
|
||
|
||
|
||
self.question = QuestionFactory().create_boolean_question( | ||
"1", "Is this a test?" | ||
) |