From 088ce7e055e73894273b3c82c4f0bb76d398bc15 Mon Sep 17 00:00:00 2001 From: waldek Date: Thu, 17 Jun 2021 14:20:30 +0200 Subject: [PATCH] adds the explication to the standalone tui version --- ccpq/lib_ccpq.py | 19 +++++++++++++------ standalone_tui.py | 5 +++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ccpq/lib_ccpq.py b/ccpq/lib_ccpq.py index effc493..a86b6b2 100644 --- a/ccpq/lib_ccpq.py +++ b/ccpq/lib_ccpq.py @@ -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""" diff --git a/standalone_tui.py b/standalone_tui.py index 22b7e61..0a3413f 100755 --- a/standalone_tui.py +++ b/standalone_tui.py @@ -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]))