summaryrefslogtreecommitdiff
path: root/routes/create.py
diff options
context:
space:
mode:
Diffstat (limited to 'routes/create.py')
-rw-r--r--routes/create.py42
1 files changed, 25 insertions, 17 deletions
diff --git a/routes/create.py b/routes/create.py
index 0a2a343..36c2521 100644
--- a/routes/create.py
+++ b/routes/create.py
@@ -7,35 +7,43 @@ from routes.tools import rows2dicts, get_alert, get_nick, generate_link, red
@app.route("/pages/create.html")
def create():
if "id" not in session:
- return red["nick"]
+ return render_template(
+ "create.html",
+ caller="create",
+ alert=get_alert()
+ )
if "quiz_id" not in session:
- return red["quiz"]
+ return render_template(
+ "create.html",
+ caller="create",
+ alert=get_alert(),
+ nick=get_nick()
+ )
if D.get_quiz_link(session["quiz_id"]):
- return red["quiz"]
+ return render_template(
+ "create.html",
+ caller="create",
+ alert=get_alert(),
+ nick=get_nick()
+ )
- return render_template("create.html",
+ return render_template(
+ "create.html",
+ caller="create",
alert=get_alert(),
nick=get_nick(),
+ quiz_set=True,
questions=rows2dicts(
D.get_questions(session["quiz_id"]),
['i','q','n','p','a']
)
)
-@app.route("/pages/quiz.html")
-def build():
- if "id" not in session:
- return red["nick"]
- return render_template("quiz.html",
- alert=get_alert(),
- nick=get_nick()
- )
-
@app.route("/set/quiz",methods=["POST"])
def new_quiz():
if not "id" in session.keys():
- session["alert"]="Tarvitset nimimerkin loudaksesi"
- return redirect("/#nick")
+ session["alert"]="Tarvitset nimimerkin loudaksesi."
+ return redirect("/#create")
user_id = session["id"]
session["quiz_id"] = D.quiz_new( user_id )
return redirect("/#create")
@@ -44,7 +52,8 @@ def new_quiz():
@app.route("/set/quiz_ready",methods=["POST"])
def quiz_ready():
if "quiz_id" not in session.keys():
- return "KUOLETTAVA: kyselyä ei ole"
+ session["alert"] = "Kyselmä jota ei ole aloitettu ei voi olla valmis."
+ return redirect("/#create")
if not D.is_user_answered(session["quiz_id"], session["id"]):
session["alert"] = "Tyhjän kyselmän luominen ei käy päinsä!"
return redirect("/#create")
@@ -52,4 +61,3 @@ def quiz_ready():
session["answer_id"] = session["quiz_id"]
D.set_quiz_link(session["quiz_id"], generate_link())
return redirect("/#analyse")
-