学习闭环增强:错题本+每周能力检测+学习概览日历+模板日历+课程管理
- 错题本:所有检测错题自动入库,带详细讲解,可标记掌握,孩子端可查 - 每周能力检测:从已学知识点确定性组卷10题,计分记录,达标关联当日 英语打卡,错题进错题本,家长可见成绩 - 家长"今日概览"改"学习概览",月日历展示每日打卡/语法点亮/周检测 - 任务模板改日历展示,灵活添加:某一天/每周X/本周/日期区间批量,可删 - 家长中心新增"课程管理"栏目(语法课程编辑+周测成绩),设备管理弱化为 栏目内二级区块 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
f98a21672d
commit
d84d827202
@@ -0,0 +1,13 @@
|
||||
"use server";
|
||||
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { getSessionUser } from "@/lib/auth";
|
||||
import { setMastered } from "@/lib/wrongbook";
|
||||
|
||||
export async function toggleMastered(id: number, mastered: boolean): Promise<void> {
|
||||
const user = await getSessionUser();
|
||||
if (!user || user.role !== "child") return;
|
||||
await setMastered(id, user.id, mastered);
|
||||
revalidatePath("/wrongbook");
|
||||
revalidatePath("/parent");
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
import { BackgroundBlobs } from "@/components/background-blobs";
|
||||
import { getSessionUser } from "@/lib/auth";
|
||||
import { listWrong } from "@/lib/wrongbook";
|
||||
import type { QuizQ } from "@/lib/quiz-parse";
|
||||
import { WrongRow } from "./wrong-row";
|
||||
|
||||
export default async function WrongBookPage() {
|
||||
const user = await getSessionUser();
|
||||
if (!user) redirect("/join");
|
||||
if (user.role !== "child") redirect("/parent");
|
||||
|
||||
const rows = await listWrong(user.id);
|
||||
const open = rows.filter((r) => !r.mastered).length;
|
||||
|
||||
return (
|
||||
<main className="relative mx-auto max-w-2xl space-y-5 p-4 pb-12">
|
||||
<BackgroundBlobs />
|
||||
<header className="flex items-center justify-between">
|
||||
<Link href="/kid" className="text-sm font-medium text-indigo-600">
|
||||
← 返回
|
||||
</Link>
|
||||
<h1 className="text-xl font-extrabold text-slate-900">我的错题本</h1>
|
||||
<span className="text-xs text-muted-foreground">待掌握 {open} 题</span>
|
||||
</header>
|
||||
|
||||
{rows.length === 0 ? (
|
||||
<div className="rounded-2xl border border-slate-100 bg-white p-8 text-center shadow-soft">
|
||||
<p className="text-3xl">🎉</p>
|
||||
<p className="mt-2 font-bold text-slate-900">还没有错题,继续保持!</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-3">
|
||||
{rows.map((r) => {
|
||||
let q: QuizQ;
|
||||
try {
|
||||
q = JSON.parse(r.question) as QuizQ;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<WrongRow
|
||||
key={r.id}
|
||||
id={r.id}
|
||||
sourceTitle={r.sourceTitle}
|
||||
q={q}
|
||||
userAnswer={r.userAnswer}
|
||||
correctAnswer={r.correctAnswer}
|
||||
mastered={r.mastered}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
"use client";
|
||||
|
||||
import { useTransition } from "react";
|
||||
import { CheckCircle2, RotateCcw } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { QuizQ } from "@/lib/quiz-parse";
|
||||
import { toggleMastered } from "./actions";
|
||||
|
||||
export function WrongRow({
|
||||
id,
|
||||
sourceTitle,
|
||||
q,
|
||||
userAnswer,
|
||||
correctAnswer,
|
||||
mastered,
|
||||
}: {
|
||||
id: number;
|
||||
sourceTitle: string | null;
|
||||
q: QuizQ;
|
||||
userAnswer: string | null;
|
||||
correctAnswer: string | null;
|
||||
mastered: boolean;
|
||||
}) {
|
||||
const [pending, startTransition] = useTransition();
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"rounded-xl border bg-white p-4 shadow-soft transition-colors",
|
||||
mastered ? "border-emerald-200 opacity-70" : "border-rose-200",
|
||||
)}
|
||||
>
|
||||
<div className="flex items-start justify-between gap-2">
|
||||
<p className="font-medium text-slate-900">{q.stem}</p>
|
||||
<span className="shrink-0 rounded-full bg-slate-100 px-2 py-0.5 text-xs text-muted-foreground">
|
||||
{sourceTitle ?? "检测"}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-2 space-y-1 text-sm">
|
||||
<p className="text-rose-600">你的答案:{userAnswer ?? "未作答"}</p>
|
||||
<p className="text-emerald-700">正确答案:{correctAnswer ?? ""}</p>
|
||||
</div>
|
||||
<p className="mt-2 rounded-lg bg-indigo-50 px-3 py-2 text-sm text-indigo-800">💡 {q.explain}</p>
|
||||
<div className="mt-3">
|
||||
<Button
|
||||
variant={mastered ? "outline" : "secondary"}
|
||||
size="sm"
|
||||
disabled={pending}
|
||||
onClick={() => startTransition(() => toggleMastered(id, !mastered))}
|
||||
>
|
||||
{mastered ? (
|
||||
<>
|
||||
<RotateCcw className="size-4" /> 改为未掌握
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<CheckCircle2 className="size-4" /> 已掌握
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user