grader/main.py

56 lines
1.6 KiB
Python
Raw Normal View History

2024-08-21 14:25:40 +00:00
import firepup650 as fp
fp.replitCursor = fp.bcolors.REPLIT + "> " + fp.bcolors.RESET
answerKey = []
answer = "0"
answerCount = 0
fp.clear()
while not False:
answer = fp.replitInput(
f"Please input the answer to question #{answerCount + 1}, empty answer to submit answer key"
2024-08-21 14:39:02 +00:00
).upper()
2024-08-21 14:25:40 +00:00
if not answer:
break
2024-08-27 14:13:54 +00:00
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
2024-08-21 14:25:40 +00:00
answerCount += 1
answerKey.append(answer)
fp.clear()
while 1:
right = 0
2024-08-21 14:37:36 +00:00
try:
2024-08-27 14:13:54 +00:00
queue = []
2024-08-21 14:37:36 +00:00
for i in range(answerCount):
2024-08-27 14:13:54 +00:00
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)
2024-08-21 14:37:36 +00:00
if answer == answerKey[i]:
right += 1
2024-08-27 14:13:54 +00:00
print(f" Answer {i + 1} is correct")
2024-08-21 14:37:36 +00:00
else:
2024-08-27 14:13:54 +00:00
print(f" Answer {i + 1} is incorrect")
2024-08-21 14:37:36 +00:00
except KeyboardInterrupt:
pass
2024-08-21 14:25:40 +00:00
print(
2024-08-21 14:45:54 +00:00
f"\nThe student got {right}/{answerCount} correct, which is approximately {round((right/answerCount) * 100, 2)}%.\n"
2024-08-21 14:25:40 +00:00
)