From 6762226bf267b2bc6cf1ac3604f39a06f912ec0d Mon Sep 17 00:00:00 2001 From: Vivek Santayana Date: Mon, 29 Aug 2022 17:09:29 +0100 Subject: [PATCH] Moved render question function to quiz module --- server/app/tools/data.py | 14 +++----------- server/app/tools/quiz.py | 8 ++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) 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')