def add_exam(): try: pass_time = datetime.strptime( input("Enter time of pass(DD.MM.YYYY HH:MM): "), '%d.%m.%Y %H:%M').strftime('%d.%m.%Y %H:%M') exam_name = input("Enter name of exam: ") score = input("Enter score of exam: ") enrollee_id = 0 examiner_id = 0 score = None if score != "": score = int(score) while True: #select enrollee by surname enrollee_surn = input("Enter surname of enrollee: ") if enrollee_surn == "-1": return enrollees = Enrollee.findBySurname(enrollee_surn) if len(enrollees) == 0: print( "No results. Enter '-1' to stop adding exam ornew surname to try again: " ) else: print_arr(enrollees) user_input = int( input( "Enter number of selected enrollee, or '-1' to stop adding exam: " )) if user_input >= 0 or user_input < len(enrollees): enrollee_id = enrollees[user_input - 1].id break elif user_input == -1: return else: print("Incorrect input") while True: #select examiner by surname examiner_surn = input("Enter surname of examiner: ") if examiner_surn == "-1": return examiners = Examiner.findBySurname(examiner_surn) if len(examiners) == 0: print( "No results. Enter '-1' to stop adding exam or new surname to try again: " ) else: print_arr(examiners) user_input = int( input( "Enter number of selected examiner, or '-1' to stop adding exam: " )) if user_input >= 0 or user_input < len(examiners): examiner_id = examiners[user_input - 1].id break elif user_input == -1: return else: print("Incorrect input") Exam.create(pass_time, exam_name, score, enrollee_id, examiner_id) except: print("Error")
def find_enrollee(): try: sur = input("Enter surname to search: ") enrollees = Enrollee.findBySurname(sur) print_arr(enrollees) if len(enrollees) == 0: print("No results") else: res = int( input( "Enter number of selected enrollee or '-1' to go back: ")) if res > 0 and res <= len(enrollees): manipulate_enrollee(enrollees[res - 1]) return elif res == -1: return else: print("Incorrect input") except: print("Error")
def find_enrollee(self, listbox, find_label): listbox.delete(0, END) self.find_enrollee_list = Enrollee.findBySurname(find_label.get()) for elem in self.find_enrollee_list: listbox.insert(END, elem.to_string()) return
def findEnrolleeOnClick(self): model = QStandardItemModel(self.findEnrList) for i in Enrollee.findBySurname(self.findSurnameInput.text()): item = QStandardItem(i.to_string()) model.appendRow(item) self.findEnrList.setModel(model)