diff options
author | Kristina Hänninen <khannine@local> | 2023-11-21 12:52:55 +0200 |
---|---|---|
committer | Kristina Hänninen <khannine@local> | 2023-11-21 12:52:55 +0200 |
commit | 4c5fd0076b4903320ba470ebf0cd454e5f7a2995 (patch) | |
tree | 8765cb09df85d08b4a6207e0dc959901fddcc4b2 /db_actions.py | |
parent | b868d0ba58384fce5a9a45ae153dee9815327d55 (diff) |
Initial anwsering form and related
Diffstat (limited to 'db_actions.py')
-rw-r--r-- | db_actions.py | 11 |
1 files changed, 11 insertions, 0 deletions
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 |