Exemplo n.º 1
0
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")
Exemplo n.º 2
0
def find_examiner():
    try:
        sur = input("Enter surname to search: ")
        examiners = Examiner.findBySurname(sur)
        print_arr(examiners)
        if len(examiners) == 0:
            print("No results")
        else:
            res = int(input("Enter number of selected examiner or '-1' to go back: "))
            if res > 0 and res <= len(examiners):
                manipulate_examiner(examiners[res - 1])
            elif res == -1:
                return
            else:
                print("Incorrect input")
    except:
        print("Error")
Exemplo n.º 3
0
 def find_examiner(self, listbox, find_label):
     listbox.delete(0, END)
     self.find_examiner_list = Examiner.findBySurname(find_label.get())
     for elem in self.find_examiner_list:
         listbox.insert(END, elem.to_string())
     return
Exemplo n.º 4
0
 def findExaminerClick(self):
     model = QStandardItemModel(self.findExaminerList)
     for i in Examiner.findBySurname(self.findExaminerInput.text()):
         item = QStandardItem(i.to_string())
         model.appendRow(item)
     self.findExaminerList.setModel(model)