diff options
author | Tuomas Klavér <tklavr@local> | 2023-11-20 02:04:12 +0200 |
---|---|---|
committer | Tuomas Klavér <tklavr@local> | 2023-11-20 02:04:12 +0200 |
commit | d13d4860f3d5b51d659379aa8a38742bfe49bf37 (patch) | |
tree | eaf65876d9a4497f282dab300007338144c53001 /db_actions.py | |
parent | 4724a8667371abcf8b0a5a7355a7c2588841c135 (diff) |
Questions now shows up. DB -> JSON -> JS -> DOM
Diffstat (limited to 'db_actions.py')
-rw-r--r-- | db_actions.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/db_actions.py b/db_actions.py index fca9ab0..b604870 100644 --- a/db_actions.py +++ b/db_actions.py @@ -76,3 +76,13 @@ def answer_new(user_id, question_id, answer): "created":int(time()) } ) db.session.commit() + +def get_questions(quiz_id): + sql = "SELECT q.id, q.question, q.neg_answer, q.pos_answer, a.answer \ + FROM questionaires quiz \ + JOIN questions q ON q.id = ANY(quiz.questionset) \ + JOIN answers a ON a.user_id = quiz.creator_id \ + WHERE a.question_id = q.id AND quiz.id = (:quiz_id);" + return db.session.execute( text(sql), { "quiz_id":quiz_id } ).fetchall() + +
\ No newline at end of file |