From: W. Trevor King Date: Tue, 5 Feb 2013 18:54:18 +0000 (-0500) Subject: question: Add ChoiceQuestion for one-of-several correct answers X-Git-Tag: v0.1~55 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=52ce4bb8bc6c9d0c5b5115ed48eab9f7d6b75f49;p=quizzer.git question: Add ChoiceQuestion for one-of-several correct answers --- diff --git a/quizzer/question.py b/quizzer/question.py index 2dd57e9..34fe8c1 100644 --- a/quizzer/question.py +++ b/quizzer/question.py @@ -58,6 +58,11 @@ class NormalizedStringQuestion (Question): return self.normalize(answer) == self.normalize(self.answer) +class ChoiceQuestion (Question): + def check(self, answer): + return answer in self.answer + + class ScriptQuestion (Question): _state_attributes = Question._state_attributes + [ 'interpreter', diff --git a/quizzes/monty-python.json b/quizzes/monty-python.json index 894105e..13d6210 100644 --- a/quizzes/monty-python.json +++ b/quizzes/monty-python.json @@ -2,8 +2,12 @@ "version": "0.1", "questions": [ { + "class": "ChoiceQuestion", "prompt": "What is your name?", - "answer": "", + "answer": [ + "Sir Lancelot", + "Sir Robin" + ], "help": "This should be easy" }, {