schönes Siegerpodest (und bessere Punkteübersicht)

This commit is contained in:
ben8
2025-07-29 19:01:20 +02:00
parent 2da75fdb52
commit d03c99b8e3
12 changed files with 1210 additions and 76 deletions

View File

@@ -2,9 +2,9 @@
{% block content %}
<div class="container mx-auto px-4">
<div class="bg-white rounded-lg shadow-md p-6 mb-6 dark:bg-transparent dark:text-white">
<div class="bg-white rounded-lg shadow-md p-6 mb-6 dark:bg-transparent dark:text-white ">
<h1 class="text-3xl font-bold mb-6">Ergebnisse</h1>
{% if request.session.mode == "learn" or is_host %}
<div class="mb-6">
<h2 class="text-xl font-bold mb-4">Aktuelle Frage</h2>
@@ -64,61 +64,58 @@
<p class="text-gray-600" id="option-count-1">0 Antworten</p>
</div>
</div>
{% endif %}
{% else %}
<div class="flex flex-col items-center justify-center text-center pt-4">
{% if participant.last_answer_correct %}
<!-- Richtig-Symbol -->
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke-width="1.5" stroke="currentColor"
class="text-green-500 size-40">
<path stroke-linecap="round" stroke-linejoin="round"
d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
</svg>
<!-- Feedback-Text -->
<div id="antwort-richtig"
class="pt-3 text-gray-600 dark:text-white font-bold max-w-xs md:max-w-sm">
Hier erscheint gleich dein Feedback...
</div>
{% elif participant.last_answer_correct == False %}
<!-- Falsch-Symbol -->
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke-width="1.5" stroke="currentColor"
class="text-red-500 size-40">
<path stroke-linecap="round" stroke-linejoin="round"
d="m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
</svg>
<!-- Feedback-Text -->
<div id="antwort-falsch"
class="pt-3 text-gray-600 dark:text-white font-bold max-w-xs md:max-w-sm">
Hier erscheint gleich dein Feedback...
</div>
{% endif %}
<p class="text-blue-600 font-bold text-md">+{{ participant.last_score }} Punkte</p>
</div>
{% endif %}
</div>
<div class="mb-6">
{% if request.session.mode == "learn" %}
<h2 class="text-xl font-bold mb-4">Punktestand</h2>
{% if is_last_question and request.session.mode != "learn" %}
<!-- Siegerpodest -->
<div class="flex justify-center items-end gap-4 mb-8">
<!-- Platz 2 links -->
{% with participant=participants.1 %}
<div class="flex flex-col items-center break-words">
<span class="display_name text-gray-600 font-black text-2xl dark:text-white " id="display_name-1">{{ participant.display_name }}</span>
<p data-score="{{ participant.score }}" data-last-score="{{ participant.last_score }}" class="dark:text-white text-gray-600 font-bold show-score text-md" id="score-1">{{ participant.score }}</p>
<div class="h-40 w-24 rounded-t-md font-bold text-center text-base shadow-lg bg-gradient-to-b from-gray-400 via-gray-300 to-gray-300 flex flex-col items-center justify-center text-black dark:text-white cursor-pointer leading-tight">
<span class="size-10 rounded-full bg-white text-black text-center flex items-center justify-center font-bold text-3xl">🥈</span><br>{{ participant.display_name }}
</div>
</div>
{% endwith %}
<!-- Platz 1 mitte -->
{% with participant=participants.0 %}
<div class="flex flex-col items-center break-words">
<span class="display_name text-gray-600 font-black text-2xl dark:text-white" id="display_name-0">{{ participant.display_name }}</span>
<p data-score="{{ participant.score }}" data-last-score="{{ participant.last_score }}" class="dark:text-white text-gray-600 font-bold show-score text-md" id="score-0">{{ participant.score }}</p>
<div class="h-64 w-24 rounded-t-md font-bold text-center text-base shadow-lg bg-gradient-to-b from-yellow-400 via-yellow-300 to-yellow-600 flex flex-col items-center justify-center text-black dark:text-white cursor-pointer leading-tight">
<span class="size-12 rounded-full bg-white text-black text-center flex items-center justify-center font-bold text-4xl"> 🥇</span><br>
</div>
</div>
{% endwith %}
<!-- Platz 3 rechts -->
{% with participant=participants.2 %}
<div class="flex flex-col items-center break-words">
<span class="display_name text-gray-600 font-black text-2xl dark:text-white " id="display_name-2">{{ participant.display_name }}</span>
<p data-score="{{ participant.score }}" data-last-score="{{ participant.last_score }}" class="dark:text-white text-gray-600 font-bold show-score text-md" id="score-2">{{ participant.score }}</p>
<div class="h-30 w-24 rounded-t-md font-bold text-center text-base shadow-lg bg-gradient-to-b from-orange-500 via-orange-400 to-orange-700 flex flex-col items-center justify-center text-black dark:text-white cursor-pointer leading-tight">
<span class="size-10 rounded-full bg-white text-black text-center flex items-center justify-center font-bold text-3xl ">🥉</span><br>{{ participant.display_name }}
</div>
</div>
{% endwith %}
</div>
{% endif %}
{% endif %}
<div id="scoreboard" class="leading-relaxed">
{% for participant in participants %}
{% if not is_last_question or request.session.mode == "learn" %}
{% if request.session.mode == "learn" %}
{% if participant == my_participant or is_host %}
<div class="dark:bg-transparent mt-2 shadow-sm p-4 bg-gray-100 rounded-lg border-2 border {% if forloop.counter <= 3 %}border-yellow-500{% else %}border-transparent{% endif %}">
<div class="flex flex-col items-start gap-1">
@@ -189,13 +186,29 @@
{% if is_host %}
{% if is_last_question %}
{% if is_last_question and request.session.mode != "learn" %}
<button id="winner-button" class="mt-4 w-full p-3 rounded-full bg-blue-600 text-white font-bold hover:bg-blue-700 transition-colors duration-200">
Siegerpodest
</button>
{% else %}
<button id="finish-button" class="mt-4 w-full p-3 rounded-full bg-blue-600 text-white font-bold hover:bg-blue-700 transition-colors duration-200">
Quiz beenden
</button>
{% endif %}
{% else %}
<button id="next-button" class="mt-4 w-full p-3 rounded-full bg-blue-600 text-white font-bold hover:bg-blue-700 transition-colors duration-200">
{% if request.session.mode == "learn" %}
<button id="next-button" class="mt-4 w-full p-3 rounded-full bg-blue-600 text-white font-bold hover:bg-blue-700 transition-colors duration-200">
Nächste Frage
</button>
{% else %}
<button id="scoreboard-button" class="mt-4 w-full p-3 rounded-full bg-blue-600 text-white font-bold hover:bg-blue-700 transition-colors duration-200">
Punkteübersicht
</button>
{% endif %}
{% endif %}
{% endif %}
</div>
@@ -205,23 +218,6 @@
{% block extra_js %}
{% if is_last_question %}
<script>
// Hilfsfunktion für Pausen
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function triggerConfetti() {
const end = Date.now() + 15 * 1000;
(function frame() {
confetti({ particleCount: 2, angle: 60, spread: 55, origin: { x: 0 } });
confetti({ particleCount: 2, angle: 120, spread: 55, origin: { x: 1 } });
if (Date.now() < end) requestAnimationFrame(frame);
})();
}
triggerConfetti();
</script>
{% endif %}
{% include 'play/game/common_scripts.html' %}
{% if is_host %}
@@ -232,6 +228,16 @@
<script>
function triggerConfetti() {
const end = Date.now() + 30 * 1000;
(function frame() {
confetti({ particleCount: 2, angle: 60, spread: 55, origin: { x: 0 } });
confetti({ particleCount: 2, angle: 120, spread: 55, origin: { x: 1 } });
if (Date.now() < end) requestAnimationFrame(frame);
})();
}
async function start() {
elements=document.getElementsByClassName("show-score");
@@ -269,6 +275,9 @@
{% if is_last_question %}
start();
bounce();
{% if request.session.mode == "learn" %}
triggerConfetti();
{% endif %}
{% else %}
@@ -348,10 +357,11 @@ if (antwortRichtig) {
gameSocket.onmessage = function(e) {
const data = JSON.parse(e.data);
if (data.type === 'game_state_update' &&
data.redirect_url &&
(data.action === 'next_question' || data.action === 'finish_game')) {
window.location.href = data.redirect_url;
} else if (data.type === 'answer_stats') {
data.redirect_url &&
(data.action === 'next_question' || data.action === 'finish_game' || data.action === 'show_winner_podest'|| data.action === 'show_scoreboard')) {
window.location.href = data.redirect_url;
}
else if (data.type === 'answer_stats') {
updateAnswerStats(data.stats);
}
};
@@ -377,7 +387,30 @@ if (antwortRichtig) {
}));
});
}
var podestButton = document.getElementById('winner-button');
if (podestButton) {
podestButton.addEventListener('click', function() {
gameSocket.send(JSON.stringify({
'type': 'winner_podest',
'host_id': hostId
}));
});
}
{% else %}
var scoreboardButton = document.getElementById('scoreboard-button');
if (scoreboardButton) {
scoreboardButton.addEventListener('click', function() {
gameSocket.send(JSON.stringify({
'type': 'scoreboard',
'host_id': hostId
}));
});
}
var nextButton = document.getElementById('next-button');
if (nextButton) {
nextButton.addEventListener('click', function() {