Quiz: 3. Alle 3 Fragen + Punktezähler
This commit is contained in:
parent
36aa124e06
commit
3a820fa9e4
1 changed files with 46 additions and 5 deletions
51
js/quiz.js
51
js/quiz.js
|
|
@ -7,15 +7,41 @@ const fragen = [
|
||||||
"Eine Mal-Technik mit Wasserfarben"
|
"Eine Mal-Technik mit Wasserfarben"
|
||||||
],
|
],
|
||||||
richtig: 1
|
richtig: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
frage: "Welche Farbe erzeugt die Cyanotypie typischerweise?",
|
||||||
|
antworten: [
|
||||||
|
"Rot",
|
||||||
|
"Schwarz",
|
||||||
|
"Blau"
|
||||||
|
],
|
||||||
|
richtig: 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
frage: "Was wird bei der Cyanotypie zur Belichtung benötigt?",
|
||||||
|
antworten: [
|
||||||
|
"Eine Dunkelkammer",
|
||||||
|
"UV-Licht / Sonnenlicht",
|
||||||
|
"Ein Drucker"
|
||||||
|
],
|
||||||
|
richtig: 1
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
let aktuelle = 0;
|
||||||
const quiz = document.getElementById("quiz");
|
let punkte = 0;
|
||||||
|
|
||||||
const f = fragen[0];
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
quiz.innerHTML = `
|
zeigeFrage();
|
||||||
|
});
|
||||||
|
|
||||||
|
function zeigeFrage() {
|
||||||
|
const quiz = document.getElementById("quiz");
|
||||||
|
const f = fragen[aktuelle];
|
||||||
|
|
||||||
|
quiz.innerHTML = `
|
||||||
<div class="quiz-frage">
|
<div class="quiz-frage">
|
||||||
|
<p class="frage-nummer">Frage ${aktuelle + 1} von ${fragen.length} | Punkte: ${punkte}</p>
|
||||||
<p class="frage-text">${f.frage}</p>
|
<p class="frage-text">${f.frage}</p>
|
||||||
<div class="antworten">
|
<div class="antworten">
|
||||||
${f.antworten.map((a, i) => `
|
${f.antworten.map((a, i) => `
|
||||||
|
|
@ -34,12 +60,27 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
if (gewählt === f.richtig) {
|
if (gewählt === f.richtig) {
|
||||||
feedback.textContent = "✅ Richtig!";
|
feedback.textContent = "✅ Richtig!";
|
||||||
feedback.style.color = "#16a34a";
|
feedback.style.color = "#16a34a";
|
||||||
|
punkte++;
|
||||||
} else {
|
} else {
|
||||||
feedback.textContent = "❌ Falsch!";
|
feedback.textContent = "❌ Falsch!";
|
||||||
feedback.style.color = "#ef4444";
|
feedback.style.color = "#ef4444";
|
||||||
}
|
}
|
||||||
|
|
||||||
document.querySelectorAll(".quiz-btn").forEach(b => b.disabled = true);
|
document.querySelectorAll(".quiz-btn").forEach(b => b.disabled = true);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
aktuelle++;
|
||||||
|
if (aktuelle < fragen.length) {
|
||||||
|
zeigeFrage();
|
||||||
|
} else {
|
||||||
|
quiz.innerHTML = `
|
||||||
|
<div class="quiz-ende">
|
||||||
|
<p>Du hast ${punkte} von ${fragen.length} richtig!</p>
|
||||||
|
<p>Punkte: ${punkte}</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}, 800);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
Loading…
Reference in a new issue