From 4c5fd0076b4903320ba470ebf0cd454e5f7a2995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristina=20H=C3=A4nninen?= Date: Tue, 21 Nov 2023 12:52:55 +0200 Subject: Initial anwsering form and related --- db_actions.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'db_actions.py') diff --git a/db_actions.py b/db_actions.py index b604870..5a76b00 100644 --- a/db_actions.py +++ b/db_actions.py @@ -85,4 +85,15 @@ def get_questions(quiz_id): WHERE a.question_id = q.id AND quiz.id = (:quiz_id);" return db.session.execute( text(sql), { "quiz_id":quiz_id } ).fetchall() + +def get_user_answer(user_id, question_id): + sql = "SELECT answer \ + FROM answers \ + WHERE question_id = (:question_id) AND user_id = (:user_id);" + result = db.session.execute( text(sql), { + 'question_id': question_id, + 'user_id': user_id + } ).fetchone() + return result[0] if result else result + \ No newline at end of file -- cgit v1.2.3