{
"prompt": "What is your quest?",
"answer": "To seek the Holy Grail",
- "hint": "Think like a Pythonista"
+ "hint": "Think like a Pythonista",
+ "dependencies": [
+ "What is your name?"
+ ]
},
{
"prompt": "What is your favourite color?",
"answer": "Blue",
- "hint": "Channel Sir Lancelot"
+ "hint": "Channel Sir Lancelot",
+ "dependencies": [
+ "What is your quest?"
+ ]
},
{
"prompt": "What is the capital of Assyria?",
"answer": "I don't know that",
- "hint": "Sir Robin didn't know it either"
+ "hint": "Sir Robin didn't know it either",
+ "dependencies": [
+ "What is your quest?"
+ ]
}
]
}
class Question (object):
- def __init__(self, id=None, prompt=None, answer=None, help=None):
+ def __init__(self, id=None, prompt=None, answer=None, help=None,
+ dependencies=None):
if id is None:
id = prompt
self.id = id
self.prompt = prompt
self.answer = answer
self.help = help
+ if dependencies is None:
+ dependencies = []
+ self.dependencies = dependencies
def __getstate__(self):
return {
'prompt': self.prompt,
'answer': self.answer,
'help': self.help,
+ 'dependencies': self.dependencies,
}
def __setstate__(self, state):
if 'id' not in state:
state['id'] = state.get('prompt', None)
+ if 'dependencies' not in state:
+ state['dependencies'] = []
self.__dict__.update(state)
def check(self, answer):