summaryrefslogtreecommitdiff
path: root/routes/set/answers.py
diff options
context:
space:
mode:
authorJani Peter Karhunen <jkarhun2@local>2023-11-25 03:32:29 +0200
committerJani Peter Karhunen <jkarhun2@local>2023-11-25 03:32:29 +0200
commitd2de3ae10b6f5314bd4b8243218212d2004f35b0 (patch)
tree2ab448e0c2ec361478851dbcb43bcd176d17b584 /routes/set/answers.py
parentc059696450d301b99956d643c21b0e46b4fc39dc (diff)
MEGA Commit. Rework of routing. Visuals. Answer analysis and much more.
Diffstat (limited to 'routes/set/answers.py')
-rw-r--r--routes/set/answers.py32
1 files changed, 0 insertions, 32 deletions
diff --git a/routes/set/answers.py b/routes/set/answers.py
deleted file mode 100644
index 859d65c..0000000
--- a/routes/set/answers.py
+++ /dev/null
@@ -1,32 +0,0 @@
-from app import app
-from flask import render_template, session, request, redirect
-import db_actions as D
-
-def validate_answer(ans):
- if len(ans)<1:
- return False
- try:
- value=int(ans)
- if value<0 or value>1000:
- return False
- except ValueError:
- return False
- return True
-
-@app.route("/set/answers",methods=["POST"])
-def set_answers():
- if "id" not in session.keys():
- return "KUOLETTAVA: Nimimerkkiä ei ole vielä valittu!"
- if "quiz_id" not in session.keys():
- return "KUOLETTAVA: Yrität vastata kyselyyn ilman sen valintaa!"
-
- user_id = session["id"]
- for id, answer in request.form.items():
- question_id = int(id)
- if not validate_answer(answer):
- return "KUOLETTAVA: Epäkelpo vastaus!"
- if D.get_user_answer(user_id,question_id):
- return "KUOLETTAVA: On jo vastattu!"
- D.answer_new(user_id, question_id, answer)
-
- return redirect("/#analyse")