From ba58228467d2d3e9dad87e04a74eece56d8c02e3 Mon Sep 17 00:00:00 2001 From: 240403 <240403@epvc.pt> Date: Sun, 17 May 2026 17:49:23 +0100 Subject: [PATCH] todos os placholders da tela de alunos resolvidos --- lib/core/models/achievement.dart | 16 ---- lib/core/services/gamification_service.dart | 85 +------------------ .../pages/student_achievements_page.dart | 54 ------------ 3 files changed, 3 insertions(+), 152 deletions(-) diff --git a/lib/core/models/achievement.dart b/lib/core/models/achievement.dart index 154a553..c47c3ff 100644 --- a/lib/core/models/achievement.dart +++ b/lib/core/models/achievement.dart @@ -185,22 +185,6 @@ class SystemAchievements { isActive: true, createdAt: DateTime.now(), ), - Achievement( - id: 'first_quiz', - name: 'Primeiro Passo', - description: 'Complete seu primeiro quiz', - icon: 'emoji_events', - category: 'quiz', - requirements: AchievementRequirement( - type: 'quiz_completion', - value: 1, - operator: '>=', - ), - points: 10, - rarity: 'common', - isActive: true, - createdAt: DateTime.now(), - ), Achievement( id: 'perfect_score', name: 'Perfeição', diff --git a/lib/core/services/gamification_service.dart b/lib/core/services/gamification_service.dart index eac1aca..5de7583 100644 --- a/lib/core/services/gamification_service.dart +++ b/lib/core/services/gamification_service.dart @@ -352,74 +352,7 @@ class GamificationService { } } - /// Método público para inicializar dados de gamificação (para testes) - static Future initializeGamificationData(String userId) async { - try { - final userStats = await getUserStats(userId); - if (userStats == null) { - await _createInitialUserStats(userId); - Logger.info('Gamification data initialized for user $userId'); - } - } catch (e) { - Logger.error('Error initializing gamification data: $e'); - } - } - - /// Método público para simular quiz completion (para testes) - static Future simulateQuizCompletion(String userId, { - required int score, - required int totalQuestions, - required String materialName, - }) async { - Logger.info('=== SIMULATING QUIZ COMPLETION ==='); - Logger.info('User: $userId'); - Logger.info('Score: $score/$totalQuestions'); - Logger.info('Material: $materialName'); - - await recordQuizActivity( - userId, - score: score, - totalQuestions: totalQuestions, - materialName: materialName, - ); - - // Verificar estado após simulação - await debugUserStats(userId); - } - - /// Método de debugging para verificar estado completo do usuário - static Future debugUserStats(String userId) async { - try { - Logger.info('=== DEBUGGING USER STATS ==='); - - final userStats = await getUserStats(userId); - if (userStats == null) { - Logger.error('User stats not found for $userId'); - return; - } - - Logger.info('Current Streak: ${userStats.currentStreak}'); - Logger.info('Longest Streak: ${userStats.longestStreak}'); - Logger.info('Total Study Time: ${userStats.totalStudyTime}'); - Logger.info('Weekly Study Time: ${userStats.weeklyStudyTime}'); - Logger.info('Monthly Study Time: ${userStats.monthlyStudyTime}'); - Logger.info('Mastered Concepts: ${userStats.masteredConcepts.length}'); - Logger.info('Unlocked Achievements: ${userStats.unlockedAchievements.length}'); - - for (final concept in userStats.masteredConcepts) { - Logger.info(' - Concept: ${concept.conceptName}, Level: ${concept.masteryLevel}'); - } - - for (final achievement in userStats.unlockedAchievements) { - Logger.info(' - Achievement: ${achievement.achievementId}, Unlocked: ${achievement.unlockedAt}'); - } - - Logger.info('=== END DEBUG ==='); - } catch (e) { - Logger.error('Error debugging user stats: $e'); - } - } - + /// Métodos privados static Future _createInitialUserStats(String userId) async { @@ -626,6 +559,7 @@ class GamificationService { achievement.requirements.checkCondition(completedQuizzes)) { await _unlockAchievement(userId, achievement.id); } else if (achievement.category == 'quiz' && achievement.requirements.type == 'quiz_completion' && + achievement.id == 'first_quiz' && achievement.requirements.checkCondition(1)) { await _unlockAchievement(userId, achievement.id); } else if (achievement.category == 'concept' && achievement.requirements.type == 'concepts_mastered' && @@ -637,22 +571,9 @@ class GamificationService { } Logger.info('=== END CHECKING QUIZ ACHIEVEMENTS ==='); - // Verificar conquistas genéricas de número de quizzes - await _checkQuizCountAchievements(userId, completedQuizzes); - } - - static Future _checkQuizCountAchievements(String userId, int completedQuizzes) async { - final achievements = await getAvailableAchievements(); - final quizCountAchievements = achievements.where((a) => a.category == 'quiz_count'); - - for (final achievement in quizCountAchievements) { - if (achievement.requirements.type == 'quiz_completion' && - achievement.requirements.checkCondition(completedQuizzes)) { - await _unlockAchievement(userId, achievement.id); - } - } } + static Future _unlockAchievement(String userId, String achievementId) async { try { Logger.info('=== ATTEMPTING TO UNLOCK ACHIEVEMENT ==='); diff --git a/lib/features/achievements/presentation/pages/student_achievements_page.dart b/lib/features/achievements/presentation/pages/student_achievements_page.dart index b916ac4..f6777ea 100644 --- a/lib/features/achievements/presentation/pages/student_achievements_page.dart +++ b/lib/features/achievements/presentation/pages/student_achievements_page.dart @@ -142,60 +142,6 @@ class _StudentAchievementsPageState extends State { ), ), - // Debug buttons (remover em produção) - if (!const bool.fromEnvironment('dart.vm.product')) ...[ - Container( - margin: const EdgeInsets.all(16), - child: Row( - children: [ - Expanded( - child: ElevatedButton( - onPressed: () async { - final user = AuthService.currentUser; - if (user != null) { - await GamificationService.initializeGamificationData(user.uid); - _loadAchievements(); - } - }, - child: const Text('Inicializar Dados'), - ), - ), - const SizedBox(width: 8), - Expanded( - child: ElevatedButton( - onPressed: () async { - final user = AuthService.currentUser; - if (user != null) { - await GamificationService.simulateQuizCompletion( - user.uid, - score: 8, - totalQuestions: 10, - materialName: 'Matemática Básica', - ); - _loadAchievements(); - } - }, - child: const Text('Simular Quiz'), - ), - ), - const SizedBox(width: 8), - Expanded( - child: ElevatedButton( - onPressed: () async { - final user = AuthService.currentUser; - if (user != null) { - await GamificationService.debugUserStats(user.uid); - } - }, - style: ElevatedButton.styleFrom(backgroundColor: Colors.orange), - child: const Text('Debug Stats'), - ), - ), - ], - ), - ), - ], - // Content Expanded( child: _loading