Compare commits

...
Author SHA1 Message Date
robin a9ccdca62c feat: show percentages
feat: show file size in MB
2026-11-13 17:09:21 +01:00
robin 7ddb932a6c test: add more test files 2026-11-13 17:09:01 +01:00
robin f3546408d2 feat: auto generate edits 2026-11-13 16:18:25 +01:00
robin d026cc5470 feat: add table showing existing edits 2026-11-13 15:46:00 +01:00
robin 203bab6cf7 refactor: rename variable task to songId 2026-11-13 15:29:27 +01:00
robin 6595eed927 feat: create per song page
feat: add edit id
2026-11-13 15:23:49 +01:00
robin cb050dbc44 feat: add add button 2026-11-13 13:31:40 +01:00
robin 28984e3ce6 feat: sjow songs list 2026-11-13 13:24:29 +01:00
robin cf71bdf928 refactor: remove unnessacary print() 2026-11-13 13:00:31 +01:00
robin 47389fb0a7 feat: write bitrate and sampling rate into songs.json 2026-11-13 12:59:53 +01:00
robin ec510b5980 refactor: own taslsList page 2026-11-13 12:51:08 +01:00
robin 6673986662 refactor: own admin_title per page 2026-11-13 12:31:30 +01:00
robin ea7cef7f3b refactor: move results to own page 2026-11-13 12:29:10 +01:00
robin 3f62e4e2d2 refactor: support for multiple formats 2026-11-13 12:17:38 +01:00
robin 29ebab923d feat: admin: create subtask and upload file 2026-11-05 15:49:35 +01:00
robin 36196a736a feat: add admin_add 2026-11-05 14:57:41 +01:00
robin 9b3428d0ab remove: debug song from databse 2026-11-05 14:51:38 +01:00
robin ac349b03aa fix: choice menu gets visible again 2026-11-05 14:47:08 +01:00
robin 32cd1922f5 refactor: better session check 2026-11-05 14:44:51 +01:00
robin 819b9a13dd feat: add privacy policy
feat: add index
2026-11-03 21:18:28 +01:00
robin 43185dee64 feat: save guesses and show in admin page 2026-11-01 21:46:03 +01:00
robin 023152d417 update .gitignore 2026-11-01 21:45:56 +01:00
37 changed files with 1301 additions and 127 deletions

No files matched your search

