This quiz on Motion MCQ Challenge Class 9 Ch 7 is purely created out of your class 9 NCERT science chapter 7 motion . If you think have prepared the chapter then test yourself.
It will be better if you first read the below two posts before attempting the MCQ quiz:
Even if you are not fully prepare, you can try this MCQ quiz.
So, lets dive in!
Motion MCQ Challenge Class 9 Ch 7
Basic Concepts of Motion and Describing Position Motion Quiz
`}
Restart Quiz
`;
}
renderCompletion() {
return `
Quiz Completed!
Click below to see your results.
View Report
`;
}
createConfetti() {
const colors = ['#f39c12', '#e74c3c', '#3498db', '#27ae60', '#9b59b6'];
const confettiContainer = document.createElement('div');
confettiContainer.className = 'confetti-container';
for (let i = 0; i < 30; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.left = Math.random() * 100 + '%';
confetti.style.background = colors[Math.floor(Math.random() * colors.length)];
confetti.style.animationDelay = Math.random() * 0.5 + 's';
confetti.style.animationDuration = (Math.random() * 0.5 + 1.5) + 's';
confettiContainer.appendChild(confetti);
}
document.body.appendChild(confettiContainer);
setTimeout(() => {
document.body.removeChild(confettiContainer);
}, 2500);
}
attachEventListeners() {
document.querySelectorAll('.option').forEach(button => {
button.addEventListener('click', (e) => this.handleOptionClick(e));
});
const nextBtn = document.getElementById('next-btn');
if (nextBtn) nextBtn.addEventListener('click', () => this.handleNextQuestion());
const viewReportBtn = document.getElementById('view-report-btn');
if (viewReportBtn) viewReportBtn.addEventListener('click', () => this.handleViewReport());
const restartBtn = document.getElementById('restart-btn');
if (restartBtn) restartBtn.addEventListener('click', () => this.handleRestartQuiz());
}
handleOptionClick(event) {
if (this.isAnswerChecked) return;
const optionIndex = parseInt(event.target.dataset.option);
this.selectedOptionIndex = optionIndex;
this.isAnswerChecked = true;
const isCorrect = optionIndex === this.questions[this.currentQuestionIndex].correctAnswerIndex;
this.userAnswers.push({
questionIndex: this.currentQuestionIndex,
selectedOptionIndex: optionIndex,
isCorrect: isCorrect,
});
if (isCorrect) {
this.createConfetti();
}
this.render();
}
handleNextQuestion() {
this.selectedOptionIndex = null;
this.isAnswerChecked = false;
if (this.currentQuestionIndex < this.questions.length - 1) {
this.currentQuestionIndex++;
} else {
this.quizCompleted = true;
}
this.render();
}
handleViewReport() {
this.showReport = true;
this.render();
}
handleRestartQuiz() {
this.currentQuestionIndex = 0;
this.selectedOptionIndex = null;
this.isAnswerChecked = false;
this.userAnswers = [];
this.quizCompleted = false;
this.showReport = false;
this.render();
}
}
document.addEventListener('DOMContentLoaded', () => {
new Quiz();
});