Allow Saving of assignments

This commit is contained in:
Firepup Sixfifty 2024-08-27 09:32:54 -05:00
parent 0338d91684
commit a6db2d9430
Signed by: Firepup650
SSH key fingerprint: SHA256:cb8sEJwc0kQJ6/nMUhscWRe35itf0NFMdSKl3v4qt48

50
main.py
View file

@ -1,28 +1,46 @@
import firepup650 as fp
keys = {"Create new assignment": False}
try:
from assignments import keys
except:
with open("assignments.py", "w") as file:
file.write(f"keys = {keys}")
fp.replitCursor = fp.bcolors.REPLIT + "> " + fp.bcolors.RESET
answerKey = []
answer = "0"
answerCount = 0
key = False
if len(keys) > 1:
key = fp.menu(keys, "Please select an assignment to grade")
fp.clear()
while not False:
answer = fp.replitInput(
f"Please input the answer to question #{answerCount + 1}, empty answer to submit answer key"
).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)
if key:
answerKey = key
answerCount = len(key)
else:
while not False:
answer = fp.replitInput(
f"Please input the answer to question #{answerCount + 1}, empty answer to submit answer key"
).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)
name = fp.replitInput("Please enter the name of this assignment")
keys[name] = answerKey
with open("assignments.py", "w") as file:
file.write(f"keys = {keys}")
fp.clear()