Add much more practice content to every section

Hoeren 28 exercises, Lesen 22 texts, Schreiben 24 tasks, Sprechen 20 topics + 8 planning tasks + 10 presentations, Grammatik 20 lessons with ~260 exercises and a random drill, 332 words with gap-fill, plural and hat/ist drills.
This commit is contained in:
X4Lo committed 2026-11-05 21:47:08 +00:00
1 parent 1f1d28a34d
commit c754477f07
16 files changed
+2054 -17

No files matched your search

+67 -2
View File
@@ -1,7 +1,7 @@
"use client";
import { useMemo, useState } from "react";
import { lessons, type GrammarEx, type Lesson } from "@/data/grammatik";
import { allGrammarExercises, lessons, type GrammarEx, type Lesson } from "@/data/grammatik";
import Ar from "@/components/Ar";
import SpeakButton from "@/components/SpeakButton";
import ResultCard from "@/components/ResultCard";
@@ -10,14 +10,33 @@ import { sfx } from "@/lib/sfx";
export default function GrammatikPage() {
const [lesson, setLesson] = useState<Lesson | null>(null);
const [drill, setDrill] = useState(0);
const p = useProgress();
if (drill > 0) return <Drill key={drill} onBack={() => setDrill(0)} onAgain={() => setDrill((d) => d + 1)} />;
if (lesson) return <LessonView key={lesson.id} lesson={lesson} onBack={() => setLesson(null)} />;
return (
<div>
<h1>🧩 Grammatik</h1>
<p className="sub">
Die wichtigsten B1-Themen – auf Arabisch erklärt, mit Übungen. <Ar>أهم مواضيع B1 – مشروحة بالعربية مع تمارين.</Ar>
{lessons.length} B1-Themen mit {allGrammarExercises.length} Übungen – auf Arabisch erklärt. <Ar>مواضيع B1 مشروحة بالعربية مع تمارين كثيرة.</Ar>
</p>
<button
className="tile"
style={{ background: "linear-gradient(135deg, var(--purple), var(--blue))", color: "#fff", marginBottom: 12 }}
onClick={() => setDrill(1)}
>
<div className="row">
<span className="emoji">🎲</span>
<div style={{ flex: 1 }}>
<div className="t" style={{ marginTop: 0 }}>
Zufalls-Drill: 20 gemischte Fragen
</div>
<div className="s" style={{ color: "#fff", opacity: 0.9 }}>
Aus allen Themen – jedes Mal anders! • تمرين عشوائي من كل المواضيع
</div>
</div>
</div>
</button>
<div className="grid grid-2">
{lessons.map((l) => {
const score = p.done[l.id];
@@ -127,6 +146,52 @@ function LessonView({ lesson, onBack }: { lesson: Lesson; onBack: () => void })
);
}
function Drill({ onBack, onAgain }: { onBack: () => void; onAgain: () => void }) {
const items = useMemo(() => [...allGrammarExercises].sort(() => Math.random() - 0.5).slice(0, 20), []);
const [results, setResults] = useState<(boolean | null)[]>(() => items.map(() => null));
const [done, setDone] = useState<{ c: number; xp: number } | null>(null);
const answered = results.filter((r) => r !== null).length;
const onAnswer = (i: number, ok: boolean) => {
const next = results.map((r, j) => (j === i ? ok : r));
setResults(next);
if (next.every((r) => r !== null) && !done) {
const c = next.filter(Boolean).length;
const xp = 10 + c * 2;
recordResult("grammatik-drill", "grammatik", (c / next.length) * 100, xp);
setDone({ c, xp });
}
};
return (
<div>
<button className="btn secondary small" style={{ marginTop: 16 }} onClick={onBack}>
← Zurück
</button>
<h1 style={{ fontSize: 24 }}>🎲 Zufalls-Drill</h1>
<div className="row">
<span className="pill">
{answered} / {items.length}
</span>
<span className="pill green">✅ {results.filter((r) => r === true).length}</span>
</div>
<div className="bar" style={{ marginTop: 8 }}>
<div style={{ width: `${(answered / items.length) * 100}%` }} />
</div>
{items.map((it, i) => (
<div key={i} className="card" style={{ marginTop: 12 }}>
<div className="row" style={{ marginBottom: 6 }}>
<span className="pill">{i + 1}</span>
<span className="small muted">{it.lessonTitle}</span>
</div>
{it.ex.kind === "mc" ? <McEx ex={it.ex} onAnswer={(ok) => onAnswer(i, ok)} /> : <OrderEx ex={it.ex} onAnswer={(ok) => onAnswer(i, ok)} />}
</div>
))}
{done && <ResultCard correct={done.c} total={items.length} xp={done.xp} onRetry={onAgain} />}
</div>
);
}
function McEx({ ex, onAnswer }: { ex: Extract<GrammarEx, { kind: "mc" }>; onAnswer: (ok: boolean) => void }) {
const [chosen, setChosen] = useState<number | null>(null);
return (
+100 -1
View File
@@ -9,12 +9,16 @@ import { addXp, getProgress, recordResult, reviewCard, todayStr, useProgress } f
import { speak } from "@/lib/speech";
import { sfx } from "@/lib/sfx";
import { fireConfetti } from "@/components/AppShell";
import { gapFillQuestions, perfektQuestions, pluralQuestions, type DrillQ } from "@/lib/drills";
type Mode = "karten" | "quiz" | "artikel" | "memory" | "liste";
type Mode = "karten" | "quiz" | "luecke" | "plural" | "perfekt" | "artikel" | "memory" | "liste";
const modes: { id: Mode; de: string; ar: string }[] = [
{ id: "karten", de: "🃏 Karteikarten", ar: "البطاقات" },
{ id: "quiz", de: "🎯 Quiz", ar: "اختبار" },
{ id: "luecke", de: "✏️ Lückentext", ar: "املأ الفراغ" },
{ id: "plural", de: "🔢 Plural", ar: "الجمع" },
{ id: "perfekt", de: "⏮️ hat/ist", ar: "الماضي التام" },
{ id: "artikel", de: "⚡ der/die/das", ar: "لعبة الأدوات" },
{ id: "memory", de: "🧠 Memory", ar: "لعبة الذاكرة" },
{ id: "liste", de: "📚 Wortliste", ar: "قائمة الكلمات" },
@@ -84,6 +88,8 @@ export default function WortschatzPage() {
<Flashcards words={words} onRestart={() => setKey((k) => k + 1)} />
) : mode === "quiz" ? (
<VocabQuiz words={words} topic={topic} onRestart={() => setKey((k) => k + 1)} />
) : mode === "luecke" || mode === "plural" || mode === "perfekt" ? (
<McDrill words={words} mode={mode} onRestart={() => setKey((k) => k + 1)} />
) : mode === "artikel" ? (
<ArticleGame words={words} onRestart={() => setKey((k) => k + 1)} />
) : mode === "memory" ? (
@@ -317,6 +323,99 @@ function VocabQuiz({ words, topic, onRestart }: { words: Word[]; topic: string;
);
}
// ---------------- Generierte Drills (Lückentext, Plural, hat/ist) ----------------
const drillInfo = {
luecke: { title: "Welches Wort fehlt?", ar: "أي كلمة ناقصة؟", make: gapFillQuestions },
plural: { title: "Plural", ar: "الجمع", make: pluralQuestions },
perfekt: { title: "Perfekt mit hat oder ist?", ar: "hat أم ist؟", make: perfektQuestions },
} as const;
function McDrill({ words, mode, onRestart }: { words: Word[]; mode: keyof typeof drillInfo; onRestart: () => void }) {
const info = drillInfo[mode];
const qs = useMemo(() => {
let list = info.make(words);
if (list.length < 5) list = info.make(allWords); // Thema hat zu wenige passende Wörter
return shuffle(list).slice(0, 15);
}, [info, words]);
const [i, setI] = useState(0);
const [chosen, setChosen] = useState<number | null>(null);
const [correct, setCorrect] = useState(0);
const [result, setResult] = useState<{ xp: number } | null>(null);
if (result) return <ResultCard correct={correct} total={qs.length} xp={result.xp} onRetry={onRestart} />;
const q: DrillQ | undefined = qs[i];
if (!q) return null;
const pick = (k: number) => {
if (chosen !== null) return;
setChosen(k);
const ok = k === q.answer;
if (ok) {
sfx.correct();
setCorrect((c) => c + 1);
} else sfx.wrong();
if (q.speak) speak(q.speak, { rate: 0.9 });
};
const next = () => {
if (i + 1 >= qs.length) {
const xp = 5 + correct * 2;
recordResult(`vocab-${mode}`, "wortschatz", (correct / qs.length) * 100, xp);
setResult({ xp });
} else {
setI(i + 1);
setChosen(null);
}
};
return (
<div className="card fade-in" key={i}>
<div className="row small muted">
<span>
{info.title} • <span className="ar">{info.ar}</span>
</span>
<span className="spacer" />
<span>
{i + 1} / {qs.length} • ✅ {correct}
</span>
</div>
<div className="bar" style={{ margin: "8px 0 16px" }}>
<div style={{ width: `${(i / qs.length) * 100}%` }} />
</div>
<div style={{ fontSize: 21, fontWeight: 800, textAlign: "center" }}>{q.prompt}</div>
<Ar block>
<div className="muted" style={{ textAlign: "center" }}>
{q.hintAr}
</div>
</Ar>
<div className={q.options.length === 2 ? "grid grid-2" : ""}>
{q.options.map((o, k) => {
let cls = "option";
if (chosen !== null && k === q.answer) cls += " correct";
else if (chosen === k) cls += " wrong";
return (
<button key={k} className={cls} disabled={chosen !== null} onClick={() => pick(k)} style={q.options.length === 2 ? { justifyContent: "center", fontSize: 20 } : undefined}>
{q.options.length > 2 && <span className="key">{"abcd"[k]}</span>}
<span>{o}</span>
</button>
);
})}
</div>
{chosen !== null && (
<>
<div className={`feedback ${chosen === q.answer ? "ok" : "no"}`}>
{chosen === q.answer ? "Richtig! 🎉" : `Richtig: ${q.options[q.answer]}`}
{q.explain && <span style={{ fontWeight: 600 }}> – {q.explain}</span>}
</div>
<button className="btn blue block" style={{ marginTop: 12 }} onClick={next}>
{i + 1 >= qs.length ? "Ergebnis 🏁" : "Weiter →"}
</button>
</>
)}
</div>
);
}
// ---------------- Artikel-Spiel ----------------
function ArticleGame({ words, onRestart }: { words: Word[]; onRestart: () => void }) {
const nouns = useMemo(() => {