Beispiel #1
0
def start_student_edit_menu():
    """
    Call functions that get user input and show inner menu to modify Student object
    or creat new Student object.

    Args:
        students (list of :obj: Student): list of all students
    """

    user_request = None
    user_welcome = "Student edit manager"
    student_edit_menu = [
        'Add student', 'Delete student', 'Modify student name',
        'Modify student surname', 'Modify student password',
        'Modify student email'
    ]

    while user_request != "0":

        get_students_list(False)

        codecooler_view.print_menu(user_welcome, student_edit_menu, "Exit")
        user_request = codecooler_view.get_inputs("Please choose a number",
                                                  ["Number"])[0]

        handle_student_edit_requests(user_request)

    codecooler_view.clear_window()
def start_controller(students):
    """
    Contain main logic for AttendanceController. Call functions that allow
    mentor check attendance and see student's prevous attendance.

    Args:
        student (:obj: `Student`): object representation of student
    """
    students_attendance = AttendanceModel.get_attendance_list()
    user_choice = None
    menu_options = ["Check attendnace", "View student attendance"]

    while user_choice != "0":
        codecooler_view.clear_window()

        codecooler_view.print_menu("Student's attendance menu", menu_options,
                                   "Exit")
        user_choice = codecooler_view.get_inputs("Please choose a number",
                                                 ["Number"])[0]

        if user_choice == "1":
            _check_attendance(students_attendance, students)

        elif user_choice == "2":
            display_student_list(students)
            choosen_student = codecooler_view.get_inputs(
                "Student attendance detail", ["Student idx"])
            attendance_student_list = _get_attendnace_list(
                students_attendance, choosen_student[0])
            _calculate_attendnace(students_attendance, choosen_student[0])

    codecooler_view.clear_window()
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 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()
Beispiel #5
0
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()
Beispiel #6
0
def get_students_grades():
    """
    Call functions to display detail about choosen student grades
    """

    check_grades = codecooler_view.get_inputs(
        "Do you want to see grades of any student?",
        ["Type \'Yes\' or anything else to go back to menu"])
    check_grades = check_grades[0].lower()
    if check_grades == "yes":
        idx = codecooler_view.get_inputs("Please provide idx of the student",
                                         ["Idx"])[0]
        student_controller.view_grades(idx)

    else:
        codecooler_view.clear_window()
Beispiel #7
0
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)
Beispiel #8
0
def start_mentor_edit_menu():
    """
    Call functions that get user input and show inner menu with options to modification Mentor object
    or creat new Mentor object.
    """

    mentor_edit_menu = ['Add mentor', 'Delete mentor', 'Modify mentor name',
                        'Modify mentor surname', 'Modify mentor password',
                        'Modify mentor email']
    user_welcome = "Mentors edit manager"
    user_request = None

    while user_request != "0":
        codecooler_view.clear_window()
        get_mentors_list()
        codecooler_view.print_menu(user_welcome, mentor_edit_menu, "Exit")
        user_request = codecooler_view.get_inputs("Please choose a number", ["Number"])[0]

        handle_mentor_edit_requests(user_request)
Beispiel #9
0
def start_chat(name):
    """
    Contain logic for talkbox. Call function to print previous 20 massages
    and add new write by user. Also validate if new masseg isn't too long.
    """

    received_message = None

    while received_message != "0":
        talkbox_view.print_chat(TalkBox.get_talkbox()[::-1])
        received_message = talkbox_view.get_message()
        codecooler_view.clear_window()

        if len(received_message) > 70:
            talkbox_view.too_long_message()
            sleep(1.5)

        elif received_message != "0":
            TalkBox.add_message(name, received_message)
Beispiel #10
0
def change_password(idx):
    """
    Allow user to change his password

    Args:
        idx (string): unique id of user
    """

    user = find_user_by_id(idx)
    passes = codecooler_view.get_inputs("Please provide data",
                                        ["Old password", "New password"])

    if passes[0] == user.password:
        user.password = passes[1]
        codecooler_view.print_result("Password changed succesfully!\n")

    else:
        codecooler_view.print_error_message('Wrong old password provided.')

    sleep(1.5)
    codecooler_view.clear_window()
def handle_menu(user_choice, idx, name, surname):
    """
    Contain logic for call functions to perform assign tasks.

    Args:
        user_choice (string): menu option choosen by user
        name (string): name of user
        surname (string): surname of user
        idx (strung): unique user idx
    """

    if user_choice == "1":
        get_students_list()
    elif user_choice == "2":
        show_ranking()
    elif user_choice == "3":
        codecooler_controller.change_password(idx)
    elif user_choice == "4":
        talkbox.start_talkbox(name, surname)

    codecooler_view.clear_window()
Beispiel #12
0
def start_controller(name, surname, idx):
    """
    Call functions that get user input and show menu

    Args:
        name (string): name of user
        surname (string): surname of user
        idx (string): unique user's id
    """

    user_welcome = "Welcome {} {}".format(name, surname)
    main_menu = ['List mentors', 'Edit mentors', 'List Students', "Students ranking",
                 'Change your password', "Enter talkbox"]
    user_request = None

    while user_request != "0":
        codecooler_view.clear_window()
        codecooler_view.print_menu(user_welcome, main_menu, "Exit")
        user_request = codecooler_view.get_inputs("Please choose a number", ["Number"])[0]
        codecooler_view.clear_window()

        handle_main_menu_requests(user_request, idx, name, surname)
Beispiel #13
0
def login():
    """
    Contain logic of user login to program. Create list of all users and check if user login and password are correct.
    """

    found = False
    data_loader.load_data_from_files()
    mergedlist = Student.student_list + Mentor.mentor_list + OfficeManager.office_managers_list + Manager.manager_list

    while not found:
        passes = codecooler_view.get_inputs(
            "Please provide your login and password", ["Login", "Password"])
        idx, password = passes[0], passes[1]

        for ccooler in mergedlist:
            if idx == ccooler.idx and password == ccooler.password:
                codecooler_view.clear_window()
                start_controller(ccooler)
                found = True
                break

        if not found:
            codecooler_view.print_result("Wrong login or password!\n")
Beispiel #14
0
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)