feat: institutional + support + training admin sections (backend + frontend)
Ship three fully-wired admin areas end-to-end with APIs, seeds, tests and docs. Backend (new `encoach_lms_api` addon + existing addons): - Institutional: academic years/terms, departments, admission registers & admissions, courses/batches, lessons, fees (terms + student fees + invoicing with income-account auto-wiring), gradebook (assignments/grades), library, facilities (encoach.asset), student leave, result templates + marksheets (incl. delete-with-cascade). - Support: `encoach.ticket` model + CRUD/assignee routes; payment records derived from `op.student.fees.details` and `account.move`; platform settings backed by `encoach.code` and `ir.config_parameter` (packages + grading config). - Training: `encoach.vocab.item` + `encoach.grammar.rule` (plus progress models) with CRUD, pagination, search/level filters, and upsert-style progress endpoints. Odoo 19 compatibility: `_sql_constraints` replaced with `@api.constrains`; `ValidationError`/`UserError` mapped to HTTP 400. Frontend: - Rewire institutional admin pages (Academic Year Manager, Admissions, Courses, Lessons, Fees, Gradebook, Library, Facilities, Student Leave, Marksheets, Taxonomy, Resources) to real APIs with React Query invalidation and dialogs. - New typed services: `payments.service.ts`, `platformSettings.service.ts`, `training.service.ts`. Updated `fees/gradebook/lms/courseware/taxonomy/ resources/student-progress/generation` services + related types. - Rewrite `VocabularyPage`, `GrammarPage`, `PaymentRecordPage`, `SettingsPage`, `TicketsPage` to consume live data with search/filter/progress/CRUD flows. - New shared components: `TaxonomyCascade`, `MaterialViewer`, `teacher/TeacherLibrary`. - Favicons/branding assets and misc. UX polish across teacher/student pages. Tooling & QA: - Seeders: `seed_demo.py`, `seed_demo_data.py`, `seed_institutional.py` (idempotent, covers institutional + support + training fixtures incl. income-account wiring). - API write-flow test suites: `test_write_flows.py` (institutional), `test_support_flows.py` (support), `test_training_flows.py` (training), `test_ai_full.py`. All suites pass end-to-end. - Docs: add `docs/PROJECT_SUMMARY.md` with per-section scope, artifacts and QA. - `.gitignore`: ignore `pgdata_bak_*/`, `frontend/.vite/`, `frontend/dist/`, `frontend/node_modules/`. Made-with: Cursor
This commit is contained in:
@@ -4,30 +4,26 @@ import { Badge } from "@/components/ui/badge";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useCourses, useAssignments, useAttendance, useGrades } from "@/hooks/queries";
|
||||
import { ArrowLeft, CheckCircle, Circle, FileText, Video, HelpCircle } from "lucide-react";
|
||||
|
||||
const iconMap = { video: Video, reading: FileText, quiz: HelpCircle };
|
||||
import { useCourse, useChapters, useGrades, useCourseCompletion } from "@/hooks/queries";
|
||||
import { ArrowLeft, BookOpen, Lock, ChevronRight, Play, CheckCircle2, Trophy } from "lucide-react";
|
||||
|
||||
export default function StudentCourseDetail() {
|
||||
const { id } = useParams();
|
||||
const { data: coursesData, isLoading: lc } = useCourses();
|
||||
const { data: assignmentsData, isLoading: la } = useAssignments();
|
||||
const { data: attendanceData, isLoading: lat } = useAttendance();
|
||||
const { data: gradesData, isLoading: lg } = useGrades();
|
||||
const courses = coursesData?.items ?? [];
|
||||
const assignments = assignmentsData?.items ?? [];
|
||||
const attendanceRecords = attendanceData ?? [];
|
||||
const courseId = Number(id);
|
||||
const { data: course, isLoading: lc } = useCourse(courseId);
|
||||
const { data: chapters = [], isLoading: lch } = useChapters(courseId);
|
||||
const { data: gradesData, isLoading: lg } = useGrades({ course_id: courseId });
|
||||
const { data: completion } = useCourseCompletion(courseId);
|
||||
const gradeRecords = gradesData ?? [];
|
||||
if (lc || la || lat || lg) return <div className="flex items-center justify-center min-h-[400px]"><div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary" /></div>;
|
||||
|
||||
const course = courses.find(c => c.id === id);
|
||||
if (lc || lch || lg) return <div className="flex items-center justify-center min-h-[400px]"><div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary" /></div>;
|
||||
|
||||
if (!course) return <div className="p-8 text-center text-muted-foreground">Course not found.</div>;
|
||||
|
||||
const courseAssignments = assignments.filter(a => a.courseId === id);
|
||||
const courseAttendance = attendanceRecords.filter(a => a.courseId === id);
|
||||
const courseGrades = gradeRecords.filter(g => g.courseId === id);
|
||||
const sortedChapters = [...chapters].sort((a, b) => a.sequence - b.sequence);
|
||||
const completedChapters = completion?.chapters_completed ?? 0;
|
||||
const progress = completion?.progress_percent ?? (chapters.length > 0 ? Math.round((completedChapters / chapters.length) * 100) : 0);
|
||||
const isCompleted = completion?.status === "completed";
|
||||
const postTestAvailable = completion?.post_test_available ?? false;
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -35,91 +31,116 @@ export default function StudentCourseDetail() {
|
||||
<Button variant="ghost" size="icon" asChild><Link to="/student/courses"><ArrowLeft className="h-4 w-4" /></Link></Button>
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold">{course.title}</h1>
|
||||
<p className="text-muted-foreground">{course.instructor} · {course.code}</p>
|
||||
<p className="text-muted-foreground">{course.code} · {chapters.length} chapters</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{isCompleted && (
|
||||
<Card className="border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-800">
|
||||
<CardContent className="pt-6 flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<Trophy className="h-8 w-8 text-green-600" />
|
||||
<div>
|
||||
<p className="font-semibold text-green-800 dark:text-green-200">Course Completed!</p>
|
||||
<p className="text-sm text-green-600 dark:text-green-400">You've finished all {chapters.length} chapters.</p>
|
||||
</div>
|
||||
</div>
|
||||
{postTestAvailable && (
|
||||
<Button asChild>
|
||||
<Link to={`/student/my-exams?course_id=${courseId}`}>Take Post-Test</Link>
|
||||
</Button>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
<Card>
|
||||
<CardContent className="pt-6">
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<span className="text-sm text-muted-foreground">Overall Progress</span>
|
||||
<span className="text-sm font-bold">{course.progress}%</span>
|
||||
<span className="text-sm font-bold">{progress}%</span>
|
||||
</div>
|
||||
<Progress value={course.progress} className="h-3" />
|
||||
<Progress value={progress} className="h-3" />
|
||||
<p className="text-xs text-muted-foreground mt-2">{completedChapters} of {chapters.length} chapters completed</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Tabs defaultValue="materials">
|
||||
<Tabs defaultValue="chapters">
|
||||
<TabsList>
|
||||
<TabsTrigger value="materials">Materials</TabsTrigger>
|
||||
<TabsTrigger value="assignments">Assignments ({courseAssignments.length})</TabsTrigger>
|
||||
<TabsTrigger value="attendance">Attendance</TabsTrigger>
|
||||
<TabsTrigger value="grades">Grades</TabsTrigger>
|
||||
<TabsTrigger value="chapters">Chapters ({chapters.length})</TabsTrigger>
|
||||
<TabsTrigger value="grades">Grades ({gradeRecords.length})</TabsTrigger>
|
||||
<TabsTrigger value="about">About</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="materials" className="space-y-4 mt-4">
|
||||
{course.modules.length === 0 ? (
|
||||
<p className="text-muted-foreground text-sm py-8 text-center">No modules available yet.</p>
|
||||
) : course.modules.map(mod => (
|
||||
<Card key={mod.id}>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="text-base">{mod.title}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2">
|
||||
{mod.lessons.map(lesson => {
|
||||
const Icon = iconMap[lesson.type];
|
||||
return (
|
||||
<div key={lesson.id} className="flex items-center gap-3 p-2 rounded hover:bg-muted/50">
|
||||
{lesson.completed ? <CheckCircle className="h-4 w-4 text-success shrink-0" /> : <Circle className="h-4 w-4 text-muted-foreground shrink-0" />}
|
||||
<Icon className="h-4 w-4 text-muted-foreground shrink-0" />
|
||||
<span className="text-sm flex-1">{lesson.title}</span>
|
||||
<span className="text-xs text-muted-foreground">{lesson.duration}</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="assignments" className="mt-4 space-y-3">
|
||||
{courseAssignments.map(a => (
|
||||
<Card key={a.id}>
|
||||
<CardContent className="pt-4 flex items-center justify-between">
|
||||
<div>
|
||||
<p className="font-medium text-sm">{a.title}</p>
|
||||
<p className="text-xs text-muted-foreground">Due: {a.dueDate}</p>
|
||||
</div>
|
||||
<Badge variant={a.status === "graded" ? "default" : a.status === "overdue" ? "destructive" : "secondary"}>
|
||||
{a.status}
|
||||
</Badge>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="attendance" className="mt-4 space-y-3">
|
||||
{courseAttendance.map(a => (
|
||||
<div key={a.id} className="flex items-center justify-between p-3 rounded border">
|
||||
<span className="text-sm">{a.date}</span>
|
||||
<Badge variant={a.status === "present" ? "default" : a.status === "absent" ? "destructive" : "secondary"}>
|
||||
{a.status}
|
||||
</Badge>
|
||||
<TabsContent value="chapters" className="space-y-3 mt-4">
|
||||
{sortedChapters.length === 0 ? (
|
||||
<div className="text-center py-12">
|
||||
<BookOpen className="h-10 w-10 text-muted-foreground mx-auto mb-3" />
|
||||
<p className="text-muted-foreground text-sm">No chapters available yet.</p>
|
||||
</div>
|
||||
) : sortedChapters.map((ch, idx) => (
|
||||
<Link
|
||||
key={ch.id}
|
||||
to={ch.is_unlocked ? `/student/courses/${courseId}/chapters/${ch.id}` : "#"}
|
||||
className={ch.is_unlocked ? "" : "pointer-events-none"}
|
||||
>
|
||||
<Card className={`transition-shadow ${ch.is_unlocked ? "hover:shadow-md cursor-pointer" : "opacity-60"}`}>
|
||||
<CardContent className="flex items-center gap-4 py-4">
|
||||
<div className="flex items-center justify-center h-10 w-10 rounded-full bg-primary/10 text-primary font-bold text-sm shrink-0">
|
||||
{idx + 1}
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<p className="font-medium text-sm truncate">{ch.name}</p>
|
||||
{!ch.is_unlocked && <Lock className="h-3 w-3 text-muted-foreground shrink-0" />}
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground mt-0.5">
|
||||
{ch.material_count} materials
|
||||
{ch.description ? ` · ${ch.description.slice(0, 60)}${ch.description.length > 60 ? "..." : ""}` : ""}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
{ch.is_unlocked ? (
|
||||
<Badge variant="secondary" className="text-xs">
|
||||
<Play className="h-3 w-3 mr-1" /> Open
|
||||
</Badge>
|
||||
) : (
|
||||
<Badge variant="outline" className="text-xs">Locked</Badge>
|
||||
)}
|
||||
<ChevronRight className="h-4 w-4 text-muted-foreground" />
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Link>
|
||||
))}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="grades" className="mt-4 space-y-3">
|
||||
{courseGrades.map(g => (
|
||||
{gradeRecords.length === 0 ? (
|
||||
<p className="text-muted-foreground text-sm text-center py-8">No grades yet for this course.</p>
|
||||
) : gradeRecords.map(g => (
|
||||
<div key={g.id} className="flex items-center justify-between p-3 rounded border">
|
||||
<div>
|
||||
<p className="text-sm font-medium">{g.assignmentTitle}</p>
|
||||
<p className="text-sm font-medium">{g.assignment_title}</p>
|
||||
<p className="text-xs text-muted-foreground">{g.date}</p>
|
||||
</div>
|
||||
<span className="font-bold text-primary">{g.grade}/{g.maxGrade}</span>
|
||||
<span className="font-bold text-primary">{g.grade}/{g.max_grade}</span>
|
||||
</div>
|
||||
))}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="about" className="mt-4">
|
||||
<Card>
|
||||
<CardHeader><CardTitle className="text-base">About this Course</CardTitle></CardHeader>
|
||||
<CardContent className="space-y-3">
|
||||
<p className="text-sm text-muted-foreground">{course.description || "No description available."}</p>
|
||||
<div className="grid grid-cols-2 gap-4 text-sm">
|
||||
<div><span className="text-muted-foreground">Enrolled Students:</span> <span className="font-medium">{course.enrolled}</span></div>
|
||||
<div><span className="text-muted-foreground">Max Capacity:</span> <span className="font-medium">{course.max_capacity}</span></div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user