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:
@@ -79,6 +79,7 @@ export const queryKeys = {
|
||||
lms: {
|
||||
courses: (params?: Record<string, unknown>) => ["lms", "courses", params] as const,
|
||||
course: (id: number) => ["lms", "courses", id] as const,
|
||||
myCourses: ["lms", "my-courses"] as const,
|
||||
students: (params?: Record<string, unknown>) => ["lms", "students", params] as const,
|
||||
teachers: (params?: Record<string, unknown>) => ["lms", "teachers", params] as const,
|
||||
batches: (params?: Record<string, unknown>) => ["lms", "batches", params] as const,
|
||||
@@ -155,6 +156,7 @@ export const queryKeys = {
|
||||
list: (params?: Record<string, unknown>) => ["subject-registrations", "list", params] as const,
|
||||
available: (params?: Record<string, unknown>) => ["subject-registrations", "available", params] as const,
|
||||
},
|
||||
courseCompletion: (courseId: number) => ["course-completion", courseId] as const,
|
||||
chapters: (courseId: number) => ["chapters", "list", courseId] as const,
|
||||
chapter: (id: number) => ["chapters", "detail", id] as const,
|
||||
chapterMaterials: (chapterId: number) => ["chapter-materials", chapterId] as const,
|
||||
@@ -211,6 +213,7 @@ export const queryKeys = {
|
||||
studentProgress: {
|
||||
all: ["student-progress"] as const,
|
||||
list: (params?: Record<string, unknown>) => ["student-progress", "list", params] as const,
|
||||
detail: (id: number) => ["student-progress", "detail", id] as const,
|
||||
},
|
||||
libraryMedia: {
|
||||
all: ["library-media"] as const,
|
||||
|
||||
@@ -66,7 +66,10 @@ export function useGenerateTerms() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (yearId: number) => academicService.generateTerms(yearId),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: queryKeys.academicTerms.all }),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: queryKeys.academicTerms.all });
|
||||
qc.invalidateQueries({ queryKey: queryKeys.academicYears.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +120,19 @@ export function useUploadMaterial() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateMaterialFromResource() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({ chapterId, resourceId, name }: { chapterId: number; resourceId: number; name?: string }) =>
|
||||
coursewareService.createMaterialFromResource(chapterId, resourceId, name),
|
||||
onSuccess: (_, { chapterId }) => {
|
||||
qc.invalidateQueries({ queryKey: queryKeys.chapterMaterials(chapterId) });
|
||||
qc.invalidateQueries({ queryKey: queryKeys.chapterProgress(chapterId) });
|
||||
qc.invalidateQueries({ queryKey: queryKeys.chapter(chapterId) });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteMaterial() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
@@ -145,13 +158,24 @@ export function useMarkMaterialViewed() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useCourseCompletion(courseId: number) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.courseCompletion(courseId),
|
||||
queryFn: () => coursewareService.getCourseCompletion(courseId),
|
||||
enabled: !!courseId,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCompleteChapter() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (chapterId: number) => coursewareService.markChapterComplete(chapterId),
|
||||
onSuccess: (_, chapterId) => {
|
||||
mutationFn: ({ chapterId, courseId }: { chapterId: number; courseId: number }) =>
|
||||
coursewareService.markChapterComplete(chapterId),
|
||||
onSuccess: (_, { chapterId, courseId }) => {
|
||||
qc.invalidateQueries({ queryKey: queryKeys.chapterProgress(chapterId) });
|
||||
qc.invalidateQueries({ queryKey: queryKeys.chapter(chapterId) });
|
||||
qc.invalidateQueries({ queryKey: queryKeys.courseCompletion(courseId) });
|
||||
qc.invalidateQueries({ queryKey: queryKeys.lms.myCourses });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { queryKeys } from "./keys";
|
||||
import { feesService } from "@/services/fees.service";
|
||||
import { feesService, type FeesPlanFilters } from "@/services/fees.service";
|
||||
import type { PaginationParams } from "@/types";
|
||||
|
||||
export function useFeesPlans(params?: PaginationParams) {
|
||||
export function useFeesPlans(params?: FeesPlanFilters) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.feesPlans.list(params),
|
||||
queryFn: () => feesService.listFeesPlans(params),
|
||||
@@ -18,7 +18,7 @@ export function useFeesPlan(id: number) {
|
||||
});
|
||||
}
|
||||
|
||||
export function useStudentFees(params?: PaginationParams) {
|
||||
export function useStudentFees(params?: FeesPlanFilters) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.studentFees.list(params),
|
||||
queryFn: () => feesService.listStudentFees(params),
|
||||
|
||||
@@ -11,10 +11,11 @@ export function useGradebooks(params?: PaginationParams) {
|
||||
});
|
||||
}
|
||||
|
||||
export function useGradebookLines(params?: PaginationParams) {
|
||||
export function useGradebookLines(params?: PaginationParams & { gradebook_id?: number }) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.gradebookLines.list(params),
|
||||
queryFn: () => gradebookService.listGradebookLines(params),
|
||||
enabled: params?.gradebook_id ? !!params.gradebook_id : true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { queryKeys } from "./keys";
|
||||
import { lmsService } from "@/services";
|
||||
import type { PaginationParams, CourseCreateRequest, LmsStudentCreateRequest, LmsTeacherCreateRequest } from "@/types";
|
||||
import type { PaginationParams, CourseCreateRequest, LmsStudentCreateRequest, LmsTeacherCreateRequest, EnrollStudentRequest, BulkEnrollRequest } from "@/types";
|
||||
|
||||
export function useCourses(params?: PaginationParams & { status?: string }) {
|
||||
return useQuery({
|
||||
@@ -26,6 +26,38 @@ export function useCreateCourse() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useMyEnrolledCourses() {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.lms.myCourses,
|
||||
queryFn: () => lmsService.getMyEnrolledCourses(),
|
||||
});
|
||||
}
|
||||
|
||||
export function useEnrollStudent() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({ studentId, data }: { studentId: number; data: EnrollStudentRequest }) =>
|
||||
lmsService.enrollStudent(studentId, data),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: ["lms", "students"] });
|
||||
qc.invalidateQueries({ queryKey: queryKeys.lms.myCourses });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useBulkEnroll() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({ courseId, data }: { courseId: number; data: BulkEnrollRequest }) =>
|
||||
lmsService.bulkEnrollInCourse(courseId, data),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: ["lms", "students"] });
|
||||
qc.invalidateQueries({ queryKey: ["lms", "courses"] });
|
||||
qc.invalidateQueries({ queryKey: queryKeys.lms.myCourses });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useStudents(params?: PaginationParams & { search?: string; batch_id?: number }) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.lms.students(params),
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { queryKeys } from "./keys";
|
||||
import { studentProgressService } from "@/services/student-progress.service";
|
||||
import type { PaginationParams } from "@/types";
|
||||
import { studentProgressService, type StudentProgressFilters } from "@/services/student-progress.service";
|
||||
|
||||
export function useStudentProgressList(params?: PaginationParams) {
|
||||
export function useStudentProgressList(params?: StudentProgressFilters) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.studentProgress.list(params),
|
||||
queryFn: () => studentProgressService.listProgress(params),
|
||||
});
|
||||
}
|
||||
|
||||
export function useStudentProgressDetail(id: number | null | undefined) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.studentProgress.detail(id ?? 0),
|
||||
queryFn: () => studentProgressService.getProgress(id as number),
|
||||
enabled: !!id,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user