From 0338d9168416ab69a50943db5c8c904f294756f4 Mon Sep 17 00:00:00 2001 From: Firepup Sixfifty Date: Tue, 27 Aug 2024 09:13:54 -0500 Subject: [PATCH] Multiple answers at once support --- main.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 9381a2e..0d2a4b1 100644 --- a/main.py +++ b/main.py @@ -14,6 +14,13 @@ while not False: ).upper() if not answer: break + if len(answer) > 1: + multi = fp.replitInput("Is this multiple answers? (Y|n)") + if multi.upper() != "N": + for i in range(len(answer)): + answerCount += 1 + answerKey.append(answer[i]) + continue answerCount += 1 answerKey.append(answer) @@ -22,15 +29,25 @@ fp.clear() while 1: right = 0 try: + queue = [] for i in range(answerCount): - answer = fp.replitInput( - f"Please input the student's answer to question {i + 1}. ^C at any time to show results immediately." - ).upper() + answer = "" + if not queue: + answer = fp.replitInput( + f"Please input the student's answer to question {i + 1}. ^C at any time to show results immediately." + ).upper() + else: + answer = queue.pop(0) + if len(answer) > 1: + multi = fp.replitInput("Is this multiple answers? (Y|n)") + if multi.upper() != "N": + queue = list(answer) + answer = queue.pop(0) if answer == answerKey[i]: right += 1 - print(" That is correct") + print(f" Answer {i + 1} is correct") else: - print(" That is incorrect") + print(f" Answer {i + 1} is incorrect") except KeyboardInterrupt: pass print(