- Restructure: move backend from new_project/ to backend/ - Add full React/TypeScript frontend (37 pages, 17 services, 16 type defs, 11 query hooks) - Add docs/ with SRS specs, user stories, and workflow documentation - Update .gitignore for new directory layout Workflows implemented: WF1 User Signup, WF2 Placement Test, WF3 Exam Configuration, WF4 General English Exam, WF5 Course Generation, WF6 Entity Student Onboarding, AI Course Generation, Adaptive Learning Engine UI, White-Label Branding, Score Release Made-with: Cursor
79 lines
3.3 KiB
TypeScript
79 lines
3.3 KiB
TypeScript
import { api } from "@/lib/api-client";
|
|
import type {
|
|
Proficiency, ProficiencySummary, LearningPlan,
|
|
DiagnosticSession, DiagnosticQuestion, DiagnosticAnswer, DiagnosticResult,
|
|
TopicContent, ApiSuccessResponse,
|
|
} from "@/types";
|
|
|
|
export const adaptiveService = {
|
|
async startDiagnostic(subjectId: number): Promise<{ session: DiagnosticSession; first_question: DiagnosticQuestion }> {
|
|
return api.post("/diagnostic/start", { subject_id: subjectId });
|
|
},
|
|
|
|
async answerDiagnostic(data: DiagnosticAnswer): Promise<{ next_question?: DiagnosticQuestion; completed: boolean }> {
|
|
return api.post("/diagnostic/answer", data);
|
|
},
|
|
|
|
async getDiagnosticResult(sessionId: number): Promise<DiagnosticResult> {
|
|
return api.get(`/diagnostic/${sessionId}/result`);
|
|
},
|
|
|
|
async getProficiency(params: { subject_id?: number }): Promise<Proficiency[]> {
|
|
const raw = await api.get<{ data: Proficiency[] } | Proficiency[]>("/proficiency", params as Record<string, string | number | boolean | undefined>);
|
|
return Array.isArray(raw) ? raw : (raw as { data: Proficiency[] }).data ?? [];
|
|
},
|
|
|
|
async getProficiencySummary(): Promise<ProficiencySummary[]> {
|
|
const raw = await api.get<{ data: ProficiencySummary[] } | ProficiencySummary[]>("/proficiency/summary");
|
|
return Array.isArray(raw) ? raw : (raw as { data: ProficiencySummary[] }).data ?? [];
|
|
},
|
|
|
|
async getClassProficiency(params?: { subject_id?: number }): Promise<unknown> {
|
|
return api.get("/proficiency/class", params as Record<string, string | number | boolean | undefined>);
|
|
},
|
|
|
|
async getLearningPlan(params: { subject_id?: number }): Promise<LearningPlan> {
|
|
return api.get<LearningPlan>("/learning-plan", params as Record<string, string | number | boolean | undefined>);
|
|
},
|
|
|
|
async generateLearningPlan(data: { subject_id: number; target_completion?: string }): Promise<LearningPlan> {
|
|
return api.post<LearningPlan>("/learning-plan/generate", data);
|
|
},
|
|
|
|
async updateLearningPlan(id: number, data: Partial<LearningPlan>): Promise<LearningPlan> {
|
|
return api.patch<LearningPlan>(`/learning-plan/${id}`, data);
|
|
},
|
|
|
|
async pauseLearningPlan(id: number): Promise<LearningPlan> {
|
|
return api.post<LearningPlan>(`/learning-plan/${id}/pause`);
|
|
},
|
|
|
|
async resumeLearningPlan(id: number): Promise<LearningPlan> {
|
|
return api.post<LearningPlan>(`/learning-plan/${id}/resume`);
|
|
},
|
|
|
|
async getTopicContent(topicId: number): Promise<TopicContent> {
|
|
return api.get<TopicContent>(`/topics/${topicId}/content`);
|
|
},
|
|
|
|
async generateTopicContent(topicId: number): Promise<TopicContent> {
|
|
return api.post<TopicContent>(`/topics/${topicId}/generate-content`);
|
|
},
|
|
|
|
async getPracticeQuestions(topicId: number): Promise<{ questions: unknown[] }> {
|
|
return api.post(`/topics/${topicId}/practice`);
|
|
},
|
|
|
|
async gradePractice(topicId: number, answers: unknown[]): Promise<{ results: unknown[]; mastery_update: number }> {
|
|
return api.post(`/topics/${topicId}/practice/grade`, { answers });
|
|
},
|
|
|
|
async startMasteryQuiz(topicId: number): Promise<{ questions: unknown[] }> {
|
|
return api.post(`/topics/${topicId}/mastery-quiz`);
|
|
},
|
|
|
|
async submitMasteryQuiz(topicId: number, answers: unknown[]): Promise<{ passed: boolean; score: number; mastery_update: number }> {
|
|
return api.post(`/topics/${topicId}/mastery-quiz/submit`, { answers });
|
|
},
|
|
};
|