Points for question can be generated randomly now.

- The points each question is worth are generated now.
      To switch back to the old fixed scheme change get_random_points to False
      in the Question() class. That will become a cmd line option in the future.
      I only got until 2:30 pm. :)
    - The range is set in the Question class for now. Each game round will
      get it's own config in the questions.yaml in the future.
This commit is contained in:
Frank Becker 2011-12-18 14:24:32 +01:00
parent b143c4dbc1
commit 97671f43f4
5 changed files with 153 additions and 149 deletions

View File

@ -19,8 +19,8 @@
"text": "> 600 Gy"
}
],
"source": "",
"tier": 100,
"source": false,
"tier": 9,
"image": "data/pix/q_fukushima.jpg"
},
{
@ -43,8 +43,8 @@
"text": "No crime that requires this measurement."
}
],
"source": "",
"tier": 150,
"source": false,
"tier": 10,
"image": "data/pix/q_bundestrojaner.jpg"
},
{
@ -67,8 +67,8 @@
"right": true
}
],
"source": "",
"tier": 225,
"source": false,
"tier": 3,
"image": "data/pix/q_paypal4.jpg"
},
{
@ -91,8 +91,8 @@
"right": true
}
],
"source": "",
"tier": 337,
"source": false,
"tier": 9,
"image": "data/pix/q_russian.jpg"
},
{
@ -116,8 +116,8 @@
"text": "Pakistan"
}
],
"source": "",
"tier": 506,
"source": false,
"tier": 6,
"image": "data/pix/q_cluster.jpg"
},
{
@ -140,8 +140,8 @@
"text": "Degree of expert knowlege that a politician has, when he demands the wiretapping of encrypted data."
}
],
"source": "",
"tier": 759,
"source": false,
"tier": 1,
"image": "data/pix/q_uhl.jpg"
},
{
@ -164,8 +164,8 @@
"right": true
}
],
"source": "",
"tier": 1139,
"source": false,
"tier": 6,
"image": "data/pix/q_cybercrime.png"
},
{
@ -188,8 +188,8 @@
"text": "514 days"
}
],
"source": "",
"tier": 1709,
"source": false,
"tier": 8,
"image": "data/pix/q_belgium.gif"
},
{
@ -212,8 +212,8 @@
"text": "~6k"
}
],
"source": "",
"tier": 2563,
"source": false,
"tier": 1,
"image": "data/pix/q_hadopi.png"
},
{
@ -236,8 +236,8 @@
"text": "Picture taken with 1st digital camera"
}
],
"source": "",
"tier": 3844,
"source": false,
"tier": 8,
"image": "data/pix/q_brain.png"
},
{
@ -260,8 +260,8 @@
"text": "~ 2 weeks"
}
],
"source": "",
"tier": 5555,
"source": false,
"tier": 5,
"image": "data/pix/q_kernel.gif"
},
{
@ -284,8 +284,8 @@
"right": true
}
],
"source": "",
"tier": 7531,
"source": false,
"tier": 2,
"image": "data/pix/q_drone.jpg"
},
{
@ -308,8 +308,8 @@
"text": "By random, during standart maintainance"
}
],
"source": "",
"tier": 0,
"source": false,
"tier": 10,
"image": "data/pix/q_drone2.jpg"
},
{
@ -332,8 +332,8 @@
"text": "Do no evil"
}
],
"source": "",
"tier": 0,
"source": false,
"tier": 6,
"image": "data/pix/q_autocomplete.jpg"
},
{
@ -356,8 +356,8 @@
"right": true
}
],
"source": "",
"tier": 0,
"source": false,
"tier": 6,
"image": "data/pix/q_ca4.jpg"
},
{
@ -380,8 +380,8 @@
"text": ".rss"
}
],
"source": "",
"tier": 0,
"source": false,
"tier": 7,
"image": "data/pix/q_sudan.png"
},
{
@ -404,8 +404,8 @@
"text": "Virgin (by publishing a list of illegal downloaders)"
}
],
"source": "",
"tier": 0,
"source": false,
"tier": 5,
"image": "data/pix/q_london.jpg"
},
{
@ -428,35 +428,8 @@
"text": "Buenos Aires"
}
],
"source": "",
"tier": 0,
"source": false,
"tier": 6,
"image": "data/pix/q_hackspace.jpg"
},
{
"text": "Who was awarded the Pwnie award this year?",
"explanation": [
"data/pix/a_target.jpg"
],
"answers": [
{
"text": "Sony",
"right": true
},
{
"text": "Sony",
"right": true
},
{
"text": "Sony",
"right": true
},
{
"text": "Sony",
"right": true
}
],
"source": "",
"tier": 0,
"image": "data/pix/q_target.png"
}
]

