Skip to content
Snippets Groups Projects
Commit 0667c19e authored by leo's avatar leo
Browse files

~fast fertig

parent 34f70ff8
No related branches found
No related tags found
1 merge request!1V2
...@@ -9,6 +9,6 @@ class BaseModel(Model): ...@@ -9,6 +9,6 @@ class BaseModel(Model):
class Meta(): class Meta():
database = sqlite database = sqlite
from model.base import Question, Answer from model.base import Question, Answer, Submit
sqlite.create_tables([Question, Answer]) sqlite.create_tables([Question, Answer, Submit])
\ No newline at end of file \ No newline at end of file
...@@ -6,12 +6,12 @@ class Question(BaseModel): ...@@ -6,12 +6,12 @@ class Question(BaseModel):
text = CharField() text = CharField()
class Submit(BaseModel):
token = CharField()
class Answer(BaseModel): class Answer(BaseModel):
text = CharField() text = CharField()
question = ForeignKeyField(Question, backref="answers") question = ForeignKeyField(Question, backref="answers")
submit = ForeignKeyField(Submit, backref="answers")
class Submit(BaseModel):
\ No newline at end of file
No preview for this file type
static/LNP300_blue.jpg

19.8 KiB

static/LNP300_green.jpg

20.3 KiB

File added
static/LNP300_green.png

35.1 KiB

File added
@font-face { font-family: PressStart2P; src: url('../../static/PressStart2P-Regular.ttf'); }
.vertical-center {
min-height: 100%; /* Fallback for browsers do NOT support vh unit */
min-height: 100vh; /* These two lines are counted as one :-) */
display: flex;
align-items: center;
}
.my-auto {
margin-top: auto;
margin-bottom: auto;
}
.hor-cent {
margin: 0 auto;
border-radius: 10px;
width: 40%;
background-color: black;
color: white;
position: relative;
}
.imgplacer {
margin: 0 auto;
width: 50%;
}
img {
width: 100%;
}
.fw {
width: 100%;
}
.ccc-blue{
color: #0084b0;
}
.ccc-green{
color: #00a356;
}
.white{
color: white;
}
body {
background-color: #232323;
font-family: PressStart2P;
}
@media (max-width: 1275.98px) {
.hor-cent {
width:90%;
}
.imgplacer {
width: 60%;
}
}
{% extends "main.jinja" %}
{% block content%}
{{message}}
{% endblock %}
\ No newline at end of file
<html>
<head></head>
<body>
<form action="/submit" method="POST">
{% for quest in questions %}
{% set questid = quest.id %}
{% set questtext = quest.text %}
{{ questtext }}
<br>
<input type="hidden" name="question_ids[]" value="{{questid}}"/>
<input type="text" name="{{questid}}" value="">
<br><br>
{% endfor %}
<input type="submit" value="Submit">
</form>
</body>
</html>
\ No newline at end of file
{% extends "main.jinja" %}
{% block content%}
Trage hier deine Antworten ein:<br><br>
<form action="/submit" method="POST">
{% for quest in questions %}
{% set questid = quest.id %}
{% set questtext = quest.text %}
{{ questtext }}
<br>
<input class="form-control" type="hidden" name="question_ids[]" value="{{questid}}"/>
<input class="form-control" type="text" name="{{questid}}" value="">
<br><br>
{% endfor %}
<input type="submit" value="Submit">
</form>
{% endblock %}
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="/static/main.css">
</head>
<body>
<div class="container-fluid">
<div class="row p-3 m-2">
<div class="col-3">
</div>
<div class="col-6">
<h3 class="ccc-blue">Chaos-Familien-Duell</h3>
<div class="imgplacer">
<img src="/static/LNP300_green.png" alt="lnp300-logo">
</div>
<div class="white">
{% block content %}
{% endblock %}
</div>
</div>
</div>
</div>
</body>
</html>
import uuid import uuid
from flask import Flask, render_template, redirect, request, Blueprint, session from flask import Flask, render_template, redirect, request, Blueprint, session
from model import Question, Answer from model import Question, Answer, Submit
questions = Blueprint("questions", "questions") questions = Blueprint("questions", "questions")
@questions.route("/") @questions.route("/")
def index(): def index():
return render_template("index.html", questions=Question.select()) if "token" in session:
return render_template("feedback.jinja", message="Vielen Dank für deine Antworten!")
return render_template("index.jinja", questions=Question.select())
@questions.route("/debug") @questions.route("/debug")
def debug(): def debug():
...@@ -21,20 +23,23 @@ def submit_answers(): ...@@ -21,20 +23,23 @@ def submit_answers():
if "token" in session: if "token" in session:
return "nanan, du hast schon!" return "nanan, du hast schon!"
session["token"] = uuid.uuid4() token = uuid.uuid4()
session["token"] = token
submit = Submit.get_or_create(token=token)[0]
question_ids = request.form.getlist("question_ids[]") question_ids = request.form.getlist("question_ids[]")
if question_ids is None: if question_ids is None:
return "No answers submitted!" return render_template("feedback.jinja", message="ERROR: Keine Question-ID übermittelt!")
for question_id in question_ids: for question_id in question_ids:
question = Question.get_or_none(id=question_id) question = Question.get_or_none(id=question_id)
if question is None: if question is None:
return "No question found by that id %s" % question_id return render_template("feedback.jinja", message="ERROR: Keine Frage mit der ID '%s' gefunden" % question_id)
answer = request.form.get(question_id) answer = request.form.get(question_id)
answer = Answer.create(text=answer, question=question) answer = Answer.create(text=answer, question=question, submit=submit)
answer.save() answer.save()
return "Vielen Dankeschön" return render_template("feedback.jinja", message="Vielen Dank für deine Antworten!")
\ No newline at end of file \ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment