Creates an instance of ProgressService.
Repository for progress data operations
Prisma client for direct database access
Retrieves user progress data, automatically creating initial progress record if none exists.
This method ensures every user has a progress record by creating one with default values (0 experience points, 5 lives, 0 streak) when no existing progress is found.
The unique identifier of the user
Promise resolving to the user's progress data
Updates specific fields of a user's progress record.
The unique identifier of the user
Object containing the fields to update
Promise resolving to the updated progress data
Processes lesson completion, calculates experience points, and updates user progress.
This method handles the complete lesson completion workflow including duplicate prevention, experience calculation based on performance, streak updates, and progress tracking. Experience points are calculated using the lesson's base points with performance multipliers:
The unique identifier of the user
Lesson completion data including lesson_id, score, and time_spent
Promise resolving to updated progress, completion record, and experience points gained
Synchronizes offline lesson completions with the server, handling conflicts and duplicates.
This method processes multiple lesson completions from offline usage, automatically detecting and skipping duplicates while maintaining data integrity. Completions are processed in chronological order and experience points are accumulated and applied in a single update.
The unique identifier of the user
Offline sync data containing completions and last sync timestamp
Promise resolving to sync statistics and updated progress
Retrieves comprehensive progress summary including lessons and courses statistics.
The unique identifier of the user
Promise resolving to detailed progress summary
Retrieves paginated list of user's lesson completions with sorting options.
The unique identifier of the user
Optional
options: QueryOptions = {}Optional pagination and sorting parameters
Promise resolving to paginated completion results
Checks whether a specific lesson has been completed by the user.
The unique identifier of the user
The unique identifier of the lesson
Promise resolving to true if lesson is completed, false otherwise
Retrieves aggregated completion statistics for a specific lesson (analytics function).
The unique identifier of the lesson
Promise resolving to lesson completion statistics
Resets user progress to initial state (administrative function).
This method resets experience points to 0, lives to 5, streak to 0, and clears the last completed lesson.
The unique identifier of the user
Promise resolving to the reset progress data
Awards bonus experience points to a user for special achievements or events.
The unique identifier of the user
The number of bonus experience points to award
Description of why the bonus was awarded (for logging)
Promise resolving to the updated progress data
Updates user's current lives count for gamification features.
Lives are clamped between 0 and 10 to maintain game balance.
The unique identifier of the user
The change in lives (positive to add, negative to subtract)
Promise resolving to the updated progress data
Progress tracking and gamification service for managing user learning progress.
ProgressService