diff --git a/frontend/app/learn/page.tsx b/frontend/app/learn/page.tsx index 0a8a83b..14065a9 100644 --- a/frontend/app/learn/page.tsx +++ b/frontend/app/learn/page.tsx @@ -13,17 +13,16 @@ import { calculateCurrentMastery, getReviewTypesByDifficulty } from '@/lib/utils // 擴展的Flashcard接口,包含智能複習需要的欄位 interface ExtendedFlashcard extends Omit { - userLevel?: number; // 學習者程度 (1-100) - 向後兼容 - wordLevel?: number; // 詞彙難度 (1-100) - 向後兼容 + userLevel?: number; // 學習者程度數值 (從CEFR轉換) + wordLevel?: number; // 詞彙難度數值 (從CEFR轉換) nextReviewDate?: string; // 下次復習日期 (可選) currentInterval?: number; // 當前間隔天數 isOverdue?: boolean; // 是否逾期 overdueDays?: number; // 逾期天數 baseMasteryLevel?: number; // 基礎熟悉度 lastReviewDate?: string; // 最後復習日期 - synonyms?: string[]; // 同義詞 (向後兼容) - exampleImage?: string; // 例句圖片 (向後兼容) - // 注意:difficultyLevel已在基礎Flashcard接口中定義 + synonyms?: string[]; // 同義詞 + exampleImage?: string; // 例句圖片 } export default function LearnPage() { @@ -375,21 +374,30 @@ export default function LearnPage() { .filter(card => card.id !== currentCard.id) .map(card => card.word); - // If we don't have enough words in the deck, add some default options - const additionalOptions = ['determine', 'achieve', 'consider', 'negotiate', 'establish', 'maintain']; - const allOtherWords = [...otherWords, ...additionalOptions]; - - // Take 3 other words (avoiding duplicates) + // 優先從其他詞卡生成選項,必要時使用備用詞彙 const selectedOtherWords: string[] = []; - for (const word of allOtherWords) { + + // 從其他詞卡取得選項 + for (const word of otherWords) { if (selectedOtherWords.length >= 3) break; if (word !== currentWord && !selectedOtherWords.includes(word)) { selectedOtherWords.push(word); } } - // Ensure we have exactly 4 options: current word + 3 others - const options = [currentWord, ...selectedOtherWords].sort(() => Math.random() - 0.5); + // 如果詞卡不足,補充基礎詞彙 + if (selectedOtherWords.length < 3) { + const backupWords = ['important', 'beautiful', 'interesting', 'difficult', 'wonderful', 'excellent']; + for (const word of backupWords) { + if (selectedOtherWords.length >= 3) break; + if (word !== currentWord && !selectedOtherWords.includes(word)) { + selectedOtherWords.push(word); + } + } + } + + // 確保有4個選項:當前詞彙 + 3個其他選項 + const options = [currentWord, ...selectedOtherWords.slice(0, 3)].sort(() => Math.random() - 0.5); setQuizOptions(options); // Reset quiz state when card changes @@ -408,27 +416,36 @@ export default function LearnPage() { .filter(card => card.id !== currentCard.id) .map(card => card.example); - // Add some default sentence options if not enough - const additionalSentences = [ - 'I think this is a good opportunity for us.', - 'She decided to take a different approach.', - 'They managed to solve the problem quickly.', - 'We need to consider all possible solutions.' - ]; - - const allOtherSentences = [...otherSentences, ...additionalSentences]; - - // Take 3 other sentences (avoiding duplicates) + // 優先從其他詞卡的例句生成選項 const selectedOtherSentences: string[] = []; - for (const sentence of allOtherSentences) { + + // 從其他詞卡的例句取得選項 + for (const sentence of otherSentences) { if (selectedOtherSentences.length >= 3) break; if (sentence !== currentSentence && !selectedOtherSentences.includes(sentence)) { selectedOtherSentences.push(sentence); } } - // Ensure we have exactly 4 options: current sentence + 3 others - const options = [currentSentence, ...selectedOtherSentences].sort(() => Math.random() - 0.5); + // 如果例句不足,使用基礎例句補充 + if (selectedOtherSentences.length < 3) { + const backupSentences = [ + 'This is a very important decision.', + 'The weather looks beautiful today.', + 'We need to find a good solution.', + 'Learning English can be interesting.' + ]; + + for (const sentence of backupSentences) { + if (selectedOtherSentences.length >= 3) break; + if (sentence !== currentSentence && !selectedOtherSentences.includes(sentence)) { + selectedOtherSentences.push(sentence); + } + } + } + + // 確保有4個選項:當前例句 + 3個其他選項 + const options = [currentSentence, ...selectedOtherSentences.slice(0, 3)].sort(() => Math.random() - 0.5); setSentenceOptions(options); }, [currentCard, dueCards, mode]) @@ -739,9 +756,9 @@ export default function LearnPage() { - {/* Demo Information Panel */} + {/* Smart Review Information Panel */}
-

🎯 智能適配演示

+

🧠 CEFR智能複習系統