Files
encoach_frontend_new_v2/src/services/exams.service.ts
Yamen Ahmad 11a7265460 feat(v3): restructure project + add complete frontend
- 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
2026-04-10 17:26:42 +04:00

63 lines
2.4 KiB
TypeScript

import { api } from "@/lib/api-client";
import type { Exam, ExamModule, Rubric, RubricGroup, ExamStructure, PaginatedResponse, PaginationParams, ApiSuccessResponse } from "@/types";
export interface ExamListParams extends PaginationParams {
module?: ExamModule;
subject_id?: number;
entity_id?: number;
}
export const examsService = {
async list(module: ExamModule, params?: PaginationParams): Promise<PaginatedResponse<Exam>> {
return api.get<PaginatedResponse<Exam>>(`/exam/${module}`, params as Record<string, string | number | boolean | undefined>);
},
async getById(module: ExamModule, id: number): Promise<Exam> {
return api.get<Exam>(`/exam/${module}/${id}`);
},
async create(data: Partial<Exam>): Promise<Exam> {
return api.post<Exam>("/exam", data);
},
async update(id: number, data: Partial<Exam>): Promise<Exam> {
return api.patch<Exam>(`/exam/${id}`, data);
},
async delete(id: number): Promise<ApiSuccessResponse> {
return api.delete<ApiSuccessResponse>(`/exam/${id}`);
},
async setAccess(id: number, access: "public" | "private"): Promise<Exam> {
return api.patch<Exam>(`/exam/${id}/access`, { access });
},
async listRubrics(params?: PaginationParams): Promise<PaginatedResponse<Rubric>> {
return api.get<PaginatedResponse<Rubric>>("/rubrics", params as Record<string, string | number | boolean | undefined>);
},
async createRubric(data: Partial<Rubric>): Promise<Rubric> {
return api.post<Rubric>("/rubrics", data);
},
async listRubricGroups(params?: PaginationParams): Promise<PaginatedResponse<RubricGroup>> {
return api.get<PaginatedResponse<RubricGroup>>("/rubric-groups", params as Record<string, string | number | boolean | undefined>);
},
async listStructures(params?: PaginationParams & { entity_id?: number }): Promise<PaginatedResponse<ExamStructure>> {
return api.get<PaginatedResponse<ExamStructure>>("/exam-structures", params as Record<string, string | number | boolean | undefined>);
},
async createStructure(data: Partial<ExamStructure>): Promise<ExamStructure> {
return api.post<ExamStructure>("/exam-structures", data);
},
async deleteStructure(id: number): Promise<ApiSuccessResponse> {
return api.delete<ApiSuccessResponse>(`/exam-structures/${id}`);
},
async getAvatars(): Promise<{ id: number; name: string; thumbnail: string }[]> {
return api.get("/exam/avatars");
},
};