def handle_menu(user): """ It doesnt return anything, just handle menu for mentor """ list_options = ['Check the list of students', 'Add an assignment', 'Grade an assignment submitted by students', 'Check attendance of students', 'Add a student to a class', 'Remove a student from class', "Edit student's data", 'Show students of specific group', 'Give a card to student', 'Add student to specific group', 'Show full report of students performance between provided dates', 'Add a team'] while True: os.system('clear') Ui.print_message(('\n...:::Logged in as {}:::...\n').format(user)) Ui.print_menu("What you want to do?", list_options, 'Log out') chose_option = Ui.get_inputs(["Please enter a number: "], "") if chose_option[0] == '1': # print list of students MentorMenu.show_students_data() Ui.get_inputs([''], "Click enter to go back") elif chose_option[0] == '2': # add an assignment to assignment list Assignments.add_an_assignment() Common.write_assignment_to_db('database.db', Assignments.assignments_list) elif chose_option[0] == '3': # grade assignments submitted by students Submission.grade_an_submission() Common.write_submission_to_db('database.db', Submission.submission_list) elif chose_option[0] == '4': # check attendance of students Attendance.attendance_mini_menu() Common.write_attendance_to_db('database.db', Attendance.attendances_list) elif chose_option[0] == '5': # add a student to a class Student.add_person(Student.student_list) Common.write_student_to_db('database.db', Student.student_list) elif chose_option[0] == '6': # remove student from class ManagerMenu.show_students() Student.remove_person(Student.student_list) Common.write_student_to_db('database.db', Student.student_list) elif chose_option[0] == '7': # edit students data ManagerMenu.show_students() person = Student.choose_person_to_change_data(Student.student_list) if person: Employee.data_to_change(person) Common.write_student_to_db('database.db', Student.student_list) elif chose_option[0] == '8': # show students of specific group stu_list = Student.student_list Ui.print_student_teams(stu_list) Ui.get_inputs([''], "Click enter to go back") elif chose_option[0] == '9': # give a card to students MentorMenu.show_students_data() person = Student.choose_person_to_change_data(Student.student_list) if person: Student.change_student_card(person) Common.write_student_to_db('database.db', Student.student_list) elif chose_option[0] == '10': # add student to specific team os.system('clear') Student.add_student_to_team() Common.write_student_to_db('database.db', Student.student_list) elif chose_option[0] == '11': # Show full report of students performance between provided dates Student.show_full_report_of_students_performance() elif chose_option[0] == '12': # Add a new team Student.add_team() Common.write_team_to_db('database.db', Student.teams_list) elif chose_option[0] == '0': sys.exit() else: Ui.print_message('There is no such option.')
def handle_menu(user): ''' Allows to choose an action to perform. ''' options = ["View regular employees list", "Add an employee", "Edit employees' data", "Fire an employee", "View mentors list", 'Show the full statistics about mentors', "Add a mentor", "Edit mentors' data", "Fire a mentor", "View students list", "View students' grades", 'Show full statistics about students'] while True: os.system('clear') Ui.print_message(('\n...:::Logged in as {}:::...\n').format(user)) Ui.print_menu("What you want to do?", options, "Log out") inputs = Ui.get_inputs(["Please enter a number: "], "") option = inputs[0] if option == '1': ManagerMenu.show_regular_employees() Ui.get_inputs([''], "Click enter to go back") elif option == '2': Employee.add_person(Employee.employees_list) Common.write_staff_to_file('database.db', Employee.employees_list) elif option == '3': # change regular employee's data ManagerMenu.show_regular_employees() person = Employee.choose_person_to_change_data(Employee.employees_list) if person: Employee.data_to_change(person) Common.write_staff_to_file('database.db', Employee.employees_list) elif option == '4': ManagerMenu.show_regular_employees() Employee.remove_person(Employee.employees_list) elif option == '5': ManagerMenu.show_mentors() Ui.get_inputs([''], "Click enter to go back") elif option == '6': # Show full statistics about mentors ManagerMenu.show_mentors() Ui.get_inputs([''], "Click enter to go back") elif option == '7': Mentor.add_person(Mentor.mentors_list) Common.write_staff_to_file('database.db', Mentor.mentors_list) elif option == '8': # change mentor's data ManagerMenu.show_mentors() person = Mentor.choose_person_to_change_data(Mentor.mentors_list) if person: Mentor.data_to_change(person) Common.write_staff_to_file('database.db', Mentor.mentors_list) elif option == '9': # fire mentor ManagerMenu.show_mentors() Mentor.remove_person(Mentor.mentors_list) Common.write_staff_to_file('database.db', Mentor.mentors_list) elif option == '10': ManagerMenu.show_students() elif option == '11': ManagerMenu.show_average_of_grades() Ui.get_inputs([''], "Click enter to go back") elif option == '12': ManagerMenu.show_full_statistics_about_students() Ui.get_inputs([''], "Click enter to go back") elif option == '0': ManagerMenu.save() sys.exit() else: Ui.print_error_message('There is no such option.')