Exemple #1
0
def view_menu():
    end_prompt = "Press any key to continue"
    print("\nYou are using the file {!s}\n".format(FILE_NAME))

    print("Choose an option by typing the number and pressing RETURN")
    print("\t[1] View class report.")
    print("\t[2] View student report.")
    print("\t[3] View class statistics.")
    print("\t[4] Back to main menu.")

    choice = input("> ")

    if choice == '1':
        ParseXML.print_all_grades(FILE_NAME)
        input(end_prompt)
        view_menu()

    elif choice == '2':
        print("List of students:\n")
        ParseXML.list_students(FILE_NAME)
        print("\nEnter the name of a student, then press RETURN.")
        name = input("> \n")

        if ErrorHandler.is_a_student(name, FILE_NAME):
            ParseXML.one_student_grades(FILE_NAME, name)
            input(end_prompt)
            view_menu()
        else:
            print("{!s} is not a student. Press RETURN to go back to"
                  " menu.".format(name))
            input("")
            view_menu()

    elif choice == '3':
        pass
        # TODO (CREATE STATISTICS)

    elif choice == '4':
        main_menu()
    else:
        print("Invalid selection.")
        view_menu()
Exemple #2
0
def view_menu():
    end_prompt = "Press any key to continue"
    print("\nYou are using the file {!s}\n".format(FILE_NAME))

    print("Choose an option by typing the number and pressing RETURN")
    print("\t[1] View class report.")
    print("\t[2] View student report.")
    print("\t[3] View class statistics.")
    print("\t[4] Back to main menu.")

    choice = input("> ")

    if choice == '1':
        ParseXML.print_all_grades(FILE_NAME)
        input(end_prompt)
        view_menu()

    elif choice == '2':
        print("List of students:\n")
        ParseXML.list_students(FILE_NAME)
        print("\nEnter the name of a student, then press RETURN.")
        name = input("> \n")

        if ErrorHandler.is_a_student(name, FILE_NAME):
            ParseXML.one_student_grades(FILE_NAME, name)
            input(end_prompt)
            view_menu()
        else:
            print("{!s} is not a student. Press RETURN to go back to"
                  " menu.".format(name))
            input("")
            view_menu()

    elif choice == '3':
        pass
        # TODO (CREATE STATISTICS)

    elif choice == '4':
        main_menu()
    else:
        print("Invalid selection.")
        view_menu()