summaryrefslogtreecommitdiff
path: root/db_actions.py
diff options
context:
space:
mode:
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