- Configure workspace Git repository with comprehensive .gitignore - Add Odoo as submodule for ERP reference code - Include documentation: SETUP.md, GIT-STRUCTURE.md - Add gitignore templates for projects (backend, frontend, database) - Structure supports independent repos per project/subproject level Workspace includes: - core/ - Reusable patterns, modules, orchestration system - projects/ - Active projects (erp-suite, gamilit, trading-platform, etc.) - knowledge-base/ - Reference code and patterns (includes Odoo submodule) - devtools/ - Development tools and templates - customers/ - Client implementations template 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
93 lines
2.3 KiB
TypeScript
93 lines
2.3 KiB
TypeScript
/**
|
|
* Educational API
|
|
* API client for Educational Module endpoints
|
|
*
|
|
* Endpoints:
|
|
* - getModules: Get all modules (with optional difficulty filter)
|
|
* - getModuleById: Get a specific module by ID
|
|
* - getModuleExercises: Get all exercises for a module
|
|
* - getExerciseById: Get a specific exercise by ID
|
|
*/
|
|
|
|
import apiClient from '@/services/api/apiClient';
|
|
import type { Module, Exercise, DifficultyLevel } from '@/shared/types/educational.types';
|
|
|
|
/**
|
|
* Get all modules
|
|
* @param difficulty - Optional difficulty filter
|
|
* @param classroomId - Optional classroom ID to filter modules assigned to a specific classroom
|
|
* @returns Array of Module
|
|
*/
|
|
export const getModules = async (
|
|
difficulty?: DifficultyLevel,
|
|
classroomId?: string,
|
|
): Promise<Module[]> => {
|
|
const params: Record<string, string> = {};
|
|
|
|
if (difficulty) {
|
|
params.difficulty = difficulty;
|
|
}
|
|
|
|
if (classroomId) {
|
|
params.classroomId = classroomId;
|
|
}
|
|
|
|
const { data } = await apiClient.get('/educational/modules', {
|
|
params: Object.keys(params).length > 0 ? params : undefined,
|
|
});
|
|
return data;
|
|
};
|
|
|
|
/**
|
|
* Get a specific module by ID
|
|
* @param id - Module ID
|
|
* @returns Module
|
|
*/
|
|
export const getModuleById = async (id: string): Promise<Module> => {
|
|
const { data } = await apiClient.get(`/educational/modules/${id}`);
|
|
return data;
|
|
};
|
|
|
|
/**
|
|
* Get all exercises for a module
|
|
* @param moduleId - Module ID
|
|
* @returns Array of Exercise
|
|
*/
|
|
export const getModuleExercises = async (moduleId: string): Promise<Exercise[]> => {
|
|
const { data } = await apiClient.get(`/educational/modules/${moduleId}/exercises`);
|
|
return data;
|
|
};
|
|
|
|
/**
|
|
* Get a specific exercise by ID
|
|
* @param id - Exercise ID
|
|
* @returns Exercise
|
|
*/
|
|
export const getExerciseById = async (id: string): Promise<Exercise> => {
|
|
const { data } = await apiClient.get(`/educational/exercises/${id}`);
|
|
return data;
|
|
};
|
|
|
|
/**
|
|
* Search modules by keyword
|
|
* @param keyword - Search keyword
|
|
* @returns Array of Module
|
|
*/
|
|
export const searchModules = async (keyword: string): Promise<Module[]> => {
|
|
const { data } = await apiClient.get('/educational/modules/search', {
|
|
params: { q: keyword },
|
|
});
|
|
return data;
|
|
};
|
|
|
|
// Export all as educationalApi object
|
|
export const educationalApi = {
|
|
getModules,
|
|
getModuleById,
|
|
getModuleExercises,
|
|
getExerciseById,
|
|
searchModules,
|
|
};
|
|
|
|
export default educationalApi;
|