wanderhome-quiz/server/app/views.py

25 lines
592 B
Python
Raw Normal View History

2022-08-29 17:09:07 +01:00
from .tools.data import check_file, load
from .tools.quiz import compile_results, evaluate_answers, render_questions
2022-08-24 15:55:53 +01:00
2022-08-29 17:09:07 +01:00
from flask import Blueprint, jsonify, request
2022-08-24 15:55:53 +01:00
from flask.helpers import abort
views = Blueprint(
name='views',
import_name=__name__
)
2022-08-31 00:48:13 +01:00
@views.route('/questions/')
def _questions():
return render_questions()
2022-08-24 15:55:53 +01:00
2022-08-29 17:09:07 +01:00
@views.route('/submit/', methods=['POST'])
2022-08-24 15:55:53 +01:00
def _submit():
2022-08-29 17:09:07 +01:00
answers = request.json
scores = evaluate_answers(answers)
results = compile_results(results=scores)
return jsonify(results)
2022-08-24 15:55:53 +01:00
2022-08-29 17:09:07 +01:00
@views.route('/results/')
2022-08-24 15:55:53 +01:00
def _results():
pass