Exercise management service for the WayrApp language learning platform.
This service provides CRUD operations for exercises within the content management system,
handling exercise lifecycle management, type-specific validation, and data integrity enforcement.
It serves as the primary business logic layer for exercise-related operations, ensuring that all
exercise data conforms to type-specific schemas and maintaining consistency across the platform.
The service manages six distinct exercise types: translation (source-to-target language conversion),
fill-in-the-blank (text completion with multiple blanks), vof (true/false verification),
pairs (matching left-right associations), informative (content display), and ordering (sequence arrangement).
Each exercise type has its own validation rules and data structure requirements that are enforced
during creation and updates.
Key architectural responsibilities include exercise creation with type-specific validation,
exercise retrieval with pagination and filtering support, exercise updates with data consistency checks,
exercise deletion with dependency validation, bulk exercise retrieval by IDs, and comprehensive
data validation for all supported exercise types. The service integrates with the repository layer
for data persistence and provides detailed error handling for all business rule violations.
Exercise data validation is performed through private methods that ensure each exercise type
contains the required fields and follows the correct data structure. This includes validating
translation pairs, blank positions and answers, boolean statements, matching pairs, informative
content, and ordering sequences with proper numbering.
Author
Exequiel Trujillo
Since
1.0.0
Example
// Initialize service with Prisma client import { PrismaClient } from'@prisma/client'; import { ExerciseService } from'./ExerciseService';
// Get exercises by type with pagination constfillBlankExercises = awaitexerciseService.getExercisesByType('fill-in-the-blank', { page:1, limit:10, sortBy:'created_at', sortOrder:'desc' });
Exercise management service for the WayrApp language learning platform.
This service provides CRUD operations for exercises within the content management system, handling exercise lifecycle management, type-specific validation, and data integrity enforcement. It serves as the primary business logic layer for exercise-related operations, ensuring that all exercise data conforms to type-specific schemas and maintaining consistency across the platform.
The service manages six distinct exercise types: translation (source-to-target language conversion), fill-in-the-blank (text completion with multiple blanks), vof (true/false verification), pairs (matching left-right associations), informative (content display), and ordering (sequence arrangement). Each exercise type has its own validation rules and data structure requirements that are enforced during creation and updates.
Key architectural responsibilities include exercise creation with type-specific validation, exercise retrieval with pagination and filtering support, exercise updates with data consistency checks, exercise deletion with dependency validation, bulk exercise retrieval by IDs, and comprehensive data validation for all supported exercise types. The service integrates with the repository layer for data persistence and provides detailed error handling for all business rule violations.
Exercise data validation is performed through private methods that ensure each exercise type contains the required fields and follows the correct data structure. This includes validating translation pairs, blank positions and answers, boolean statements, matching pairs, informative content, and ordering sequences with proper numbering.
Author
Exequiel Trujillo
Since
1.0.0
Example