View File

@ -19,9 +19,9 @@
"text": 623
}
],
"source": "",
"tier": 150,
"image": "data/pix/question1.png"
"source": false,
"tier": 1652,
"image": "data/pix/q_wp_pornstars.png"
},
{
"text": "How many user-related data records (name, address, birth date) did the Saxon State retriev after it cought about > 1 mio cell phone connection records?",
@ -43,8 +43,8 @@
"text": "940k"
}
],
"source": "",
"tier": 225,
"source": false,
"tier": 135,
"image": "data/pix/question1.png"
},
{
@ -67,8 +67,8 @@
"text": "denied his account"
}
],
"source": "",
"tier": 337,
"source": false,
"tier": 1342,
"image": "data/pix/question1.png"
},
{
@ -91,8 +91,8 @@
"right": true
}
],
"source": "",
"tier": 506,
"source": false,
"tier": 954,
"image": "data/pix/question1.png"
},
{
@ -115,8 +115,8 @@
"text": "It fucks up documents just as well."
}
],
"source": "",
"tier": 759,
"source": false,
"tier": 1514,
"image": "data/pix/question1.png"
},
{
@ -139,8 +139,8 @@
"text": "$50 mio"
}
],
"source": "",
"tier": 1139,
"source": false,
"tier": 1074,
"image": "data/pix/question1.png"
},
{
@ -163,8 +163,8 @@
"text": "Huawei"
}
],
"source": "",
"tier": 1709,
"source": false,
"tier": 918,
"image": "data/pix/question1.png"
},
{
@ -187,8 +187,8 @@
"text": "$500 mio"
}
],
"source": "",
"tier": 2563,
"source": false,
"tier": 1549,
"image": "data/pix/question1.png"
},
{
@ -211,8 +211,8 @@
"text": "proprietary"
}
],
"source": "",
"tier": 3844,
"source": false,
"tier": 921,
"image": "data/pix/question1.png"
}
]

View File

@ -19,8 +19,8 @@
"text": "bungling"
}
],
"source": "",
"tier": 100,
"source": false,
"tier": 2278,
"image": "data/pix/question1.png"
},
{
@ -43,8 +43,8 @@
"text": "Chile"
}
],
"source": "",
"tier": 150,
"source": false,
"tier": 2599,
"image": "data/pix/question1.png"
},
{
@ -67,8 +67,8 @@
"right": true
}
],
"source": "",
"tier": 225,
"source": false,
"tier": 2033,
"image": "data/pix/question1.png"
},
{
@ -91,8 +91,8 @@
"text": "Conterfai Lugary"
}
],
"source": "",
"tier": 337,
"source": false,
"tier": 1178,
"image": "data/pix/van_gogh_ipad.jpg"
},
{
@ -115,8 +115,8 @@
"text": "to protect democracy"
}
],
"source": "",
"tier": 759,
"source": false,
"tier": 2616,
"image": "data/pix/question1.png"
},
{
@ -139,8 +139,8 @@
"text": "Geo-tracking"
}
],
"source": "",
"tier": 1139,
"source": false,
"tier": 2286,
"image": "data/pix/question1.png"
},
{
@ -163,8 +163,8 @@
"right": true
}
],
"source": "",
"tier": 1709,
"source": false,
"tier": 2478,
"image": "data/pix/question1.png"
},
{
@ -187,8 +187,8 @@
"text": "Emacs"
}
],
"source": "",
"tier": 3844,
"source": false,
"tier": 3577,
"image": "data/pix/question1.png"
}
]

View File

