Esempio n. 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 _check_attendance(students_attendance, students):
    """
    Create `AttendnaceModel` object with given student id, state and current date.

    Args:
        students_attendance (list of :obj: `AttendanceModels`): list with detail of attendance for all students
        students (list of :obj: `StudentModels`):list with detail of all students

    Examples:
        `AttendnaceModel` object have state as float representing presance of student during class in current day date.
        Presence with it's float value is as follow: Present: 1.0, Not present: 0.0 and Late: 0.8
    """
    current_date = str(date.today())

    for student in students:

        try:
            _vaildate_correct_date(current_date, student, students_attendance)
        except ValueError as err:
            print(err)
            codecooler_view.state_locker()
            continue

        user_choice = None
        attendance_state = None
        check_attendance_person = "Check attendance for {} {}".format(
            student.name, student.surname)

        while user_choice not in ["0", "1", "2", "3"]:
            codecooler_view.print_menu(check_attendance_person,
                                       ["Present", "Not present", "Late"],
                                       "Exit")
            user_choice = codecooler_view.get_inputs("Please choose a number",
                                                     ["Number"])[0]
            attendance_values = {'1': '1.0', '2': '0.0', '3': '0.8'}

            if user_choice in attendance_values:
                attendance_state = attendance_values[user_choice]

            else:
                codecooler_view.print_error_message('Wrong option!')

        if attendance_state:
            student_attendance = AttendanceModel(student.idx, current_date,
                                                 float(attendance_state))
            students_attendance.append(student_attendance)
Esempio n. 4
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)
Esempio n. 5
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)
Esempio n. 6
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)
def start_controller(name, surname, idx):
    """
    Allow office manager perform assign tasks. Call functions to print menu for user
    and get input of choosen option: show students list, students ranking or use talkbox.

    Args:
        name (string): name of user
        surname (string): surname of user
        idx (strung): unique user idx
    """

    user_choice = None

    while user_choice != "0":

        codecooler_view.print_menu("Welcome {} {}".format(name, surname),
                                   ["Show student list", "Students ranking", "Change your password",
                                    "Enter talkbox"], "Exit")
        user_choices = codecooler_view.get_inputs("Please choose a number", ["Number"])
        user_choice = user_choices[0]
        handle_menu(user_choice, idx, name, surname)
Esempio n. 8
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)