コード例 #1
0
ファイル: RunQuiz.py プロジェクト: MegenisJ/DQSQuiz-
def MainMenu():
    if Verify() == True:
        Setup.enterSchool()
        #Setup.select_topic()
    settings = Setup.load_settings()
    QuestionList = ReadQuestionList()
    while True:
        print("Main Menu")
        print("1. Run Quiz")
        print("2. Change/ Delete Questions")
        print("3. Add new Question")
        print("4. Change topic")
        print("5. Add to list of schools attending")
        print("6. Stats")
        print("7. Exit")
        #print("4. View Stats")
        menu = input()
        #ReadQuestionList()
        if menu == "1":  #run quiz

            settings = Setup.load_settings()
            Topic = Setup.select_topic()
            UserQuiz = Quiz(Topic)

            UserQuiz.TakeQuiz(Topic)

        elif menu == "2":  #Alice Change / Delete Questions
            if Verify() == True:
                QuestionList = ReadQuestionList()
                AmendQuestions.main()

        elif menu == "3":  # Add a new question
            if Verify() == True:
                AddQuestion(QuestionList)
        elif menu == "4":  #Change the topic
            if Verify() == True:
                Topic = Setup.select_topic()
        elif menu == "5":  #change attending schools
            if Verify() == True:
                Setup.enterSchool()
        elif menu == "6":
            if Verify() == True:
                for q in QuestionList:
                    with open('questions.csv', 'r') as csvfile:
                        rdr = csv.reader(csvfile)
                        for row in rdr:
                            print("Question " + row[0])
                            s = Stats(int(row[8]), int(row[9]), int(row[10]))
                            pc = s.CalcPercentCorrect()
                            pq = s.CalcPercentQuit()
                            print("Percentage of time answered correct: " +
                                  str(pc))
                            print(
                                "Percentage of time quiz is quit on this question: "
                                + str(pq))

        elif menu == "7":
            break
            #False
        else:
            print("invalid input")