adds the explication to the standalone tui version
This commit is contained in:
parent
90befc0953
commit
088ce7e055
|
@ -11,7 +11,9 @@ from rich.markdown import Markdown
|
||||||
LEVEL = "LEVEL"
|
LEVEL = "LEVEL"
|
||||||
QUESTION = "QUESTION"
|
QUESTION = "QUESTION"
|
||||||
ANSWER = "ANSWER"
|
ANSWER = "ANSWER"
|
||||||
# EXPLANATION = ""
|
EXPLICATION = "EXPLICATION"
|
||||||
|
POSSIBILITIES = "POSSIBILITIES"
|
||||||
|
UUID = "UUID"
|
||||||
|
|
||||||
|
|
||||||
class Question(object):
|
class Question(object):
|
||||||
|
@ -34,6 +36,10 @@ class Question(object):
|
||||||
self._answers = self._data[ANSWER].strip().split(" ")
|
self._answers = self._data[ANSWER].strip().split(" ")
|
||||||
self._answers = [x for x in self._answers if x]
|
self._answers = [x for x in self._answers if x]
|
||||||
self._create_list_of_possibilities()
|
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):
|
def dump_json(self):
|
||||||
"""
|
"""
|
||||||
|
@ -41,10 +47,11 @@ class Question(object):
|
||||||
TODO needs a key to include the date for issue 5
|
TODO needs a key to include the date for issue 5
|
||||||
"""
|
"""
|
||||||
data = {
|
data = {
|
||||||
"UUID": self.get_uuid(),
|
UUID: self.get_uuid(),
|
||||||
QUESTION: self.get_question(),
|
QUESTION: self.get_question(),
|
||||||
ANSWER: self.get_right_answers(),
|
ANSWER: self.get_right_answers(),
|
||||||
"POSSIBILITIES": self.get_possibilities(),
|
POSSIBILITIES: self.get_possibilities(),
|
||||||
|
EXPLICATION: self.get_explication()
|
||||||
}
|
}
|
||||||
return json.dumps(data)
|
return json.dumps(data)
|
||||||
|
|
||||||
|
@ -54,9 +61,9 @@ class Question(object):
|
||||||
def get_question(self):
|
def get_question(self):
|
||||||
return self._question
|
return self._question
|
||||||
|
|
||||||
def get_explanation(self):
|
def get_explication(self):
|
||||||
"""PLACEHOLDER for issue 5"""
|
"""returns the explication as a string"""
|
||||||
pass
|
return self._explication
|
||||||
|
|
||||||
def _create_list_of_possibilities(self):
|
def _create_list_of_possibilities(self):
|
||||||
"""creates and cleans a list of all the possible answers"""
|
"""creates and cleans a list of all the possible answers"""
|
||||||
|
|
|
@ -73,8 +73,9 @@ class Tui(object):
|
||||||
self._console.print(md)
|
self._console.print(md)
|
||||||
|
|
||||||
def show_explanation(self, question):
|
def show_explanation(self, question):
|
||||||
"""PLACEHOLDER for issue 5"""
|
md = "--- \n {} \n \n ---".format(question.get_explication())
|
||||||
pass
|
md = Markdown(md)
|
||||||
|
self._console.print(md)
|
||||||
|
|
||||||
def show_success(self, success):
|
def show_success(self, success):
|
||||||
md = "# {}".format(random.choice(MSG[success]))
|
md = "# {}".format(random.choice(MSG[success]))
|
||||||
|
|
Loading…
Reference in New Issue