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
144 lines
5.4 KiB
TypeScript
144 lines
5.4 KiB
TypeScript
import { useEffect } from "react";
|
|
import { Label } from "@/components/ui/label";
|
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
|
import { Badge } from "@/components/ui/badge";
|
|
import { Checkbox } from "@/components/ui/checkbox";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import { taxonomyService } from "@/services/taxonomy.service";
|
|
import { lmsService } from "@/services/lms.service";
|
|
|
|
interface TaxonomyCascadeProps {
|
|
subjectId: string;
|
|
onSubjectChange: (id: string) => void;
|
|
domainId: string;
|
|
onDomainChange: (id: string) => void;
|
|
topicIds: number[];
|
|
onTopicIdsChange: (ids: number[]) => void;
|
|
objectiveIds: number[];
|
|
onObjectiveIdsChange: (ids: number[]) => void;
|
|
}
|
|
|
|
export function TaxonomyCascade({
|
|
subjectId, onSubjectChange,
|
|
domainId, onDomainChange,
|
|
topicIds, onTopicIdsChange,
|
|
objectiveIds, onObjectiveIdsChange,
|
|
}: TaxonomyCascadeProps) {
|
|
const { data: subjects } = useQuery({
|
|
queryKey: ["taxonomy", "subjects"],
|
|
queryFn: () => taxonomyService.listSubjects(),
|
|
});
|
|
|
|
const numericSubjectId = subjectId !== "none" ? Number(subjectId) : undefined;
|
|
const numericDomainId = domainId !== "none" ? Number(domainId) : undefined;
|
|
|
|
const { data: domains } = useQuery({
|
|
queryKey: ["taxonomy", "domains", numericSubjectId],
|
|
queryFn: () => taxonomyService.listDomains({ subject_id: numericSubjectId }),
|
|
enabled: !!numericSubjectId,
|
|
});
|
|
|
|
const { data: topics } = useQuery({
|
|
queryKey: ["taxonomy", "topics", numericDomainId],
|
|
queryFn: () => taxonomyService.listTopics({ domain_id: numericDomainId }),
|
|
enabled: !!numericDomainId,
|
|
});
|
|
|
|
const { data: objectivesData } = useQuery({
|
|
queryKey: ["learning-objectives", topicIds],
|
|
queryFn: () => lmsService.listLearningObjectives({ topic_ids: topicIds.join(",") }),
|
|
enabled: topicIds.length > 0,
|
|
});
|
|
const objectives = objectivesData?.items ?? [];
|
|
|
|
useEffect(() => {
|
|
if (subjectId === "none") {
|
|
if (domainId !== "none") onDomainChange("none");
|
|
if (topicIds.length > 0) onTopicIdsChange([]);
|
|
if (objectiveIds.length > 0) onObjectiveIdsChange([]);
|
|
}
|
|
}, [subjectId]);
|
|
|
|
useEffect(() => {
|
|
if (domainId === "none") {
|
|
if (topicIds.length > 0) onTopicIdsChange([]);
|
|
if (objectiveIds.length > 0) onObjectiveIdsChange([]);
|
|
}
|
|
}, [domainId]);
|
|
|
|
const toggleTopic = (id: number) => {
|
|
const next = topicIds.includes(id) ? topicIds.filter(t => t !== id) : [...topicIds, id];
|
|
onTopicIdsChange(next);
|
|
if (next.length === 0 && objectiveIds.length > 0) onObjectiveIdsChange([]);
|
|
};
|
|
|
|
const toggleObjective = (id: number) => {
|
|
onObjectiveIdsChange(
|
|
objectiveIds.includes(id) ? objectiveIds.filter(o => o !== id) : [...objectiveIds, id],
|
|
);
|
|
};
|
|
|
|
return (
|
|
<div className="space-y-3">
|
|
<div className="grid grid-cols-2 gap-3">
|
|
<div className="space-y-1.5">
|
|
<Label className="text-xs">Subject</Label>
|
|
<Select value={subjectId} onValueChange={(v) => { onSubjectChange(v); if (v === "none") { onDomainChange("none"); } }}>
|
|
<SelectTrigger className="h-8 text-sm"><SelectValue placeholder="Select subject" /></SelectTrigger>
|
|
<SelectContent>
|
|
<SelectItem value="none">None</SelectItem>
|
|
{(subjects ?? []).map(s => <SelectItem key={s.id} value={String(s.id)}>{s.name}</SelectItem>)}
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
<div className="space-y-1.5">
|
|
<Label className="text-xs">Domain</Label>
|
|
<Select value={domainId} onValueChange={onDomainChange} disabled={!numericSubjectId}>
|
|
<SelectTrigger className="h-8 text-sm"><SelectValue placeholder={numericSubjectId ? "Select domain" : "Select subject first"} /></SelectTrigger>
|
|
<SelectContent>
|
|
<SelectItem value="none">None</SelectItem>
|
|
{(domains ?? []).map(d => <SelectItem key={d.id} value={String(d.id)}>{d.name}</SelectItem>)}
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
</div>
|
|
|
|
{numericDomainId && (topics ?? []).length > 0 && (
|
|
<div className="space-y-1.5">
|
|
<Label className="text-xs">Topics</Label>
|
|
<div className="flex flex-wrap gap-1.5 p-2 rounded border bg-muted/30 max-h-[100px] overflow-y-auto">
|
|
{(topics ?? []).map(t => (
|
|
<Badge
|
|
key={t.id}
|
|
variant={topicIds.includes(t.id) ? "default" : "outline"}
|
|
className="cursor-pointer select-none text-xs"
|
|
onClick={() => toggleTopic(t.id)}
|
|
>
|
|
{t.name}
|
|
</Badge>
|
|
))}
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{topicIds.length > 0 && objectives.length > 0 && (
|
|
<div className="space-y-1.5">
|
|
<Label className="text-xs">Learning Objectives</Label>
|
|
<div className="space-y-1 p-2 rounded border bg-muted/30 max-h-[100px] overflow-y-auto">
|
|
{objectives.map(o => (
|
|
<label key={o.id} className="flex items-center gap-2 text-xs cursor-pointer">
|
|
<Checkbox
|
|
checked={objectiveIds.includes(o.id)}
|
|
onCheckedChange={() => toggleObjective(o.id)}
|
|
/>
|
|
<span>{o.name}</span>
|
|
{o.bloom_level && <Badge variant="outline" className="text-[10px] h-4">{o.bloom_level}</Badge>}
|
|
</label>
|
|
))}
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|