app/static/script.js aktualisiert
This commit is contained in:
parent
2a3bb99cb5
commit
c4a6b81e51
@ -45,6 +45,7 @@ function nextQuestion() {
|
|||||||
btn.innerText = "Prüfen";
|
btn.innerText = "Prüfen";
|
||||||
btn.onclick = checkAnswer;
|
btn.onclick = checkAnswer;
|
||||||
btn.className = "action-btn primary";
|
btn.className = "action-btn primary";
|
||||||
|
|
||||||
document.getElementById('feedback').innerText = '';
|
document.getElementById('feedback').innerText = '';
|
||||||
|
|
||||||
const lids = Array.from(document.querySelectorAll('#lesson-list input:checked')).map(cb => cb.value);
|
const lids = Array.from(document.querySelectorAll('#lesson-list input:checked')).map(cb => cb.value);
|
||||||
@ -90,6 +91,7 @@ function renderCard(card) {
|
|||||||
`;
|
`;
|
||||||
container.appendChild(row);
|
container.appendChild(row);
|
||||||
});
|
});
|
||||||
|
|
||||||
const first = container.querySelector('input');
|
const first = container.querySelector('input');
|
||||||
if(first) first.focus();
|
if(first) first.focus();
|
||||||
}
|
}
|
||||||
@ -104,6 +106,7 @@ function checkAnswer() {
|
|||||||
type: i.dataset.type || 'german'
|
type: i.dataset.type || 'german'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
attempts++;
|
attempts++;
|
||||||
|
|
||||||
fetch('/api/check', {
|
fetch('/api/check', {
|
||||||
@ -119,10 +122,21 @@ function checkAnswer() {
|
|||||||
res.results.forEach((r, idx) => {
|
res.results.forEach((r, idx) => {
|
||||||
const el = inputs[idx];
|
const el = inputs[idx];
|
||||||
el.classList.remove('wrong', 'correct', 'typo', 'incomplete');
|
el.classList.remove('wrong', 'correct', 'typo', 'incomplete');
|
||||||
if (r.status === 'correct') { el.classList.add('correct'); }
|
|
||||||
else if (r.status === 'typo') { el.classList.add('typo'); }
|
if (r.status === 'correct') {
|
||||||
else if (r.status === 'incomplete') { el.classList.add('incomplete'); globalMsg = r.msg; }
|
el.classList.add('correct');
|
||||||
else { el.classList.add('wrong'); }
|
// NEU: Überschreibe den Text mit der perfekten Lösung (mit Strichen)
|
||||||
|
el.value = r.correct;
|
||||||
|
} else if (r.status === 'typo') {
|
||||||
|
el.classList.add('typo');
|
||||||
|
// Optional: Bei Tippfehler auch korrigieren?
|
||||||
|
// el.value = r.correct; (Geschmackssache, hier lassen wir es erstmal so)
|
||||||
|
} else if (r.status === 'incomplete') {
|
||||||
|
el.classList.add('incomplete');
|
||||||
|
globalMsg = r.msg;
|
||||||
|
} else {
|
||||||
|
el.classList.add('wrong');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.all_correct) {
|
if (res.all_correct) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user