modified: app.py
modified: templates/quiz.html
This commit is contained in:
9
app.py
9
app.py
@@ -224,5 +224,14 @@ def index():
|
|||||||
user = session.get('user') # Benutzerinfos aus der Session holen, falls vorhanden
|
user = session.get('user') # Benutzerinfos aus der Session holen, falls vorhanden
|
||||||
return render_template('index.html', user=user)
|
return render_template('index.html', user=user)
|
||||||
|
|
||||||
|
@app.route("/reset_quiz/<playlist_id>")
|
||||||
|
def reset_quiz(playlist_id):
|
||||||
|
session.pop(f'played_tracks_{playlist_id}', None)
|
||||||
|
session.pop(f'score_{playlist_id}', None)
|
||||||
|
next_mode = request.args.get('next_mode')
|
||||||
|
if next_mode:
|
||||||
|
return redirect(url_for('quiz', playlist_id=playlist_id, mode=next_mode))
|
||||||
|
return redirect(url_for('playlists'))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host="0.0.0.0", port=5000, debug=True)
|
app.run(host="0.0.0.0", port=5000, debug=True)
|
||||||
|
|||||||
@@ -266,8 +266,11 @@
|
|||||||
// Song-Infos ergänzen (du müsstest sie ggf. aus dem Backend mitgeben)
|
// Song-Infos ergänzen (du müsstest sie ggf. aus dem Backend mitgeben)
|
||||||
resultContainer.innerHTML += `
|
resultContainer.innerHTML += `
|
||||||
<div style="margin-top:10px;">
|
<div style="margin-top:10px;">
|
||||||
<img src="{{ track.album.images[0].url }}" alt="Cover" style="width:80px;border-radius:8px;">
|
<img src="{{ track.album.images[0].url }}" alt="Cover" style="width:80px;border-radius:8px;"><br>
|
||||||
<br>
|
<strong>Song:</strong> {{ track.name }}<br>
|
||||||
|
<strong>Künstler:</strong> {{ track.artists[0].name }}<br>
|
||||||
|
<strong>Album:</strong> {{ track.album.name }}<br>
|
||||||
|
<strong>Jahr:</strong> {{ track.album.release_date[:4] }}<br>
|
||||||
<a href="{{ track.external_urls.spotify }}" target="_blank" style="color:#1DB954;">Auf Spotify öffnen</a>
|
<a href="{{ track.external_urls.spotify }}" target="_blank" style="color:#1DB954;">Auf Spotify öffnen</a>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@@ -281,7 +284,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function switchGameMode(mode) {
|
function switchGameMode(mode) {
|
||||||
window.location.href = `/quiz/{{ playlist_id }}?mode=${mode}`;
|
window.location.href = `/reset_quiz/{{ playlist_id }}?next_mode=${mode}`;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
@@ -289,10 +292,13 @@
|
|||||||
<body>
|
<body>
|
||||||
<div style="text-align:center; margin-bottom: 10px;">
|
<div style="text-align:center; margin-bottom: 10px;">
|
||||||
<span id="progressInfo">Frage {{ question_number }} von {{ total_questions }}</span>
|
<span id="progressInfo">Frage {{ question_number }} von {{ total_questions }}</span>
|
||||||
<span id="scoreInfo" style="margin-left:20px;">Punkte: {{ score }}</span>
|
<span id="scoreInfo" style="margin-left:20px;">
|
||||||
|
Richtige: {{ score }} / {{ question_number }}
|
||||||
|
({{ ((score / question_number) * 100) | round(0) if question_number > 0 else 0 }}%)
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div style="text-align:center; margin-bottom: 20px;">
|
<div style="text-align:center; margin-bottom: 20px;">
|
||||||
<a href="/playlists" class="btn btn-danger" style="margin-top:10px;">Quiz beenden</a>
|
<a href="/reset_quiz/{{ playlist_id }}" class="btn btn-danger" style="margin-top:10px;">Quiz beenden</a>
|
||||||
</div>
|
</div>
|
||||||
<h2 id="question-text">Wer ist der Künstler dieses Songs?</h2>
|
<h2 id="question-text">Wer ist der Künstler dieses Songs?</h2>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user