Testas Žodžių skiemenavimas

Žodžių skiemenavimas

Paspausk tarp raidžių, kad pažymėtum, kur baigiasi skiemuo.


Žodis 1 iš 10

// --- Duomenys --- const words = [ { word: 'lapinas', syllables: [2, 4] }, // la-pi-nas { word: 'automobilis', syllables: [2, 4, 6, 8] }, // au-to-mo-bi-lis { word: 'mokytoja', syllables: [2, 4, 6] }, // mo-ky-to-ja { word: 'knygynas', syllables: [3, 5] }, // kny-gy-nas { word: 'pavasaris', syllables: [2, 4, 6] }, // pa-va-sa-ris { word: 'kompiuteris', syllables: [3, 6, 8] }, // kom-piu-te-ris { word: 'atėjimas', syllables: [1, 3, 5] }, // a-tė-ji-mas { word: 'dramblys', syllables: [5] }, // dramb-lys (dramb-lys) { word: 'egzaminas', syllables: [2, 4, 6] }, // eg-za-mi-nas { word: 'sąsiuvinis', syllables: [2, 5, 7] } // są-siu-vi-nis ];

// --- Būsenos kintamieji --- let currentWordIndex = 0; let userSyllables = []; let isChecked = false; let correctAnswers = 0; // Pridėta: Teisingų atsakymų skaičius

// --- DOM elementai --- const mainCard = document.getElementById('main-card'); // Pagrindinė kortelė const wordContainer = document.getElementById('word-container'); const checkBtn = document.getElementById('check-btn'); const nextBtn = document.getElementById('next-btn'); const feedbackEl = document.getElementById('feedback'); const progressEl = document.getElementById('progress'); const instructionEl = document.getElementById('instruction'); const resultsCard = document.getElementById('results-card'); // Rezultatų kortelė const finalScoreEl = document.getElementById('final-score'); const accuracyEl = document.getElementById('accuracy');

// --- Funkcijos ---

/** * Paruošia ir atvaizduoja dabartinį žodį ekrane. */ function displayWord() { wordContainer.innerHTML = ''; userSyllables = []; isChecked = false; const currentWord = words[currentWordIndex].word;

currentWord.split('').forEach((letter, index) => { const letterSpan = document.createElement('span'); letterSpan.textContent = letter; wordContainer.appendChild(letterSpan);

if (index { if (isChecked) return; toggleSyllableBreak(divider, index + 1); }); wordContainer.appendChild(divider); } });

updateProgress(); }

/** * Įjungia arba išjungia skiemens žymę. */ function toggleSyllableBreak(dividerEl, position) { dividerEl.classList.toggle('selected'); if (userSyllables.includes(position)) { userSyllables = userSyllables.filter(s => s !== position); } else { userSyllables.push(position); } userSyllables.sort((a, b) => a - b); }

/** * Patikrina vartotojo atsakymą ir pateikia grįžtamąjį ryšį. */ function checkAnswer() { if (isChecked) return; isChecked = true;

const correctSyllables = words[currentWordIndex].syllables; const isCorrect = userSyllables.length === correctSyllables.length && userSyllables.every((val, index) => val === correctSyllables[index]);

if (isCorrect) { feedbackEl.innerHTML = 'Puiku! Teisingai! 🎉'; correctAnswers++; // Atnaujiname teisingų atsakymų skaičių } else { const correctWord = formatCorrectAnswer(words[currentWordIndex].word, correctSyllables); feedbackEl.innerHTML = `Beveik... Pabandyk dar kartą.
Teisingas atsakymas: ${correctWord}`; }

checkBtn.classList.add('hidden'); checkBtn.classList.add('btn-disabled'); nextBtn.classList.remove('hidden');

if (currentWordIndex === words.length - 1) { nextBtn.textContent = 'Baigti užduotį'; } }

/** * Formatuoja žodį su skiemenų brūkšneliais teisingam atsakymui parodyti. */ function formatCorrectAnswer(word, syllables) { let result = ''; let lastIndex = 0; syllables.forEach(pos => { result += word.substring(lastIndex, pos) + '-'; lastIndex = pos; }); result += word.substring(lastIndex); return result; }

/** * Pereina prie kito žodžio arba užbaigia užduotį. */ function goToNextWord() { currentWordIndex++; if (currentWordIndex < words.length) { feedbackEl.innerHTML = ''; checkBtn.classList.remove('hidden'); checkBtn.classList.remove('btn-disabled'); nextBtn.classList.add('hidden'); displayWord(); } else { // Užbaigiame užduotį ir parodome rezultatus showFinalResults(); } } /** * Rodo galutinius rezultatus. */ function showFinalResults() { mainCard.classList.add('hidden'); // Paslepiame pagrindinę kortelę resultsCard.classList.remove('hidden'); // Parodome rezultatų kortelę const totalWords = words.length; const percentage = ((correctAnswers / totalWords) * 100).toFixed(0); instructionEl.textContent = 'Sveikiname atlikus užduotį!'; finalScoreEl.innerHTML = `${correctAnswers} / ${totalWords} teisingų atsakymų`; accuracyEl.textContent = `Tiklsumas: ${percentage}%`; }

/** * Atnaujina eigos indikatorių. */ function updateProgress() { progressEl.textContent = `Žodis ${currentWordIndex + 1} iš ${words.length}`; }

// --- Įvykių klausytojai --- checkBtn.addEventListener('click', checkAnswer); nextBtn.addEventListener('click', goToNextWord);

// --- Pradinis paleidimas --- displayWord();


Testas Žodžių skiemenavimas
Į viršų