// This React component is designed to be self-contained and can be imported // into other React projects or compiled into a JavaScript bundle // for embedding into a standard HTML web page. import React, { useState, useEffect } from 'react'; // Main App component const App = () => { // State variables for managing the test const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0); // Index of the current question const [userAnswers, setUserAnswers] = useState([]); // Array to store user's selected answers const [score, setScore] = useState(0); // User's score const [showResults, setShowResults] = useState(false); // Flag to show/hide results section const [showTips, setShowTips] = useState(false); // Flag to show/hide tips section const [selectedOption, setSelectedOption] = useState(null); // Currently selected option for the active question const [shuffledQuestions, setShuffledQuestions] = useState([]); // Questions for the current test session, shuffled const [feedbackMessage, setFeedbackMessage] = useState(''); // Message for immediate feedback (Correct/Incorrect) const [showFeedback, setShowFeedback] = useState(false); // Flag to show/hide feedback message // Define a larger set of GED test questions across subjects const allQuestions = [ // Reasoning Through Language Arts (RLA) - Aiming for ~20 questions { id: 1, subject: "Reasoning Through Language Arts", question: "Read the following passage and answer the question: 'The ancient city of Petra, carved into rose-red cliffs in Jordan, is a marvel of engineering and artistry. Its intricate facades and tombs, built by the Nabataeans, draw visitors from around the globe, eager to witness its grandeur.' What is the main purpose of this passage?", options: [ "To describe the geology of Jordan.", "To explain how ancient cities were built.", "To highlight the unique features and appeal of Petra.", "To detail the history of the Nabataeans." ], correctAnswer: "To highlight the unique features and appeal of Petra." }, { id: 2, subject: "Reasoning Through Language Arts", question: "Which of the following sentences uses correct subject-verb agreement?", options: [ "The team are celebrating their victory.", "Each of the students have completed their assignment.", "Neither the cat nor the dogs is in the house.", "The group of volunteers was ready to help." ], correctAnswer: "The group of volunteers was ready to help." }, { id: 3, subject: "Reasoning Through Language Arts", question: "Identify the figure of speech: 'The silence in the room was deafening.'", options: [ "Simile", "Metaphor", "Personification", "Oxymoron" ], correctAnswer: "Oxymoron" }, { id: 4, subject: "Reasoning Through Language Arts", question: "What is the function of a conjunction in a sentence?", options: [ "To describe a noun", "To show action", "To connect words, phrases, or clauses", "To replace a noun" ], correctAnswer: "To connect words, phrases, or clauses" }, { id: 5, subject: "Reasoning Through Language Arts", question: "Choose the sentence that demonstrates proper comma usage:", options: [ "She bought apples, oranges and bananas.", "He likes to read, write, and draw.", "After the rain stopped the sun came out.", "My favorite colors are blue green and yellow." ], correctAnswer: "He likes to read, write, and draw." }, { id: 6, subject: "Reasoning Through Language Arts", question: "What is the definition of 'inference' in reading comprehension?", options: [ "A direct statement from the text.", "A conclusion reached on the basis of evidence and reasoning.", "The author's main point.", "A summary of the passage." ], correctAnswer: "A conclusion reached on the basis of evidence and reasoning." }, { id: 7, subject: "Reasoning Through Language Arts", question: "Which literary device involves a contrast between what is said and what is actually meant?", options: [ "Alliteration", "Hyperbole", "Irony", "Onomatopoeia" ], correctAnswer: "Irony" }, { id: 8, subject: "Reasoning Through Language Arts", question: "In the sentence 'The old, dilapidated house stood on the hill,' which words are adjectives?", options: [ "old, stood", "dilapidated, house", "old, dilapidated", "house, hill" ], correctAnswer: "old, dilapidated" }, { id: 9, subject: "Reasoning Through Language Arts", question: "What is the purpose of an introductory paragraph in an essay?", options: [ "To provide detailed evidence.", "To summarize the main points.", "To hook the reader and state the thesis.", "To offer a counter-argument." ], correctAnswer: "To hook the reader and state the thesis." }, { id: 10, subject: "Reasoning Through Language Arts", question: "Which of the following is a run-on sentence?", options: [ "I went to the store, and I bought milk.", "She studied hard she passed the test.", "Although it was cold, we still went for a walk.", "The dog barked loudly." ], correctAnswer: "She studied hard she passed the test." }, { id: 11, subject: "Reasoning Through Language Arts", question: "What does 'bias' mean in the context of a written text?", options: [ "A factual statement.", "A balanced presentation of different viewpoints.", "A prejudice in favor of or against one thing, person, or group compared with another.", "The author's personal opinion, clearly stated." ], correctAnswer: "A prejudice in favor of or against one thing, person, or group compared with another." }, { id: 12, subject: "Reasoning Through Language Arts", question: "Which word is a synonym for 'benevolent'?", options: [ "Cruel", "Kind", "Strict", "Angry" ], correctAnswer: "Kind" }, { id: 13, subject: "Reasoning Through Language Arts", question: "Identify the correct use of a semicolon:", options: [ "I like pizza; and pasta.", "She is tired; however, she must finish her work.", "He went to the market; to buy groceries.", "The cat; slept all day." ], correctAnswer: "She is tired; however, she must finish her work." }, { id: 14, subject: "Reasoning Through Language Arts", question: "What is the main idea of a narrative text?", options: [ "The moral of the story.", "The central message or lesson.", "The sequence of events.", "The most important point the author wants to convey about the story." ], correctAnswer: "The most important point the author wants to convey about the story." }, { id: 15, subject: "Reasoning Through Language Arts", question: "Which word correctly completes the sentence: 'The effect of the medicine ____ immediate.'", options: [ "was", "were", "are", "is" ], correctAnswer: "was" }, // Mathematical Reasoning - Aiming for ~15 questions { id: 16, subject: "Mathematical Reasoning", question: "Calculate: $15 - 3 \\times 4 + 2$", options: [ "$5$", "$14$", "$20$", "$38$" ], correctAnswer: "$5$" }, { id: 17, subject: "Mathematical Reasoning", question: "What is 15% of 200?", options: [ "$15$", "$20$", "$30$", "$45$" ], correctAnswer: "$30$" }, { id: 18, subject: "Mathematical Reasoning", question: "If a recipe calls for 2 cups of flour for 8 cookies, how much flour is needed for 24 cookies?", options: [ "4 cups", "6 cups", "8 cups", "12 cups" ], correctAnswer: "6 cups" }, { id: 19, subject: "Mathematical Reasoning", question: "Simplify the expression: $2(x + 3) - x$", options: [ "$x + 3$", "$x + 6$", "$3x + 3$", "$3x + 6$" ], correctAnswer: "$x + 6$" }, { id: 20, subject: "Mathematical Reasoning", question: "A square has an area of $64 cm^2$. What is the length of one side?", options: [ "4 cm", "8 cm", "16 cm", "32 cm" ], correctAnswer: "8 cm" }, { id: 21, subject: "Mathematical Reasoning", question: "What is the median of the following set of numbers: 12, 8, 15, 10, 13?", options: [ "10", "11", "12", "13" ], correctAnswer: "12" }, { id: 22, subject: "Mathematical Reasoning", question: "Solve for y: $2y - 5 = 11$", options: [ "$y = 3$", "$y = 6$", "$y = 8$", "$y = 16$" ], correctAnswer: "$y = 8$" }, { id: 23, subject: "Mathematical Reasoning", question: "A circle has a radius of 7 inches. What is its approximate circumference? (Use $\\pi \\approx 3.14$)", options: [ "21.98 inches", "43.96 inches", "153.86 inches", "14 inches" ], correctAnswer: "43.96 inches" }, { id: 24, subject: "Mathematical Reasoning", question: "What is the value of $|-9|$?", options: [ "$-9$", "$0$", "$9$", "$18$" ], correctAnswer: "$9$" }, { id: 25, subject: "Mathematical Reasoning", question: "If a car travels at a constant speed of 60 mph, how long will it take to travel 210 miles?", options: [ "2.5 hours", "3 hours", "3.5 hours", "4 hours" ], correctAnswer: "3.5 hours" }, { id: 26, subject: "Mathematical Reasoning", question: "What is the least common multiple (LCM) of 4 and 6?", options: [ "2", "12", "24", "36" ], correctAnswer: "12" }, { id: 27, subject: "Mathematical Reasoning", question: "Convert 1/5 to a decimal.", options: [ "0.1", "0.2", "0.5", "0.05" ], correctAnswer: "0.2" }, { id: 28, subject: "Mathematical Reasoning", question: "If a bag contains 5 red marbles and 3 blue marbles, what is the probability of picking a red marble?", options: [ "3/8", "5/8", "1/2", "5/3" ], correctAnswer: "5/8" }, { id: 29, subject: "Mathematical Reasoning", question: "What is the next number in the sequence: 2, 4, 8, 16, ___?", options: [ "20", "24", "32", "64" ], correctAnswer: "32" }, { id: 30, subject: "Mathematical Reasoning", question: "Evaluate the expression: $4^2 - \\sqrt{25}$", options: [ "3", "11", "16", "21" ], correctAnswer: "11" }, // Science - Aiming for ~15 questions { id: 31, subject: "Science", question: "Which part of a plant is primarily responsible for absorbing water and nutrients from the soil?", options: [ "Leaves", "Stem", "Roots", "Flowers" ], correctAnswer: "Roots" }, { id: 32, subject: "Science", question: "What is the force that pulls objects towards the center of the Earth?", options: [ "Friction", "Gravity", "Magnetism", "Tension" ], correctAnswer: "Gravity" }, { id: 33, subject: "Science", question: "Which of the following is a producer in a food chain?", options: [ "Lion", "Deer", "Grass", "Fungus" ], correctAnswer: "Grass" }, { id: 34, subject: "Science", question: "What is the primary function of the human heart?", options: [ "To digest food", "To pump blood throughout the body", "To filter waste from blood", "To produce hormones" ], correctAnswer: "To pump blood throughout the body" }, { id: 35, subject: "Science", question: "Which state of matter has a definite shape and a definite volume?", options: [ "Solid", "Liquid", "Gas", "Plasma" ], correctAnswer: "Solid" }, { id: 36, subject: "Science", question: "What is the process of a liquid turning into a gas?", options: [ "Melting", "Freezing", "Condensation", "Evaporation" ], correctAnswer: "Evaporation" }, { id: 37, subject: "Science", question: "Which organelle is known as the 'powerhouse' of the cell?", options: [ "Nucleus", "Mitochondria", "Ribosome", "Cell Wall" ], correctAnswer: "Mitochondria" }, { id: 38, subject: "Science", question: "What is the unit of measurement for electric current?", options: [ "Volt", "Ohm", "Ampere", "Watt" ], correctAnswer: "Ampere" }, { id: 39, subject: "Science", question: "Which type of rock is formed from cooled and solidified magma or lava?", options: [ "Sedimentary", "Metamorphic", "Igneous", "Sandstone" ], correctAnswer: "Igneous" }, { id: 40, subject: "Science", question: "What is the outermost layer of the Earth?", options: [ "Mantle", "Outer Core", "Inner Core", "Crust" ], correctAnswer: "Crust" }, { id: 41, subject: "Science", question: "Which of the following is a common symptom of a viral infection?", options: [ "Broken bones", "Fever", "Muscle sprains", "Allergic reaction" ], correctAnswer: "Fever" }, { id: 42, subject: "Science", question: "What is the primary role of decomposers in an ecosystem?", options: [ "To produce food", "To consume producers", "To break down dead organic matter", "To provide shelter" ], correctAnswer: "To break down dead organic matter" }, { id: 43, subject: "Science", question: "Which of the following describes a physical change?", options: [ "Rusting of iron", "Burning of wood", "Dissolving sugar in water", "Baking a cake" ], correctAnswer: "Dissolving sugar in water" }, { id: 44, subject: "Science", question: "What is the smallest unit of an element that retains the chemical properties of that element?", options: [ "Molecule", "Compound", "Atom", "Cell" ], correctAnswer: "Atom" }, { id: 45, subject: "Science", question: "Which gas makes up the largest percentage of Earth's atmosphere?", options: [ "Oxygen", "Carbon Dioxide", "Argon", "Nitrogen" ], correctAnswer: "Nitrogen" }, // Social Studies - Aiming for ~15 questions { id: 46, subject: "Social Studies", question: "Which document begins with the words 'We the People'?", options: [ "Declaration of Independence", "Bill of Rights", "Articles of Confederation", "U.S. Constitution" ], correctAnswer: "U.S. Constitution" }, { id: 47, subject: "Social Studies", question: "What is the main purpose of the Bill of Rights?", options: [ "To establish the three branches of government.", "To outline the powers of the President.", "To protect individual liberties and rights.", "To define the process for amending the Constitution." ], correctAnswer: "To protect individual liberties and rights." }, { id: 48, subject: "Social Studies", question: "Which historical event led to the United States entering World War II?", options: [ "The attack on Pearl Harbor", "The Great Depression", "The sinking of the Lusitania", "The Cuban Missile Crisis" ], correctAnswer: "The attack on Pearl Harbor" }, { id: 49, subject: "Social Studies", question: "What is the term for a system of government where power is held by the people and exercised through elected representatives?", options: [ "Monarchy", "Oligarchy", "Democracy", "Dictatorship" ], correctAnswer: "Democracy" }, { id: 50, subject: "Social Studies", question: "Which of the following is a primary source document?", options: [ "A history textbook", "A biography of Abraham Lincoln", "A diary entry from a Civil War soldier", "A documentary about ancient Egypt" ], correctAnswer: "A diary entry from a Civil War soldier" }, { id: 51, subject: "Social Studies", question: "What is the purpose of a census in the United States?", options: [ "To determine voting patterns.", "To count the population for representation and funding.", "To track economic growth.", "To identify eligible voters." ], correctAnswer: "To count the population for representation and funding." }, { id: 52, subject: "Social Studies", question: "Which major river flows through Egypt and is crucial to its civilization?", options: [ "Amazon River", "Mississippi River", "Nile River", "Yangtze River" ], correctAnswer: "Nile River" }, { id: 53, subject: "Social Studies", question: "What was the main cause of the American Civil War?", options: [ "Taxation without representation", "Slavery and states' rights", "Disputes over land ownership", "Religious differences" ], correctAnswer: "Slavery and states' rights" }, { id: 54, subject: "Social Studies", question: "Which economic system is characterized by private ownership of the means of production?", options: [ "Socialism", "Communism", "Capitalism", "Feudalism" ], correctAnswer: "Capitalism" }, { id: 55, subject: "Social Studies", question: "What is the geographic term for a narrow strip of land connecting two larger landmasses?", options: [ "Peninsula", "Island", "Isthmus", "Archipelago" ], correctAnswer: "Isthmus" }, { id: 56, subject: "Social Studies", question: "Who wrote 'Common Sense,' a pamphlet that advocated for American independence?", options: [ "Benjamin Franklin", "George Washington", "Thomas Paine", "John Adams" ], correctAnswer: "Thomas Paine" }, { id: 57, subject: "Social Studies", question: "Which international organization was formed after World War II to promote peace and cooperation?", options: [ "League of Nations", "NATO", "United Nations", "Red Cross" ], correctAnswer: "United Nations" }, { id: 58, subject: "Social Studies", question: "What is the purpose of checks and balances in the U.S. government?", options: [ "To ensure all branches have equal power.", "To prevent any one branch from becoming too powerful.", "To speed up the legislative process.", "To divide power between federal and state governments." ], correctAnswer: "To prevent any one branch from becoming too powerful." }, { id: 59, subject: "Social Studies", question: "Which ancient civilization developed the concept of democracy?", options: [ "Roman Empire", "Ancient Egypt", "Ancient Greece", "Mesopotamia" ], correctAnswer: "Ancient Greece" }, { id: 60, subject: "Social Studies", question: "What is the study of the Earth's physical features and human activity and their interaction?", options: [ "History", "Economics", "Sociology", "Geography" ], correctAnswer: "Geography" } ]; // Effect to shuffle questions when the component mounts or test is retaken useEffect(() => { shuffleQuestions(); }, []); // Empty dependency array means this runs once on mount // Function to shuffle the questions array const shuffleQuestions = () => { const shuffled = [...allQuestions].sort(() => Math.random() - 0.5); setShuffledQuestions(shuffled); }; // Function to handle option selection const handleOptionSelect = (option) => { setSelectedOption(option); }; // Function to move to the next question or submit the test const handleNextQuestion = () => { const currentQuestion = shuffledQuestions[currentQuestionIndex]; const isCorrect = selectedOption === currentQuestion.correctAnswer; // Set feedback message and show it setFeedbackMessage(isCorrect ? "Correct!" : "Incorrect!"); setShowFeedback(true); // Store the selected answer for the current question const updatedAnswers = [...userAnswers]; updatedAnswers[currentQuestionIndex] = selectedOption; setUserAnswers(updatedAnswers); // Wait for a short duration before proceeding setTimeout(() => { setShowFeedback(false); // Hide feedback if (currentQuestionIndex < shuffledQuestions.length - 1) { setCurrentQuestionIndex(currentQuestionIndex + 1); setSelectedOption(null); // Reset selected option for the new question } else { // If it's the last question, submit the test calculateScore(); setShowResults(true); } }, 1000); // Show feedback for 1 second }; // Function to calculate the final score const calculateScore = () => { let newScore = 0; shuffledQuestions.forEach((question, index) => { if (userAnswers[index] === question.correctAnswer) { newScore += 1; } }); setScore(newScore); }; // Function to restart the test const handleRetakeTest = () => { setCurrentQuestionIndex(0); setUserAnswers([]); setScore(0); setShowResults(false); setShowTips(false); setSelectedOption(null); setFeedbackMessage(''); // Clear any previous feedback setShowFeedback(false); // Hide feedback shuffleQuestions(); // Shuffle questions again for a new test }; // GED Test Tips const gedTips = [ "**Understand the Test Format:** Familiarize yourself with the structure of each GED subject test (Reasoning Through Language Arts, Mathematical Reasoning, Science, Social Studies).", "**Practice Regularly:** Consistent practice with sample questions and full-length practice tests is crucial. This helps you get used to the timing and question types.", "**Focus on Weak Areas:** Identify your areas of weakness and dedicate more study time to them. Don't just study what you already know.", "**Read Carefully:** For reading comprehension and social studies, read passages and questions thoroughly before answering. Don't rush.", "**Show Your Work (Math):** Even if you can do mental math, practice showing your steps for mathematical reasoning. This can help you catch errors and earn partial credit if available.", "**Manage Your Time:** Practice pacing yourself during the test. Each section has a time limit, so make sure you allocate enough time for each question.", "**Utilize Resources:** Take advantage of official GED study guides, online courses, and local adult education centers.", "**Stay Healthy:** Get enough sleep, eat well, and manage stress. A clear mind performs better on test day.", "**Review Your Answers:** If time permits, review your answers before submitting each section.", "**Don't Be Afraid to Guess:** On multiple-choice questions, if you're unsure, make an educated guess. There's no penalty for wrong answers on the GED." ]; return (
Question {currentQuestionIndex + 1} of {shuffledQuestions.length} {shuffledQuestions[currentQuestionIndex]?.subject && ( {shuffledQuestions[currentQuestionIndex].subject} )}
You scored {score} out of {shuffledQuestions.length}!
{score === shuffledQuestions.length ? "Excellent! You got all questions correct." : score >= shuffledQuestions.length / 2 ? "Good job! Keep practicing to improve." : "You might want to review the material and try again." }