adds the explication to the standalone tui version

This commit is contained in:
waldek 2021-06-17 14:20:30 +02:00
parent 90befc0953
commit 088ce7e055
2 changed files with 16 additions and 8 deletions

View File

@ -11,7 +11,9 @@ from rich.markdown import Markdown
LEVEL = "LEVEL"
QUESTION = "QUESTION"
ANSWER = "ANSWER"
# EXPLANATION = ""
EXPLICATION = "EXPLICATION"
POSSIBILITIES = "POSSIBILITIES"
UUID = "UUID"
class Question(object):
@ -34,6 +36,10 @@ class Question(object):
self._answers = self._data[ANSWER].strip().split(" ")
self._answers = [x for x in self._answers if x]
self._create_list_of_possibilities()
try:
self._explication = self._data[EXPLICATION].strip()
except:
self._explication = "No explication available for this question"
def dump_json(self):
"""
@ -41,10 +47,11 @@ class Question(object):
TODO needs a key to include the date for issue 5
"""
data = {
"UUID": self.get_uuid(),
UUID: self.get_uuid(),
QUESTION: self.get_question(),
ANSWER: self.get_right_answers(),
"POSSIBILITIES": self.get_possibilities(),
POSSIBILITIES: self.get_possibilities(),
EXPLICATION: self.get_explication()
}
return json.dumps(data)
@ -54,9 +61,9 @@ class Question(object):
def get_question(self):
return self._question
def get_explanation(self):
"""PLACEHOLDER for issue 5"""
pass
def get_explication(self):
"""returns the explication as a string"""
return self._explication
def _create_list_of_possibilities(self):
"""creates and cleans a list of all the possible answers"""

View File

@ -73,8 +73,9 @@ class Tui(object):
self._console.print(md)
def show_explanation(self, question):
"""PLACEHOLDER for issue 5"""
pass
md = "--- \n {} \n \n ---".format(question.get_explication())
md = Markdown(md)
self._console.print(md)
def show_success(self, success):
md = "# {}".format(random.choice(MSG[success]))