@ -19,8 +19,8 @@
"text": "Oracle"
}
],
"source": "",
"tier": 100,
"source": false,
"tier": 25,
"image": "data/pix/orgchart-ms.png"
},
{
@ -43,8 +43,8 @@
"right": true
}
],
"source": "",
"tier": 150,
"source": false,
"tier": 26,
"image": "data/pix/question1.png"
},
{
@ -67,8 +67,8 @@
"text": "Dennis Ritchie"
}
],
"source": "",
"tier": 337,
"source": false,
"tier": 10,
"image": "data/pix/question1.png"
},
{
@ -91,8 +91,8 @@
"text": "Dennis Ritchie"
}
],
"source": "",
"tier": 506,
"source": false,
"tier": 55,
"image": "data/pix/question1.png"
},
{
@ -115,8 +115,8 @@
"text": "Dennis Ritchie"
}
],
"source": "",
"tier": 759,
"source": false,
"tier": 62,
"image": "data/pix/question1.png"
},
{
@ -140,7 +140,7 @@
}
],
"source": "http://themoderatevoice.com/114102/americas-rejection-of-evolution-reflected-in-miss-usa-pageant/",
"tier": 1139,
"tier": 18,
"image": "data/pix/question1.png"
},
{
@ -163,8 +163,8 @@
"right": true
}
],
"source": "",
"tier": 1709,
"source": false,
"tier": 43,
"image": "data/pix/question1.png"
},
{
@ -187,8 +187,8 @@
"text": "dog"
}
],
"source": "",
"tier": 2563,
"source": false,
"tier": 10,
"image": "data/pix/question1.png"
},
{
@ -211,8 +211,8 @@
"text": "dog"
}
],
"source": "",
"tier": 3844,
"source": false,
"tier": 53,
"image": "data/pix/question1.png"
},
{
@ -235,8 +235,35 @@
"text": "dog"
}
],
"source": "",
"tier": 5555,
"source": false,
"tier": 57,
"image": "data/pix/question1.png"
},
{
"text": "Who was awarded the Pwnie award this year?",
"explanation": [
"data/pix/a_target.jpg"
],
"answers": [
{
"text": "Sony",
"right": true
},
{
"text": "Sony",
"right": true
},
{
"text": "Sony",
"right": true
},
{
"text": "Sony",
"right": true
}
],
"source": false,
"tier": 23,
"image": "data/pix/q_target.png"
}
]

View File

@ -26,6 +26,7 @@ __license__ = "Python"
import os
import sys
import random
import json
from optparse import OptionParser
@ -41,39 +42,17 @@ class Question(yaml.YAMLObject):
yaml_tag = u"!Question"
web_root = "data"
# {round_no1: [tier1, tier2, ...], round_no2: [tier1, ...]}
registered_questions = {}
points_fixed = {
1: 100,
2: 150,
3: 225,
4: 337,
5: 506,
6: 759,
7: 1139,
8: 1709,
9: 2563,
10: 3844,
11: 5555,
12: 7531,
}
points_rnd_by_round = {
1: 100,
2: 150,
3: 225,
4: 337,
5: 506,
6: 759,
7: 1139,
8: 1709,
9: 2563,
10: 3844,
11: 5555,
12: 7531,
# Generate random points in range of points_per_round
gen_random_points = True
points_per_round = {
1: (1, 10),
2: (100, 2000),
3: (50, 4000),
4: (5, 80),
}
# kinda a symlink to the points generating dict
points = points_rnd_by_round
# {round_no1: [tier1, tier2, ...], round_no2: [tier1, ...]}
registered_questions = {}
def __init__(self, question=u"", tier=0, answers=[], game_round=0,
media=("", "", ""), media_path="data", web_root="data"):
@ -116,13 +95,38 @@ class Question(yaml.YAMLObject):
"""docstring for __repr__"""
return "%s(%r)" % (self.__class__.__name__, self.question)
def _get_points(self, game_round, tier):
"""returns the points by game_round/tier combo"""
points_fixed = {
1: 100,
2: 150,
3: 225,
4: 337,
5: 506,
6: 759,
7: 1139,
8: 1709,
9: 2563,
10: 3844,
11: 5555,
12: 7531,
}
if not self.gen_random_points:
return points_fixed.get(tier, 0)
range = self.points_per_round.get(game_round)
points = random.randint(*range)
return points
@property
def as_dict(self):
"""dump data suiteable for json conversion"""
data = {}
data['text'] = self.question
data['tier'] = self.points.get(int(self.tier), 0)
data['tier'] = self._get_points(int(self.game_round), int(self.tier))
try:
data['source'] = self.source
except AttributeError: