Słowa powinny być usuwane z listy wyboru po dokonaniu prawidłowego wyboru przez…
- User
Słowa powinny być usuwane z listy wyboru po dokonaniu prawidłowego wyboru przez użytkownika: ///////////////////////////////////
// FUNKCJE UNIKATOWE DLA PLIKU
///////////////////////////////////
function generateRandomWord() { const availableWords = fullContentData.filter(word => !excludedWords.includes(word.lemma)); if (availableWords.length === 0) { document.getElementById('result').innerText = 'No more words to study.'; return; } const randomIndex = Math.floor(Math.random() * availableWords.length); const randomWord = availableWords[randomIndex]; currentWord = randomWord.lemma; currentWordData = randomWord; // Store the current word data
codedocument.getElementById('result').innerText = ''; const sentenceWithBlank = randomWord.example.replace(new RegExp(randomWord.word, 'i'), '______'); document.getElementById('example-sentence-text').innerText = sentenceWithBlank; document.getElementById('new-sentence-btn').style.display = 'none'; document.getElementById('edit-word-btn').style.display = 'none'; generateAnswerButtons(randomWord);}
function generateAnswerButtons(word) { const answerButtonsDiv = document.getElementById('answer-buttons'); answerButtonsDiv.innerHTML = '';
code// Get all words except the current word and shuffle them let options = fullContentData.filter(w => w.lemma !== word.lemma).map(w => w.word); // Select the first 4 options and add the correct word to the options options = options.sort(() => Math.random() - 0.5).slice(0, 4); options.push(word.word); options = options.sort(() => Math.random() - 0.5); options.forEach(option => { const button = document.createElement('button'); button.classList.add('btn', 'btn-primary', 'm-1'); button.textContent = option; button.onclick = () => checkAnswer(option, word.word, word.example, word.example_translation); answerButtonsDiv.appendChild(button); }); - Assistant