Deutsch Quiz - Tiere
Invata animalele in limba germana
Intrebarea 1 din 10
Ce inseamna cuvantul german?
Hund
Punctaj: 0
#tierquiz .tq-answer {
display:block;
width:100%;
margin:8px 0;
padding:12px;
background:#f0f7f2;
color:#222;
border:1px solid #4b9b72;
border-radius:8px;
font-size:17px;
cursor:pointer;
}
#tierquiz .tq-answer:disabled {
cursor:default;
opacity:1;
}
#tierquiz button:focus,
#tierquiz .tq-answer:focus {
outline:2px solid #26734d;
}
(function () {
var root = document.getElementById("tierquiz");
if (!root || root.dataset.started === "yes") return;
root.dataset.started = "yes";
var questions = [
{ word: "Hund", correct: "caine", options: ["pisica", "caine", "iepure"] },
{ word: "Katze", correct: "pisica", options: ["cal", "pisica", "vaca"] },
{ word: "Pferd", correct: "cal", options: ["oaie", "caine", "cal"] },
{ word: "Kuh", correct: "vaca", options: ["vaca", "pisica", "pasare"] },
{ word: "Hase", correct: "iepure", options: ["iepure", "cal", "porc"] },
{ word: "Maus", correct: "soarece", options: ["vaca", "soarece", "caine"] },
{ word: "Vogel", correct: "pasare", options: ["peste", "pisica", "pasare"] },
{ word: "Fisch", correct: "peste", options: ["peste", "oaie", "iepure"] },
{ word: "Schwein", correct: "porc", options: ["cal", "porc", "soarece"] },
{ word: "Schaf", correct: "oaie", options: ["pasare", "vaca", "oaie"] }
];
var index = 0;
var score = 0;
var answered = false;
var progress = root.querySelector("#tq-progress");
var word = root.querySelector("#tq-word");
var options = root.querySelector("#tq-options");
var feedback = root.querySelector("#tq-feedback");
var scoreText = root.querySelector("#tq-score");
var next = root.querySelector("#tq-next");
var result = root.querySelector("#tq-result");
function showQuestion() {
answered = false;
var q = questions[index];
progress.textContent = "Intrebarea " + (index + 1) + " din " + questions.length;
word.textContent = q.word;
feedback.textContent = "";
scoreText.textContent = "Punctaj: " + score;
options.textContent = "";
next.style.display = "none";
q.options.forEach(function (answer) {
var button = document.createElement("button");
button.type = "button";
button.className = "tq-answer";
button.textContent = answer;
button.addEventListener("click", function () {
checkAnswer(answer, button);
});
options.appendChild(button);
});
}
function checkAnswer(answer, button) {
if (answered) return;
answered = true;
var q = questions[index];
var buttons = options.querySelectorAll("button");
buttons.forEach(function (b) {
b.disabled = true;
});
if (answer === q.correct) {
score++;
feedback.textContent = "Richtig! Raspuns corect.";
feedback.style.color = "#26734d";
} else {
feedback.textContent = "Falsch! Raspuns corect: " + q.correct;
feedback.style.color = "#b42318";
}
scoreText.textContent = "Punctaj: " + score;
button.style.fontWeight = "bold";
next.textContent = index === questions.length - 1
? "Vezi rezultatul"
: "Urmatoarea intrebare";
next.style.display = "inline-block";
}
next.addEventListener("click", function () {
if (!answered) return;
index++;
if (index < questions.length) {
showQuestion();
} else {
progress.textContent = "Joc terminat";
word.textContent = "";
options.textContent = "";
feedback.textContent = "";
scoreText.textContent = "";
next.style.display = "none";
result.textContent = "Ai obtinut " + score + " puncte din " + questions.length + ".";
result.style.fontSize = "24px";
result.style.fontWeight = "bold";
result.style.color = "#26734d";
var restart = document.createElement("button");
restart.type = "button";
restart.textContent = "Joaca din nou";
restart.className = "tq-answer";
restart.addEventListener("click", function () {
index = 0;
score = 0;
result.textContent = "";
showQuestion();
});
options.appendChild(restart);
}
});
showQuestion();
})();