diff --git a/routes.py b/routes.py
index f90ecfb..cf85796 100644
--- a/routes.py
+++ b/routes.py
@@ -9,6 +9,7 @@ import os
import time
from functools import wraps
from db import init_db, get_db, close_db, create_participant, now
+from datetime import datetime, timezone
bp = Blueprint("main", __name__)
@@ -23,10 +24,22 @@ def load_songs_list():
with open(BASE_DIR / "data" / "songs.json", encoding="utf-8") as f:
return json.load(f)
+@bp.route("/datenschutz")
+def datenschutz():
+ return render_template("datenschutz.html")
+
+@bp.route("/agree-dse", methods=["POST"])
+def agree_dse():
+ session["dse_agreed"] = True
+ session["dse_agreed_at"] = datetime.now(timezone.utc).isoformat()
+ return redirect(url_for("main.index"))
+
@bp.route("/login")
def login():
if "name" in session:
return redirect(url_for("main.index"))
+ elif "dse_agreed" not in session:
+ return redirect(url_for("main.datenschutz"))
return render_template("login.html")
@@ -39,7 +52,7 @@ def index():
session.clear() # neuer Teilnehmer = frischer Stand
session["name"] = name
session["pid"] = create_participant(name)
- return redirect(url_for("main.test"))
+ #return redirect(url_for("main.test"))
if "pid" not in session:
return redirect(url_for("main.login"))
return render_template("index.html")
@@ -50,12 +63,16 @@ def index():
def test():
if "name" not in session:
return redirect(url_for("main.index"))
+ elif "dse_agreed" not in session:
+ return redirect(url_for("main.datenschutz"))
return render_template("test.html", name=session["name"])
@bp.route("/api/getRandomSong")
def api_getRandomSong():
if "name" not in session:
return jsonify({"error": "no session detected"}), 401
+ elif "dse_agreed" not in session:
+ return jsonify({"error": "no agreement on privacy policy detected"}), 401
done = session.get("done", [])
#print(done)
@@ -90,6 +107,8 @@ def api_getRandomSong():
def api_rate():
if "pid" not in session or "current" not in session:
return jsonify({"error": "no session detected"}), 401
+ elif "dse_agreed" not in session:
+ return redirect(url_for("main.datenschutz"))
data = request.get_json(silent=True) or {}
choice = data.get("choice")
@@ -113,8 +132,12 @@ def api_rate():
done.append(cur["id"])
session["done"] = done
session.pop("current", None)
+
+ truth = cur["truth"]
+ if not current_app.debug:
+ truth = False
- return jsonify({"saved": True})
+ return jsonify({"saved": True, "solution": {"truth": truth, "choice": choice}})
def admin_required(view):
diff --git a/static/style/style.css b/static/style/style.css
index a0378dc..623ab8b 100644
--- a/static/style/style.css
+++ b/static/style/style.css
@@ -46,6 +46,15 @@ header {
flex-wrap: wrap;
}
+footer {
+ position: fixed;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ background: var(--surface);
+ border-top: 1px solid var(--border);
+}
+
.brand {
font-weight: 600;
font-size: 1.1rem;
diff --git a/static/style/test.css b/static/style/test.css
index 09bea3f..9c46989 100644
--- a/static/style/test.css
+++ b/static/style/test.css
@@ -80,4 +80,67 @@
.rating .choices { grid-template-columns: 1fr 1fr; }
.rating .choice-none { grid-column: 1 / -1; }
.rating button[type="submit"] { width: 100%; }
+}
+
+.result {
+ margin-top: 1.5rem;
+ padding: 1.25rem 0.5rem 0.5rem; /* oben 1.25rem, sonst 0.5rem */
+ border-radius: calc(0.5rem + 6px); /* padding + button radius */
+ border: 1px solid transparent;
+}
+
+.result.invisible {
+ display: none;
+}
+
+.result.wrong {
+ background-color: #fde8e8;
+ border-color: #f5b5b5;
+ color: #9b1c1c;
+}
+
+.result.right {
+ background-color: #e3f6e8;
+ border-color: #a6dbb4;
+ color: #166534;
+}
+
+@media (prefers-color-scheme: dark) {
+ .result.wrong {
+ background-color: #3b1c1c;
+ border-color: #7f3434;
+ color: #fca5a5;
+ }
+
+ .result.right {
+ background-color: #12301d;
+ border-color: #2f6b45;
+ color: #86efac;
+ }
+}
+
+.result fieldset {
+ margin: 0 0 1rem;
+ padding: 0;
+ border: 0;
+ min-width: 0;
+}
+
+.result legend {
+ padding: 0;
+ margin-bottom: .75rem;
+ font-size: 1.05rem;
+ font-weight: 600;
+}
+
+.result button[type="submit"] {
+ min-height: 2.75rem;
+ padding: 0 1.75rem;
+ font-weight: 600;
+}
+
+.result button[type="submit"]:disabled { opacity: .5; cursor: default; }
+
+@media (max-width: 480px) {
+ .result button[type="submit"] { width: 100%; }
}
\ No newline at end of file
diff --git a/templates/base.html b/templates/base.html
index 6aa1f11..2226fc6 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -27,5 +27,6 @@
{% block content %}{% endblock %}
+