Generate one json file per game round
- Now one json file is generated per game round and printed to stdout (for now, will be files later on)
This commit is contained in:
parent
bb865905bf
commit
e7a885048d
|
@ -13,7 +13,6 @@ readeable format assuming yaml is more human readable
|
|||
TODO:
|
||||
* Add own constructor to Question() / nice to have
|
||||
* Deal with media files
|
||||
* Fix to output only questions per round as json
|
||||
"""
|
||||
|
||||
__author__ = "Frank Becker <fb@alien8.de>"
|
||||
|
@ -160,6 +159,10 @@ def init_parser():
|
|||
options = parser.parse_args()[0]
|
||||
return options
|
||||
|
||||
def questions_per_round(questions, game_round=None):
|
||||
"""docstring for questions_per_round"""
|
||||
return [q for q in questions if q.game_round == game_round]
|
||||
|
||||
def main():
|
||||
"""docstring for main"""
|
||||
|
||||
|
@ -181,7 +184,12 @@ def main():
|
|||
questions.append(q)
|
||||
if options.debug:
|
||||
print Question.registered_questions
|
||||
print json.dumps([q.as_dict for q in questions], indent=2)
|
||||
|
||||
game_rounds = sorted(Question.registered_questions.keys())
|
||||
for r in game_rounds:
|
||||
print json.dumps([q.as_dict for q in questions_per_round(
|
||||
questions, game_round=r)], indent=2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
#--- !Question
|
||||
#question: What is the question?
|
||||
#answers:
|
||||
# - Answer 1
|
||||
# - Answer 2
|
||||
# - Answer 3
|
||||
# - Answer 4
|
||||
#tier: 1
|
||||
#game_round: 1
|
||||
#media:
|
||||
# - aaa
|
||||
# - bbb
|
||||
# - ccc
|
||||
|
||||
!!python/object:__main__.Question
|
||||
question: What is the question?
|
||||
answers:
|
||||
- true: Answer 1
|
||||
- false: Answer 2
|
||||
- false: Answer 3
|
||||
- false: Answer 4
|
||||
tier: 1
|
||||
game_round: 1
|
||||
media:
|
||||
- pix/question1.png
|
||||
- pix/question1_big.png
|
||||
- videos/question1.webm
|
||||
|
||||
--- !Question
|
||||
question: What are users in Facebook called?
|
||||
answers:
|
||||
- false: Hostage
|
||||
- false: Victims
|
||||
- true: Target
|
||||
- false: Product
|
||||
tier: 2
|
||||
game_round: 1
|
||||
media:
|
||||
- pix/facebook.jpg
|
||||
- pix/facebook-jail.png
|
||||
- videos/faschistbook.webm
|
||||
|
||||
--- !Question
|
||||
question: What are users in Facebook called?
|
||||
answers:
|
||||
- false: Hostage
|
||||
- false: Victims
|
||||
- true: Target
|
||||
- false: Product
|
||||
tier: 2
|
||||
game_round: 2
|
||||
media:
|
||||
- pix/facebook.jpg
|
||||
- pix/facebook-jail.png
|
||||
- videos/faschistbook.webm
|
Loading…
Reference in New Issue