def handle_main_menu_requests(user_request, idx, name, surname): """ Call function that perform task from menu choosen by user: see list of students, mentors, edit mentors, use talkbox Args: user_request (string): option choosen by user idx (string): uniqe person id name (string): person name surname (strin): person surname """ if user_request == '1': get_mentors_list(lock=True) elif user_request == '2': start_mentor_edit_menu() elif user_request == '3': get_students_list() elif user_request == "4": rank = student_controller.get_ranking() codecooler_view.print_table(["Name", "Total points"], rank) codecooler_view.state_locker() elif user_request == '5': codecooler_controller.change_password(idx) elif user_request == "6": talkbox.start_talkbox(name, surname)
def display_student_list(students): """ Call functions to display formatted table with Student object details and row heads as given in variable. """ students = instances_manager.prepare_data_to_visualize(students) titles = ["Idx", "Password", "Name", "Surname", "Email"] codecooler_view.print_table(titles, students)
def get_students_list(): """ Call functions to display formatted table with Student object details """ titles = ["Idx", "Password", "Name", "Surname", "Email"] students = instances_manager.prepare_data_to_visualize(Student.student_list) codecooler_view.print_table(titles, students) get_students_grades()
def show_ranking(): """ Call functions to display students ranking by grades """ rank = student_controller.get_ranking() codecooler_view.print_table(["Name", "Total points"], rank) codecooler_view.state_locker() codecooler_view.clear_window()
def show_assignments(): """ Call functions to display existing Assigment objects in formatted table. """ assignments = [[assign.title] for assign in Assignment.get_assignments_list()] title = ['Assignment title'] codecooler_view.print_table(title, assignments)
def get_students_list(): """ Call functions to display students list as formatted table """ titles = ["Idx", "Password", "Name", "Surname", "Email"] students = instances_manager.prepare_data_to_visualize(Student.student_list) codecooler_view.clear_window() codecooler_view.print_table(titles, students) codecooler_view.state_locker()
def get_mentors_list(lock=False): """ Call functions to display formatted table with all Mentor objects details """ titles = ["Idx", "Password", "Name", "Surname", "Email"] mentors = instances_manager.prepare_data_to_visualize(Mentor.mentor_list) codecooler_view.print_table(titles, mentors) if lock: codecooler_view.state_locker()
def get_students_list(present_student_grades=False): """ Call functions to display formatted table with Student object details Args: present_student_grades (bool): tell if show detail about student grades """ codecooler_view.clear_window() titles = ["Idx", "Password", "Name", "Surname", "Email"] students = instances_manager.prepare_data_to_visualize( Student.student_list) codecooler_view.print_table(titles, students) if present_student_grades: get_students_grades()
def start_controller(name, surname, idx): """ Allow mentor perform assign tasks. Call functions to print menu for user and get input of choosen option. Then call proper function to perform given task. Args: name (string): name of user surname (string): surname of user idx (string): unique user's id """ students = Student.get_students_list() option = None while option != "0": codecooler_view.clear_window() codecooler_view.print_menu("Welcome {} {}".format(name, surname), [ "Students list", "Add assignment", "Grade assignment", "Check attendace", "Edit student", "Student ranking", "Change your password", "Enter talkbox" ], "Exit") option = codecooler_view.get_inputs("Please choose a number", ["Number"])[0] codecooler_view.clear_window() if option == "1": get_students_list(present_student_grades=True) elif option == "2": assignment_controller.start_controller(students) elif option == "3": show_assignments() submit_assignment_controller.start_controller("mentor", idx) elif option == "4": attendance_controller.start_controller(students) elif option == "5": start_student_edit_menu() elif option == "6": rank = student_controller.get_ranking() codecooler_view.print_table(["Name", "Total points"], rank) codecooler_view.state_locker() elif option == "7": codecooler_controller.change_password(idx) elif option == "8": talkbox.start_talkbox(name, surname)
def start_controller(name, surname, idx): """ Allow student user perform assign tasks. Call functions to print menu for user and get input of choosen user_choice Args: name (string): name of user surname (string): surname of user idx (string): unique user's id """ user_choice = None while user_choice != "0": codecooler_view.clear_window() codecooler_view.print_menu("Welcome {} {}".format(name, surname), [ "Submit assignment", "View grades", "Students ranking", "Change your password", "Enter talkbox", "Debt calculator" ], "Exit") user_choice = codecooler_view.get_inputs("Please choose a number", ["Number"])[0] codecooler_view.clear_window() if user_choice == "1": submit_assignment_controller.start_controller("student", idx) elif user_choice == "2": view_grades(idx) elif user_choice == "3": rank = get_ranking() codecooler_view.print_table(["Name", "Total points"], rank) codecooler_view.state_locker() codecooler_view.clear_window() elif user_choice == "4": codecooler_controller.change_password(idx) elif user_choice == "5": talkbox.start_talkbox(name, surname) elif user_choice == "6": show_debt(idx)
def view_grades(idx): """ Allow student to see assigments grades Args: idx (string): unique user's id """ students_grades = [] all_grades = Grade.get_grades_list() for grade in all_grades: if idx == grade.idx and grade.grade != 0: students_grades.append([grade.idx, grade.title, str(grade.grade)]) if len(students_grades) > 0: titles = ["Students idx", "Assignment", "Grade"] codecooler_view.print_table(titles, students_grades) codecooler_view.state_locker() else: codecooler_view.print_result("There is no grades!") sleep(1.5)