From 5b75e095f668790a222e1f22b65d967396ff0249 Mon Sep 17 00:00:00 2001 From: Samuel Hoffman Date: Tue, 28 Jan 2020 10:55:56 -0500 Subject: [PATCH] /api/v1/questions/final - allow only checking final answer if a boolean 'checkOnly' property is present in the JSON body and is true, the endpoint will respond with correct/incorrect but will not record the answer in the database. --- CodeChallenge/api/questions.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CodeChallenge/api/questions.py b/CodeChallenge/api/questions.py index fa5a83d..4b8d733 100644 --- a/CodeChallenge/api/questions.py +++ b/CodeChallenge/api/questions.py @@ -228,6 +228,10 @@ def answer_eval(): correct = str_cmp(eval_output, q.answer) + if request.json.get("checkOnly", False): + return jsonify(correct=correct, + status="success") + ans = Answer.query.filter_by(user_id=user.id, question_id=q.id).first() if ans is None: