From d13d4860f3d5b51d659379aa8a38742bfe49bf37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tuomas=20Klav=C3=A9r?= Date: Mon, 20 Nov 2023 02:04:12 +0200 Subject: Questions now shows up. DB -> JSON -> JS -> DOM --- db_actions.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'db_actions.py') 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 -- cgit v1.2.3