diff options
Diffstat (limited to 'routes')
-rw-r--r-- | routes/analyse.py | 12 | ||||
-rw-r--r-- | routes/answer.py | 8 | ||||
-rw-r--r-- | routes/create.py | 4 | ||||
-rw-r--r-- | routes/question.py | 4 |
4 files changed, 14 insertions, 14 deletions
diff --git a/routes/analyse.py b/routes/analyse.py index 7f968d0..152a189 100644 --- a/routes/analyse.py +++ b/routes/analyse.py @@ -4,7 +4,7 @@ from flask import render_template,session,request,redirect from routes.tools import rows2dicts, get_alert, get_nick, csrf_check def find_best_and_worst(aid, uid): - answers=D.get_all_answers_for_quiz(aid) + answers=D.quiz.answers(aid) alist=rows2dicts( answers, ['q','u','a'] ) questions = set(x['q'] for x in alist) users = set(x['u'] for x in alist) @@ -54,7 +54,7 @@ def analyse(): alert=get_alert() ) - if "answer_id" in session and D.is_user_answered(session["answer_id"],sid): + if "answer_id" in session and D.quiz.user(session["answer_id"],sid): aid = session["answer_id"] else: return render_template( @@ -65,13 +65,13 @@ def analyse(): ) uid1 = session["anal_user1"] if "anal_user1" in session else sid - uid1 = sid if uid1 != sid and not D.is_user_answered(aid,uid1) else uid1 + uid1 = sid if uid1 != sid and not D.quiz.user(aid,uid1) else uid1 uid2 = session["anal_user2"] if "anal_user2" in session else sid - uid2 = sid if uid2 != sid and not D.is_user_answered(aid,uid2) else uid2 + uid2 = sid if uid2 != sid and not D.quiz.user(aid,uid2) else uid2 - comparable = D.get_comparable( aid, uid1, uid2 ) + comparable = D.analyse.comparable( aid, uid1, uid2 ) avg=0 for i in range(len(comparable)): avg += comparable[i][5] @@ -84,7 +84,7 @@ def analyse(): nick=get_nick(), code=D.quiz.get_link(aid), questions = rows2dicts( comparable, ['q','n','p','a1','a2','c'] ), - users = rows2dicts( D.get_users_answered(aid), ['id','nick'] ), + users = rows2dicts( D.quiz.users(aid), ['id','nick'] ), user1=int(uid1), user2=int(uid2), avg = avg, diff --git a/routes/answer.py b/routes/answer.py index f3a506c..2307a83 100644 --- a/routes/answer.py +++ b/routes/answer.py @@ -63,7 +63,7 @@ def answer(): nick = get_nick() ) - if D.is_user_answered(aid, sid): + if D.quiz.user(aid, sid): return render_template( "answer.html", caller = "answer", @@ -76,7 +76,7 @@ def answer(): caller = "answer", alert = get_alert(), nick = get_nick(), - questions = rows2dicts( D.get_questions(aid), ['i','q','n','p'] ), + questions = rows2dicts( D.quiz.questions(aid), ['i','q','n','p'] ), link = D.quiz.get_link( aid ) ) @@ -99,7 +99,7 @@ def set_answers(): if int(answer) < 0 or int(answer) > 999: session["alert"]="Luvattoman pieniä tai suuria lukuja!" return redirect( "/#answer" ) - elif D.get_user_answer(int(sid), int(question)) != -1: + elif D.answer.get(int(sid), int(question)) != -1: session["alert"]="Kyselyyn olikin jo saatu vastauksia." return redirect( "/#answer" ) except ValueError: @@ -109,6 +109,6 @@ def set_answers(): for question, answer in request.form.items(): if question=="csrf": continue - D.answer_new(int(sid), int(question), int(answer)) + D.answer.new(int(sid), int(question), int(answer)) return redirect("/#analyse") diff --git a/routes/create.py b/routes/create.py index 7322079..d2701a2 100644 --- a/routes/create.py +++ b/routes/create.py @@ -33,7 +33,7 @@ def create(): nick=get_nick(), quiz_set=True, questions=rows2dicts( - D.get_questions(session["quiz_id"]), + D.quiz.questions(session["quiz_id"]), ['i','q','n','p','a'] ) ) @@ -57,7 +57,7 @@ def quiz_ready(): if "quiz_id" not in session.keys(): 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"]): + if not D.quiz.user(session["quiz_id"], session["id"]): session["alert"] = "Tyhjän kyselmän luominen ei käy päinsä!" return redirect("/#create") quiz_id = session["quiz_id"] diff --git a/routes/question.py b/routes/question.py index 9ddb527..6965529 100644 --- a/routes/question.py +++ b/routes/question.py @@ -45,8 +45,8 @@ def new_question(): session["alert"] = "Vastauksessasi on nyt jotain häikkää." return redirect("/#question") - question_id = D.question_new( question, neg_ans, pos_ans ) + question_id = D.question.new( question, neg_ans, pos_ans ) D.quiz.add(qid, question_id) - D.answer_new(sid, question_id, answer) + D.answer.new(sid, question_id, answer) return redirect("/#create") |