Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save compiler-errors/900de648034cdb2bcf8232dd2aeecf3b to your computer and use it in GitHub Desktop.
Save compiler-errors/900de648034cdb2bcf8232dd2aeecf3b to your computer and use it in GitHub Desktop.
TerribleGradingAssistantScript.py
from sys import stdin, stdout
currentStudent = dict() # A map of gradingReason to possible additional message
gradingReasons = [] # List of grading reasons (which are pairs of general message and point values)
thisTeam = None # Our current team name
def printMenu():
global thisTeam
global currentStudent
global gradingReasons
for i, gr in enumerate(gradingReasons):
if gr == " ": # Spaces are just plain old strings stuck into gradingReasons
print()
continue
m, v = gr
if gr in currentStudent:
pm = currentStudent[gr]
pm = (" - " + pm) if pm != "" else ""
if len(pm+m) > 130:
pm = pm[0: 127 - len(m)] + "..."
print(f"#{i} [*] {v} - {m}{pm}")
else:
print(f"#{i} [ ] {v} - {m}")
def spitTeam():
global thisTeam
global currentStudent
global gradingReasons
print(f">>>> GRADING {thisTeam} <<<<")
if thisTeam != None:
with open(thisTeam+".txt", "w") as f:
for i, gr in enumerate(gradingReasons):
if gr == " ":
f.write('\n')
continue
m, v = gr
if gr in currentStudent:
pm = currentStudent[gr]
pm = (" - " + pm) if pm != "" else ""
f.write(f"[{v}] - {m}{pm}\n")
def main():
global thisTeam
global currentStudent
global gradingReasons
while True:
try:
print()
spitTeam()
printMenu()
print("> ", end="", flush=True)
command = stdin.readline()
if command == "":
continue
command = command.split()
if len(command) == 0:
continue
command[0] = command[0].lower()
if command[0] == "":
continue
if command[0] == 'a' or command[0] == 'add':
value = int(command[1])
message = " ".join(command[2:])
gradingReasons.append((message, value))
elif command[0] == 'as':
gradingReasons.append(" ")
elif command[0] == 'ai' or command[0] == 'a2' or command[0] == 'addto':
where = int(command[1])
value = int(command[2])
message = " ".join(command[3:])
gradingReasons.insert(where, (message, value))
elif command[0] == 'd' or command[0] == 'done':
thisTeam = command[1]
currentStudent = dict()
elif command[0] == 'r' or command[0] == 'remove':
value = int(command[1])
gradingReasons.remove(gradingReasons[value])
elif command[0] == 'x' or command[0] == 'exit':
break
else:
reason = gradingReasons[int(command[0])]
message = " ".join(command[1:])
if reason in currentStudent:
del currentStudent[reason]
else:
currentStudent[reason] = message
except:
pass
if __name__ == '__main__':
main()
print("Goodbye!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment