summaryrefslogtreecommitdiff
path: root/db_actions.py
diff options
context:
space:
mode:
authorKristina Hänninen <khannine@local>2023-11-21 12:52:55 +0200
committerKristina Hänninen <khannine@local>2023-11-21 12:52:55 +0200
commit4c5fd0076b4903320ba470ebf0cd454e5f7a2995 (patch)
tree8765cb09df85d08b4a6207e0dc959901fddcc4b2 /db_actions.py
parentb868d0ba58384fce5a9a45ae153dee9815327d55 (diff)
Initial anwsering form and related
Diffstat (limited to 'db_actions.py')
-rw-r--r--db_actions.py11
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