fix config problem, filter on short answers

This commit is contained in:
Thorsten
2016-01-31 22:22:41 +01:00
parent f51a34028f
commit 75f169c6c6

View File

@@ -21,12 +21,13 @@ def get_questions(directory=None):
return all_questions return all_questions
def get_random_question(quizcfg): def get_random_question():
with plugin_config('quiz') as quizcfg:
questions = get_questions() questions = get_questions()
# select a random question # select a random question
used_ids = quizcfg.get('used_ids', []) used_ids = quizcfg.get('used_ids', [])
q_index = None q_index = None
while q_index is None: while q_index is None or len(questions[q_index+1].split()) > 2:
rand = random.choice(range(0, len(questions)-2, 2)) rand = random.choice(range(0, len(questions)-2, 2))
if rand not in used_ids: if rand not in used_ids:
q_index = rand q_index = rand
@@ -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])],