import React, { useState, useEffect, useCallback } from 'react'; import { Trophy, Clock, CheckCircle2, XCircle, ChevronRight, RefreshCcw, FileDown, GraduationCap } from 'lucide-react'; const QUIZ_DATA = [ { question: "다음 영영풀이에 해당하는 단어는 무엇입니까?\n'in danger of disappearing because there are very few left alive'", options: ["wild", "various", "endangered", "global", "wonderful"], answer: 2, rationale: "멸종 위기에 처한(endangered)은 생존해 있는 개체 수가 매우 적어 사라질 위험에 처한 상태를 의미합니다." }, { question: "다음 문장의 빈칸에 알맞은 표현을 고르세요.\n'Only one person _________ the fire in the building.'", options: ["searched", "prepared", "returned", "survived", "waved"], answer: 3, rationale: "화재와 같은 위험한 상황에서 계속 살아가다라는 뜻인 'survived(살아남았다)'가 문맥상 가장 적절합니다." }, { question: "다음 중 '심부름하다'라는 의미의 이디엄(Idiom)은?", options: ["take part in", "run an errand", "at the same time", "search for", "cleanup"], answer: 1, rationale: "run an errand는 다른 사람을 위해 소소한 일을 하기 위해 어딘가에 다녀오는 '심부름하다'라는 뜻입니다." }, { question: "다음 단어와 우리말 뜻의 연결이 옳지 않은 것은?", options: ["aquarium - 수족관", "ceremony - 의식", "issue - 문제, 사안", "various - 다양한", "luckily - 불행하게도"], answer: 4, rationale: "luckily는 '운 좋게도'라는 뜻이며, '불행하게도'는 unfortunately입니다." }, { question: "다음 영영풀이에 해당하는 단어는 무엇입니까?\n'a sea animal that looks like a large fish and is very intelligent'", options: ["dolphin", "fishing net", "wave", "wild", "blog"], answer: 0, rationale: "큰 물고기처럼 생겼으며 매우 지능이 높은 바다 동물은 돌고래(dolphin)입니다." } ]; const App = () => { const [gameState, setGameState] = useState('START'); // START, QUIZ, RESULT const [currentIndex, setCurrentIndex] = useState(0); const [score, setScore] = useState(0); const [timeLeft, setTimeLeft] = useState(60); const [selectedOption, setSelectedOption] = useState(null); const [isAnswered, setIsAnswered] = useState(false); // Timer logic useEffect(() => { let timer; if (gameState === 'QUIZ' && !isAnswered && timeLeft > 0) { timer = setInterval(() => { setTimeLeft((prev) => prev - 1); }, 1000); } else if (timeLeft === 0 && !isAnswered) { handleOptionClick(-1); // Time out } return () => clearInterval(timer); }, [gameState, isAnswered, timeLeft]); const handleStart = () => { setGameState('QUIZ'); setCurrentIndex(0); setScore(0); setTimeLeft(60); setIsAnswered(false); setSelectedOption(null); }; const handleOptionClick = (index) => { if (isAnswered) return; setSelectedOption(index); setIsAnswered(true); if (index === QUIZ_DATA[currentIndex].answer) { const bonus = 10 + timeLeft; setScore((prev) => prev + bonus); } }; const handleNext = () => { if (currentIndex < QUIZ_DATA.length - 1) { setCurrentIndex((prev) => prev + 1); setIsAnswered(false); setSelectedOption(null); setTimeLeft(60); } else { setGameState('RESULT'); } }; const handlePrint = () => { window.print(); }; return (
{idx + 1}. {q.question}
Lesson 1: 핵심 단어 마스터 퀴즈
{QUIZ_DATA[currentIndex].rationale}
모든 문제를 성실히 해결했습니다.
최종 점수
{score}pt