Skip to content

Commit

Permalink
Fix repeat question issue
Browse files Browse the repository at this point in the history
  • Loading branch information
thejackal360 committed Dec 13, 2023
1 parent fff2afe commit b917562
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/elena/elena.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand Down

0 comments on commit b917562

Please sign in to comment.