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 /question.py | |
parent | 4724a8667371abcf8b0a5a7355a7c2588841c135 (diff) |
Questions now shows up. DB -> JSON -> JS -> DOM
Diffstat (limited to 'question.py')
-rw-r--r-- | question.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/question.py b/question.py index e7494bc..96673c2 100644 --- a/question.py +++ b/question.py @@ -4,9 +4,13 @@ import db_actions as D def validate_answer(ans): + if len(ans)<1: + return False return True def validate_question(question): + if len(question)<2: + return False return True @app.route("/new_question",methods=["POST"]) @@ -18,9 +22,9 @@ def new_question(): if not validate_question(question): msg = "Kysymys on virheellinen" elif not validate_answer(neg_ans): - msg = "Vasen selite virheellinen" + msg = "Vasen selite on virheellinen" elif not validate_answer(pos_ans): - msg = "Oikea selite virheellinen" + msg = "Oikea selite on virheellinen" elif "id" not in session.keys(): msg = "Tarvitaan nimimerkki" elif "quiz_id" not in session.keys(): @@ -34,5 +38,3 @@ def new_question(): return redirect("/#create") session["alert"]="Kysymystä ei luotu: "+msg return redirect("/#create") - - |