// Collocation Practice โ drills on natural word combinations. // Two modes: "pick the correct collocation" MCQ and "spot the error" correction. function CollocationPractice({ state, update }) { const [category, setCategory] = useState('all'); const [mode, setMode] = useState('mcq'); // 'mcq' | 'error' | 'browse' const [current, setCurrent] = useState(null); const [selected, setSelected] = useState(null); const [locked, setLocked] = useState(false); const [stats, setStats] = useState({ correct: 0, total: 0 }); const [browseIdx, setBrowseIdx] = useState(0); const pool = useMemo(() => { if (category === 'all') return window.COLLOCATIONS; return window.COLLOCATIONS.filter(c => c.cat === category); }, [category]); const generateMCQ = useCallback(() => { if (!pool.length) return; const correct = pool[Math.floor(Math.random() * pool.length)]; // Build 3 wrong distractors from different collocations const others = window.COLLOCATIONS.filter(c => c.col !== correct.col); const distractors = []; while (distractors.length < 3 && others.length > distractors.length) { const pick = others[Math.floor(Math.random() * others.length)]; if (!distractors.find(d => d.col === pick.col)) distractors.push(pick); } // Extract the verb/adjective part for the quiz const options = [correct, ...distractors].sort(() => Math.random() - 0.5); setCurrent({ correct, options, correctIndex: options.findIndex(o => o.col === correct.col) }); setSelected(null); setLocked(false); }, [pool]); const generateError = useCallback(() => { if (!pool.length) return; const item = pool[Math.floor(Math.random() * pool.length)]; // Show the WRONG version and ask user to spot + fix it const showWrong = Math.random() > 0.4; // 60% show wrong, 40% show correct setCurrent({ item, showWrong, displayed: showWrong ? item.wrong : item.col }); setSelected(null); setLocked(false); }, [pool]); useEffect(() => { if (mode === 'mcq') generateMCQ(); else if (mode === 'error') generateError(); }, [mode, generateMCQ, generateError]); const chooseMCQ = (i) => { if (locked) return; setSelected(i); setLocked(true); setStats(s => ({ correct: s.correct + (i === current.correctIndex ? 1 : 0), total: s.total + 1 })); }; const chooseError = (answer) => { if (locked) return; const isCorrect = (answer === 'wrong' && current.showWrong) || (answer === 'correct' && !current.showWrong); setSelected(answer); setLocked(true); setStats(s => ({ correct: s.correct + (isCorrect ? 1 : 0), total: s.total + 1 })); }; const next = () => { mode === 'mcq' ? generateMCQ() : generateError(); }; const accuracy = stats.total > 0 ? Math.round(stats.correct / stats.total * 100) : 0; return (
Natural English uses specific word pairs. Getting these right jumps you from band 6 to band 7.