+4
View File
@@ -174,3 +174,7 @@ cython_debug/
# PyPI configuration file
.pypirc
# Database
results.db
results.db-wal
results.db-shm
+142
View File
@@ -0,0 +1,142 @@
[
{
"name": "Umsonst gelebt",
"artist": "Jugend Chor",
"original": {
"filename": "8101b201694b47fe88d3764e66d8894e.mp3",
"sampling_rate": 44100,
"bitrate": 256000,
"size": 7037136
},
"edits": [
{
"id": "55fa1a2bf70e4c3297e1c7070389276d",
"filename": "55fa1a2bf70e4c3297e1c7070389276d.mp3",
"mode": "vbr",
"quality": 6,
"bitrate": 65146,
"sampling_rate": 22050,
"size": 1780043
},
{
"id": "05cc0367e7af4977ac1f79d816e9f164",
"filename": "05cc0367e7af4977ac1f79d816e9f164.mp3",
"mode": "cbr",
"quality": null,
"bitrate": 64000,
"sampling_rate": 8000,
"size": 1750133
}
],
"id": "001"
},
{
"name": "Meinem Jesus will ich weihen",
"artist": "Jungscharchor",
"original": {
"filename": "27894cac76974fb58fdeb5a8fa639605.mp3",
"sampling_rate": 44100,
"bitrate": 128000,
"size": 1810393
},
"edits": [
{
"id": "2c06e685fb224f629d7a20d31ec5e6d9",
"filename": "2c06e685fb224f629d7a20d31ec5e6d9.mp3",
"mode": "vbr",
"quality": 9,
"bitrate": 30101,
"sampling_rate": 22050,
"size": 417068
}
],
"id": "002"
},
{
"name": "Ich glaube an Jesus",
"artist": "Gruppe",
"original": {
"filename": "c9bf5b8afe124b949f09211359b8ff5b.mp3",
"sampling_rate": 44100,
"bitrate": 128000,
"size": 3432051
},
"edits": [
{
"id": "52f737589f4b461eaf7b0a3273921613",
"filename": "52f737589f4b461eaf7b0a3273921613.mp3",
"mode": "vbr",
"quality": 4,
"bitrate": 55191,
"sampling_rate": 22050,
"size": 1465187
}
],
"id": "003"
},
{
"name": "Bin erlöst von aller Sünd",
"artist": "Jungscharchor",
"original": {
"filename": "5a94207c76b343b8b802b6c2894c69fa.mp3",
"sampling_rate": 44100,
"bitrate": 128000,
"size": 2686933
},
"edits": [
{
"id": "7822fb105be341c9b169ef7ace84aeb8",
"filename": "7822fb105be341c9b169ef7ace84aeb8.mp3",
"mode": "vbr",
"quality": 9,
"bitrate": 43628,
"sampling_rate": 44100,
"size": 903637
}
],
"id": "004"
},
{
"name": "Du bist nah mir wie das Meer dem Strande",
"artist": "Jungscharlehrer",
"original": {
"filename": "380549bd1fb84a728d0068e42043f074.mp3",
"sampling_rate": 44100,
"bitrate": 128000,
"size": 2466338
},
"edits": [
{
"id": "d6a8f772629b43ecb5a9b03a6dea010c",
"filename": "d6a8f772629b43ecb5a9b03a6dea010c.mp3",
"mode": "vbr",
"quality": 2,
"bitrate": 67476,
"sampling_rate": 22050,
"size": 1280972
}
],
"id": "005"
},
{
"name": "Zeugnis",
"original": {
"filename": "9a534ade55264c16a392c48dc14aedcc.mp3",
"sampling_rate": 44100,
"bitrate": 128000,
"size": 12757866
},
"edits": [
{
"id": "fd6ed7f4a2c64a498ff64beaf19eacc2",
"filename": "fd6ed7f4a2c64a498ff64beaf19eacc2.mp3",
"mode": "cbr",
"quality": null,
"bitrate": 32000,
"sampling_rate": 8000,
"size": 3187229
}
],
"id": "006"
}
]
+60
View File
@@ -0,0 +1,60 @@
import sqlite3
import uuid
from contextlib import closing
from datetime import datetime
from pathlib import Path
from flask import g
DB_PATH = Path(__file__).parent / "results.db"
def init_db():
with closing(sqlite3.connect(DB_PATH)) as con:
con.execute("PRAGMA journal_mode=WAL") # bessere Parallelität beim Schreiben
con.executescript("""
CREATE TABLE IF NOT EXISTS participants (
id TEXT PRIMARY KEY, -- zufällige ID pro Teilnahme
name TEXT NOT NULL,
created TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS ratings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
participant_id TEXT NOT NULL,
song_id NOT NULL, -- bewusst ohne Typ: bleibt Zahl oder Text wie in songs.json
choice TEXT NOT NULL, -- 'a', 'b' oder 'non'
truth TEXT NOT NULL, -- Position des Originals ('a' oder 'b')
original_chosen INTEGER NOT NULL, -- 1 = Original als besser gewählt
edit TEXT, -- welche Bearbeitung gespielt wurde
created TEXT NOT NULL,
UNIQUE (participant_id, song_id) -- Doppelklick erzeugt keine zweite Zeile
);
""")
con.commit()
def get_db():
if "db" not in g:
g.db = sqlite3.connect(DB_PATH, timeout=10) # wartet bei gleichzeitigem Schreiben
g.db.row_factory = sqlite3.Row
return g.db
def close_db(_exc=None):
db = g.pop("db", None)
if db is not None:
db.close()
def now():
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
def create_participant(name):
pid = uuid.uuid4().hex
db = get_db()
with db:
db.execute("INSERT INTO participants (id, name, created) VALUES (?, ?, ?)",
(pid, name, now()))
return pid
+7 -1
View File
@@ -1,8 +1,14 @@
from flask import Flask
from routes import bp
import os
from dotenv import load_dotenv
load_dotenv()
app = Flask(__name__)
app.secret_key = "secret-key-ultra-pro-max-123"
app.secret_key = os.environ["SECRET_KEY"]
app.config["MAX_CONTENT_LENGTH"] = 50 * 1024 * 1024 # 50 MB
app.register_blueprint(bp)
if __name__ == "__main__":
-28
View File
@@ -1,28 +0,0 @@
[
{
"name": "r",
"guesses": [
{
"song_id": "001",
"right": true
},
{
"song_id": "002",
"right": false
}
]
},
{
"name": "Robin",
"guesses": [
{
"song_id": "001",
"right": true
},
{
"song_id": "002",
"right": true
}
]
}
]
+381 -53
View File
@@ -1,53 +1,131 @@
from flask import Blueprint, render_template, request, redirect, url_for, session, jsonify
from flask import Blueprint, render_template, request, redirect, url_for, session, jsonify, Response, current_app, abort
import json
from werkzeug.utils import secure_filename
from pathlib import Path
import random
import csv
import hmac
import io
import os
import time
import re
import uuid
from functools import wraps
from db import init_db, get_db, close_db, create_participant, now
from datetime import datetime, timezone
import threading
from mutagen import File
import subprocess
bp = Blueprint("main", __name__)
init_db()
bp.teardown_app_request(close_db)
BASE_DIR = Path(__file__).parent
BASE_MUSIC_DIR = BASE_DIR / "static" / "data" / "music"
BASE_MUSIC_FILENAME_DIR = "data/music/"
SONGS_PATH = BASE_DIR / "data" / "songs.json"
_songs_lock = threading.Lock()
def load_songs_list():
with open("songs.json", encoding="utf-8") as f:
with open(SONGS_PATH, encoding="utf-8") as f:
return json.load(f)
def load_results_list():
with open("results.json", encoding="utf-8") as f:
return json.load(f)
def save_songs_list(songs):
tmp = SONGS_PATH.with_suffix(".json.tmp")
with open(tmp, "w", encoding="utf-8") as f:
json.dump(songs, f, ensure_ascii=False, indent=2)
os.replace(tmp, SONGS_PATH) # atomar ersetzen
def write_results_list(results):
with open("results.json", mode="w", encoding="utf-8") as f:
json.dump(results, f, ensure_ascii=False, indent=2)
def next_song_id(songs, prefix="", width=3):
nums = []
for s in songs:
m = re.fullmatch(rf"{prefix}(\d+)", str(s["id"]))
if m:
nums.append(int(m.group(1)))
return f"{prefix}{max(nums, default=0) + 1:0{width}d}"
def add_song(song):
with _songs_lock:
songs = load_songs_list()
song["id"] = next_song_id(songs)
songs.append(song)
save_songs_list(songs)
return song
ALLOWED_EXTENSIONS = {"mp3", "wav", "flac", "ogg", "m4a"}
def allowed_file(filename):
return "." in filename and filename.rsplit(".", 1)[1].lower() in ALLOWED_EXTENSIONS
def session_required(api=False, participant=True):
"""Prüft Datenschutz-Zustimmung und (optional) angelegten Teilnehmer.
api=True -> JSON-Fehler statt Redirect
participant=False -> nur Datenschutz prüfen (z. B. für die Namenseingabe)
"""
def decorator(view):
@wraps(view)
def wrapper(*args, **kwargs):
if "dse_agreed" not in session:
if api:
return jsonify({"error": "privacy policy not accepted"}), 403
return redirect(url_for("main.datenschutz"))
if participant and "pid" not in session:
if api:
return jsonify({"error": "no session detected"}), 401
return redirect(url_for("main.login"))
return view(*args, **kwargs)
return wrapper
return decorator
@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")
@session_required(participant=False)
def login():
if "name" in session:
if "pid" in session:
return redirect(url_for("main.index"))
return render_template("login.html")
@bp.route("/", methods=["GET", "POST"])
def index():
if request.method == "POST":
session["name"] = request.form["name"].strip()
if "name" not in session:
@bp.route("/start", methods=["POST"])
@session_required(participant=False)
def start():
name = request.form.get("name", "").strip()[:60]
if not name:
return redirect(url_for("main.login"))
dse_at = session.get("dse_agreed_at")
session.clear()
session["dse_agreed"] = True
session["dse_agreed_at"] = dse_at
session["name"] = name
session["pid"] = create_participant(name)
return redirect(url_for("main.index"))
@bp.route("/")
@session_required()
def index():
return render_template("index.html")
@bp.route("/test")
@session_required()
def test():
if "name" not in session:
return redirect(url_for("main.index"))
return render_template("test.html", name=session["name"])
@bp.route("/api/getRandomSong")
@session_required(api=True)
def api_getRandomSong():
if "name" not in session:
return jsonify({"error": "no session detected"}), 401
done = session.get("done", [])
#print(done)
remaining = [s for s in load_songs_list() if s["id"] not in done]
@@ -59,8 +137,8 @@ def api_getRandomSong():
truth = random.choice(["a", "b"])
session["current"] = {"id": song["id"], "truth": truth}
truth_path = BASE_MUSIC_FILENAME_DIR + song["original"]["filename"] + ".mp3"
random_lie_path = BASE_MUSIC_FILENAME_DIR + random.choice(song["edits"])["filename"] + ".mp3"
truth_path = BASE_MUSIC_FILENAME_DIR + song["original"]["filename"]
random_lie_path = BASE_MUSIC_FILENAME_DIR + random.choice(song["edits"])["filename"]
if truth == "a":
path_a = truth_path
@@ -78,42 +156,292 @@ def api_getRandomSong():
})
@bp.route("/api/rate", methods=["POST"])
def api_rate():
if "name" not in session or "current" not in session:
return jsonify({"error": "no session detected"}), 401
@session_required(api=True)
def api_rate():
data = request.get_json(silent=True) or {}
choice = data.get("choice")
if choice == "gleich": # beide Schreibweisen akzeptieren
choice = "non"
if choice not in ("a", "b", "non"):
return jsonify({"error": "invalid choice"}), 400
song_id = session["current"]["id"]
solution = session["current"]["truth"]
name = session["name"]
results = load_results_list()
person = next((p for p in results if p["name"] == name), None)
if person is None: # create person if not created yet
results.append({
"name": name,
"guesses": [{
"song_id": song_id,
"right": choice == solution
}]
})
else:
person["guesses"].append({
"song_id": song_id,
"right": choice == solution
})
write_results_list(results)
cur = session["current"]
db = get_db()
with db: # eine Transaktion, wird automatisch committet
db.execute(
"""INSERT OR IGNORE INTO ratings
(participant_id, song_id, choice, truth, original_chosen, edit, created)
VALUES (?, ?, ?, ?, ?, ?, ?)""",
(session["pid"], cur["id"], choice, cur["truth"],
int(choice == cur["truth"]), cur.get("edit"), now()))
done = session.get("done", [])
done.append(song_id)
if cur["id"] not in done:
done.append(cur["id"])
session["done"] = done
session.pop("current", None)
return jsonify({"saved": True})
truth = cur["truth"]
if not current_app.debug:
truth = False
return jsonify({"saved": True, "solution": {"truth": truth, "choice": choice}})
def admin_required(view):
@wraps(view)
def wrapper(*args, **kwargs):
if not session.get("admin"):
return redirect(url_for("main.admin_login"))
return view(*args, **kwargs)
return wrapper
@bp.route("/admin/login", methods=["GET", "POST"])
def admin_login():
error = None
if request.method == "POST":
# Erst zur Anfragezeit lesen, damit load_dotenv() aus main.py schon gelaufen ist
expected = os.environ.get("ADMIN_PASSWORD", "")
given = request.form.get("password", "")
if not expected:
error = "Es ist kein Admin-Passwort konfiguriert (.env)."
elif hmac.compare_digest(given.encode(), expected.encode()):
session["admin"] = True
return redirect(url_for("main.admin"))
else:
time.sleep(1) # bremst automatisches Durchprobieren
error = "Falsches Passwort."
return render_template("admin_login.html", error=error)
@bp.route("/admin/logout", methods=["POST"])
def admin_logout():
session.pop("admin", None)
return redirect(url_for("main.admin_login"))
CHOICE_LABELS = {"a": "A", "b": "B", "non": "Kein Unterschied"}
@bp.route("/admin")
@admin_required
def admin():
return render_template("admin.html")
def csv_safe(value):
"""Verhindert, dass Calc/Excel einen Namen wie '=1+1' als Formel ausführt."""
s = str(value)
return "'" + s if s[:1] in ("=", "+", "-", "@") else s
@bp.route("/admin/export.csv")
@admin_required
def admin_export():
songs = {s["id"]: s["name"] for s in load_songs_list()}
out = io.StringIO()
w = csv.writer(out, delimiter=";")
w.writerow(["Name", "Gestartet", "Song-ID", "Song", "Original gewählt",
"Wahl", "Position Original", "Bearbeitung"])
query = """SELECT p.name, p.created AS started, r.song_id, r.original_chosen,
r.choice, r.truth, r.edit
FROM ratings r JOIN participants p ON p.id = r.participant_id
ORDER BY p.created, r.id"""
for r in get_db().execute(query):
w.writerow([
csv_safe(r["name"]),
r["started"],
r["song_id"],
csv_safe(songs.get(r["song_id"], "")),
"ja" if r["original_chosen"] else "nein",
CHOICE_LABELS.get(r["choice"], r["choice"]),
r["truth"].upper(),
r["edit"] or "",
])
return Response("\ufeff" + out.getvalue(), mimetype="text/csv",
headers={"Content-Disposition": "attachment; filename=ergebnisse.csv"})
@bp.route("/debug/reset", methods=["POST"])
def debug_reset():
if not current_app.debug:
abort(404) # im normalen Betrieb existiert die Route praktisch nicht
session.clear()
return redirect(url_for("main.login"))
@bp.route("/admin/add")
@admin_required
def admin_add():
return render_template("admin_add.html")
@bp.route("/admin/results")
@admin_required
def admin_results():
db = get_db()
songs = {s["id"]: s["name"] for s in load_songs_list()}
by_person = {}
for r in db.execute("SELECT * FROM ratings ORDER BY id"):
by_person.setdefault(r["participant_id"], []).append({
"song_id": r["song_id"],
"right": bool(r["original_chosen"]),
"choice": CHOICE_LABELS.get(r["choice"], r["choice"]),
"edit": r["edit"] or "–",
})
rows = []
for p in db.execute("SELECT id, name, created FROM participants ORDER BY created DESC"):
guesses = by_person.get(p["id"], [])
if not guesses:
continue # nur Teilnehmer mit mindestens einer Bewertung
total = len(guesses)
right = sum(g["right"] for g in guesses)
rows.append({
"name": p["name"],
"started": p["created"],
"total": total,
"right": right,
"quote": round(100 * right / total),
"guesses": guesses,
})
total_all = sum(r["total"] for r in rows)
right_all = sum(r["right"] for r in rows)
stats = {
"people": len(rows),
"guesses": total_all,
"quote": round(100 * right_all / total_all) if total_all else None,
}
return render_template("admin_results.html", rows=rows, stats=stats, songs=songs)
@bp.route("/admin/list")
@admin_required
def admin_list():
songs = load_songs_list()
return render_template("admin_tasksList.html", songs=songs)
@bp.route("/admin/add/<songId>")
@admin_required
def admin_add_task(songId):
song = False
for s in load_songs_list():
if s["id"] == songId:
song = s
if not song:
return 404
return render_template("admin_add_task.html", song=song)
@bp.route("/api/admin/add", methods=["POST"])
@admin_required
def api_admin_add():
title = request.form.get("title", "").strip()
file = request.files.get("file")
if not title:
return jsonify({"saved": False, "error": "Titel fehlt"}), 400
if not file or file.filename == "":
return jsonify({"saved": False, "error": "Keine Datei"}), 400
if not allowed_file(file.filename):
return jsonify({"saved": False, "error": "Dateityp nicht erlaubt"}), 400
ext = os.path.splitext(secure_filename(file.filename))[1].lower()
filename_new = uuid.uuid4().hex + ext
BASE_MUSIC_DIR.mkdir(parents=True, exist_ok=True)
path = BASE_MUSIC_DIR / filename_new
file.save(path)
# read bitrate and sampling rate
audio = File(path)
#stem = os.path.splitext(filename_new)[0]
song = add_song({
"name": title,
"original": {
"filename": filename_new,
"sampling_rate": audio.info.sample_rate,
"bitrate": audio.info.bitrate,
"size": path.stat().st_size, # Bytes
},
"edits": [],
})
return jsonify({"saved": True, "filename": filename_new})
VALID_SAMPLING_RATES = {8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000}
@bp.route("/api/admin/add/<songId>", methods=["POST"])
@admin_required
def api_admin_add_task(songId):
mode = request.form.get("mode", "cbr")
sampling_rate = request.form.get("sampling_rate", type=int)
if mode not in ("cbr", "vbr"):
return jsonify({"saved": False, "error": "Ungültiger Modus"}), 400
if sampling_rate not in VALID_SAMPLING_RATES:
return jsonify({"saved": False, "error": "Ungültige Abtastrate"}), 400
songs = load_songs_list()
song = next((s for s in songs if str(s["id"]) == songId), None)
if song is None:
return jsonify({"saved": False, "error": "Song nicht gefunden"}), 404
original = song["original"]
if sampling_rate > original["sampling_rate"]:
return jsonify({"saved": False, "error": "Abtastrate höher als Original"}), 400
if mode == "vbr":
quality = request.form.get("quality", type=int)
if quality is None or not 0 <= quality <= 9:
return jsonify({"saved": False, "error": "Ungültige VBR-Qualität"}), 400
quality_args = ["-q:a", str(quality)]
else:
bitrate_kbps = request.form.get("bitrate", type=int)
if not bitrate_kbps or bitrate_kbps <= 0:
return jsonify({"saved": False, "error": "Bitrate fehlt"}), 400
if bitrate_kbps * 1000 > original["bitrate"] + 1000:
return jsonify({"saved": False, "error": "Bitrate höher als Original"}), 400
quality_args = ["-b:a", f"{bitrate_kbps}k"]
src = BASE_MUSIC_DIR / original["filename"]
if not src.is_file():
return jsonify({"saved": False, "error": "Originaldatei fehlt"}), 404
edit_id = uuid.uuid4().hex
dst = BASE_MUSIC_DIR / (edit_id + ".mp3") # immer MP3, siehe Hinweis unten
try:
subprocess.run(
["ffmpeg", "-y", "-i", str(src), "-vn",
"-c:a", "libmp3lame", *quality_args,
"-ar", str(sampling_rate), str(dst)],
check=True, capture_output=True, timeout=300,
)
except subprocess.CalledProcessError as e:
dst.unlink(missing_ok=True)
current_app.logger.error("ffmpeg: %s", e.stderr.decode(errors="replace")[-1000:])
return jsonify({"saved": False, "error": "Konvertierung fehlgeschlagen"}), 500
except subprocess.TimeoutExpired:
dst.unlink(missing_ok=True)
return jsonify({"saved": False, "error": "Zeitüberschreitung"}), 500
# tatsächliche Werte aus der fertigen Datei lesen
out = File(dst)
actual_bitrate = out.info.bitrate if out else None
actual_rate = out.info.sample_rate if out else sampling_rate
song.setdefault("edits", []).append({
"id": edit_id,
"filename": dst.name,
"mode": mode,
"quality": quality if mode == "vbr" else None,
"bitrate": actual_bitrate,
"sampling_rate": actual_rate,
"size": dst.stat().st_size, # Bytes
})
save_songs_list(songs)
return jsonify({"saved": True, "id": edit_id})
-38
View File
@@ -1,38 +0,0 @@
[
{
"name": "Beweis",
"artist": "Alle",
"id": "001",
"original_name": "-",
"original": {
"filename": "m001",
"sampling_rate": 44.1,
"bitrate": 48
},
"edits": [
{
"filename": "m002",
"sampling_rate": 44.1,
"bitrate": 47
}
]
},
{
"name": "Umsonst gelebt",
"artist": "Jugend Chor",
"id": "002",
"original_name": "-",
"original": {
"filename": "m003",
"sampling_rate": 44.1,
"bitrate": 256
},
"edits": [
{
"filename": "m004",
"sampling_rate": 22.1,
"bitrate": 63
}
]
}
]
+132
View File
@@ -0,0 +1,132 @@
/* static/admin.css */
.form-error {
margin: 0 0 1rem;
padding: .5rem .75rem;
color: var(--text);
background: var(--surface);
border: 1px solid #d14343;
border-radius: 8px;
font-size: .95rem;
}
.admin-head {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: .75rem;
margin-bottom: 1rem;
}
.admin-head h2 { margin: 0; }
.admin-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.admin-actions form { margin: 0; }
.button {
display: inline-flex;
align-items: center;
min-height: 2.75rem;
padding: 0 1rem;
color: var(--accent-text);
background: var(--accent);
border-radius: 6px;
text-decoration: none;
}
button.secondary {
min-height: 2.75rem;
color: var(--text);
background: transparent;
border-color: var(--border);
}
.stats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
gap: .75rem;
margin-bottom: 1.5rem;
}
.stat {
display: flex;
flex-direction: column;
padding: .75rem 1rem;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
}
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .9rem; }
.table-wrap { overflow-x: auto; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: .85rem; font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.person {
margin-bottom: .5rem;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
}
.person summary { padding: .75rem 1rem; cursor: pointer; font-weight: 600; }
.person .table-wrap { margin: 0; padding: 0 .5rem .5rem; }
.muted, .empty { color: var(--muted); font-weight: 400; }
.form label {
display: block;
margin-bottom: .25rem;
margin-top: 1rem;
font-size: .9rem;
color: var(--muted);
}
.form input,
.form button {
width: 100%;
font-size: 1rem; /* mind. 16px, sonst zoomt iOS beim Fokussieren hinein */
min-height: 2.75rem; /* gut mit dem Daumen treffbar */
}
.form button {
margin-top: 1rem;
}
.file-upload {
display: flex;
align-items: center;
gap: 0.75rem;
position: relative;
}
/* Das echte Input bleibt für Tastatur und Screenreader erreichbar, ist aber unsichtbar */
.file-upload input[type="file"] {
position: absolute;
width: 1px;
height: 1px;
opacity: 0;
overflow: hidden;
}
.file-button {
display: inline-block;
padding: 0.5rem 1rem;
border: 1px solid var(--border);
border-radius: 6px;
background: var(--surface);
cursor: pointer;
font: inherit;
transition: background 0.15s, border-color 0.15s;
}
.file-name {
color: var(--text);
font-size: 0.9rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
+52
View File
@@ -43,6 +43,16 @@ header {
align-items: center;
justify-content: space-between;
gap: 1rem;
flex-wrap: wrap;
}
footer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: var(--surface);
border-top: 1px solid var(--border);
}
.brand {
@@ -128,4 +138,46 @@ audio { width: 100%; }
.login-card button {
margin-top: 1rem;
}
.header-right { display: flex; align-items: center; gap: .75rem; }
.header-right form { margin: 0; }
.debug-reset {
padding: .25rem .6rem;
font-size: .8rem;
color: var(--text);
background: transparent;
border: 1px dashed var(--muted);
}
td.toggle {
width: 1.5em;
cursor: pointer;
text-align: center;
user-select: none;
height: 20px;
}
td.toggle a {
display: inline-flex;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
background-color: var(--accent);
color: var(--accent-text);
text-decoration: none;
border-radius: 4px;
cursor: pointer;
user-select: none;
}
td.toggle a:hover {
filter: brightness(1.1); /* optional: Hover-Effekt */
}
.percentage {
color: var(--muted);
font-size: small;
}
+63
View File
@@ -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%; }
}
+21
View File
@@ -0,0 +1,21 @@
{% extends "base.html" %}
{% block content %}
<link rel="stylesheet" href="{{ url_for('static', filename='style/admin.css') }}">
<div class="admin-head">
<h2>{% block admin_title %}Admin{% endblock %}</h2>
<div class="admin-actions">
{% block admin_header %}{% endblock %}
<form method="post" action="{{ url_for('main.admin_logout') }}">
<button type="submit" class="secondary">Abmelden</button>
</form>
</div>
</div>
{% block admin_content %}
<a class="button" href="{{ url_for('main.admin_list') }}">Unteraufgaben</a>
<a class="button" href="{{ url_for('main.admin_results') }}">Auswertung</a>
{% endblock %}
{% endblock %}
+41
View File
@@ -0,0 +1,41 @@
{% extends "admin.html" %}
{% block admin_title %}Unteraufgabe hinzufügen{% endblock %}
{% block admin_content %}
<form class="form" id="form">
<label for="titel">Titel</label>
<input id="title" name="title" type="text" autocomplete="off" required autofocus>
<label for="file">Datei</label>
<div class="file-upload">
<input id="file" name="file" type="file" accept="audio/*,.mp3,.wav,.flac,.ogg,.m4a" required>
<label for="file" class="file-button">Audiodatei wählen</label>
<span class="file-name" id="file-name">Keine Datei ausgewählt</span>
</div>
<button type="submit">Erstellen</button>
</form>
<script>
const form = document.getElementById("form");
form.addEventListener("submit", async (event) => {
event.preventDefault();
const res = await fetch("/api/admin/add", {
method: "POST",
body: new FormData(form),
});
const result = await res.json();
console.log(result);
});
const fileInput = document.getElementById("file");
const fileName = document.getElementById("file-name");
fileInput.addEventListener("change", () => {
fileName.textContent = fileInput.files.length
? fileInput.files[0].name
: "Keine Datei ausgewählt";
});
</script>
{% endblock %}
+99
View File
@@ -0,0 +1,99 @@
{% extends "admin.html" %}
{% block admin_title %}Kopie erstellen{% endblock %}
{% block admin_content %}
<form class="form" id="form">
<label for="mode">Modus</label>
<select id="mode" name="mode">
<option value="cbr">Konstant (CBR)</option>
<option value="vbr">Variabel (VBR)</option>
</select>
<div id="cbr-field">
<label for="bitrate">Bitrate (kbit/s)</label>
<select id="bitrate" name="bitrate">
{% for b in [32, 48, 64, 96, 128, 160, 192, 256, 320] if b * 1000 <= song.original.bitrate %}
<option value="{{ b }}">{{ b }} kbit/s</option>
{% endfor %}
</select>
</div>
<div id="vbr-field" hidden>
<label for="quality">VBR-Qualität</label>
<select id="quality" name="quality">
<option value="0">V0 (beste, ca. 220–260 kbit/s)</option>
<option value="2">V2 (ca. 170–210 kbit/s)</option>
<option value="4">V4 (ca. 140–185 kbit/s)</option>
<option value="6">V6 (ca. 100–130 kbit/s)</option>
<option value="8">V8 (ca. 70–105 kbit/s)</option>
<option value="9">V9 (schlechteste, ca. 65–85 kbit/s)</option>
</select>
</div>
<label for="sampling_rate">Abtastrate (Hz)</label>
<select id="sampling_rate" name="sampling_rate" required>
{% for r in [8000, 11025, 16000, 22050, 32000, 44100, 48000] if r <= song.original.sampling_rate %}
<option value="{{ r }}" {% if r == song.original.sampling_rate %}selected{% endif %}>{{ r }} Hz</option>
{% endfor %}
</select>
<button type="submit">Erstellen</button>
</form>
<div class="table-wrap" style="margin-top: 2rem;">
<table>
<thead>
<th>ID</th>
<th>Bitrate (bit/s)</th>
<th>Abtastrate (Hz)</th>
<th>Dateigröße (MB)</th>
</thead>
<tbody>
<tr>
<td>Original</td>
<td>{{ song.original.bitrate }}</td>
<td>{{ song.original.sampling_rate }}</td>
<td>{{ (song.original.size / 1000000) | round(2) }}</td>
</tr>
{% if song.edits %}
{% for e in song.edits %}
<tr>
<td>{{ e.id }}</td>
<td>{{ e.bitrate }} <span class="percentage">({{ (e.bitrate / song.original.bitrate * 100) | round(1) }}%) {{ e.get("mode", "cbr") | upper }}</span></td>
<td>{{ e.sampling_rate }} <span class="percentage">({{ (e.sampling_rate / song.original.sampling_rate * 100) | round(1) }}%)</span></td>
<td>{{ (e.size / 1000000) | round(2) }} <span class="percentage">({{ (e.size / song.original.size * 100) | round(1) }}%)</span></td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
<script>
const form = document.getElementById("form");
form.addEventListener("submit", async (event) => {
event.preventDefault();
const button = form.querySelector("button");
button.disabled = true; // Doppelklick verhindern
try {
const res = await fetch("/api/admin/add/{{ song.id }}", {
method: "POST",
body: new FormData(form),
});
if (!res.ok) throw new Error("Fehler " + res.status);
location.reload(); // Tabelle aktualisieren
} catch (err) {
alert("Erstellen fehlgeschlagen: " + err.message);
button.disabled = false;
}
});
const mode = document.getElementById("mode");
mode.addEventListener("change", () => {
document.getElementById("cbr-field").hidden = mode.value !== "cbr";
document.getElementById("vbr-field").hidden = mode.value !== "vbr";
});
</script>
{% endblock %}
+15
View File
@@ -0,0 +1,15 @@
{% extends "base.html" %}
{% block content %}
<div class="login-wrap">
<div class="login-card">
<h1>Auswertung</h1>
<p class="login-hint">Dieser Bereich ist passwortgeschützt.</p>
{% if error %}<p class="form-error" role="alert">{{ error }}</p>{% endif %}
<form method="post">
<label for="password">Passwort</label>
<input id="password" name="password" type="password" autocomplete="current-password" required autofocus>
<button type="submit">Anmelden</button>
</form>
</div>
</div>
{% endblock %}
+65
View File
@@ -0,0 +1,65 @@
{% extends "admin.html" %}
{% block admin_title %}Auswertung{% endblock %}
{% block admin_content %}
<a class="button" href="{{ url_for('main.admin_export') }}">CSV exportieren</a>
<div class="stats">
<div class="stat"><span class="stat-value">{{ stats.people }}</span><span class="stat-label">Teilnehmer</span></div>
<div class="stat"><span class="stat-value">{{ stats.guesses }}</span><span class="stat-label">Bewertungen</span></div>
<div class="stat">
<span class="stat-value">{{ stats.quote ~ ' %' if stats.quote is not none else '–' }}</span>
<span class="stat-label">Original gewählt</span>
</div>
</div>
{% if not rows %}
<p class="empty">Noch keine Ergebnisse vorhanden.</p>
{% else %}
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Name</th><th>Gestartet</th>
<th class="num">Bewertungen</th><th class="num">Original gewählt</th><th class="num">Quote</th>
</tr>
</thead>
<tbody>
{% for r in rows %}
<tr>
<td>{{ r.name }}</td>
<td class="muted">{{ r.started }}</td>
<td class="num">{{ r.total }}</td>
<td class="num">{{ r.right }}</td>
<td class="num">{{ r.quote }} %</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<h3>Einzelergebnisse</h3>
{% for r in rows %}
<details class="person">
<summary>{{ r.name }} <span class="muted">({{ r.right }}/{{ r.total }}, {{ r.started }})</span></summary>
<div class="table-wrap">
<table>
<thead><tr><th>Song</th><th>Original gewählt</th><th>Wahl</th><th>Bearbeitung</th></tr></thead>
<tbody>
{% for g in r.guesses %}
<tr>
<td>{{ songs.get(g.song_id, g.song_id) }}</td>
<td>{{ 'ja' if g.right else 'nein' }}</td>
<td>{{ g.choice }}</td>
<td>{{ g.edit }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</details>
{% endfor %}
{% endif %}
{% endblock %}
+52
View File
@@ -0,0 +1,52 @@
{% extends "admin.html" %}
{% block admin_title %}Unteraufgaben{% endblock %}
{% block admin_header %}
<a class="button" href="{{ url_for('main.admin_add') }}">Unteraufgabe hinzufügen</a>
{% endblock %}
{% block admin_content %}
{% if not songs %}
<p class="empty">Noch keine Unteraufgabe vorhanden.</p>
{% else %}
<div class="table-wrap">
<table>
<thead>
<th></th>
<th>Name</th>
<th>ID</th>
<th>Bitrate (bit/s)</th>
<th>Abtastrate (Hz)</th>
<th>Dateigröße (MB)</th>
</thead>
<tbody>
{% for s in songs %}
<tr>
<td class="toggle">
<a href="{{ url_for('main.admin_add_task', songId=s.id) }}">+</a>
</td>
<td>{{ s.name }}</td>
<td>{{ s.id }}</td>
<td>{{ s.original.bitrate }}</td>
<td>{{ s.original.sampling_rate }}</td>
<td>{{ (s.original.size / 1000000) | round(2) }}</td>
</tr>
{% if s.edits %}
{% for e in s.edits %}
<tr class="sub-row">
<td></td>
<td></td>
<td></td>
<td>{{ e.bitrate }} <span class="percentage">({{ (e.bitrate / s.original.bitrate * 100) | round(1) }}%)</span></td>
<td>{{ e.sampling_rate }} <span class="percentage">({{ (e.sampling_rate / s.original.sampling_rate * 100) | round(1) }}%)</span></td>
<td>{{ (e.size / 1000000) | round(2) }} <span class="percentage">({{ (e.size / s.original.size * 100) | round(1) }}%)</span></td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
</tbody>
{% endif %}
{% endblock %}
+11 -3
View File
@@ -11,14 +11,22 @@
<header>
<div class="header-inner">
<a class="brand" href="{{ url_for('main.index') }}">AudioRating</a>
{% if session.get('name') %}
<span class="user">Angemeldet als {{ session['name'] }}</span>
{% endif %}
<div class="header-right">
{% if session.get('name') %}
<span class="user">Angemeldet als {{ session['name'] }}</span>
{% endif %}
{% if config.DEBUG %}
<form method="post" action="{{ url_for('main.debug_reset') }}">
<button type="submit" class="debug-reset" title="Nur im Debug-Modus sichtbar">Reset</button>
</form>
{% endif %}
</div>
</div>
</header>
<main>
{% block content %}{% endblock %}
</main>
<footer><a href="/datenschutz">Datenschutzerklärung</a></footer>
</body>
</html>
+55
View File
@@ -0,0 +1,55 @@
{% extends "base.html" %}
{% block content %}
<h1>Datenschutzerklärung</h1>
<h2>Kurz</h2>
<ul>
<li>Sobald bei den Unteraufgaben auf "Bestätigen" gedrückt wird, wird die Auswahl und ihre Richtigkeit auf dem Server gespeichert.</li>
<li>Die Ergebnisse (allgemein und personenbezogen) können auf einer passwortgeschützten Seite von dem Admin und dem verantwortlichen Tontechniker eingesehen werden.</li>
<li>Die gesammelten Daten einer Person werden nach Antrag an <a href="mailto:robin@schanbros.de">robin@schanbros.de</a> innerhalb von 3 Tagen gelöscht oder anonymisiert.</li>
<li>Personenbezogene Daten werden nach der Auswertung anonymisiert.</li>
</ul>
<h2>Rechtlich vollständig</h2>
<p>
Verantwortlicher: Robin Schanbacher, Friedrich-List-Straße 7, 72127 Kusterdingen, <a href="mailto:robin@schanbros.de">robin@schanbros.de</a>
</p>
<p>
Verarbeitete Daten:
<ul>
<li>Eingetragener Name (auf Login-Seite) zur Identifikation</li>
<li>Auswahl bei den Aufgaben inkl. Richtigkeit und Zeitpunkt</li>
<li>Technisch notwendiges Session-Cookie zur technischen Identifikation und Überprüfung</li>
<li>Ein technisch notwendiges Cookie, das speichert, dass Sie der Datenschutzerklärung zugestimmt haben (Einwilligung)</li>
</ul>
</p>
<p>
Zweck: Analyse, wie stark Aufnahmen komprimiert werden sollten, damit sie Speicherplatz sparen, aber trotzdem in guter Qualität vorhanden sind.
</p>
<p>
Rechtsgrundlage: Ihre Einwilligung (Art. 6 Abs. 1 lit. a DSGVO). Diese können Sie jederzeit mit Wirkung für die Zukunft widerrufen.
</p>
<p>
Einsicht in die Daten: Admin (Verantwortlicher) und der verantwortlicher Tontechniker (Artur Schanbacher, Friedrich-List-Straße 7, 72127 Kusterdingen, <a href="mailto:arutras@gmail.com">arutras@gmail.com</a>). Der Tontechniker darf Teile der allgemeinen Auswertung an Dritte weitergeben, jedoch nur in anonymisierter bzw. zusammengefasster Form, ohne Namen oder Rückschluss auf einzelne Personen.
</p>
<p>
Speicherdauer: Nach Abschluss der Auswertung werden die Daten anonymisiert (Namen entfernt) und können dauerhaft archiviert werden.
</p>
<p>
Hosting: Die Anwendung läuft auf einem eigenen Server.
</p>
<p>
Ihre Rechte: Auskunft, Berichtigung, Löschung, Einschränkung, Widerspruch und Datenübertragbarkeit sowie Widerruf der Einwilligung (mit Wirkung für die Zukunft; bis dahin bleibt die Verarbeitung rechtmäßig). Eine formlose E-Mail an den Verantwortlichen genügt. Die Löschung erfolgt innerhalb von drei Tagen. Sie haben außerdem das Recht, sich bei einer Aufsichtsbehörde zu beschweren, z. B. beim Landesbeauftragten für den Datenschutz und die Informationsfreiheit Baden-Württemberg.
</p>
<p>
Die Teilnahme ist freiwillig. Ohne Einwilligung und Angabe eines Namens ist eine Teilnahme am Test jedoch nicht möglich.
</p>
<form action="{{ url_for('main.agree_dse') }}" method="post">
<button type="submit">Ich bin mit diesen Bedingungen einverstanden</button>
</form>
{% endblock %}
+57
View File
@@ -1,6 +1,63 @@
{% extends "base.html" %}
{% block content %}
<link rel="stylesheet" href="{{ url_for('static', filename='style/player.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='style/test.css') }}">
<h2>Beispiel und Beweis</h2>
<div class="ab-player" id="player">
<p class="status" role="status"></p>
<div class="track is-active">
<button type="button" class="track-label" aria-pressed="true" aria-label="Version A hören">A</button>
<canvas aria-hidden="true"></canvas>
</div>
<div class="track">
<button type="button" class="track-label" aria-pressed="false" aria-label="Version B hören">B</button>
<canvas aria-hidden="true"></canvas>
</div>
<div class="transport">
<button type="button" class="play" aria-label="Abspielen" disabled>
<svg class="icon-play" viewBox="0 0 24 24" aria-hidden="true"><path d="M7 4.5v15l13-7.5z"/></svg>
<svg class="icon-pause" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 4h4v16H6zM14 4h4v16h-4z"/></svg>
</button>
<span class="time">0:00 / 0:00</span>
<button type="button" class="toggle" disabled>A/B wechseln</button>
<p class="hint">Leertaste startet und pausiert. [A] wechselt auf A, [B] auf B. [T] wechselt zwischen A und B.</p>
</div>
</div>
<script src="{{ url_for('static', filename='player.js') }}"></script>
<script>
(async () => {
const player = new ABPlayer(document.getElementById("player"));
player.reset();
document.getElementById("player").hidden = true;
try {
await player.load("/static/data/music/m001.mp3", "/static/data/music/m002.mp3");
} catch (err) {
console.error(err);
}
})();
</script>
<div style="height: 50px;"></div>
<h2>Informationen</h2>
<ul>
<li>Dieser Test ist keine Prüfung, sondern dient lediglich der Analyse, wie stark Aufnahmen von der Vereinigung höchstens komprimiert werden sollten.</li>
<li>Der Test besteht aus mehreren Unteraufgaben (alle der gleichen Art; neue kommen wahrscheinlich noch).</li>
<li>Jede Unteraufgabe kann nur einmal abgeschlossen werden.</li>
<li>Sobald bei den Unteraufgaben auf "Bestätigen" gedrückt wird, wird die Auswahl und ihre Richtigkeit auf dem Server gespeichert.</li>
<li>Die Ergebisse (allgemein und personenbezogen) können auf einer passwortgeschützen Seite von dem Admin und dem Verantwortlichen Tontechniker eingesehen werden.</li>
<li>Die gesammelten Daten einer Person werden nach Antrag an <a href="mailto:robin@schanbros.de">robin@schanbros.de</a> innerhalb von 3 Tagen gelöscht.</li>
</ul>
<form action="{{ url_for('main.test') }}" method="get">
<button type="submit">Test starten</button>
</form>
+1 -1
View File
@@ -7,7 +7,7 @@
<h1>Willkommen</h1>
<p class="login-hint">Bitte gib deinen Namen ein, um den Test zu starten.</p>
<form method="post" action="{{ url_for('main.index') }}">
<form method="post" action="{{ url_for('main.start') }}">
<label for="name">Name</label>
<input id="name" name="name" type="text" autocomplete="name" required autofocus>
<button type="submit">Starten</button>
+43 -3
View File
@@ -47,16 +47,31 @@
</label>
</div>
</fieldset>
<button type="submit">Weiter</button>
<button type="submit">Bestätigen</button>
</form>
<div class="result invisible" id="result">
<fieldset>
<legend id="result_title"></legend>
<div id="result_content"></div>
</fieldset>
<button onclick="loadNext();">Weiter</button>
</div>
<script src="{{ url_for('static', filename='player.js') }}"></script>
<script>
const player = new ABPlayer(document.getElementById("player"));
const form = document.getElementById("rating");
async function loadNext() {
const rating_div = document.getElementById("rating");
rating_div.style = "";
const result_div = document.getElementById("result");
result_div.classList.add("invisible");
const res = await fetch("{{ url_for('main.api_getRandomSong') }}");
if (res.status === 401) {
@@ -103,8 +118,33 @@ form.addEventListener("submit", async (e) => {
}
if (!res.ok) throw new Error("HTTP " + res.status);
form.reset();
await loadNext();
const rating_div = document.getElementById("rating");
rating_div.style = "display: none;";
const result_div = document.getElementById("result");
result_div.classList.remove("invisible");
const result_title = document.getElementById("result_title");
const result_content = document.getElementById("result_content");
const data = await res.json();
console.log(data);
if (data.solution.truth !== false) {
if (data.solution.truth === data.solution.choice) {
result_div.classList.add("right");
result_title.innerHTML = "Richtig";
result_content.innerHTML = "Du hast richtig gehört!";
console.log("Richtig [debug]");
} else {
result_title.innerHTML = "Falsch";
result_content.innerHTML = "Du hast falsch gehört!";
result_div.classList.add("wrong");
console.log("Falsch [debug]");
}
} else {
form.reset();
await loadNext();
}
} catch (err) {
console.error(err);
player.setStatus("Die Bewertung konnte nicht gespeichert werden. Bitte versuche es erneut.");