diff --git a/server/app/tools/data.py b/server/app/tools/data.py index a95e3f5..6d44f26 100644 --- a/server/app/tools/data.py +++ b/server/app/tools/data.py @@ -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 - \ No newline at end of file + with open(f'./{data_dir}/{filename}') as file: return json.load(file) \ No newline at end of file diff --git a/server/app/tools/quiz.py b/server/app/tools/quiz.py index ccbdd67..bf4d915 100644 --- a/server/app/tools/quiz.py +++ b/server/app/tools/quiz.py @@ -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')