Esempio n. 1
0
    def test_check_answer(self):
        answerPartsOriginal = ["* t [keyword1] [keyword2] t", "* t [keyword3] t"]

        answerParts = answerPartsOriginal[:]
        userAnswer = "I like to keyword3"
        isCorrectAnswer = quizlet.check_answer(userAnswer, answerParts)

        self.assertTrue(isCorrectAnswer)
        self.assertEqual(answerParts, [answerPartsOriginal[0]])

        userAnswer = "I like to keyword1"
        isCorrectAnswer = quizlet.check_answer(userAnswer, answerParts)

        self.assertFalse(isCorrectAnswer)
        self.assertEqual(answerParts, [answerPartsOriginal[0]])

        userAnswer = "I like to keyword1 and keyword2"
        isCorrectAnswer = quizlet.check_answer(userAnswer, answerParts)

        self.assertTrue(isCorrectAnswer)
        self.assertEqual(answerParts, [])
Esempio n. 2
0
    def test_check_answer(self):
        answerPartsOriginal = [
            "* t [keyword1] [keyword2] t", "* t [keyword3] t"
        ]

        answerParts = answerPartsOriginal[:]
        userAnswer = "I like to keyword3"
        isCorrectAnswer = quizlet.check_answer(userAnswer, answerParts)

        self.assertTrue(isCorrectAnswer)
        self.assertEqual(answerParts, [answerPartsOriginal[0]])

        userAnswer = "I like to keyword1"
        isCorrectAnswer = quizlet.check_answer(userAnswer, answerParts)

        self.assertFalse(isCorrectAnswer)
        self.assertEqual(answerParts, [answerPartsOriginal[0]])

        userAnswer = "I like to keyword1 and keyword2"
        isCorrectAnswer = quizlet.check_answer(userAnswer, answerParts)

        self.assertTrue(isCorrectAnswer)
        self.assertEqual(answerParts, [])
Esempio n. 3
0
            elif userAnswer == "hint":
                display_hint(answerParts)
            elif userAnswer == "see":
                see_answer_part(answerParts)
                # Force a repeat of this question later, but don't keep
                # appending the same question if the user wants to see more
                # answer parts.
                if(terms[-1] != term):
                    terms.append(term)
            elif userAnswer == "skip":
                break

            ###########################################
            # Check for correct answer if not an option
            ###########################################
            elif(quizlet.check_answer(userAnswer, answerParts)):
                print("Correct!")
            else:
                print("Incorrect")

    print("Finished!")

######################################################
# Begin script execution
######################################################
if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--shuffle", action="store_true", 
            help="shuffle the terms in random order")
    parser.add_argument("--hints", action="store_true", 
            help="always display hints (useful for first learning terms)")