todos os placholders da tela de alunos resolvidos
This commit is contained in:
@@ -352,74 +352,7 @@ 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
|
||||
|
||||
static Future<void> _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<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 {
|
||||
try {
|
||||
Logger.info('=== ATTEMPTING TO UNLOCK ACHIEVEMENT ===');
|
||||
|
||||
Reference in New Issue
Block a user