mirror of
http://aero2k.de/t/repos/urlbot-native.git
synced 2017-09-06 15:25:38 +02:00
fix config problem, filter on short answers
This commit is contained in:
@@ -21,18 +21,19 @@ def get_questions(directory=None):
|
|||||||
return all_questions
|
return all_questions
|
||||||
|
|
||||||
|
|
||||||
def get_random_question(quizcfg):
|
def get_random_question():
|
||||||
questions = get_questions()
|
with plugin_config('quiz') as quizcfg:
|
||||||
# select a random question
|
questions = get_questions()
|
||||||
used_ids = quizcfg.get('used_ids', [])
|
# select a random question
|
||||||
q_index = None
|
used_ids = quizcfg.get('used_ids', [])
|
||||||
while q_index is None:
|
q_index = None
|
||||||
rand = random.choice(range(0, len(questions)-2, 2))
|
while q_index is None or len(questions[q_index+1].split()) > 2:
|
||||||
if rand not in used_ids:
|
rand = random.choice(range(0, len(questions)-2, 2))
|
||||||
q_index = rand
|
if rand not in used_ids:
|
||||||
|
q_index = rand
|
||||||
|
|
||||||
quizcfg['active_id'] = q_index
|
quizcfg['active_id'] = q_index
|
||||||
quizcfg['used_ids'] = used_ids + [q_index]
|
quizcfg['used_ids'] = used_ids + [q_index]
|
||||||
return questions[q_index], questions[q_index+1]
|
return questions[q_index], questions[q_index+1]
|
||||||
|
|
||||||
|
|
||||||
@@ -134,7 +135,7 @@ def start_random_question():
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
quizcfg["locked"] = True
|
quizcfg["locked"] = True
|
||||||
qa = get_random_question(quizcfg)
|
qa = get_random_question()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'msg': ['Q: {}'.format(qa[0])],
|
'msg': ['Q: {}'.format(qa[0])],
|
||||||
|
|||||||
Reference in New Issue
Block a user