todos os placholders da tela de alunos resolvidos
This commit is contained in:
@@ -185,22 +185,6 @@ class SystemAchievements {
|
|||||||
isActive: true,
|
isActive: true,
|
||||||
createdAt: DateTime.now(),
|
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(
|
Achievement(
|
||||||
id: 'perfect_score',
|
id: 'perfect_score',
|
||||||
name: 'Perfeição',
|
name: 'Perfeição',
|
||||||
|
|||||||
@@ -352,73 +352,6 @@ class GamificationService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Método público para inicializar dados de gamificação (para testes)
|
|
||||||
static Future<void> 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<void> 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<void> 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
|
/// Métodos privados
|
||||||
|
|
||||||
@@ -626,6 +559,7 @@ class GamificationService {
|
|||||||
achievement.requirements.checkCondition(completedQuizzes)) {
|
achievement.requirements.checkCondition(completedQuizzes)) {
|
||||||
await _unlockAchievement(userId, achievement.id);
|
await _unlockAchievement(userId, achievement.id);
|
||||||
} else if (achievement.category == 'quiz' && achievement.requirements.type == 'quiz_completion' &&
|
} else if (achievement.category == 'quiz' && achievement.requirements.type == 'quiz_completion' &&
|
||||||
|
achievement.id == 'first_quiz' &&
|
||||||
achievement.requirements.checkCondition(1)) {
|
achievement.requirements.checkCondition(1)) {
|
||||||
await _unlockAchievement(userId, achievement.id);
|
await _unlockAchievement(userId, achievement.id);
|
||||||
} else if (achievement.category == 'concept' && achievement.requirements.type == 'concepts_mastered' &&
|
} else if (achievement.category == 'concept' && achievement.requirements.type == 'concepts_mastered' &&
|
||||||
@@ -637,21 +571,8 @@ class GamificationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Logger.info('=== END CHECKING QUIZ ACHIEVEMENTS ===');
|
Logger.info('=== END CHECKING QUIZ ACHIEVEMENTS ===');
|
||||||
// Verificar conquistas genéricas de número de quizzes
|
|
||||||
await _checkQuizCountAchievements(userId, completedQuizzes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> _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<void> _unlockAchievement(String userId, String achievementId) async {
|
static Future<void> _unlockAchievement(String userId, String achievementId) async {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -142,60 +142,6 @@ class _StudentAchievementsPageState extends State<StudentAchievementsPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// 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
|
// Content
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _loading
|
child: _loading
|
||||||
|
|||||||
Reference in New Issue
Block a user