Initializes the LessonService with required repository dependencies.
Prisma database client for repository initialization
Creates a new lesson within a specified module with comprehensive validation.
Validates module existence, ensures lesson ID uniqueness, and prevents order conflicts within the parent module before creating the lesson record.
Lesson creation data including ID, module_id, experience_points, and order
The newly created lesson object
Retrieves a single lesson by its unique identifier and module ID. Uses composite key lookup to prevent horizontal access vulnerabilities.
The unique lesson identifier
The module identifier to ensure lesson belongs to the correct module
The lesson object with all its properties
Retrieves paginated lessons belonging to a specific module.
Validates module existence before fetching lessons with support for pagination, sorting, and filtering options.
The unique module identifier
Optional
options: QueryOptions = {}Query options for pagination, sorting, and filtering
Page number for pagination
Number of items per page
Field to sort by
Sort direction
Paginated lesson results with metadata
Retrieves paginated lessons across all modules in the system.
Optional
options: QueryOptions = {}Query options for pagination, sorting, and filtering
Page number for pagination
Number of items per page
Field to sort by
Sort direction
Additional filters to apply
Paginated lesson results with metadata
Updates an existing lesson with partial data and order conflict validation. Uses composite key lookup to prevent horizontal access vulnerabilities.
Validates lesson existence and prevents order conflicts within the same module when updating lesson properties. ID and module_id cannot be modified.
The unique lesson identifier
The module identifier to ensure lesson belongs to the correct module
Partial lesson data for update
Updated experience points value
Updated lesson order within the module
The updated lesson object
Permanently deletes a lesson and all its associated exercise assignments. Uses composite key lookup to prevent horizontal access vulnerabilities.
Validates lesson existence before deletion and ensures the operation completes successfully. This operation cascades to remove all lesson-exercise relationships.
The unique lesson identifier
The module identifier to ensure lesson belongs to the correct module
Resolves when deletion is complete
Assigns an exercise to a lesson at a specific order position with comprehensive validation.
Validates both lesson and exercise existence, prevents duplicate assignments, and ensures order uniqueness within the lesson before creating the assignment relationship.
The unique lesson identifier
Exercise assignment data
The unique exercise identifier to assign
The order position of the exercise within the lesson
The created lesson-exercise assignment relationship
Removes an exercise assignment from a lesson with validation.
Validates lesson and exercise existence, confirms the assignment relationship exists, and removes the lesson-exercise association.
The unique lesson identifier
The unique exercise identifier to unassign
Resolves when unassignment is complete
Retrieves all exercises assigned to a specific lesson in their defined order.
Validates lesson existence and returns all lesson-exercise relationships sorted by their order position within the lesson.
The unique lesson identifier
Array of lesson-exercise assignments ordered by position
Reorders exercises within a lesson by updating their position sequence.
Validates lesson existence, ensures all provided exercise IDs are currently assigned to the lesson, validates completeness of the reorder list, and prevents duplicates before applying the new exercise order.
The unique lesson identifier
Array of exercise IDs in their new desired order
Resolves when reordering is complete
Reorders lessons within a module by updating their position sequence.
Validates module existence, ensures all provided lesson IDs are currently assigned to the module, validates completeness of the reorder list, and prevents duplicates before applying the new lesson order.
The unique module identifier
Array of lesson IDs in their new desired order
Resolves when reordering is complete
Service class for comprehensive lesson management operations within the WayrApp content system.
Provides complete CRUD functionality for lessons, exercise assignment management, and maintains data integrity across the content hierarchy. Handles complex business logic including validation of module relationships, order conflict resolution, and exercise reordering operations.