'use client' import { useState } from 'react' import { Navigation } from '@/components/shared/Navigation' import { VocabChoiceTest } from '@/components/review/simple/VocabChoiceTest' import { SIMPLE_CARDS, CardState } from '@/lib/data/reviewSimpleData' export default function TestVocabChoicePage() { const [currentCardIndex, setCurrentCardIndex] = useState(0) const [score, setScore] = useState({ correct: 0, total: 0 }) const currentCard = SIMPLE_CARDS[currentCardIndex] // 生成測驗選項 (包含正確答案和3個干擾項) const generateOptions = (correctWord: string) => { const allWords = SIMPLE_CARDS.map(card => card.word).filter(word => word !== correctWord) const shuffledWords = allWords.sort(() => Math.random() - 0.5) const distractors = shuffledWords.slice(0, 3) const options = [correctWord, ...distractors] return options.sort(() => Math.random() - 0.5) // 隨機排列選項 } const handleAnswer = (confidence: number) => { const isCorrect = confidence >= 2 setScore(prev => ({ correct: prev.correct + (isCorrect ? 1 : 0), total: prev.total + 1 })) // 移動到下一張卡片 setTimeout(() => { if (currentCardIndex < SIMPLE_CARDS.length - 1) { setCurrentCardIndex(prev => prev + 1) } else { alert(`測試完成!正確率: ${score.correct + (isCorrect ? 1 : 0)}/${score.total + 1}`) } }, 100) } const handleSkip = () => { setScore(prev => ({ ...prev, total: prev.total + 1 })) if (currentCardIndex < SIMPLE_CARDS.length - 1) { setCurrentCardIndex(prev => prev + 1) } else { alert(`測試完成!正確率: ${score.correct}/${score.total + 1}`) } } const handleRestart = () => { setCurrentCardIndex(0) setScore({ correct: 0, total: 0 }) } if (!currentCard) { return (

測試完成!

) } return (
{/* 進度顯示 */}

詞彙選擇測驗

第 {currentCardIndex + 1} / {SIMPLE_CARDS.length} 題
得分: {score.correct} / {score.total} {score.total > 0 && ` (${Math.round(score.correct / score.total * 100)}%)`}
{/* 測驗組件 */} {/* 控制按鈕 */}
) }