Initial commit: ExaMetra v1.0.0 — Free & open-source competence & grading platform

Features:
- 15+ views: Dashboard, Classes, Progress, Flower, Matrix, Assessments, Grading, Reports, Attendance, Calendar, Lesson Plans, Analytics, Parent Communication, Behavior Tracking, Settings
- 34+ API endpoints
- 30+ Prisma models
- 700+ i18n keys (German + English)
- Keyboard shortcuts (Cmd+K, Cmd+1-9, Cmd+/)
- Batch deletion, drag-and-drop seating, custom color palette
- Demo accounts (admin, teacher, student, parent)
- Dark mode, responsive design, print styles
- CSV/PDF export, notification system, onboarding tour
- Zero emojis — all replaced with Lucide icons
- MIT License
This commit is contained in:
Mustafa Cetin committed 2026-07-29 05:46:10 +00:00
commit 0c1f739989
156 files changed
+51090

No files matched your search

+127
View File
@@ -0,0 +1,127 @@
import { NextResponse } from 'next/server';
import { z } from 'zod';
import { db } from '@/lib/db';
import { getSession } from '@/lib/auth';
export async function GET(
_request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const session = await getSession();
if (!session) {
return NextResponse.json({ error: 'Not authenticated' }, { status: 401 });
}
const { id: classGroupId } = await params;
const enrollments = await db.enrollment.findMany({
where: {
classGroupId,
endDate: null,
student: { deletedAt: null },
},
include: {
student: true,
schoolYear: { select: { id: true, label: true } },
},
orderBy: { student: { lastName: 'asc' } },
});
const students = enrollments.map((e) => ({
...e.student,
enrollmentId: e.id,
schoolYearId: e.schoolYearId,
schoolYear: e.schoolYear,
startDate: e.startDate,
}));
return NextResponse.json(students);
} catch (error) {
console.error('Class students GET error:', error);
return NextResponse.json(
{ error: 'Internal server error' },
{ status: 500 }
);
}
}
export async function POST(
request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const session = await getSession();
if (!session) {
return NextResponse.json({ error: 'Not authenticated' }, { status: 401 });
}
if (
session.user?.role !== 'SUPER_ADMIN' &&
session.user?.role !== 'SCHOOL_ADMIN' &&
session.user?.role !== 'TEACHER'
) {
return NextResponse.json({ error: 'Forbidden' }, { status: 403 });
}
const { id: classGroupId } = await params;
const body = await request.json();
const schema = z.object({
studentId: z.string().min(1),
schoolYearId: z.string().min(1),
startDate: z
.string()
.optional()
.transform((v) => (v ? new Date(v) : new Date())),
});
const parsed = schema.safeParse(body);
if (!parsed.success) {
return NextResponse.json(
{ error: 'Validation failed', details: parsed.error.issues },
{ status: 400 }
);
}
const { studentId, schoolYearId, startDate } = parsed.data;
// Check if already enrolled
const existing = await db.enrollment.findFirst({
where: {
studentId,
classGroupId,
endDate: null,
},
});
if (existing) {
return NextResponse.json(
{ error: 'Student already enrolled in this class' },
{ status: 409 }
);
}
const enrollment = await db.enrollment.create({
data: {
studentId,
classGroupId,
schoolYearId,
startDate,
},
include: {
student: true,
classGroup: true,
schoolYear: { select: { id: true, label: true } },
},
});
return NextResponse.json(enrollment, { status: 201 });
} catch (error) {
console.error('Class students POST error:', error);
return NextResponse.json(
{ error: 'Internal server error' },
{ status: 500 }
);
}
}