Moved render question function to quiz module
This commit is contained in:
parent
a064bd6b9f
commit
6762226bf2
@ -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
|
||||
|
||||
with open(f'./{data_dir}/{filename}') as file: return json.load(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')
|
||||
|
Loading…
Reference in New Issue
Block a user