Header Ads Widget

Responsive Advertisement

Advanced Online Exam System

Online Exam System

Time Left: 60:00

]; let timeLeft = 3600; let timer = setInterval(function() { timeLeft--; let minutes = Math.floor(timeLeft / 60); let seconds = timeLeft % 60; document.getElementById("timer").innerText = `Time Left: ${minutes}:${seconds < 10 ? '0' : ''}${seconds}`; if (timeLeft <= 0) { clearInterval(timer); submitExam(); } }, 1000); function loadExam() { let examDiv = document.getElementById("exam"); questions.forEach((question, index) => { let html = `
${index + 1}. ${question.q}
`; html += `
`; question.options.forEach(option => { html += ``; }); html += `
`; examDiv.innerHTML += html; }); } function submitExam() { clearInterval(timer); let score = 0; questions.forEach((question, index) => { let selected = document.querySelector(`input[name='q${index}']:checked`); if (selected && selected.value === question.answer) { score++; } }); document.getElementById("result").innerText = `Your Score: ${score}/${questions.length}`; } loadExam();

Post a Comment

0 Comments