Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf71bdf928 | ||
|
|
47389fb0a7 | ||
|
|
ec510b5980 | ||
|
|
6673986662 | ||
|
|
ea7cef7f3b | ||
|
|
3f62e4e2d2 |
No files matched your search
+2
-2
@@ -5,13 +5,13 @@
|
||||
"id": "002",
|
||||
"original_name": "-",
|
||||
"original": {
|
||||
"filename": "m003",
|
||||
"filename": "m003.mp3",
|
||||
"sampling_rate": 44.1,
|
||||
"bitrate": 256
|
||||
},
|
||||
"edits": [
|
||||
{
|
||||
"filename": "m004",
|
||||
"filename": "m004.mp3",
|
||||
"sampling_rate": 22.1,
|
||||
"bitrate": 63
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ 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
|
||||
|
||||
bp = Blueprint("main", __name__)
|
||||
|
||||
@@ -135,8 +136,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
|
||||
@@ -226,42 +227,7 @@ CHOICE_LABELS = {"a": "A", "b": "B", "non": "Kein Unterschied"}
|
||||
@bp.route("/admin")
|
||||
@admin_required
|
||||
def admin():
|
||||
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.html", rows=rows, stats=stats, songs=songs)
|
||||
return render_template("admin.html")
|
||||
|
||||
|
||||
def csv_safe(value):
|
||||
@@ -310,6 +276,52 @@ def debug_reset():
|
||||
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("/api/admin/add", methods=["POST"])
|
||||
@admin_required
|
||||
def api_admin_add():
|
||||
@@ -330,11 +342,18 @@ def api_admin_add():
|
||||
BASE_MUSIC_DIR.mkdir(parents=True, exist_ok=True)
|
||||
file.save(BASE_MUSIC_DIR / filename_new)
|
||||
|
||||
stem = os.path.splitext(filename_new)[0]
|
||||
# read bitrate and sampling rate
|
||||
audio = File(BASE_MUSIC_DIR / filename_new)
|
||||
|
||||
#stem = os.path.splitext(filename_new)[0]
|
||||
song = add_song({
|
||||
"name": title,
|
||||
"artist": artist,
|
||||
"original": {"filename": stem},
|
||||
"original": {
|
||||
"filename": filename_new,
|
||||
"sampling_rate": audio.info.sample_rate,
|
||||
"bitrate": audio.info.bitrate
|
||||
},
|
||||
"edits": [],
|
||||
})
|
||||
|
||||
|
||||
+6
-58
@@ -1,73 +1,21 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Auswertung – HörVergleich{% endblock %}
|
||||
{% block content %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style/admin.css') }}">
|
||||
|
||||
<div class="admin-head">
|
||||
<h2>Auswertung</h2>
|
||||
<h2>{% block admin_title %}Admin{% endblock %}</h2>
|
||||
<div class="admin-actions">
|
||||
<a class="button" href="{{ url_for('main.admin_export') }}">CSV exportieren</a>
|
||||
<a class="button" href="{{ url_for('main.admin_add') }}">Unteraufgabe hinzufügen</a>
|
||||
{% block admin_header %}{% endblock %}
|
||||
<form method="post" action="{{ url_for('main.admin_logout') }}">
|
||||
<button type="submit" class="secondary">Abmelden</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
{% block admin_content %}
|
||||
|
||||
{% 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>
|
||||
<a class="button" href="{{ url_for('main.admin_list') }}">Unteraufgaben</a>
|
||||
<a class="button" href="{{ url_for('main.admin_results') }}">Auswertung</a>
|
||||
|
||||
<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 %}
|
||||
{% endblock %}
|
||||
@@ -1,8 +1,8 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style/admin.css') }}">
|
||||
{% extends "admin.html" %}
|
||||
|
||||
<h2>Unteraufgabe hinzufügen</h2>
|
||||
{% 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>
|
||||
|
||||
@@ -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,13 @@
|
||||
{% 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 %}
|
||||
|
||||
{{ songs }}
|
||||
|
||||
{% endblock %}
|
||||
Reference in new issue
Block a user