Skip to Content
coming soon..
import React, { useState, useEffect } from 'react';
const GrammarQuiz = () => {
const [currentQuestion, setCurrentQuestion] = useState(0);
const [selectedAnswers, setSelectedAnswers] = useState({});
const [showResults, setShowResults] = useState(false);
const [score, setScore] = useState(0);
const [timeLeft, setTimeLeft] = useState(3600);
const [quizStarted, setQuizStarted] = useState(false);
const questions = [
{
id: 1,
topic: "Subject-Verb Agreement",
question: "Neither of the boys ___ going to the party.",
options: ["are", "were", "is", "be"],
correct: 2
},
{
id: 2,
topic: "Subject-Verb Agreement",
question: "Each of the players ___ a trophy.",
options: ["receive", "receives", "received", "receiving"],
correct: 1
},
{
id: 3,
topic: "Tenses",
question: "By next year, she ___ her degree.",
options: ["completes", "will complete", "will have completed", "completed"],
correct: 2
},
{
id: 4,
topic: "Tenses",
question: "I ___ here since 2010.",
options: ["live", "lived", "am living", "have lived"],
correct: 3
},
{
id: 5,
topic: "Articles",
question: "She is ___ honest woman.",
options: ["a", "an", "the", "no article"],
correct: 1
},
{
id: 6,
topic: "Articles",
question: "He bought ___ umbrella yesterday.",
options: ["a", "an", "the", "no article"],
correct: 1
},
{
id: 7,
topic: "Prepositions",
question: "The book is lying ___ the table.",
options: ["in", "on", "over", "into"],
correct: 1
},
{
id: 8,
topic: "Prepositions",
question: "He jumped ___ the well.",
options: ["in", "into", "onto", "over"],
correct: 1
},
{
id: 9,
topic: "Conjunctions",
question: "He is poor ___ honest.",
options: ["or", "but", "and", "if"],
correct: 1
},
{
id: 10,
topic: "Conjunctions",
question: "Wait here ___ I come back.",
options: ["unless", "until", "if", "although"],
correct: 1
},
{
id: 11,
topic: "Direct & Indirect Speech",
question: "She said, I am writing a letter. She said that she ___ a letter.",
options: ["is writing", "was writing", "writes", "had written"],
correct: 1
},
{
id: 12,
topic: "Direct & Indirect Speech",
question: "He said, I will help you. He said that he ___ help me.",
options: ["will", "would", "shall", "can"],
correct: 1
},
{
id: 13,
topic: "Active & Passive Voice",
question: "The police caught the thief. The thief ___ by the police.",
options: ["caught", "is caught", "was caught", "has been caught"],
correct: 2
},
{
id: 14,
topic: "Active & Passive Voice",
question: "They will complete the work. The work ___ completed by them.",
options: ["will be", "shall be", "is", "was"],
correct: 0
},
{
id: 15,
topic: "Grammar & Usage",
question: "Choose the correct sentence:",
options: ["The team are playing well.", "The team is playing well.", "The teams is playing well.", "The team were playing well."],
correct: 1
},
{
id: 16,
topic: "Grammar & Usage",
question: "Choose the correct form of the verb: He ___ a book right now.",
options: ["reads", "is reading", "read", "was reading"],
correct: 1
},
{
id: 17,
topic: "Grammar & Usage",
question: "Identify the incorrect article usage:",
options: ["He is a honest man.", "He is an honest man.", "She is a doctor.", "She is an engineer."],
correct: 0
},
{
id: 18,
topic: "Grammar & Usage",
question: "Choose the correct preposition: She is interested ___ music.",
options: ["on", "for", "in", "at"],
correct: 2
},
{
id: 19,
topic: "Grammar & Usage",
question: "Identify the correct conjunction: I wanted to go to the park ___ it was raining heavily.",
options: ["because", "but", "and", "if"],
correct: 1
},
{
id: 20,
topic: "Grammar & Usage",
question: "Which sentence is in active voice?",
options: ["The ball was thrown by him.", "The cake is being eaten by her.", "She ate the cake.", "The door was opened by the teacher."],
correct: 2
},
{
id: 21,
topic: "Grammar & Usage",
question: "Choose the correct sentence in indirect speech:",
options: ["He said that he is going to the market.", "He says that he was going to the market.", "He said that he was going to the market.", "He said he will go to the market."],
correct: 2
},
{
id: 22,
topic: "Grammar & Usage",
question: "Identify the sentence with subject-verb agreement error:",
options: ["The books are on the table.", "The boy run fast.", "She writes every day.", "They are happy."],
correct: 1
},
{
id: 23,
topic: "Grammar & Usage",
question: "Fill in the blank with the correct form of the verb: If she ___ earlier, she would have caught the train.",
options: ["leaves", "left", "had left", "was leaving"],
correct: 2
},
{
id: 24,
topic: "Grammar & Usage",
question: "Choose the correct preposition: She walked ___ the road.",
options: ["through", "on", "in", "across"],
correct: 3
},
{
id: 25,
topic: "Vocabulary",
question: "Choose the synonym of courageous:",
options: ["Timid", "Brave", "Shy", "Weak"],
correct: 1
},
{
id: 26,
topic: "Vocabulary",
question: "Choose the antonym of difficult:",
options: ["Hard", "Simple", "Tough", "Complicated"],
correct: 1
},
{
id: 27,
topic: "Vocabulary",
question: "Which of the following is a one-word substitution for a person who loves books:",
options: ["Bibliophile", "Technophile", "Philosopher", "Scientist"],
correct: 0
},
{
id: 28,
topic: "Vocabulary",
question: "Choose the correct meaning of the idiom Break the ice:",
options: ["To make a difficult situation more relaxed.", "To create a frozen lake.", "To start a fight.", "To get rid of cold weather."],
correct: 0
},
{
id: 29,
topic: "Vocabulary",
question: "Which of the following phrases means To die?",
options: ["Kick the bucket", "Cut the cord", "Hit the nail on the head", "Bury the hatchet"],
correct: 0
},
{
id: 30,
topic: "Vocabulary",
question: "What is the meaning of the phrasal verb give in?",
options: ["To resist", "To submit", "To start", "To push"],
correct: 1
},
{
id: 31,
topic: "Vocabulary",
question: "Choose the word that fits best in the context: He was the most ___ of all the competitors.",
options: ["Weak", "Weakest", "Strongest", "Strong"],
correct: 2
},
{
id: 32,
topic: "Vocabulary",
question: "Which of the following is a synonym for brilliant?",
options: ["Dull", "Shiny", "Mediocre", "Bright"],
correct: 3
},
{
id: 33,
topic: "Vocabulary",
question: "What does loquacious mean?",
options: ["Silent", "Talkative", "Intelligent", "Curious"],
correct: 1
},
{
id: 34,
topic: "Vocabulary",
question: "Choose the antonym of luminous:",
options: ["Glowing", "Bright", "Dull", "Shiny"],
correct: 2
},
{
id: 35,
topic: "Sentence Correction",
question: "Identify the error in the sentence: She have been working here for five years.",
options: ["She", "have", "been", "no error"],
correct: 1
},
{
id: 36,
topic: "Sentence Correction",
question: "Choose the sentence with correct punctuation:",
options: ["He said I will meet you tomorrow.", "He said I will meet you tomorrow.", "He said, I will meet you tomorrow.", "He said I will, meet you tomorrow."],
correct: 2
},
{
id: 37,
topic: "Sentence Correction",
question: "Find the error in the sentence: Neither the teacher nor the students were happy with the decision.",
options: ["Neither", "were", "teacher", "no error"],
correct: 1
},
{
id: 38,
topic: "Sentence Correction",
question: "Fill in the blank with the correct word: She ___ to the market when I saw her.",
options: ["goes", "gone", "was going", "is going"],
correct: 2
},
{
id: 39,
topic: "Sentence Correction",
question: "Choose the correct sentence:",
options: ["She don't like coffee.", "She doesn't like coffee.", "She do not like coffee.", "She not like coffee."],
correct: 1
},
{
id: 40,
topic: "Sentence Correction",
question: "Choose the correct form of the verb: By the time he arrives, we ___ the work.",
options: ["will finish", "will have finished", "finish", "had finished"],
correct: 1
},
{
id: 41,
topic: "Sentence Correction",
question: "Find the error: He has read the book, isn't it?",
options: ["He", "has", "isn't", "no error"],
correct: 2
},
{
id: 42,
topic: "Sentence Correction",
question: "Choose the correct phrase: She is very good ___ solving problems.",
options: ["in", "at", "for", "with"],
correct: 1
},
{
id: 43,
topic: "Sentence Correction",
question: "Fill in the blank: I cannot believe she ___ it.",
options: ["do", "does", "did", "done"],
correct: 2
},
{
id: 44,
topic: "Sentence Correction",
question: "Choose the sentence with no error: She wanted to tell me that she had finished the work.",
options: ["She", "wanted", "to tell", "no error"],
correct: 3
},
{
id: 45,
topic: "Comprehension Skills",
question: "Based on a passage about a scientist's discovery, what was the main contribution of the scientist?",
options: ["He discovered a new medicine.", "He invented a new device.", "He made an important scientific discovery.", "He wrote a book on science."],
correct: 2
},
{
id: 46,
topic: "Comprehension Skills",
question: "What can be inferred from the passage?",
options: ["The scientist was not recognized for his work.", "The scientist had a huge impact on the scientific community.", "The scientist faced major opposition to his discoveries.", "The scientist was young when he made the discovery."],
correct: 1
},
{
id: 47,
topic: "Comprehension Skills",
question: "Choose the correct statement based on the passage:",
options: ["The scientist's discovery was not important.", "The discovery changed the course of history.", "The scientist was not well respected.", "The scientist did not face challenges."],
correct: 1
},
{
id: 48,
topic: "Comprehension Skills",
question: "What is the primary focus of the passage?",
options: ["The life of the scientist.", "The challenges faced by the scientist.", "The scientific discovery made by the scientist.", "The recognition the scientist received."],
correct: 2
},
{
id: 49,
topic: "Comprehension Skills",
question: "What can be concluded about the scientist's work?",
options: ["It was controversial.", "It was widely accepted.", "It was ignored by many.", "It was irrelevant to his field."],
correct: 1
},
{
id: 50,
topic: "Writing Skills",
question: "Which of the following is an example of formal writing?",
options: ["Hey! What's up?", "Dear Sir, I am writing to inform you...", "Gotta go, see you later!", "Yo, let's meet tomorrow."],
correct: 1
},
{
id: 51,
topic: "Writing Skills",
question: "Choose the correct sentence for a formal letter:",
options: ["I would like to inform you that my leave was approved.", "I'm telling you that I got leave.", "I want to inform you that I have leave.", "Just to let you know, I got my leave."],
correct: 0
},
{
id: 52,
topic: "Writing Skills",
question: "Which of the following is a good example of a report conclusion?",
options: ["The report discusses all issues.", "In conclusion, it is clear that we need to take further action.", "This is the end of the report.", "The report was not very helpful."],
correct: 1
},
{
id: 53,
topic: "Writing Skills",
question: "Which of the following is an appropriate sentence for an essay introduction?",
options: ["Let's talk about the issue.", "This essay will explore the impact of global warming.", "I will now tell you about global warming.", "So, global warming is a problem."],
correct: 1
},
{
id: 54,
topic: "Writing Skills",
question: "Choose the correct sentence for a paragraph:",
options: ["It is clear that pollution is increasing at an alarming rate.", "Pollution is a problem, and it is happening right now.", "Pollution is a serious issue that needs to be addressed.", "Pollution causes damage to the environment."],
correct: 2
},
{
id: 55,
topic: "Arrangement-based Questions",
question: "Arrange the following sentences in correct order: (1) I went to the market (2) The market was crowded (3) I bought some fruits (4) The vendors were selling fresh produce",
options: ["1-2-4-3", "1-3-2-4", "2-1-4-3", "4-2-1-3"],
correct: 0
},
{
id: 56,
topic: "Arrangement-based Questions",
question: "Rearrange to form a meaningful paragraph: (1) It was a beautiful beach (2) We decided to go on a vacation (3) The weather was perfect (4) We spent the day swimming",
options: ["2-1-3-4", "1-2-3-4", "2-3-1-4", "1-3-2-4"],
correct: 0
},
{
id: 57,
topic: "Arrangement-based Questions",
question: "Choose the odd one out:",
options: ["Dog", "Cat", "Rabbit", "Tree"],
correct: 3
},
{
id: 58,
topic: "Arrangement-based Questions",
question: "Rearrange the sentences: (1) The sun rose in the morning (2) Birds began to chirp (3) I went for a walk in the park (4) The sky turned pink and orange",
options: ["1-4-2-3", "1-2-3-4", "4-1-2-3", "1-3-4-2"],
correct: 0
},
{
id: 59,
topic: "Arrangement-based Questions",
question: "Rearrange the words to form a meaningful sentence: (the / home / today / he / will / be / late)",
options: ["He will be late home today", "Today he will be late home", "He will be home late today", "Late he will be home today"],
correct: 2
},
{
id: 60,
topic: "Arrangement-based Questions",
question: "Choose the correct sentence formation:",
options: ["He went, the door opened.", "He went because the door opened.", "He went when the door opened.", "He went, while the door opened."],
correct: 2
},
{
id: 61,
topic: "Arrangement-based Questions",
question: "Which of the following statements is logically incorrect?",
options: ["People eat food for survival.", "Humans breathe oxygen for survival.", "Plants eat food to survive.", "All animals need food to survive."],
correct: 2
},
{
id: 62,
topic: "Arrangement-based Questions",
question: "Which is the correct order: (1) I will meet you (2) I have just finished my work (3) At the cafe near the park",
options: ["2-1-3", "1-2-3", "3-2-1", "2-3-1"],
correct: 0
},
{
id: 63,
topic: "Arrangement-based Questions",
question: "Identify the odd word out:",
options: ["Run", "Swim", "Fly", "Book"],
correct: 3
},
{
id: 64,
topic: "Arrangement-based Questions",
question: "Rearrange the following words into a meaningful sentence: (on / the / is / it / chair / the / book)",
options: ["The book is on the chair", "On the chair is the book", "The chair is on the book", "It is the book on chair"],
correct: 0
}
];
useEffect(() => {
let timer;
if (quizStarted && timeLeft > 0 && !showResults) {
timer = setInterval(() => {
setTimeLeft(prev => {
if (prev <= 1) {
handleSubmit();
return 0;
}
return prev - 1;
});
}, 1000);
}
return () => clearInterval(timer);
}, [quizStarted, timeLeft, showResults]);
const formatTime = (seconds) => {
const mins = Math.floor(seconds / 60);
const secs = seconds % 60;
return mins + ":" + secs.toString().padStart(2, '0');
};
const handleAnswerSelect = (answerIndex) => {
setSelectedAnswers(prev => ({
...prev,
[currentQuestion]: answerIndex
}));
};
const handleNext = () => {
if (currentQuestion < questions.length - 1) {
setCurrentQuestion(prev => prev + 1);
}
};
const handlePrevious = () => {
if (currentQuestion > 0) {
setCurrentQuestion(prev => prev - 1);
}
};
const handleSubmit = () => {
let correctCount = 0;
questions.forEach((question, index) => {
if (selectedAnswers[index] === question.correct) {
correctCount++;
}
});
setScore(correctCount);
setShowResults(true);
};
const resetQuiz = () => {
setCurrentQuestion(0);
setSelectedAnswers({});
setShowResults(false);
setScore(0);
setTimeLeft(3600);
setQuizStarted(false);
};
const getScoreColor = () => {
const percentage = (score / questions.length) * 100;
if (percentage >= 80) return 'text-green-600';
if (percentage >= 60) return 'text-yellow-600';
return 'text-red-600';
};
const getGrade = () => {
const percentage = (score / questions.length) * 100;
if (percentage >= 90) return 'A+';
if (percentage >= 80) return 'A';
if (percentage >= 70) return 'B';
if (percentage >= 60) return 'C';
return 'D';
};
if (!quizStarted) {
return React.createElement('div', { className: "max-w-2xl mx-auto p-6 bg-white rounded-lg shadow-lg" },
React.createElement('div', { className: "text-center" },
React.createElement('h1', { className: "text-3xl font-bold text-gray-800 mb-4" }, "English Grammar Quiz"),
React.createElement('div', { className: "bg-blue-50 p-6 rounded-lg mb-6" },
React.createElement('h2', { className: "text-xl font-semibold text-blue-800 mb-3" }, "Quiz Instructions"),
React.createElement('ul', { className: "text-left text-gray-700 space-y-2" },
React.createElement('li', null, "• Total Questions: " + questions.length),
React.createElement('li', null, "• Time Limit: 60 minutes"),
React.createElement('li', null, "• Topics: Grammar & Usage, Vocabulary, Sentence Correction, Comprehension Skills, Writing Skills, Arrangement-based Questions"),
React.createElement('li', null, "• Covers: Subject-Verb Agreement, Tenses, Articles, Prepositions, Conjunctions, Direct & Indirect Speech, Active & Passive Voice"),
React.createElement('li', null, "• You can navigate between questions using Next/Previous buttons"),
React.createElement('li', null, "• Make sure to answer all questions before submitting"),
React.createElement('li', null, "• Suitable for WBCS, Banking, SSC CGL and other competitive exams")
)
),
React.createElement('button', {
onClick: () => setQuizStarted(true),
className: "bg-blue-600 text-white px-8 py-3 rounded-lg font-semibold hover:bg-blue-700 transition-colors"
}, "Start Quiz")
)
);
}
if (showResults) {
return React.createElement('div', { className: "max-w-4xl mx-auto p-6 bg-white rounded-lg shadow-lg" },
React.createElement('div', { className: "text-center mb-8" },
React.createElement('div', { className: "text-6xl mb-4" }, "🏆"),
React.createElement('h1', { className: "text-3xl font-bold text-gray-800 mb-2" }, "Quiz Results"),
React.createElement('div', { className: "text-6xl font-bold mb-2 " + getScoreColor() }, score + "/" + questions.length),
React.createElement('div', { className: "text-xl text-gray-600 mb-4" },
((score / questions.length) * 100).toFixed(1) + "% - Grade: " + getGrade()
),
React.createElement('button', {
onClick: resetQuiz,
className: "bg-blue-600 text-white px-6 py-2 rounded-lg font-semibold hover:bg-blue-700 transition-colors"
}, "🔄 Retake Quiz")
),
React.createElement('div', { className: "space-y-6" },
React.createElement('h2', { className: "text-2xl font-bold text-gray-800 mb-4" }, "Answer Review"),
questions.map((question, index) => {
const userAnswer = selectedAnswers[index];
const isCorrect = userAnswer === question.correct;
return React.createElement('div', { key: question.id, className: "bg-gray-50 p-4 rounded-lg" },
React.createElement('div', { className: "flex items-start gap-3" },
React.createElement('div', { className: "text-2xl" }, isCorrect ? '✅' : '❌'),
React.createElement('div', { className: "flex-1" },
React.createElement('div', { className: "flex items-center gap-2 mb-2" },
React.createElement('span', { className: "font-bold text-gray-800" }, "Q" + (index + 1) + "."),
React.createElement('span', { className: "bg-blue-100 text-blue-800 px-2 py-1 rounded text-sm font-medium" }, question.topic)
),
React.createElement('p', { className: "text-gray-700 mb-3 italic" }, question.question),
React.createElement('div', { className: "grid grid-cols-2 gap-2" },
question.options.map((option, optIndex) => {
let className = "p-2 rounded border text-sm ";
if (optIndex === question.correct) {
className += 'bg-green-100 border-green-500 text-green-800';
} else if (userAnswer === optIndex) {
className += 'bg-red-100 border-red-500 text-red-800';
} else {
className += 'bg-white border-gray-300';
}
let content = String.fromCharCode(97 + optIndex) + ") " + option;
if (optIndex === question.correct) content += ' ✅';
if (userAnswer === optIndex && optIndex !== question.correct) content += ' ❌';
return React.createElement('div', { key: optIndex, className: className }, content);
})
)
)
)
);
})
)
);
}
const currentQ = questions[currentQuestion];
const progress = ((currentQuestion + 1) / questions.length) * 100;
return React.createElement('div', { className: "max-w-3xl mx-auto p-6 bg-white rounded-lg shadow-lg" },
React.createElement('div', { className: "flex justify-between items-center mb-6" },
React.createElement('div', null,
React.createElement('h1', { className: "text-2xl font-bold text-gray-800" }, "English Grammar Quiz"),
React.createElement('p', { className: "text-gray-600" }, "Question " + (currentQuestion + 1) + " of " + questions.length)
),
React.createElement('div', { className: "text-right" },
React.createElement('div', { className: "text-lg font-semibold text-red-600" }, "⏰ " + formatTime(timeLeft)),
React.createElement('div', { className: "text-sm text-gray-500" }, "Time Left")
)
),
React.createElement('div', { className: "w-full bg-gray-200 rounded-full h-2 mb-6" },
React.createElement('div', {
className: "bg-blue-600 h-2 rounded-full transition-all duration-300",
style: { width: progress + "%" }
})
),
React.createElement('div', { className: "mb-6" },
React.createElement('div', { className: "flex items-center gap-2 mb-3" },
React.createElement('span', { className: "font-bold text-gray-800" }, "Q" + (currentQuestion + 1) + "."),
React.createElement('span', { className: "bg-blue-100 text-blue-800 px-3 py-1 rounded-full text-sm font-medium" }, currentQ.topic)
),
React.createElement('p', { className: "text-lg text-gray-700 mb-6 italic" }, currentQ.question),
React.createElement('div', { className: "space-y-3" },
currentQ.options.map((option, index) => {
const isSelected = selectedAnswers[currentQuestion] === index;
const className = "w-full p-4 text-left rounded-lg border-2 transition-all " +
(isSelected ? 'border-blue-500 bg-blue-50 text-blue-800' : 'border-gray-300 hover:border-gray-400 hover:bg-gray-50');
return React.createElement('button', {
key: index,
onClick: () => handleAnswerSelect(index),
className: className
}, React.createElement('span', { className: "font-medium" }, String.fromCharCode(97 + index) + ") " + option));
})
)
),
React.createElement('div', { className: "flex justify-between items-center" },
React.createElement('button', {
onClick: handlePrevious,
disabled: currentQuestion === 0,
className: "px-4 py-2 bg-gray-300 text-gray-700 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-400 transition-colors"
}, "← Previous"),
React.createElement('div', { className: "flex gap-2 overflow-x-auto max-w-xs" },
questions.map((_, index) => {
let className = "w-8 h-8 rounded-full text-sm font-medium transition-colors flex-shrink-0 ";
if (index === currentQuestion) {
className += 'bg-blue-600 text-white';
} else if (selectedAnswers[index] !== undefined) {
className += 'bg-green-200 text-green-800';
} else {
className += 'bg-gray-200 text-gray-600';
}
return React.createElement('button', {
key: index,
onClick: () => setCurrentQuestion(index),
className: className
}, index + 1);
})
),
currentQuestion === questions.length - 1 ?
React.createElement('button', {
onClick: handleSubmit,
className: "px-6 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors font-semibold"
}, "Submit Quiz") :
React.createElement('button', {
onClick: handleNext,
className: "px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
}, "Next →")
),
React.createElement('div', { className: "mt-4 text-center text-sm text-gray-600" },
"Answered: " + Object.keys(selectedAnswers).length + "/" + questions.length
)
);
};
export default GrammarQuiz;