This commit is contained in:
2026-05-03 17:01:46 +03:30
parent b5ad5420b2
commit 9c30295b4b
76 changed files with 7891 additions and 461 deletions

View File

@@ -0,0 +1,24 @@
import { NextResponse } from "next/server";
import { db } from "@/lib/db";
import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth";
// GET /api/quiz/my-results
export async function GET() {
const session = await getServerSession(authOptions);
if (!session) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
const userId = (session.user as any).id;
const submissions = await db.quizSubmission.findMany({
where: { userId },
include: {
quiz: {
include: { questions: { orderBy: { order: "asc" } } },
},
},
orderBy: { submittedAt: "desc" },
});
return NextResponse.json(submissions);
}