Added database actions in view

This commit is contained in:
Vivek Santayana 2022-08-31 01:19:15 +01:00
parent 713c6beb48
commit 5c30a974a6

View File

@ -1,3 +1,4 @@
from .models import Entry
from .tools.data import check_file, load from .tools.data import check_file, load
from .tools.quiz import compile_results, evaluate_answers, render_questions from .tools.quiz import compile_results, evaluate_answers, render_questions
@ -20,6 +21,8 @@ def _submit():
answers = request.json answers = request.json
scores = evaluate_answers(answers) scores = evaluate_answers(answers)
results = compile_results(results=scores) results = compile_results(results=scores)
new_entry = Entry(answers=answers, results=results)
new_entry.add()
return jsonify(results) return jsonify(results)
@views.route('/results/') @views.route('/results/')