Compare commits
27
Commits
fe020b7e70
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f754d8d8bf | ||
|
|
ffe20e8272 | ||
|
|
a9ccdca62c | ||
|
|
7ddb932a6c | ||
|
|
f3546408d2 | ||
|
|
d026cc5470 | ||
|
|
203bab6cf7 | ||
|
|
6595eed927 | ||
|
|
cb050dbc44 | ||
|
|
28984e3ce6 | ||
|
|
cf71bdf928 | ||
|
|
47389fb0a7 | ||
|
|
ec510b5980 | ||
|
|
6673986662 | ||
|
|
ea7cef7f3b | ||
|
|
3f62e4e2d2 | ||
|
|
29ebab923d | ||
|
|
36196a736a | ||
|
|
9b3428d0ab | ||
|
|
ac349b03aa | ||
|
|
32cd1922f5 | ||
|
|
819b9a13dd | ||
|
|
43185dee64 | ||
|
|
023152d417 | ||
|
|
255699a25c | ||
|
|
92807e857a | ||
|
|
535405cf99 |
No files matched your search
@@ -174,3 +174,7 @@ cython_debug/
|
|||||||
# PyPI configuration file
|
# PyPI configuration file
|
||||||
.pypirc
|
.pypirc
|
||||||
|
|
||||||
|
# Database
|
||||||
|
results.db
|
||||||
|
results.db-wal
|
||||||
|
results.db-shm
|
||||||
+142
@@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
from flask import Flask
|
||||||
|
from routes import bp
|
||||||
|
import os
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.secret_key = os.environ["SECRET_KEY"]
|
||||||
|
app.config["MAX_CONTENT_LENGTH"] = 50 * 1024 * 1024 # 50 MB
|
||||||
|
app.register_blueprint(bp)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run(debug=True, host="0.0.0.0")
|
||||||
@@ -0,0 +1,447 @@
|
|||||||
|
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_PATH, 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 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 "pid" in session:
|
||||||
|
return redirect(url_for("main.index"))
|
||||||
|
return render_template("login.html")
|
||||||
|
|
||||||
|
|
||||||
|
@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():
|
||||||
|
return render_template("test.html", name=session["name"])
|
||||||
|
|
||||||
|
@bp.route("/api/getRandomSong")
|
||||||
|
@session_required(api=True)
|
||||||
|
def api_getRandomSong():
|
||||||
|
done = session.get("done", [])
|
||||||
|
#print(done)
|
||||||
|
remaining = [s for s in load_songs_list() if s["id"] not in done]
|
||||||
|
#print(remaining)
|
||||||
|
if not remaining:
|
||||||
|
return jsonify({"finished": True})
|
||||||
|
|
||||||
|
song = remaining[0]
|
||||||
|
truth = random.choice(["a", "b"])
|
||||||
|
session["current"] = {"id": song["id"], "truth": truth}
|
||||||
|
|
||||||
|
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
|
||||||
|
path_b = random_lie_path
|
||||||
|
else:
|
||||||
|
path_a = random_lie_path
|
||||||
|
path_b = truth_path
|
||||||
|
|
||||||
|
return jsonify({
|
||||||
|
"finished": False,
|
||||||
|
"a": url_for("static", filename=path_a),
|
||||||
|
"b": url_for("static", filename=path_b),
|
||||||
|
"number": len(done) + 1,
|
||||||
|
"song_name": song["name"],
|
||||||
|
})
|
||||||
|
|
||||||
|
@bp.route("/api/rate", methods=["POST"])
|
||||||
|
@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
|
||||||
|
|
||||||
|
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", [])
|
||||||
|
if cur["id"] not in done:
|
||||||
|
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, "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})
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,319 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const BINS = 2000; // Auflösung der vorberechneten Pegelwerte pro Datei
|
||||||
|
const BAR_W = 3; // Balkenbreite in CSS-Pixeln
|
||||||
|
const BAR_GAP = 2; // Abstand zwischen Balken
|
||||||
|
const SEEK_STEP = 5; // Sekunden für Pfeiltasten
|
||||||
|
|
||||||
|
/** Maximaler Betrag (Spitzenpegel) pro Abschnitt, über alle Kanäle. */
|
||||||
|
function computePeaks(buffer) {
|
||||||
|
const bins = new Float32Array(BINS);
|
||||||
|
const n = buffer.length;
|
||||||
|
const step = n / BINS;
|
||||||
|
for (let ch = 0; ch < buffer.numberOfChannels; ch++) {
|
||||||
|
const data = buffer.getChannelData(ch);
|
||||||
|
for (let i = 0; i < BINS; i++) {
|
||||||
|
const s = Math.floor(i * step);
|
||||||
|
const e = Math.min(n, Math.floor((i + 1) * step));
|
||||||
|
let max = 0;
|
||||||
|
for (let j = s; j < e; j++) {
|
||||||
|
const v = Math.abs(data[j]);
|
||||||
|
if (v > max) max = v;
|
||||||
|
}
|
||||||
|
if (max > bins[i]) bins[i] = max;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bins;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fmt(t) {
|
||||||
|
t = Math.max(0, Math.floor(t));
|
||||||
|
return Math.floor(t / 60) + ":" + String(t % 60).padStart(2, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawBar(g, x, y, w, h) {
|
||||||
|
g.beginPath();
|
||||||
|
if (g.roundRect) g.roundRect(x, y, w, h, w / 2);
|
||||||
|
else g.rect(x, y, w, h);
|
||||||
|
g.fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
class ABPlayer {
|
||||||
|
constructor(root) {
|
||||||
|
this.root = root;
|
||||||
|
this.tracks = [...root.querySelectorAll(".track")];
|
||||||
|
this.canvases = this.tracks.map(t => t.querySelector("canvas"));
|
||||||
|
this.labels = this.tracks.map(t => t.querySelector(".track-label"));
|
||||||
|
this.playBtn = root.querySelector(".play");
|
||||||
|
this.timeEl = root.querySelector(".time");
|
||||||
|
this.statusEl = root.querySelector(".status");
|
||||||
|
this.toggleBtn = root.querySelector(".toggle");
|
||||||
|
|
||||||
|
this.ctx = null;
|
||||||
|
this.buffers = [null, null];
|
||||||
|
this.peaks = [null, null];
|
||||||
|
this.bars = [[], []];
|
||||||
|
this.norm = 1;
|
||||||
|
this.sources = [];
|
||||||
|
this.gains = [];
|
||||||
|
this.active = 0;
|
||||||
|
this.playing = false;
|
||||||
|
this.ready = false;
|
||||||
|
this.offset = 0;
|
||||||
|
this.startedAt = 0;
|
||||||
|
this.duration = 0;
|
||||||
|
this.raf = 0;
|
||||||
|
this.tick = this.tick.bind(this);
|
||||||
|
|
||||||
|
this.playBtn.addEventListener("click", () => this.toggle());
|
||||||
|
this.labels.forEach((btn, i) => btn.addEventListener("click", () => this.switchTo(i)));
|
||||||
|
this.canvases.forEach((cv, i) => cv.addEventListener("pointerdown", e => this.onCanvasPointer(e, i)));
|
||||||
|
document.addEventListener("keydown", e => this.onKey(e));
|
||||||
|
new ResizeObserver(() => { this.layout(); this.draw(); }).observe(root);
|
||||||
|
matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => this.draw());
|
||||||
|
this.toggleBtn.addEventListener("click", () => this.toggleAB());
|
||||||
|
|
||||||
|
this.refreshUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Laden ---------------------------------------------------------------
|
||||||
|
|
||||||
|
async load(urlA, urlB) {
|
||||||
|
this.reset();
|
||||||
|
this.root.classList.add("is-loading");
|
||||||
|
this.setStatus("Audio wird geladen …");
|
||||||
|
|
||||||
|
const ctx = this.ctx || (this.ctx = new (window.AudioContext || window.webkitAudioContext)());
|
||||||
|
try {
|
||||||
|
this.buffers = await Promise.all([urlA, urlB].map(async url => {
|
||||||
|
const res = await fetch(url);
|
||||||
|
if (!res.ok) throw new Error("HTTP " + res.status);
|
||||||
|
return ctx.decodeAudioData(await res.arrayBuffer());
|
||||||
|
}));
|
||||||
|
} catch (err) {
|
||||||
|
this.root.classList.remove("is-loading");
|
||||||
|
this.setStatus("Audio konnte nicht geladen werden.");
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.peaks = this.buffers.map(computePeaks);
|
||||||
|
// Gemeinsame Normierung, damit Pegelunterschiede zwischen A und B sichtbar bleiben
|
||||||
|
const globalMax = Math.max(...this.peaks.map(p => p.reduce((m, v) => Math.max(m, v), 0)));
|
||||||
|
this.norm = globalMax > 0 ? 1 / globalMax : 1;
|
||||||
|
this.duration = Math.max(...this.buffers.map(b => b.duration));
|
||||||
|
|
||||||
|
this.ready = true;
|
||||||
|
this.root.classList.remove("is-loading");
|
||||||
|
this.setStatus("");
|
||||||
|
this.layout();
|
||||||
|
this.refreshUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
cancelAnimationFrame(this.raf);
|
||||||
|
this.stopSources();
|
||||||
|
this.playing = false;
|
||||||
|
this.ready = false;
|
||||||
|
this.offset = 0;
|
||||||
|
this.active = 0;
|
||||||
|
this.buffers = [null, null];
|
||||||
|
this.bars = [[], []];
|
||||||
|
this.refreshUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Wiedergabe ------------------------------------------------------------
|
||||||
|
|
||||||
|
position() {
|
||||||
|
if (!this.playing) return this.offset;
|
||||||
|
const elapsed = Math.max(0, this.ctx.currentTime - this.startedAt);
|
||||||
|
return Math.min(this.duration, this.offset + elapsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
startSources() {
|
||||||
|
const ctx = this.ctx;
|
||||||
|
this.stopSources();
|
||||||
|
this.sources = this.buffers.map((buf, i) => {
|
||||||
|
const src = ctx.createBufferSource();
|
||||||
|
src.buffer = buf;
|
||||||
|
const gain = ctx.createGain();
|
||||||
|
gain.gain.value = i === this.active ? 1 : 0;
|
||||||
|
src.connect(gain).connect(ctx.destination);
|
||||||
|
this.gains[i] = gain;
|
||||||
|
return src;
|
||||||
|
});
|
||||||
|
// Beide Quellen starten gleichzeitig und laufen stumm bzw. hörbar parallel.
|
||||||
|
// Umschalten ändert nur die Lautstärke, daher ohne Lücke und exakt synchron.
|
||||||
|
const when = ctx.currentTime + 0.02;
|
||||||
|
this.sources.forEach(s => s.start(when, this.offset));
|
||||||
|
this.startedAt = when;
|
||||||
|
}
|
||||||
|
|
||||||
|
stopSources() {
|
||||||
|
this.sources.forEach(s => { try { s.stop(); s.disconnect(); } catch (_) {} });
|
||||||
|
this.sources = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
async play() {
|
||||||
|
if (!this.ready) return;
|
||||||
|
await this.ctx.resume();
|
||||||
|
if (this.offset >= this.duration) this.offset = 0;
|
||||||
|
this.startSources();
|
||||||
|
this.playing = true;
|
||||||
|
this.refreshUI();
|
||||||
|
this.raf = requestAnimationFrame(this.tick);
|
||||||
|
}
|
||||||
|
|
||||||
|
pause() {
|
||||||
|
if (!this.playing) return;
|
||||||
|
this.offset = this.position();
|
||||||
|
this.stopSources();
|
||||||
|
this.playing = false;
|
||||||
|
cancelAnimationFrame(this.raf);
|
||||||
|
this.refreshUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle() { this.playing ? this.pause() : this.play(); }
|
||||||
|
|
||||||
|
seek(t) {
|
||||||
|
if (!this.ready) return;
|
||||||
|
this.offset = Math.min(Math.max(0, t), this.duration);
|
||||||
|
if (this.playing) this.startSources();
|
||||||
|
this.refreshUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
switchTo(i) {
|
||||||
|
if (!this.ready || i === this.active) return;
|
||||||
|
this.active = i;
|
||||||
|
if (this.playing) {
|
||||||
|
const now = this.ctx.currentTime;
|
||||||
|
this.gains.forEach((g, k) => {
|
||||||
|
g.gain.cancelScheduledValues(now);
|
||||||
|
g.gain.setTargetAtTime(k === i ? 1 : 0, now, 0.005); // kurze Rampe gegen Knacken
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.refreshUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleAB() { this.switchTo(1 - this.active); }
|
||||||
|
|
||||||
|
tick() {
|
||||||
|
if (!this.playing) return;
|
||||||
|
if (this.position() >= this.duration) {
|
||||||
|
this.pause();
|
||||||
|
this.offset = 0;
|
||||||
|
this.refreshUI();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.refreshUI();
|
||||||
|
this.raf = requestAnimationFrame(this.tick);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Eingaben --------------------------------------------------------------
|
||||||
|
|
||||||
|
onCanvasPointer(e, i) {
|
||||||
|
if (!this.ready) return;
|
||||||
|
if (i !== this.active) {
|
||||||
|
this.switchTo(i); // Klick auf die andere Spur: wechseln, gleiche Stelle
|
||||||
|
} else {
|
||||||
|
const rect = this.canvases[i].getBoundingClientRect();
|
||||||
|
this.seek((e.clientX - rect.left) / rect.width * this.duration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onKey(e) {
|
||||||
|
if (!this.ready) return;
|
||||||
|
const t = e.target;
|
||||||
|
const isRadio = t.matches('input[type="radio"]');
|
||||||
|
if (t.closest("textarea, select, input:not([type=radio])")) return;
|
||||||
|
if (isRadio && (e.key === " " || e.key.startsWith("Arrow"))) return;
|
||||||
|
if ((e.key === " " || e.key === "Enter") && t.closest("button")) return;
|
||||||
|
|
||||||
|
if (e.key === " ") { e.preventDefault(); this.toggle(); }
|
||||||
|
else if (e.key === "a" || e.key === "A") this.switchTo(0);
|
||||||
|
else if (e.key === "b" || e.key === "B") this.switchTo(1);
|
||||||
|
else if (e.key === "ArrowLeft") { e.preventDefault(); this.seek(this.position() - SEEK_STEP); }
|
||||||
|
else if (e.key === "ArrowRight") { e.preventDefault(); this.seek(this.position() + SEEK_STEP); }
|
||||||
|
else if (e.key === "t" || e.key === "T") this.toggleAB();
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Darstellung -----------------------------------------------------------
|
||||||
|
|
||||||
|
setStatus(msg) { this.statusEl.textContent = msg; }
|
||||||
|
|
||||||
|
/** Balkenhöhen für die aktuelle Breite berechnen. */
|
||||||
|
layout() {
|
||||||
|
if (!this.ready) return;
|
||||||
|
this.canvases.forEach((cv, i) => {
|
||||||
|
const w = cv.clientWidth;
|
||||||
|
const n = Math.max(1, Math.floor((w + BAR_GAP) / (BAR_W + BAR_GAP)));
|
||||||
|
const buf = this.buffers[i];
|
||||||
|
const peaks = this.peaks[i];
|
||||||
|
const bars = new Array(n);
|
||||||
|
for (let k = 0; k < n; k++) {
|
||||||
|
const b0 = Math.floor((k / n) * this.duration / buf.duration * BINS);
|
||||||
|
const b1 = Math.floor(((k + 1) / n) * this.duration / buf.duration * BINS);
|
||||||
|
let max = 0;
|
||||||
|
for (let b = b0; b < Math.min(BINS, Math.max(b1, b0 + 1)); b++) {
|
||||||
|
if (peaks[b] > max) max = peaks[b];
|
||||||
|
}
|
||||||
|
bars[k] = max * this.norm;
|
||||||
|
}
|
||||||
|
this.bars[i] = bars;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshUI() {
|
||||||
|
this.root.classList.toggle("is-playing", this.playing);
|
||||||
|
this.playBtn.disabled = !this.ready;
|
||||||
|
this.playBtn.setAttribute("aria-label", this.playing ? "Pause" : "Abspielen");
|
||||||
|
this.toggleBtn.disabled = !this.ready;
|
||||||
|
this.tracks.forEach((el, i) => {
|
||||||
|
el.classList.toggle("is-active", i === this.active);
|
||||||
|
this.labels[i].setAttribute("aria-pressed", String(i === this.active));
|
||||||
|
});
|
||||||
|
this.timeEl.textContent = fmt(this.position()) + " / " + fmt(this.duration);
|
||||||
|
this.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
draw() {
|
||||||
|
const dpr = window.devicePixelRatio || 1;
|
||||||
|
const cs = getComputedStyle(this.root);
|
||||||
|
const accent = cs.getPropertyValue("--accent").trim() || "#2563eb";
|
||||||
|
const muted = cs.getPropertyValue("--muted").trim() || "#888";
|
||||||
|
const text = cs.getPropertyValue("--text").trim() || "#000";
|
||||||
|
const progress = this.duration ? this.position() / this.duration : 0;
|
||||||
|
|
||||||
|
this.canvases.forEach((cv, i) => {
|
||||||
|
const w = cv.clientWidth, h = cv.clientHeight;
|
||||||
|
if (cv.width !== Math.round(w * dpr) || cv.height !== Math.round(h * dpr)) {
|
||||||
|
cv.width = Math.round(w * dpr);
|
||||||
|
cv.height = Math.round(h * dpr);
|
||||||
|
}
|
||||||
|
const g = cv.getContext("2d");
|
||||||
|
g.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||||
|
g.clearRect(0, 0, w, h);
|
||||||
|
|
||||||
|
const bars = this.bars[i];
|
||||||
|
const isActive = i === this.active;
|
||||||
|
const n = bars.length;
|
||||||
|
if (!n) return;
|
||||||
|
|
||||||
|
const total = n * BAR_W + (n - 1) * BAR_GAP;
|
||||||
|
const x0 = (w - total) / 2;
|
||||||
|
|
||||||
|
for (let k = 0; k < n; k++) {
|
||||||
|
const played = (k + 0.5) / n <= progress;
|
||||||
|
g.fillStyle = played ? accent : muted;
|
||||||
|
g.globalAlpha = played ? (isActive ? 1 : 0.4) : (isActive ? 0.55 : 0.25);
|
||||||
|
const bh = Math.max(2, bars[k] * h * 0.92);
|
||||||
|
drawBar(g, x0 + k * (BAR_W + BAR_GAP), (h - bh) / 2, BAR_W, bh);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Abspielposition
|
||||||
|
g.globalAlpha = isActive ? 0.9 : 0.3;
|
||||||
|
g.fillStyle = text;
|
||||||
|
g.fillRect(Math.min(w - 1, x0 + progress * total), 0, 1.5, h);
|
||||||
|
g.globalAlpha = 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
/* A/B-Player. Nutzt die Variablen aus base.html (--surface, --border, --accent, ...) */
|
||||||
|
|
||||||
|
.ab-player {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: .75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ab-player .status {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: .95rem;
|
||||||
|
}
|
||||||
|
.ab-player .status:empty { display: none; }
|
||||||
|
|
||||||
|
.ab-player.is-loading .track { opacity: .5; }
|
||||||
|
|
||||||
|
/* --- Spuren -------------------------------------------------------------- */
|
||||||
|
|
||||||
|
.ab-player .track {
|
||||||
|
display: flex;
|
||||||
|
gap: .75rem;
|
||||||
|
padding: .5rem;
|
||||||
|
background: var(--surface);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 10px;
|
||||||
|
transition: border-color .15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ab-player .track.is-active { border-color: var(--accent); }
|
||||||
|
|
||||||
|
.ab-player .track canvas {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 72px;
|
||||||
|
display: block;
|
||||||
|
cursor: pointer;
|
||||||
|
touch-action: manipulation;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ab-player .track-label {
|
||||||
|
flex: none;
|
||||||
|
width: 2.75rem;
|
||||||
|
padding: 0;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text);
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ab-player .track.is-active .track-label {
|
||||||
|
color: var(--accent-text);
|
||||||
|
background: var(--accent);
|
||||||
|
border-color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Steuerung ----------------------------------------------------------- */
|
||||||
|
|
||||||
|
.ab-player .transport {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ab-player .play {
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
width: 3.25rem;
|
||||||
|
height: 3.25rem;
|
||||||
|
padding: 0;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ab-player .play:disabled { opacity: .4; cursor: default; }
|
||||||
|
.ab-player .play svg { width: 1.4rem; height: 1.4rem; fill: currentColor; }
|
||||||
|
.ab-player:not(.is-playing) .icon-pause { display: none; }
|
||||||
|
.ab-player.is-playing .icon-play { display: none; }
|
||||||
|
|
||||||
|
.ab-player .time {
|
||||||
|
color: var(--muted);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ab-player .hint {
|
||||||
|
margin: 0 0 0 auto;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: .85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ab-player button:focus-visible {
|
||||||
|
outline: 2px solid var(--accent);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ab-player .toggle {
|
||||||
|
min-height: 2.75rem;
|
||||||
|
padding: 0 1rem;
|
||||||
|
color: var(--text);
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ab-player .toggle:disabled { opacity: .4; cursor: default; }
|
||||||
|
|
||||||
|
/* --- Handy --------------------------------------------------------------- */
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.ab-player .track { gap: .5rem; }
|
||||||
|
.ab-player .track canvas { height: 56px; }
|
||||||
|
.ab-player .track-label { width: 2.5rem; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Tastaturhinweis nur dort, wo es eine Tastatur gibt */
|
||||||
|
@media (hover: none) {
|
||||||
|
.ab-player .hint { display: none; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,183 @@
|
|||||||
|
:root {
|
||||||
|
--bg: #ffffff;
|
||||||
|
--surface: #f4f5f7;
|
||||||
|
--text: #1b1e23;
|
||||||
|
--muted: #5f6672;
|
||||||
|
--border: #d8dbe0;
|
||||||
|
--accent: #2563eb;
|
||||||
|
--accent-text: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--bg: #14161a;
|
||||||
|
--surface: #1d2025;
|
||||||
|
--text: #e6e8eb;
|
||||||
|
--muted: #9aa1ac;
|
||||||
|
--border: #2f343b;
|
||||||
|
--accent: #5b8def;
|
||||||
|
--accent-text: #0e1116;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
* { box-sizing: border-box; }
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--text);
|
||||||
|
font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
header {
|
||||||
|
background: var(--surface);
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-inner {
|
||||||
|
max-width: 720px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: .75rem 1rem;
|
||||||
|
display: flex;
|
||||||
|
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 {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
color: var(--text);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user { color: var(--muted); font-size: .9rem; }
|
||||||
|
|
||||||
|
main {
|
||||||
|
max-width: 720px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 1.5rem 1rem 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
a { color: var(--accent); }
|
||||||
|
|
||||||
|
input, textarea, select, button {
|
||||||
|
font: inherit;
|
||||||
|
color: var(--text);
|
||||||
|
background: var(--surface);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: .5rem .75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
background: var(--accent);
|
||||||
|
color: var(--accent-text);
|
||||||
|
border-color: var(--accent);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
filter: brightness(1.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
audio { width: 100%; }
|
||||||
|
|
||||||
|
|
||||||
|
.login-wrap {
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
min-height: 70vh; /* Fallback für ältere Browser */
|
||||||
|
min-height: 70dvh; /* berücksichtigt die Adressleiste auf dem Handy */
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-card {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 22rem;
|
||||||
|
padding: 1.5rem;
|
||||||
|
background: var(--surface);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-card h1 {
|
||||||
|
margin: 0 0 .25rem;
|
||||||
|
font-size: 1.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-hint {
|
||||||
|
margin: 0 0 1.25rem;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: .95rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-card label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: .25rem;
|
||||||
|
font-size: .9rem;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-card input,
|
||||||
|
.login-card button {
|
||||||
|
width: 100%;
|
||||||
|
font-size: 1rem; /* mind. 16px, sonst zoomt iOS beim Fokussieren hinein */
|
||||||
|
min-height: 2.75rem; /* gut mit dem Daumen treffbar */
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
.rating {
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
padding-top: 1.25rem;
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating fieldset {
|
||||||
|
margin: 0 0 1rem;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating legend {
|
||||||
|
padding: 0;
|
||||||
|
margin-bottom: .75rem;
|
||||||
|
font-size: 1.05rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating .choices {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr 2fr;
|
||||||
|
gap: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating .choice {
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Das echte Radio bleibt für Tastatur und Screenreader erhalten, ist aber unsichtbar */
|
||||||
|
.rating .choice input {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
opacity: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating .choice span {
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
min-height: 3rem;
|
||||||
|
padding: 0 .75rem;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text);
|
||||||
|
background: var(--surface);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
transition: border-color .15s, background-color .15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating .choice input:hover + span { border-color: var(--accent); }
|
||||||
|
|
||||||
|
.rating .choice input:checked + span {
|
||||||
|
color: var(--accent-text);
|
||||||
|
background: var(--accent);
|
||||||
|
border-color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating .choice input:focus-visible + span {
|
||||||
|
outline: 2px solid var(--accent);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating button[type="submit"] {
|
||||||
|
min-height: 2.75rem;
|
||||||
|
padding: 0 1.75rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating button[type="submit"]:disabled { opacity: .5; cursor: default; }
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.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%; }
|
||||||
|
}
|
||||||
@@ -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 %}
|
||||||
@@ -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 %}
|
||||||
@@ -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 %}
|
||||||
@@ -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 %}
|
||||||
@@ -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 %}
|
||||||
@@ -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 %}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta name="color-scheme" content="light dark">
|
||||||
|
<title>{% block title %}AudioRating{% endblock %}</title>
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='style/style.css') }}">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<div class="header-inner">
|
||||||
|
<a class="brand" href="{{ url_for('main.index') }}">AudioRating</a>
|
||||||
|
<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>
|
||||||
@@ -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 %}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
{% 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>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="login-wrap">
|
||||||
|
<div class="login-card">
|
||||||
|
<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.start') }}">
|
||||||
|
<label for="name">Name</label>
|
||||||
|
<input id="name" name="name" type="text" autocomplete="name" required autofocus>
|
||||||
|
<button type="submit">Starten</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
{% 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 id="title"></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>
|
||||||
|
|
||||||
|
<form class="rating" id="rating">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Welche Version hat die bessere Qualität?</legend>
|
||||||
|
<div class="choices">
|
||||||
|
<label class="choice">
|
||||||
|
<input type="radio" name="choice" value="a" required>
|
||||||
|
<span>A</span>
|
||||||
|
</label>
|
||||||
|
<label class="choice">
|
||||||
|
<input type="radio" name="choice" value="b">
|
||||||
|
<span>B</span>
|
||||||
|
</label>
|
||||||
|
<label class="choice choice-none">
|
||||||
|
<input type="radio" name="choice" value="non">
|
||||||
|
<span>Kein Unterschied</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<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) {
|
||||||
|
location.href = "{{ url_for('main.index') }}";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await res.json();
|
||||||
|
|
||||||
|
if (data.finished) {
|
||||||
|
player.reset();
|
||||||
|
document.getElementById("title").textContent = "Fertig, danke!";
|
||||||
|
document.getElementById("player").hidden = true;
|
||||||
|
form.hidden = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById("title").textContent = "Test " + data.number + ": " + data.song_name;
|
||||||
|
try {
|
||||||
|
await player.load(data.a, data.b);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
form.addEventListener("submit", async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const choice = new FormData(form).get("choice");
|
||||||
|
const submit = form.querySelector("button[type=submit]");
|
||||||
|
|
||||||
|
submit.disabled = true;
|
||||||
|
player.pause();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await fetch("{{ url_for('main.api_rate') }}", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ choice }),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.status === 401) {
|
||||||
|
location.href = "{{ url_for('main.index') }}";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!res.ok) throw new Error("HTTP " + res.status);
|
||||||
|
|
||||||
|
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_div.classList.remove("wrong");
|
||||||
|
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");
|
||||||
|
result_div.classList.remove("right");
|
||||||
|
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.");
|
||||||
|
} finally {
|
||||||
|
submit.disabled = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
loadNext();
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
Reference in new issue
Block a user