Moved render question function to quiz module

This commit is contained in:
Vivek Santayana 2022-08-29 17:09:29 +01:00
parent a064bd6b9f
commit 6762226bf2
2 changed files with 11 additions and 11 deletions

View File

@ -4,19 +4,11 @@ import json
from os.path import isfile
from pathlib import Path
def check_file(filename:str):
def check_file(filename:str) -> bool:
data_dir = Path(app.config.get('DATA'))
if isfile(f'./{data_dir}/{filename}'): return True
return False
def load(filename:str):
def load(filename:str) -> dict:
data_dir = Path(app.config.get('DATA'))
with open(f'./{data_dir}/{filename}') as file: return json.load(file)
def render_questions():
data = load('questions.json')
for question in data:
_answers = [ answer['text'] for answer in question['answers'] ]
question['answers'] = _answers
return data

View File

@ -1,5 +1,13 @@
from .data import load
def render_questions() -> list:
data = load('questions.json')
for question in data:
_answers = [ answer['text'] for answer in question['answers'] ]
question['answers'] = _answers
question.pop('max', None)
return data
def evaluate_answers(answers:list) -> dict:
playbooks = load('playbooks.json')
questions = load('questions.json')