def run(self): finished = False while not finished: try: print("Choose one of the functionalities below:") print("1. Add, remove, update or list students") print("2. Add, remove, update or list assignments") print( "3. Give an assignment to a student or a group of students" ) print("4. Grade a student for a given assignment") print("5. Print statistics") print("6. Exit") cmd = input("Your command is = ") if cmd in self.__commands: self.__commands[cmd]() else: raise CommandError("Invalid command") except RepoError as re: print(re) except ValueError: print("The program requires another type of data") except CommandError as ce: print(ce)
def __ui_update_student(self): self.__ui_list_students() student_id = int(input("Give the id of the students to be updated = ")) print("1.3.1. Update the name of the student") print("1.3.2. Update the group of the student") cmd = input("Your command is = ") if cmd in self.__commands: self.__commands[cmd](student_id) else: raise CommandError("Invalid command")
def __ui_assignment(self): print("Choose 1 of the functionalities below:") print("2.1. Add a new assignment") print("2.2. Remove an assignment") print("2.3. Update an assignment") print("2.4. List the assignments") cmd = input("Your command is = ") if cmd in self.__commands: self.__commands[cmd]() else: raise CommandError("Invalid command")
def __ui_give_assignment(self): self.__ui_list_assignments() assignment_id = int( input("Give the id of the assignment to be given = ")) print("3.1. Give the assignment to a student") print("3.2. Give the assignment to a group of students") cmd = input("Your command is = ") if cmd in self.__commands: self.__commands[cmd](assignment_id) else: raise CommandError("Invalid command")
def __ui_update_assignment(self): self.__ui_list_assignments() assignment_id = int( input("Give the id of the assignment to be updated = ")) print("2.3.1. Update the description of the assignment") print("2.3.2. Update the deadline of the assignment") cmd = input("Your command is = ") if cmd in self.__commands: self.__commands[cmd](assignment_id) else: raise CommandError("Invalid command")
def __ui_statistics(self): print("What statistics would you like to see?") print("5.1. Print all students who received a given assignment") print( "5.2. Print all students who are late in handling at least one assignment" ) cmd = input("Your command is = ") if cmd in self.__commands: self.__commands[cmd]() else: raise CommandError("Invalid command")