correct in this "import React, { useState, useEffect } from 'react';
import { Clock, CheckCircle2, XCircle, HelpCircle, ChevronRight, AlertCircle, BookOpen, Calendar, ArrowRight, Menu, Award, BarChart3, Timer, Brain } from 'lucide-react';
interface Question {
word: string;
question: string;
options: string[];
correct: string;
}
interface VocabItem {
word: string;
synonyms: string[];
}
interface QuizAnalysis {
totalQuestions: number;
correctAnswers: number;
incorrectAnswers: number;
unattempted: number;
score: number;
accuracy: number;
timeSpent: number;
}
const day1VocabList: VocabItem[] = [
{ word: "Abrogate", synonyms: ["cancel", "repeal", "revoke", "rescind", "repudiate", "annul", "nullify", "invalidate", "negate", "exterminate", "quash"] },
{ word: "Adulation", synonyms: ["flattery", "coax", "cajolery", "bootlicking", "wheedle", "obsequiousness", "sycophancy"] },
{ word: "Amicable", synonyms: ["friendly", "gregarious", "amiable", "affable", "courteous", "genial", "polite", "harmonious", "cordial"] },
{ word: "Ablution", synonyms: ["religious washing", "cleansing", "purification", "purgation", "baptism"] },
{ word: "Assertive", synonyms: ["domineering", "authoritative", "forceful", "aggressive", "commanding", "pushy"] },
{ word: "Alert", synonyms: ["watchful", "cautious", "careful", "meticulous", "vigilant", "attentive", "observant"] },
{ word: "Accede", synonyms: ["consent", "agree", "approve", "accept", "comply", "concede", "yield", "acquiesce"] },
{ word: "Acumen", synonyms: ["expertise", "adroit", "dextrous", "affichado", "maestro", "doyen", "perspicuity", "shrewdness"] },
{ word: "Accused", synonyms: ["indicted", "impeached", "charged", "arraigned", "prosecuted"] },
{ word: "Avarice", synonyms: ["greed", "cupidity", "voracity", "covetousness", "rapacious", "avid", "grasping"] },
{ word: "August", synonyms: ["majestic", "regal", "grand", "kingly", "courtly", "dignified", "stately", "noble"] },
{ word: "Apposite", synonyms: ["appropriate", "apt", "related", "relevant", "pertained", "germane", "suitable", "fitting"] },
{ word: "Accoutrement", synonyms: ["equipment", "tools", "paraphernalia", "apparatus", "gear", "tackle", "kit"] },
{ word: "Antipathy", synonyms: ["dislike", "disdain", "detestation", "abomination", "abhorrence", "loathsome", "aversion", "anathema", "hatred", "repugnance"] },
{ word: "Abysmal", synonyms: ["bottomless", "depthless", "immeasurable", "unfathomable", "terrible", "dreadful"] },
{ word: "Artful", synonyms: ["cunning", "sly", "canny", "crafty", "wily", "scheming", "foxlike", "vulpine", "clever", "shrewd", "insidious"] },
{ word: "Ancestors", synonyms: ["forefathers", "forebears", "progenitors", "predecessors", "antecedents"] },
{ word: "Appraise", synonyms: ["judge", "evaluate", "assess", "estimate", "value", "rate", "gauge"] },
{ word: "Accrue", synonyms: ["gather", "accumulate", "assimilate", "store", "hoard", "pileup", "amass", "stock"] },
{ word: "Audacious", synonyms: ["bold", "temerity", "heroic", "candid", "fearless", "brave", "daring", "intrepid"] },
{ word: "Affluence", synonyms: ["richness", "prosperity", "opulence", "wealth", "abundance", "plenty"] },
{ word: "Abstain", synonyms: ["refrain", "avoid", "forbear", "desist", "hold back", "withhold"] },
{ word: "Aversion", synonyms: ["dislike", "hatred", "repugnance", "antipathy", "disgust", "loathing"] },
{ word: "Autocratic", synonyms: ["dictatorial", "authoritarian", "tyrannical", "despotic", "oppressive", "domineering"] },
{ word: "Atrocity", synonyms: ["violence", "brutality", "barbarity", "heinousness", "outrage", "horror"] },
{ word: "Appear", synonyms: ["seem", "look", "emerge", "surface", "manifest", "show"] },
{ word: "Abuse", synonyms: ["scorn", "insult", "despise", "debase", "affront", "maltreat", "mistreat"] },
{ word: "Adorn", synonyms: ["beautify", "decorate", "garnish", "embellish", "ornate", "deck", "enhance"] },
{ word: "Abundant", synonyms: ["plentiful", "dime-a-dozen", "copious", "plethora", "lush", "bountiful", "ample"] },
{ word: "Anticipate", synonyms: ["hope", "expect", "foresee", "await", "predict", "forecast"] },
{ word: "Adverse", synonyms: ["unfavorable", "hostile", "detrimental", "harmful", "negative", "inimical"] },
{ word: "Apex", synonyms: ["top", "pinnacle", "acme", "supreme", "summit", "zenith", "culmination", "apotheosis", "paramount", "apogee"] },
{ word: "Inform", synonyms: ["notify", "tell", "advise", "apprise", "brief", "enlighten"] },
{ word: "Absurd", synonyms: ["ridiculous", "preposterous", "nonsensical", "ludicrous", "foolish", "silly"] },
{ word: "Adversity", synonyms: ["misfortune", "mishap", "tragedy", "calamity", "sufferings", "hardships", "affliction"] },
{ word: "Antagonist", synonyms: ["opponent", "rival", "contender", "adversary", "competitor", "foe"] },
{ word: "Absolve", synonyms: ["exonerate", "acquit", "exculpate", "clear", "pardon", "forgive"] },
{ word: "Ascription", synonyms: ["attribution", "assignment", "imputation", "credit", "acknowledgment"] },
{ word: "Advocate", synonyms: ["support", "encourage", "promote", "champion", "back", "endorse"] },
{ word: "Affection", synonyms: ["liking", "fondness", "admiration", "propensity", "penchant", "affinity"] },
{ word: "Affectation", synonyms: ["show off", "sham", "flaunt", "ostentation", "hypocrisy", "pretension"] },
{ word: "Assuage", synonyms: ["pacify", "placate", "alleviate", "mitigate", "appease", "mollify", "propitiate", "tranquilize"] },
{ word: "Adamant", synonyms: ["obdurate", "stubborn", "obstinate", "pig-headed", "mulish", "perverse", "intransigent", "refractory"] },
{ word: "Arable", synonyms: ["fertile", "cultivable", "productive", "fruitful", "rich"] },
{ word: "Acerbic", synonyms: ["bitter", "acrid", "acrimonious", "vitriolic", "acidic", "sarcastic"] },
{ word: "Affable", synonyms: ["friendly", "genial", "amiable", "cordial", "sociable", "gracious"] },
{ word: "Benevolent", synonyms: ["kind", "generous", "altruistic", "philanthropic", "compassionate", "gracious"] },
{ word: "Blister", synonyms: ["wound", "sore", "lesion", "blain", "vesicle"] },
{ word: "Battered", synonyms: ["destroyed", "damaged", "beaten", "worn", "bruised"] },
{ word: "Baleful", synonyms: ["harmful", "detrimental", "parlous", "perilous", "menacing", "jeopardy", "deleterious", "hazardous", "lethal", "noxious", "noisome"] }
];
const day2VocabList: VocabItem[] = [
{ word: "Bondage", synonyms: ["Captivity", "Serfdom", "Imprisonment", "Confinement"] },
{ word: "Blaze", synonyms: ["Fire", "Flame", "Inferno"] },
{ word: "Boast", synonyms: ["Brag", "Swagger", "Egotist", "Exaggerate"] },
{ word: "Benediction", synonyms: ["Blessing", "Benison", "Approval"] },
{ word: "Barren", synonyms: ["Infertile", "Sterile", "Arid", "Futile"] },
{ word: "Benefactor", synonyms: ["Helper", "Patron", "Supporter"] },
{ word: "Bliss", synonyms: ["Happiness", "Ecstasy", "Euphoria"] },
{ word: "Bucolic", synonyms: ["Rustic", "Rural", "Pastoral"] },
{ word: "Behaviour", synonyms: ["Conduct", "Decorum", "Demeanor"] },
{ word: "Barbaric", synonyms: ["Savage", "Uncivilized", "Brutal"] },
{ word: "Brutalize", synonyms: ["Coarsen", "Dehumanize", "Mistreat"] },
{ word: "Board", synonyms: ["Wooden plank", "Food", "Provision"] },
{ word: "Bane", synonyms: ["Curse", "Threat", "Scourge"] },
{ word: "Beckoned", synonyms: ["Called", "Summoned", "Gestured"] },
{ word: "Bifurcated", synonyms: ["Divided", "Split", "Branched"] },
{ word: "Boisterous", synonyms: ["Noisy", "Clamorous", "Unruly"] },
{ word: "Brisk", synonyms: ["Quick", "Lively", "Energetic"] },
{ word: "Blunder", synonyms: ["Mistake", "Error", "Gaffe"] },
{ word: "Baffle", synonyms: ["Confuse", "Bewilder", "Perplex"] },
{ word: "Belligerent", synonyms: ["Hostile", "Aggressive", "Pugnacious"] },
{ word: "Bashful", synonyms: ["Shy", "Timid", "Coy"] },
{ word: "Brittle", synonyms: ["Fragile", "Delicate", "Frail"] },
{ word: "Brutal", synonyms: ["Savage", "Cruel", "Harsh"] },
{ word: "Badger", synonyms: ["Pester", "Annoy", "Heckle"] },
{ word: "Burgeon", synonyms: ["Grow", "Expand", "Flourish"] },
{ word: "Buoyant", synonyms: ["Cheerful", "Optimistic", "Lighthearted"] },
{ word: "Bizarre", synonyms: ["Strange", "Weird", "Peculiar"] },
{ word: "Beseech", synonyms: ["Beg", "Plead", "Implore"] },
{ word: "Banal", synonyms: ["Clichéd", "Trite", "Hackneyed"] },
{ word: "Blithe", synonyms: ["Carefree", "Cheerful", "Lighthearted"] },
{ word: "Blandishment", synonyms: ["Flattery", "Sweet talk", "Cajolery"] },
{ word: "Banter", synonyms: ["Teasing", "Joking", "Repartee"] },
{ word: "Benison", synonyms: ["Blessing", "Benediction", "Approval"] },
{ word: "Bigoted", synonyms: ["Intolerant", "Prejudiced", "Narrow-minded"] },
{ word: "Brash", synonyms: ["Rude", "Impulsive", "Reckless"] },
{ word: "Babble", synonyms: ["Chatter", "Prattle", "Gabble"] },
{ word: "Bawdy", synonyms: ["Indecent", "Ribald", "Lewd"] },
{ word: "Brevity", synonyms: ["Conciseness", "Briefness", "Succinctness"] },
{ word: "Brazen", synonyms: ["Bold", "Shameless", "Audacious"] },
{ word: "Bumptious", synonyms: ["Arrogant", "Self-assertive", "Overconfident"] },
{ word: "Bewail", synonyms: ["Lament", "Mourn", "Bemoan"] },
{ word: "Beguile", synonyms: ["Deceive", "Charm", "Enchant"] },
{ word: "Belittle", synonyms: ["Disparage", "Demean", "Undermine"] },
{ word: "Browbeat", synonyms: ["Bully", "Intimidate", "Coerce"] },
{ word: "Covenant", synonyms: ["Agreement", "Pact", "Contract"] },
{ word: "Colossal", synonyms: ["Enormous", "Gigantic", "Mammoth"] },
{ word: "Censure", synonyms: ["Criticize", "Condemn", "Denounce"] },
{ word: "Contemplation", synonyms: ["Meditation", "Reflection", "Pondering"] },
{ word: "Coherent", synonyms: ["Logical", "Consistent", "Clear"] },
{ word: "Commotion", synonyms: ["Uproar", "Disturbance", "Turmoil"] }
];
function App() {
const [view, setView] = useState<'home' | 'instructions' | 'quiz' | 'analysis' | 'settings'>('home');
const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0);
const [score, setScore] = useState(0);
const [correctCount, setCorrectCount] = useState(0);
const [incorrectCount, setIncorrectCount] = useState(0);
const [timeLeft, setTimeLeft] = useState(600);
const [selectedAnswer, setSelectedAnswer] = useState<string | null>(null);
const [questionStatus, setQuestionStatus] = useState<string[]>([]);
const [questions, setQuestions] = useState<Question[]>([]);
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
const [selectedDay, setSelectedDay] = useState<1 | 2 | 'full'>(1);
const [startTime, setStartTime] = useState(0);
const [quizAnalysis, setQuizAnalysis] = useState<QuizAnalysis | null>(null);
const [numQuestions, setNumQuestions] = useState(25);
// Calculate time based on number of questions (2 minutes per 10 questions)
useEffect(() => {
setTimeLeft(Math.ceil(numQuestions / 10) * 120);
}, [numQuestions]);
function shuffle(array: T[]): T[] {
const newArray = [...array];
for (let i = newArray.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[newArray[i], newArray[j]] = [newArray[j], newArray[i]];
}
return newArray;
}
// Initialize questions
useEffect(() => {
if (view === 'quiz') {
let currentVocabList: VocabItem[];
if (selectedDay === 'full') {
currentVocabList = [...day1VocabList, ...day2VocabList];
} else {
currentVocabList = selectedDay === 1 ? day1VocabList : day2VocabList;
}
const allSynonyms = currentVocabList.reduce((acc, item) => acc.concat(item.synonyms), []);
const generateQuestions = () => {
const questions = currentVocabList.map(item => {
const correct = item.synonyms[Math.floor(Math.random() * item.synonyms.length)];
const distractorPool = allSynonyms.filter(syn => !item.synonyms.includes(syn));
const distractors = shuffle(distractorPool.slice()).slice(0, 3);
const options = shuffle([correct, ...distractors]);
return {
word: item.word,
question: `Which of the following is a synonym for "${item.word}"?`,
options,
correct
};
});
return shuffle(questions).slice(0, numQuestions);
};
const shuffledQuestions = generateQuestions();
setQuestions(shuffledQuestions);
setQuestionStatus(new Array(shuffledQuestions.length).fill('Unattempted'));
setStartTime(Date.now());
}
}, [view, selectedDay, numQuestions]);
// Timer
useEffect(() => {
let timer: NodeJS.Timeout;
if (view === 'quiz' && timeLeft > 0) {
timer = setInterval(() => {
setTimeLeft((prev) => {
if (prev <= 1) {
clearInterval(timer);
handleQuizComplete();
return 0;
}
return prev - 1;
});
}, 1000);
}
return () => clearInterval(timer);
}, [view, timeLeft]);
const handleAnswerSelect = (answer: string) => {
setSelectedAnswer(answer);
const currentQuestion = questions[currentQuestionIndex];
const isCorrect = answer === currentQuestion.correct;
setScore((prev) => prev + (isCorrect ? 2 : -0.5));
setCorrectCount((prev) => prev + (isCorrect ? 1 : 0));
setIncorrectCount((prev) => prev + (isCorrect ? 0 : 1));
const newStatus = [...questionStatus];
newStatus[currentQuestionIndex] = isCorrect ? 'Correct' : 'Incorrect';
setQuestionStatus(newStatus);
setTimeout(() => {
if (currentQuestionIndex < questions.length - 1) {
handleNext();
} else {
handleQuizComplete();
}
}, 1000);
};
const handleNext = () => {
setCurrentQuestionIndex((prev) => prev + 1);
setSelectedAnswer(null);
};
const handleQuizComplete = () => {
const timeSpent = Math.floor((Date.now() - startTime) / 1000);
const analysis: QuizAnalysis = {
totalQuestions: questions.length,
correctAnswers: correctCount,
incorrectAnswers: incorrectCount,
unattempted: questions.length - (correctCount + incorrectCount),
score,
accuracy: (correctCount / (correctCount + incorrectCount)) * 100 || 0,
timeSpent
};
setQuizAnalysis(analysis);
setView('analysis');
};
const formatTime = (seconds: number) => {
const mins = Math.floor(seconds / 60);
const secs = seconds % 60;
return ${mins}:${secs.toString().padStart(2, '0')};
};
const startQuiz = () => {
setView('quiz');
setScore(0);
setCorrectCount(0);
setIncorrectCount(0);
setCurrentQuestionIndex(0);
setQuizAnalysis(null);
};
if (view === 'settings') {
return (
Quiz Settings
<div className="space-y-6 mb-8">
<div>
<label className="block text-lg font-semibold mb-2">Number of Questions</label>
<select
value={numQuestions}
onChange={(e) => setNumQuestions(Number(e.target.value))}
className="w-full p-2 border rounded-lg"
>
<option value={10}>10 Questions (~2 minutes)</option>
<option value={25}>25 Questions (~5 minutes)</option>
<option value={50}>50 Questions (~10 minutes)</option>
<option value={75}>75 Questions (~15 minutes)</option>
<option value={100}>100 Questions (~20 minutes)</option>
</select>
</div>
<div className="text-gray-600">
<p>Time will be adjusted based on the number of questions:</p>
<p>• 2 minutes per 10 questions</p>
<p>• Total time: {Math.ceil(numQuestions / 10) * 2} minutes</p>
</div>
</div>
<div className="flex space-x-4">
<button
onClick={() => setView('home')}
className="px-6 py-3 border-2 border-gray-300 text-gray-600 rounded-lg hover:bg-gray-50 transition-colors"
>
Back
</button>
<button
onClick={() => setView('instructions')}
className="px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors flex items-center"
>
Continue <ArrowRight className="w-5 h-5 ml-2" />
</button>
</div>
</div>
</div>
</div>
);
}
if (view === 'home') {
return (
SSC CGL Vocabulary Quiz Series
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div className="bg-white rounded-lg shadow-sm p-6 border-2 border-blue-500">
<div className="flex items-center mb-4">
<Calendar className="w-6 h-6 text-blue-600 mr-2" />
<h2 className="text-xl font-semibold">Day 1 Quiz</h2>
</div>
<p className="text-gray-600 mb-4">Master essential vocabulary with our comprehensive Day 1 quiz.</p>
<button
onClick={() => {
setSelectedDay(1);
setView('settings');
}}
className="w-full bg-blue-600 text-white rounded-lg py-2 px-4 flex items-center justify-center hover:bg-blue-700 transition-colors"
>
Start Quiz <ArrowRight className="w-4 h-4 ml-2" />
</button>
</div>
<div className="bg-white rounded-lg shadow-sm p-6 border-2 border-blue-500">
<div className="flex items-center mb-4">
<Calendar className="w-6 h-6 text-blue-600 mr-2" />
<h2 className="text-xl font-semibold">Day 2 Quiz</h2>
</div>
<p className="text-gray-600 mb-4">Continue your vocabulary journey with Day 2 quiz.</p>
<button
onClick={() => {
setSelectedDay(2);
setView('settings');
}}
className="w-full bg-blue-600 text-white rounded-lg py-2 px-4 flex items-center justify-center hover:bg-blue-700 transition-colors"
>
Start Quiz <ArrowRight className="w-4 h-4 ml-2" />
</button>
</div>
<div className="bg-white rounded-lg shadow-sm p-6 border-2 border-purple-500">
<div className="flex items-center mb-4">
<Brain className="w-6 h-6 text-purple-600 mr-2" />
<h2 className="text-xl font-semibold">Full Vocabulary Quiz</h2>
</div>
<p className="text-gray-600 mb-4">Challenge yourself with a comprehensive quiz covering all vocabulary words.</p>
<button
onClick={() => {
setSelectedDay('full');
setView('settings');
}}
className="w-full bg-purple-600 text-white rounded-lg py-2 px-4 flex items-center justify-center hover:bg-purple-700 transition-colors"
>
Start Full Quiz <ArrowRight className="w-4 h-4 ml-2" />
</button>
</div>
<div className="bg-white rounded-lg shadow-sm p-6 border-2 border-gray-200">
<div className="flex items-center mb-4">
<Calendar className="w-6 h-6 text-gray-400 mr-2" />
<h2 className="text-xl font-semibold text-gray-400">Day 3 Quiz (Coming Soon)</h2>
</div>
<p className="text-gray-400 mb-4">The next set of vocabulary words will be available soon.</p>
<button
disabled
className="w-full bg-gray-100 text-gray-400 rounded-lg py-2 px-4 cursor-not-allowed"
>
Coming Soon
</button>
</div>
</div>
</div>
</div>
);
}
if (view === 'instructions') {
return (
{selectedDay === 'full' ? 'Full Vocabulary Quiz' : Day ${selectedDay} Quiz} Instructions
<div className="space-y-4 text-gray-700 mb-8">
<p className="font-semibold text-xl text-gray-800">Important Guidelines:</p>
<ul className="list-disc pl-5 space-y-2">
<li>This quiz contains {numQuestions} questions</li>
<li>Total duration: {Math.ceil(numQuestions / 10) * 2} minutes</li>
<li>Each correct answer: +2 marks</li>
<li>Each incorrect answer: -0.5 marks</li>
<li>Answers are automatically submitted when selected</li>
<li>You can submit the quiz at any time</li>
<li>The quiz will auto-submit when the time is up</li>
</ul>
</div>
<div className="flex space-x-4">
<button
onClick={() => setView('settings')}
className="px-6 py-3 border-2 border-gray-300 text-gray-600 rounded-lg hover:bg-gray-50 transition-colors"
>
Back to Settings
</button>
<button
onClick={startQuiz}
className="px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors flex items-center"
>
Start Quiz Now <ArrowRight className="w-5 h-5 ml-2" />
</button>
</div>
</div>
</div>
</div>
);
}
if (view === 'analysis') {
return (
Quiz Analysis
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
<div className="bg-blue-50 rounded-lg p-6">
<h2 className="text-xl font-semibold mb-4 text-blue-800">Score Overview</h2>
<div className="space-y-3">
<div className="flex justify-between items-center">
<span className="text-gray-600">Total Score:</span>
<span className="text-2xl font-bold text-blue-600">{quizAnalysis?.score}</span>
</div>
<div className="flex justify-between items-center">
<span className="text-gray-600">Accuracy:</span>
<span className="text-lg font-semibold text-blue-600">
{quizAnalysis?.accuracy.toFixed(1)}%
</span>
</div>
</div>
</div>
<div className="bg-purple-50 rounded-lg p-6">
<h2 className="text-xl font-semibold mb-4 text-purple-800">Time Analysis</h2>
<div className="space-y-3">
<div className="flex justify-between items-center">
<span className="text-gray-600">Time Spent:</span>
<span className=" <span className="text-lg font-semibold text-purple-600">
{formatTime(quizAnalysis?.timeSpent || 0)}
</span>
</div>
<div className="flex justify-between items-center">
<span className="text-gray-600">Avg. Time per Question:</span>
<span className="text-lg font-semibold text-purple-600">
{((quizAnalysis?.timeSpent || 0) / (quizAnalysis?.totalQuestions || 1)).toFixed(1)}s
</span>
</div>
</div>
</div>
<div className="bg-green-50 rounded-lg p-6">
<h2 className="text-xl font-semibold mb-4 text-green-800">Question Analysis</h2>
<div className="space-y-3">
<div className="flex justify-between items-center">
<span className="text-gray-600">Total Questions:</span>
<span className="text-lg font-semibold text-green-600">{quizAnalysis?.totalQuestions}</span>
</div>
<div className="flex justify-between items-center">
<span className="text-gray-600">Correct Answers:</span>
<span className="text-lg font-semibold text-green-600">{quizAnalysis?.correctAnswers}</span>
</div>
<div className="flex justify-between items-center">
<span className="text-gray-600">Incorrect Answers:</span>
<span className="text-lg font-semibold text-red-600">{quizAnalysis?.incorrectAnswers}</span>
</div>
<div className="flex justify-between items-center">
<span className="text-gray-600">Unattempted:</span>
<span className="text-lg font-semibold text-gray-600">{quizAnalysis?.unattempted}</span>
</div>
</div>
</div>
<div className="bg-yellow-50 rounded-lg p-6">
<h2 className="text-xl font-semibold mb-4 text-yellow-800">Performance Metrics</h2>
<div className="space-y-3">
<div className="flex justify-between items-center">
<span className="text-gray-600">Attempt Rate:</span>
<span className="text-lg font-semibold text-yellow-600">
{(((quizAnalysis?.totalQuestions || 0) - (quizAnalysis?.unattempted || 0)) / (quizAnalysis?.totalQuestions || 1) * 100).toFixed(1)}%
</span>
</div>
<div className="flex justify-between items-center">
<span className="text-gray-600">Success Rate:</span>
<span className="text-lg font-semibold text-yellow-600">
{((quizAnalysis?.correctAnswers || 0) / ((quizAnalysis?.correctAnswers || 0) + (quizAnalysis?.incorrectAnswers || 1)) * 100).toFixed(1)}%
</span>
</div>
</div>
</div>
</div>
<div className="flex space-x-4">
<button
onClick={() => setView('home')}
className="px-6 py-3 bg-gray-100 text-gray-600 rounded-lg hover:bg-gray-200 transition-colors flex items-center"
>
Back to Home
</button>
<button
onClick={() => {
setView('settings');
}}
className="px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors flex items-center"
>
Try Again <ArrowRight className="w-5 h-5 ml-2" />
</button>
</div>
</div>
</div>
</div>
);
}
if (!questions || questions.length === 0) {
return (
Preparing your quiz...
);
}
const currentQuestion = questions[currentQuestionIndex];
return (
SSC Vocabulary Quiz
<button
onClick={() => setIsSidebarOpen(!isSidebarOpen)}
className="p-2 hover:bg-gray-100 rounded-lg"
>
<div className="flex-1 p-4 md:p-6 md:order-1">
<div className="bg-white rounded-lg shadow-sm p-4 mb-6">
<h1 className="text-xl md:text-2xl font-bold text-gray-800">
{selectedDay === 'full' ? 'Full Vocabulary Quiz' : `Day ${selectedDay}: SSC CGL Vocabulary Quiz`}
</h1>
<div className="flex justify-between items-center mt-4">
<div className="flex items-center space-x-4">
<div className="flex items-center">
<Clock className="w-5 h-5 text-blue-600 mr-2" />
<span className="font-semibold">
Time Left: {formatTime(timeLeft)}
</span>
</div>
<div className="flex items-center">
<BarChart3 className="w-5 h-5 text-green-600 mr-2" />
<span className="font-semibold text-green-600">
Score: {score}
</span>
</div>
</div>
<button
onClick={handleQuizComplete}
className="px-4 py-2 bg-purple-600 text-white rounded-lg hover:bg-purple-700 transition-colors flex items-center text-sm"
>
Submit Quiz <ArrowRight className="w-4 h-4 ml-2" />
</button>
</div>
</div>
<div className="bg-white rounded-lg shadow-sm p-4 md:p-6 mb-6">
<div className="flex items-center justify-between mb-4">
<span className="text-sm font-medium text-gray-500">
Question {currentQuestionIndex + 1} of {questions.length}
</span>
<span className="text-sm font-medium text-gray-500">
Marks: +2 for correct, -0.5 for incorrect
</span>
</div>
<h2 className="text-lg md:text-xl font-semibold text-gray-800 mb-6">
{currentQuestion.question}
</h2>
<div className="space-y-3">
{currentQuestion.options.map((option, index) => (
<div
key={index}
className={`p-3 md:p-4 rounded-lg border-2 cursor-pointer transition-all ${
selectedAnswer === option
? option === currentQuestion.correct
? 'border-green-500 bg-green-50'
: 'border-red-500 bg-red-50'
: 'border-gray-200 hover:border-blue-200'
}`}
onClick={() => !selectedAnswer && handleAnswerSelect(option)}
>
<label className="flex items-center cursor-pointer">
<input
type="radio"
name="answer"
value={option}
checked={selectedAnswer === option}
onChange={() => !selectedAnswer && handleAnswerSelect(option)}
className="hidden"
/>
<span className={`${
selectedAnswer === option
? option === currentQuestion.correct
? 'text-green-700'
: 'text-red-700'
: 'text-gray-700'
}`}>
{option}
</span>
</label>
</div>
))}
</div>
{selectedAnswer && (
<div className={`mt-6 p-4 rounded-lg ${
selectedAnswer === currentQuestion.correct
? 'bg-green-50 text-green-700'
: 'bg-red-50 text-red-700'
}`}>
{selectedAnswer === currentQuestion.correct ? (
<div className="flex items-center">
<CheckCircle2 className="w-5 h-5 mr-2" />
<span>Correct!</span>
</div>
) : (
<div className="flex items-center">
<XCircle className="w-5 h-5 mr-2" />
<span>Incorrect! The correct answer is: {currentQuestion.correct}</span>
</div>
)}
</div>
)}
</div>
</div>
<div className={`
fixed md:static inset-0 bg-white md:w-80 transform transition-transform duration-200 ease-in-out
${isSidebarOpen ? 'translate-x-0' : '-translate-x-full'}
md:translate-x-0 z-50 md:border-l border-gray-200
`}>
<div className="p-4 md:p-6">
<div className="md:hidden flex justify-end">
<button
onClick={() => setIsSidebarOpen(false)}
className="p-2 hover:bg-gray-100 rounded-lg"
>
✕
</button>
</div>
<h3 className="text-lg font-semibold mb-4">Question Navigation</h3>
<div className="grid grid-cols-5 gap-2 mb-6">
{questionStatus.map((status, index) => (
<div
key={index}
className={`w-8 h-8 flex items-center justify-center rounded-full text-sm ${
status === 'Unattempted'
? 'bg-gray-100 text-gray-600'
: status === 'Correct'
? 'bg-green-100 text-green-600'
: 'bg-red-100 text-red-600'
}`}
>
{index + 1}
</div>
))}
</div>
<div className="space-y-4">
<div className="flex items-center">
<CheckCircle2 className="w-5 h-5 text-green-600 mr-2" />
<span>Correct: {correctCount}</span>
</div>
<div className="flex items-center">
<XCircle className="w-5 h-5 text-red-600 mr-2" />
<span>Incorrect: {incorrectCount}</span>
</div>
<div className="flex items-center">
<HelpCircle className="w-5 h-5 text-gray-600 mr-2" />
<span>Unattempted: {questions.length - (correctCount + incorrectCount)}</span>
</div>
</div>
{timeLeft === 0 && (
<div className="mt-6 p-4 bg-yellow-50 rounded-lg">
<div className="flex items-center text-yellow-800">
<AlertCircle className="w-5 h-5 mr-2" />
<span>Time's up! Quiz completed.</span>
</div>
</div>
)}
</div>
</div>
</div>
);
}
export default App;"