From b917562237f38110ff5997477dd6e9b1ccf7b952 Mon Sep 17 00:00:00 2001 From: thejackal360 Date: Wed, 13 Dec 2023 11:24:19 -0800 Subject: [PATCH] Fix repeat question issue --- src/elena/elena.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/elena/elena.py b/src/elena/elena.py index 9cff78a..bb6b8c3 100644 --- a/src/elena/elena.py +++ b/src/elena/elena.py @@ -249,15 +249,14 @@ def handle_GET(self): self.keys = list(qdict.keys()) self.n_questions = len(self.keys) random.shuffle(self.keys) - # q = random.choice(list(qdict.keys())) if self.counter < self.n_questions: q = self.keys[self.counter] ans = qdict[q] self.counter += 1 + return jsonify({"question": q, "answer": ans}) else: self.counter = 0 - msg = "You have made it! You answered all the questions!" - msg += "Now, I will take you back to the beginning!\n" + msg = "We completed all questions in the deck and are now starting from the beginning. " self.keys = list(qdict.keys()) self.n_questions = len(self.keys) @@ -266,7 +265,7 @@ def handle_GET(self): ans = qdict[q] msg += q self.counter += 1 - return jsonify({"question": q, "answer": ans}) + return jsonify({"question": msg, "answer": ans}) elif request.headers.get("Internal-Type") in self.manual_ptype: with open(