/**
 * ============================================
 * PROGRESS TYPES
 * ============================================
 * 
 * Types for user progress tracking
 * shared between frontend and backend
 */

// ============================================
// USER PROGRESS
// ============================================

export interface UserProgress {
  userId: string;
  moduleId: string;
  exercisesCompleted: number;
  totalExercises: number;
  points: number;
  percentage: number;
  isStarted: boolean;
  isCompleted: boolean;
  lastActivityAt: string;
}

// ============================================
// MODULE PROGRESS
// ============================================

export interface ModuleProgress {
  moduleId: string;
  moduleName: string;
  isStarted: boolean;
  isCompleted: boolean;
  startedAt?: string;
  completedAt?: string;
  lastAccessedAt?: string;
  metrics: ProgressMetrics;
}

export interface ProgressMetrics {
  exercisesCompleted: number;
  totalExercises: number;
  points: number;
  percentage: number;
  averageScore?: number;
  totalTimeSpent: number;
  perfectExercises: number;
  attemptsCount: number;
}

// ============================================
// USER STATISTICS
// ============================================

export interface UserStatistics {
  totalExercisesCompleted: number;
  totalPoints: number;
  averageScore: number;
  totalStudyTime: number;
  currentStreak: number;
  longestStreak: number;
  modulesCompleted: number;
  achievementsUnlocked: number;
  rankGlobal: number | null;
}

// ============================================
// ACTIVITY
// ============================================

export interface Activity {
  id: string;
  userId: string;
  type: ActivityType;
  description: string;
  metadata?: Record<string, unknown>;
  createdAt: string;
}

export type ActivityType = 
  | 'EXERCISE_COMPLETED'
  | 'EXERCISE_ATTEMPTED'
  | 'MODULE_STARTED'
  | 'MODULE_COMPLETED'
  | 'ACHIEVEMENT_UNLOCKED'
  | 'LOGIN'
  | 'LOGOUT';
