diff --git a/index.html b/index.html new file mode 100644 index 0000000..7d0531c --- /dev/null +++ b/index.html @@ -0,0 +1,28 @@ + + + + + + + DA3_22BCE2078 + + + +

Web Programming Quiz

+
+

10:00

+
+ +
+

Question text

+ + +
+ + + \ No newline at end of file diff --git a/quiz.html b/quiz.html new file mode 100644 index 0000000..d5eb03f --- /dev/null +++ b/quiz.html @@ -0,0 +1,33 @@ + + + + + + Quiz Over + + + +
+

Quiz Over

+

Thank you for completing the quiz!

+
+ + + diff --git a/script.js b/script.js new file mode 100644 index 0000000..4f2f78d --- /dev/null +++ b/script.js @@ -0,0 +1,183 @@ + + // Set the time for 10 minutes (in seconds) + const totalTime = 10 * 60; + + // Get the timer element + const timerDisplay = document.getElementById('timer'); + + // Start the timer + function startTimer() { + let timeLeft = totalTime; + + const countdownInterval = setInterval(() => { + const minutes = Math.floor(timeLeft / 60); + let seconds = timeLeft % 60; + + // Add leading zero if seconds is less than 10 + seconds = seconds < 10 ? '0' + seconds : seconds; + + // Display the timer + timerDisplay.textContent = `${minutes}:${seconds}`; + + // Check if the timer has reached 0 + if (timeLeft === 0) { + clearInterval(countdownInterval); + // Redirect to the quiz page after the timer completes + window.location.href = 'quiz.html'; + } else { + // Decrease the time left + timeLeft--; + } + }, 1000); + } + + // Start the timer when the page loads + window.onload = startTimer; + + +const quizData = [ + { + question : 'Javascript is an ___ language?', + a: 'Object-Based', + b: 'Procedural', + c: 'Object-Oriented', + d: 'None of the above', + correct : 'c' + }, + { + question : 'What is the output of console.log(2+1)?', + a: '21', + b: 'undefined', + c: 'error', + d: '3', + correct : 'd' + }, + { + question : 'Which of the following methods is used to access HTML elements using Javascript ?', + a: 'Both B and C', + b: 'getElementbyId()', + c: 'getElementsByClassName()', + d: 'None of the above', + correct : 'a' + }, + { + question : 'What is the use of the