Space Quiz – Sequential Flow

Space Quiz

You completed the quiz in ${timeString} minutes.

Your accuracy rate is ${accuracy}% for attempted questions.

${notAttempted > 0 ? `

You left ${notAttempted} questions unanswered.

` : ''}

${message}

`; } // Get performance advice function getPerformanceAdvice(percentage, notAttempted, accuracy) { if (notAttempted > 0) { return "Try to attempt all questions next time, even if you're not completely sure of the answer."; } if (percentage >= 90) { return "Excellent work! You've shown a great understanding of the subject matter."; } else if (percentage >= 70) { return "Good job! With a bit more practice, you can improve even further."; } else if (percentage >= 50) { return "You're on the right track. Focus on the topics you got wrong to improve your score."; } return "Don't give up! Review the topics you struggled with and try again."; } // Event Listeners detailsForm.addEventListener('submit', (e) => { e.preventDefault(); userForm.classList.add('hidden'); quizContainer.classList.remove('hidden'); quizStartTime = Date.now(); loadQuestion(0); }); nextButton.addEventListener('click', () => { currentQuestionIndex++; if (currentQuestionIndex < questions.length) { loadQuestion(currentQuestionIndex); } else { showResults(); } }); // Handle question transitions with ads function handleQuestionTransition() { const adFrequency = 3; const adContainer = document.getElementById('between-questions-ad'); if ((currentQuestionIndex + 1) % adFrequency === 0 && currentQuestionIndex < questions.length - 1) { adContainer.classList.remove('hidden'); setTimeout(() => { adContainer.classList.add('hidden'); }, 5000); } } // Error handling for ads window.addEventListener('error', function(e) { if (e.target.tagName === 'SCRIPT' && e.target.src.includes('adsbygoogle')) { console.log('Ad blocked or failed to load'); document.querySelectorAll('.ad-container').forEach(container => { container.style.display = 'none'; }); } }, true); // Initialize the quiz when the page loads window.addEventListener('load', initializeQuiz);

Leave a Reply

Your email address will not be published. Required fields are marked *

Share via
Copy link