WayrApp Backend & Ecosystem Documentation - v1.0.0
    Preparing search index...

    Service class for comprehensive exercise usage tracking and management operations.

    Provides complete functionality for exercise usage analytics, cascade delete impact analysis, exercise duplication, and performance metrics collection. Handles complex business logic including usage frequency calculation, lesson assignment tracking, and exercise variation management.

    Index

    Constructors

    Methods

    • Retrieves comprehensive usage statistics for a specific exercise.

      Provides detailed information about which lessons use the exercise, including the complete hierarchical context (course → level → section → module → lesson). Calculates usage frequency and tracks when the exercise was last used.

      Parameters

      • exerciseId: string

        The unique exercise identifier

      Returns Promise<ExerciseUsage>

      Promise resolving to comprehensive usage statistics

      When exercise with the specified ID is not found

      const usage = await exerciseUsageService.getExerciseUsage('exercise-translate-001');
      console.log(`Exercise used in ${usage.totalLessons} lessons`);
      usage.lessons.forEach(lesson => {
      console.log(`Used in: ${lesson.courseName} > ${lesson.lessonName}`);
      });
    • Analyzes the impact of deleting an exercise on the content system.

      Provides comprehensive analysis of what would be affected if the exercise is deleted, including warnings about lessons that would lose content and recommendations for content creators.

      Parameters

      • exerciseId: string

        The unique exercise identifier

      Returns Promise<CascadeDeleteImpact>

      Promise resolving to impact analysis

      When exercise with the specified ID is not found

      const impact = await exerciseUsageService.getCascadeDeleteImpact('exercise-001');
      if (!impact.canDelete) {
      console.log('Cannot delete exercise:');
      impact.warnings.forEach(warning => console.log(`- ${warning}`));
      }
    • Creates a duplicate of an existing exercise with optional modifications.

      Allows content creators to create variations of existing exercises by duplicating the exercise data and applying modifications. Useful for creating difficulty variations or similar exercises with different content.

      Parameters

      • sourceExerciseId: string

        The unique identifier of the exercise to duplicate

      • options: ExerciseDuplicationOptions

        Duplication configuration options

      Returns Promise<Exercise>

      Promise resolving to the created duplicate exercise

      When source exercise is not found or duplicate ID already exists

      const duplicate = await exerciseUsageService.duplicateExercise('exercise-001', {
      id: 'exercise-001-hard',
      modifications: {
      difficulty: 'hard',
      timeLimit: 30
      }
      });
    • Retrieves comprehensive analytics for a specific exercise.

      Provides detailed analytics including usage statistics, performance metrics, and usage trends over time. Useful for content creators to understand how their exercises are being used and performing.

      Parameters

      • exerciseId: string

        The unique exercise identifier

      Returns Promise<ExerciseAnalytics>

      Promise resolving to comprehensive analytics

      When exercise with the specified ID is not found

      const analytics = await exerciseUsageService.getExerciseAnalytics('exercise-001');
      console.log(`Used in ${analytics.usageStats.uniqueLessons} lessons`);
      console.log(`Average completion rate: ${analytics.performanceMetrics.completionRate}%`);
    • Retrieves usage statistics for multiple exercises in batch.

      Efficiently retrieves usage statistics for multiple exercises at once, useful for dashboard views and bulk operations.

      Parameters

      • exerciseIds: string[]

        Array of exercise identifiers

      Returns Promise<ExerciseUsage[]>

      Promise resolving to array of usage statistics

      const usageStats = await exerciseUsageService.getBatchExerciseUsage([
      'exercise-001', 'exercise-002', 'exercise-003'
      ]);