VERSAO FINAL (core features)

This commit is contained in:
2026-05-17 18:27:22 +01:00
parent ba58228467
commit 7a26223a01
5 changed files with 203 additions and 56 deletions

View File

@@ -55,7 +55,8 @@ class _AnalyticsPageState extends State<AnalyticsPage>
for (final classDoc in classesSnapshot.docs) {
final classId = classDoc.id;
final stats = await GamificationService.getClassStats(classId);
// Forçar atualização para obter dados mais recentes
final stats = await GamificationService.getClassStats(classId, forceRefresh: true);
if (stats != null) {
classStatsList.add(stats);
}

View File

@@ -41,7 +41,8 @@ class _TeacherAnalyticsPreviewWidgetState extends State<TeacherAnalyticsPreviewW
for (final classDoc in classesSnapshot.docs) {
final classId = classDoc.id;
final stats = await GamificationService.getClassStats(classId);
// Forçar atualização para obter dados mais recentes
final stats = await GamificationService.getClassStats(classId, forceRefresh: true);
if (stats != null) {
classStatsList.add(stats);
}

View File

@@ -45,7 +45,8 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
for (final classDoc in classesSnapshot.docs) {
final classId = classDoc.id;
final stats = await GamificationService.getClassStats(classId);
// Forçar atualização para obter dados mais recentes
final stats = await GamificationService.getClassStats(classId, forceRefresh: true);
if (stats != null) {
classStatsList.add(stats);
}
@@ -73,7 +74,18 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
double get classAverageProgress {
if (_classStats.isEmpty) return 0.0;
final totalProgress = _classStats.fold(0.0, (sum, stats) => sum + stats.averageProgress);
return totalProgress / _classStats.length;
final average = totalProgress / _classStats.length;
print('=== UI PROGRESS DEBUG ===');
print('Number of classes: ${_classStats.length}');
for (int i = 0; i < _classStats.length; i++) {
print('Class ${i + 1}: ${_classStats[i].className} - ${_classStats[i].averageProgress} (${(_classStats[i].averageProgress * 100).toInt()}%)');
}
print('Total progress sum: $totalProgress');
print('Calculated average: $average (${(average * 100).toInt()}%)');
print('=== END UI PROGRESS DEBUG ===');
return average;
}
Widget build(BuildContext context) {
@@ -184,13 +196,22 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
),
),
),
Text(
'${(classAverageProgress * 100).toInt()}%',
style: const TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
),
Builder(
builder: (context) {
final displayValue = (classAverageProgress * 100).toInt();
print('=== RENDER DEBUG ===');
print('classAverageProgress: $classAverageProgress');
print('displayValue: $displayValue%');
print('=== END RENDER DEBUG ===');
return Text(
'$displayValue%',
style: const TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
),
);
},
),
],
),