Muitas coisas e já me esqueci delas todas, cenas principalmente no dashboard do aluno bug fixes e etc
This commit is contained in:
@@ -13,7 +13,8 @@ class StudentAchievementsPage extends StatefulWidget {
|
|||||||
const StudentAchievementsPage({super.key});
|
const StudentAchievementsPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StudentAchievementsPage> createState() => _StudentAchievementsPageState();
|
State<StudentAchievementsPage> createState() =>
|
||||||
|
_StudentAchievementsPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _StudentAchievementsPageState extends State<StudentAchievementsPage> {
|
class _StudentAchievementsPageState extends State<StudentAchievementsPage> {
|
||||||
@@ -82,66 +83,45 @@ class _StudentAchievementsPageState extends State<StudentAchievementsPage> {
|
|||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: cs.surface,
|
backgroundColor: cs.surface,
|
||||||
|
appBar: AppBar(
|
||||||
|
backgroundColor: cs.primary,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
elevation: 0,
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
onPressed: () => context.go('/student-dashboard'),
|
||||||
|
),
|
||||||
|
title: const Text(
|
||||||
|
'Minhas Conquistas',
|
||||||
|
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 16),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'${_unlockedAchievements.length}/${_allAchievements.length}',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white.withValues(alpha: 0.9),
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
body: Container(
|
body: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
begin: Alignment.topCenter,
|
begin: Alignment.topCenter,
|
||||||
end: Alignment.bottomCenter,
|
end: Alignment.bottomCenter,
|
||||||
colors: [
|
colors: [cs.primary.withValues(alpha: 0.05), cs.surface],
|
||||||
cs.primary.withValues(alpha: 0.05),
|
|
||||||
cs.surface,
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
// Header
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(24),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
|
||||||
onPressed: () => context.go('/student-dashboard'),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 16),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
const Text(
|
|
||||||
'Minhas Conquistas',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 24,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(
|
|
||||||
'${_unlockedAchievements.length}/${_allAchievements.length} desbloqueadas',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white.withValues(alpha: 0.8),
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
gradient: LinearGradient(
|
|
||||||
colors: [cs.primary, cs.primary.withValues(alpha: 0.8)],
|
|
||||||
),
|
|
||||||
borderRadius: const BorderRadius.only(
|
|
||||||
bottomLeft: Radius.circular(20),
|
|
||||||
bottomRight: Radius.circular(20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Content
|
// Content
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _loading
|
child: _loading
|
||||||
@@ -203,7 +183,8 @@ class _StudentAchievementsPageState extends State<StudentAchievementsPage> {
|
|||||||
return _buildEmptyState(
|
return _buildEmptyState(
|
||||||
icon: Icons.emoji_events_outlined,
|
icon: Icons.emoji_events_outlined,
|
||||||
title: 'Nenhuma conquista desbloqueada',
|
title: 'Nenhuma conquista desbloqueada',
|
||||||
subtitle: 'Complete quizzes e mantenha seu streak para desbloquear conquistas!',
|
subtitle:
|
||||||
|
'Complete quizzes e mantenha seu streak para desbloquear conquistas!',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +195,10 @@ class _StudentAchievementsPageState extends State<StudentAchievementsPage> {
|
|||||||
final achievement = _unlockedAchievements[index];
|
final achievement = _unlockedAchievements[index];
|
||||||
return _buildAchievementCard(achievement, isUnlocked: true)
|
return _buildAchievementCard(achievement, isUnlocked: true)
|
||||||
.animate()
|
.animate()
|
||||||
.slideX(duration: const Duration(milliseconds: 300))
|
.fadeIn(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeOut,
|
||||||
|
)
|
||||||
.then(delay: Duration(milliseconds: index * 50));
|
.then(delay: Duration(milliseconds: index * 50));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -236,13 +220,19 @@ class _StudentAchievementsPageState extends State<StudentAchievementsPage> {
|
|||||||
final achievement = _lockedAchievements[index];
|
final achievement = _lockedAchievements[index];
|
||||||
return _buildAchievementCard(achievement, isUnlocked: false)
|
return _buildAchievementCard(achievement, isUnlocked: false)
|
||||||
.animate()
|
.animate()
|
||||||
.slideX(duration: const Duration(milliseconds: 300))
|
.fadeIn(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeOut,
|
||||||
|
)
|
||||||
.then(delay: Duration(milliseconds: index * 50));
|
.then(delay: Duration(milliseconds: index * 50));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAchievementCard(Achievement achievement, {required bool isUnlocked}) {
|
Widget _buildAchievementCard(
|
||||||
|
Achievement achievement, {
|
||||||
|
required bool isUnlocked,
|
||||||
|
}) {
|
||||||
final cs = Theme.of(context).colorScheme;
|
final cs = Theme.of(context).colorScheme;
|
||||||
final color = _getRarityColor(achievement.rarity);
|
final color = _getRarityColor(achievement.rarity);
|
||||||
|
|
||||||
@@ -253,7 +243,7 @@ class _StudentAchievementsPageState extends State<StudentAchievementsPage> {
|
|||||||
color: isUnlocked ? cs.surface : cs.surfaceContainerHighest,
|
color: isUnlocked ? cs.surface : cs.surfaceContainerHighest,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: isUnlocked
|
color: isUnlocked
|
||||||
? color.withValues(alpha: 0.3)
|
? color.withValues(alpha: 0.3)
|
||||||
: cs.outline.withValues(alpha: 0.2),
|
: cs.outline.withValues(alpha: 0.2),
|
||||||
width: isUnlocked ? 2 : 1,
|
width: isUnlocked ? 2 : 1,
|
||||||
@@ -273,7 +263,7 @@ class _StudentAchievementsPageState extends State<StudentAchievementsPage> {
|
|||||||
width: 48,
|
width: 48,
|
||||||
height: 48,
|
height: 48,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: isUnlocked
|
color: isUnlocked
|
||||||
? color.withValues(alpha: 0.2)
|
? color.withValues(alpha: 0.2)
|
||||||
: cs.outline.withValues(alpha: 0.2),
|
: cs.outline.withValues(alpha: 0.2),
|
||||||
borderRadius: BorderRadius.circular(24),
|
borderRadius: BorderRadius.circular(24),
|
||||||
@@ -302,18 +292,20 @@ class _StudentAchievementsPageState extends State<StudentAchievementsPage> {
|
|||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
achievement.description,
|
achievement.description,
|
||||||
style: TextStyle(
|
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 14),
|
||||||
color: cs.onSurfaceVariant,
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8,
|
||||||
|
vertical: 4,
|
||||||
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: _getRarityColor(achievement.rarity).withValues(alpha: 0.2),
|
color: _getRarityColor(
|
||||||
|
achievement.rarity,
|
||||||
|
).withValues(alpha: 0.2),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -342,17 +334,9 @@ class _StudentAchievementsPageState extends State<StudentAchievementsPage> {
|
|||||||
|
|
||||||
// Status
|
// Status
|
||||||
if (isUnlocked)
|
if (isUnlocked)
|
||||||
Icon(
|
Icon(Icons.check_circle, color: Colors.green, size: 24)
|
||||||
Icons.check_circle,
|
|
||||||
color: Colors.green,
|
|
||||||
size: 24,
|
|
||||||
)
|
|
||||||
else
|
else
|
||||||
Icon(
|
Icon(Icons.lock, color: cs.outline, size: 24),
|
||||||
Icons.lock,
|
|
||||||
color: cs.outline,
|
|
||||||
size: 24,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -371,11 +355,7 @@ class _StudentAchievementsPageState extends State<StudentAchievementsPage> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(icon, size: 64, color: cs.onSurfaceVariant),
|
||||||
icon,
|
|
||||||
size: 64,
|
|
||||||
color: cs.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
title,
|
title,
|
||||||
@@ -389,10 +369,7 @@ class _StudentAchievementsPageState extends State<StudentAchievementsPage> {
|
|||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
subtitle,
|
subtitle,
|
||||||
style: TextStyle(
|
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 14),
|
||||||
color: cs.onSurfaceVariant,
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -403,29 +380,47 @@ class _StudentAchievementsPageState extends State<StudentAchievementsPage> {
|
|||||||
|
|
||||||
Color _getRarityColor(String rarity) {
|
Color _getRarityColor(String rarity) {
|
||||||
switch (rarity) {
|
switch (rarity) {
|
||||||
case 'common': return Colors.grey;
|
case 'common':
|
||||||
case 'rare': return Colors.blue;
|
return Colors.grey;
|
||||||
case 'epic': return Colors.purple;
|
case 'rare':
|
||||||
case 'legendary': return Colors.orange;
|
return Colors.blue;
|
||||||
default: return Colors.grey;
|
case 'epic':
|
||||||
|
return Colors.purple;
|
||||||
|
case 'legendary':
|
||||||
|
return Colors.orange;
|
||||||
|
default:
|
||||||
|
return Colors.grey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IconData _getIconData(String iconName) {
|
IconData _getIconData(String iconName) {
|
||||||
switch (iconName) {
|
switch (iconName) {
|
||||||
case 'emoji_events': return Icons.emoji_events;
|
case 'emoji_events':
|
||||||
case 'school': return Icons.school;
|
return Icons.emoji_events;
|
||||||
case 'local_fire_department': return Icons.local_fire_department;
|
case 'school':
|
||||||
case 'schedule': return Icons.schedule;
|
return Icons.school;
|
||||||
case 'trending_up': return Icons.trending_up;
|
case 'local_fire_department':
|
||||||
case 'star': return Icons.star;
|
return Icons.local_fire_department;
|
||||||
case 'military_tech': return Icons.military_tech;
|
case 'schedule':
|
||||||
case 'workspace_premium': return Icons.workspace_premium;
|
return Icons.schedule;
|
||||||
case 'psychology': return Icons.psychology;
|
case 'trending_up':
|
||||||
case 'lightbulb': return Icons.lightbulb;
|
return Icons.trending_up;
|
||||||
case 'whatshot': return Icons.whatshot;
|
case 'star':
|
||||||
case 'stars': return Icons.stars;
|
return Icons.star;
|
||||||
default: return Icons.emoji_events;
|
case 'military_tech':
|
||||||
|
return Icons.military_tech;
|
||||||
|
case 'workspace_premium':
|
||||||
|
return Icons.workspace_premium;
|
||||||
|
case 'psychology':
|
||||||
|
return Icons.psychology;
|
||||||
|
case 'lightbulb':
|
||||||
|
return Icons.lightbulb;
|
||||||
|
case 'whatshot':
|
||||||
|
return Icons.whatshot;
|
||||||
|
case 'stars':
|
||||||
|
return Icons.stars;
|
||||||
|
default:
|
||||||
|
return Icons.emoji_events;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,18 +45,21 @@ class _AnalyticsPageState extends State<AnalyticsPage>
|
|||||||
final user = AuthService.currentUser;
|
final user = AuthService.currentUser;
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
|
||||||
// Obter turmas do professor
|
// Obter disciplinas do professor
|
||||||
final classesSnapshot = await FirebaseFirestore.instance
|
final classesSnapshot = await FirebaseFirestore.instance
|
||||||
.collection('classes')
|
.collection('classes')
|
||||||
.where('teacherId', isEqualTo: user.uid)
|
.where('teacherId', isEqualTo: user.uid)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
final classStatsList = <ClassStats>[];
|
final classStatsList = <ClassStats>[];
|
||||||
|
|
||||||
for (final classDoc in classesSnapshot.docs) {
|
for (final classDoc in classesSnapshot.docs) {
|
||||||
final classId = classDoc.id;
|
final classId = classDoc.id;
|
||||||
// Forçar atualização para obter dados mais recentes
|
// Forçar atualização para obter dados mais recentes
|
||||||
final stats = await GamificationService.getClassStats(classId, forceRefresh: true);
|
final stats = await GamificationService.getClassStats(
|
||||||
|
classId,
|
||||||
|
forceRefresh: true,
|
||||||
|
);
|
||||||
if (stats != null) {
|
if (stats != null) {
|
||||||
classStatsList.add(stats);
|
classStatsList.add(stats);
|
||||||
}
|
}
|
||||||
@@ -105,7 +108,10 @@ class _AnalyticsPageState extends State<AnalyticsPage>
|
|||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
icon: const Icon(
|
||||||
|
Icons.arrow_back,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
onPressed: () => context.go('/teacher-dashboard'),
|
onPressed: () => context.go('/teacher-dashboard'),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
@@ -123,7 +129,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
'Acompanhe o desempenho das turmas',
|
'Acompanhe o desempenho das disciplinas',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white.withValues(alpha: 0.8),
|
color: Colors.white.withValues(alpha: 0.8),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
@@ -147,7 +153,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
|
|||||||
indicatorColor: Colors.white,
|
indicatorColor: Colors.white,
|
||||||
indicatorWeight: 2,
|
indicatorWeight: 2,
|
||||||
tabs: const [
|
tabs: const [
|
||||||
Tab(text: 'Turmas'),
|
Tab(text: 'Disciplinas'),
|
||||||
Tab(text: 'Rankings'),
|
Tab(text: 'Rankings'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -159,10 +165,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
controller: _tabController,
|
controller: _tabController,
|
||||||
children: [
|
children: [_buildClassesTab(), _buildRankingsTab()],
|
||||||
_buildClassesTab(),
|
|
||||||
_buildRankingsTab(),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -174,7 +177,9 @@ class _AnalyticsPageState extends State<AnalyticsPage>
|
|||||||
|
|
||||||
Widget _buildClassesTab() {
|
Widget _buildClassesTab() {
|
||||||
if (_loading) {
|
if (_loading) {
|
||||||
return const Center(child: CircularProgressIndicator(color: Colors.white));
|
return const Center(
|
||||||
|
child: CircularProgressIndicator(color: Colors.white),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_classStats.isEmpty) {
|
if (_classStats.isEmpty) {
|
||||||
@@ -189,7 +194,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
'Nenhuma turma encontrada',
|
'Nenhuma disciplina encontrada',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white.withValues(alpha: 0.7),
|
color: Colors.white.withValues(alpha: 0.7),
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
@@ -197,7 +202,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
'Crie turmas para ver as analytics aqui',
|
'Crie disciplinas para ver as analytics aqui',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white.withValues(alpha: 0.5),
|
color: Colors.white.withValues(alpha: 0.5),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
@@ -238,13 +243,15 @@ class _AnalyticsPageState extends State<AnalyticsPage>
|
|||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
// Class Cards
|
// Class Cards
|
||||||
..._classStats.map((stats) => Padding(
|
..._classStats.map(
|
||||||
padding: const EdgeInsets.only(bottom: 16),
|
(stats) => Padding(
|
||||||
child: ClassAnalyticsCard(
|
padding: const EdgeInsets.only(bottom: 16),
|
||||||
classStats: stats,
|
child: ClassAnalyticsCard(
|
||||||
onTap: () => _showClassRanking(stats),
|
classStats: stats,
|
||||||
|
onTap: () => _showClassRanking(stats),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -263,7 +270,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
'Selecione uma turma',
|
'Selecione uma disciplina',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white.withValues(alpha: 0.7),
|
color: Colors.white.withValues(alpha: 0.7),
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
@@ -271,7 +278,7 @@ class _AnalyticsPageState extends State<AnalyticsPage>
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
'Clique em uma turma na aba "Turmas" para ver o ranking',
|
'Clique em uma disciplina na aba "Disciplinas" para ver o ranking',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white.withValues(alpha: 0.5),
|
color: Colors.white.withValues(alpha: 0.5),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
@@ -285,7 +292,12 @@ class _AnalyticsPageState extends State<AnalyticsPage>
|
|||||||
return ClassRankingWidget(classId: _selectedClassId!);
|
return ClassRankingWidget(classId: _selectedClassId!);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildOverviewCard(String title, String value, IconData icon, Color color) {
|
Widget _buildOverviewCard(
|
||||||
|
String title,
|
||||||
|
String value,
|
||||||
|
IconData icon,
|
||||||
|
Color color,
|
||||||
|
) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.all(20),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -333,7 +345,9 @@ class _AnalyticsPageState extends State<AnalyticsPage>
|
|||||||
onAchievementCreated: (achievement) {
|
onAchievementCreated: (achievement) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text('Conquista "${achievement.name}" criada com sucesso!'),
|
content: Text(
|
||||||
|
'Conquista "${achievement.name}" criada com sucesso!',
|
||||||
|
),
|
||||||
backgroundColor: Colors.green,
|
backgroundColor: Colors.green,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,10 +10,7 @@ import '../../../../core/theme/app_theme_extension.dart';
|
|||||||
class ClassRankingWidget extends StatefulWidget {
|
class ClassRankingWidget extends StatefulWidget {
|
||||||
final String classId;
|
final String classId;
|
||||||
|
|
||||||
const ClassRankingWidget({
|
const ClassRankingWidget({super.key, required this.classId});
|
||||||
super.key,
|
|
||||||
required this.classId,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ClassRankingWidget> createState() => _ClassRankingWidgetState();
|
State<ClassRankingWidget> createState() => _ClassRankingWidgetState();
|
||||||
@@ -60,11 +57,18 @@ class _ClassRankingWidgetState extends State<ClassRankingWidget> {
|
|||||||
|
|
||||||
List<StudentRanking> get _filteredRankings {
|
List<StudentRanking> get _filteredRankings {
|
||||||
if (_searchQuery.isEmpty) return _rankings;
|
if (_searchQuery.isEmpty) return _rankings;
|
||||||
|
|
||||||
return _rankings.where((student) =>
|
return _rankings
|
||||||
student.studentName.toLowerCase().contains(_searchQuery.toLowerCase()) ||
|
.where(
|
||||||
student.studentEmail.toLowerCase().contains(_searchQuery.toLowerCase())
|
(student) =>
|
||||||
).toList();
|
student.studentName.toLowerCase().contains(
|
||||||
|
_searchQuery.toLowerCase(),
|
||||||
|
) ||
|
||||||
|
student.studentEmail.toLowerCase().contains(
|
||||||
|
_searchQuery.toLowerCase(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -118,7 +122,10 @@ class _ClassRankingWidgetState extends State<ClassRankingWidget> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 12,
|
||||||
|
vertical: 6,
|
||||||
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white.withValues(alpha: 0.2),
|
color: Colors.white.withValues(alpha: 0.2),
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
@@ -126,7 +133,11 @@ class _ClassRankingWidgetState extends State<ClassRankingWidget> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.leaderboard, color: Colors.white, size: 16),
|
const Icon(
|
||||||
|
Icons.leaderboard,
|
||||||
|
color: Colors.white,
|
||||||
|
size: 16,
|
||||||
|
),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Text(
|
Text(
|
||||||
'Ranking',
|
'Ranking',
|
||||||
@@ -177,7 +188,10 @@ class _ClassRankingWidgetState extends State<ClassRankingWidget> {
|
|||||||
),
|
),
|
||||||
if (_searchQuery.isNotEmpty)
|
if (_searchQuery.isNotEmpty)
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.clear, color: Colors.white.withValues(alpha: 0.7)),
|
icon: Icon(
|
||||||
|
Icons.clear,
|
||||||
|
color: Colors.white.withValues(alpha: 0.7),
|
||||||
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_searchQuery = '';
|
_searchQuery = '';
|
||||||
@@ -199,7 +213,7 @@ class _ClassRankingWidgetState extends State<ClassRankingWidget> {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final student = _filteredRankings[index];
|
final student = _filteredRankings[index];
|
||||||
final rankPosition = _rankings.indexOf(student) + 1;
|
final rankPosition = _rankings.indexOf(student) + 1;
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 12),
|
padding: const EdgeInsets.only(bottom: 12),
|
||||||
child: _buildStudentRankingCard(student, rankPosition),
|
child: _buildStudentRankingCard(student, rankPosition),
|
||||||
@@ -255,7 +269,7 @@ class _ClassRankingWidgetState extends State<ClassRankingWidget> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
'Nenhum aluno na turma',
|
'Nenhum aluno na disciplina',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white.withValues(alpha: 0.7),
|
color: Colors.white.withValues(alpha: 0.7),
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
@@ -276,11 +290,11 @@ class _ClassRankingWidgetState extends State<ClassRankingWidget> {
|
|||||||
|
|
||||||
Widget _buildStudentRankingCard(StudentRanking student, int rankPosition) {
|
Widget _buildStudentRankingCard(StudentRanking student, int rankPosition) {
|
||||||
final cs = Theme.of(context).colorScheme;
|
final cs = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
// Determinar cor baseada na posição
|
// Determinar cor baseada na posição
|
||||||
Color rankColor;
|
Color rankColor;
|
||||||
IconData rankIcon;
|
IconData rankIcon;
|
||||||
|
|
||||||
if (rankPosition == 1) {
|
if (rankPosition == 1) {
|
||||||
rankColor = Colors.amber;
|
rankColor = Colors.amber;
|
||||||
rankIcon = Icons.emoji_events;
|
rankIcon = Icons.emoji_events;
|
||||||
@@ -361,7 +375,9 @@ class _ClassRankingWidgetState extends State<ClassRankingWidget> {
|
|||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: _getScoreColor(student.overallScore).withValues(alpha: 0.2),
|
color: _getScoreColor(
|
||||||
|
student.overallScore,
|
||||||
|
).withValues(alpha: 0.2),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class _SignupPageState extends State<SignupPage> {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
Text(
|
Text(
|
||||||
'A carregar turmas...',
|
'A carregar anos letivos...',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
@@ -98,7 +98,7 @@ class _SignupPageState extends State<SignupPage> {
|
|||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Nenhuma turma disponível. Contacta o teu professor.',
|
'Nenhum ano letivo disponível. Contacta o teu professor.',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.error,
|
color: Theme.of(context).colorScheme.error,
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
@@ -111,7 +111,7 @@ class _SignupPageState extends State<SignupPage> {
|
|||||||
value: _selectedSchoolClassId,
|
value: _selectedSchoolClassId,
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'Turma',
|
labelText: 'Ano letivo',
|
||||||
labelStyle: TextStyle(color: Theme.of(context).colorScheme.onSurface),
|
labelStyle: TextStyle(color: Theme.of(context).colorScheme.onSurface),
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
@@ -139,7 +139,7 @@ class _SignupPageState extends State<SignupPage> {
|
|||||||
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
|
style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
|
||||||
dropdownColor: Theme.of(context).colorScheme.surface,
|
dropdownColor: Theme.of(context).colorScheme.surface,
|
||||||
hint: Text(
|
hint: Text(
|
||||||
'Seleciona a tua turma',
|
'Escolha o seu ano letivo',
|
||||||
style: TextStyle(color: Theme.of(context).colorScheme.onSurfaceVariant),
|
style: TextStyle(color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||||
),
|
),
|
||||||
items: _availableClasses
|
items: _availableClasses
|
||||||
@@ -153,7 +153,7 @@ class _SignupPageState extends State<SignupPage> {
|
|||||||
onChanged: (value) => setState(() => _selectedSchoolClassId = value),
|
onChanged: (value) => setState(() => _selectedSchoolClassId = value),
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value == null || value.isEmpty) {
|
if (value == null || value.isEmpty) {
|
||||||
return 'Seleciona a tua turma';
|
return 'Seleciona o teu ano letivo';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
@@ -246,10 +246,12 @@ class _SignupPageState extends State<SignupPage> {
|
|||||||
? AppThemeExtras.of(context).authBackgroundGradient
|
? AppThemeExtras.of(context).authBackgroundGradient
|
||||||
: [
|
: [
|
||||||
Theme.of(context).colorScheme.background,
|
Theme.of(context).colorScheme.background,
|
||||||
Theme.of(context).colorScheme.primary
|
Theme.of(
|
||||||
.withOpacity(0.1),
|
context,
|
||||||
Theme.of(context).colorScheme.secondary
|
).colorScheme.primary.withOpacity(0.1),
|
||||||
.withOpacity(0.05),
|
Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.secondary.withOpacity(0.05),
|
||||||
Theme.of(context).colorScheme.background,
|
Theme.of(context).colorScheme.background,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -424,7 +426,7 @@ class _SignupPageState extends State<SignupPage> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
// Seletor de turma (apenas para alunos)
|
// Seletor de ano letivo (apenas para alunos)
|
||||||
if (_selectedRole == 'student') ...[
|
if (_selectedRole == 'student') ...[
|
||||||
_buildClassSelector(context),
|
_buildClassSelector(context),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import '../../../../core/services/auth_service.dart';
|
import '../../../../core/services/auth_service.dart';
|
||||||
|
|
||||||
/// Página para visualizar os alunos de uma turma específica
|
/// Página para visualizar os alunos de uma disciplina específica
|
||||||
class ClassStudentsPage extends StatefulWidget {
|
class ClassStudentsPage extends StatefulWidget {
|
||||||
final String classId;
|
final String classId;
|
||||||
final String className;
|
final String className;
|
||||||
@@ -107,7 +107,7 @@ class _ClassStudentsPageState extends State<ClassStudentsPage> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
Text(
|
Text(
|
||||||
'Só podes ver os alunos das tuas próprias turmas.',
|
'Só podes ver os alunos das tuas próprias disciplinas.',
|
||||||
style: TextStyle(color: Colors.grey[600], fontSize: 14),
|
style: TextStyle(color: Colors.grey[600], fontSize: 14),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
@@ -188,7 +188,7 @@ class _ClassStudentsPageState extends State<ClassStudentsPage> {
|
|||||||
Icon(Icons.people_outline, size: 64, color: Colors.grey[300]),
|
Icon(Icons.people_outline, size: 64, color: Colors.grey[300]),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
Text(
|
Text(
|
||||||
'Nenhum aluno entrou nesta turma ainda.',
|
'Nenhum aluno entrou nesta disciplina ainda.',
|
||||||
style: TextStyle(color: Colors.grey[600], fontSize: 16),
|
style: TextStyle(color: Colors.grey[600], fontSize: 16),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
@@ -196,7 +196,7 @@ class _ClassStudentsPageState extends State<ClassStudentsPage> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 32.0),
|
padding: const EdgeInsets.symmetric(horizontal: 32.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Partilha o código da turma para os alunos se juntarem.',
|
'Partilha o código da disciplina para os alunos se juntarem.',
|
||||||
style: TextStyle(color: Colors.grey[500], fontSize: 13),
|
style: TextStyle(color: Colors.grey[500], fontSize: 13),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import '../../../../core/services/auth_service.dart';
|
import '../../../../core/services/auth_service.dart';
|
||||||
|
|
||||||
/// Página para o aluno entrar numa turma usando o código
|
/// Página para o aluno entrar numa disciplina usando o código
|
||||||
class JoinClassPage extends ConsumerStatefulWidget {
|
class JoinClassPage extends ConsumerStatefulWidget {
|
||||||
const JoinClassPage({super.key});
|
const JoinClassPage({super.key});
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ class _JoinClassPageState extends ConsumerState<JoinClassPage> {
|
|||||||
final code = _codeController.text.trim().toUpperCase();
|
final code = _codeController.text.trim().toUpperCase();
|
||||||
|
|
||||||
if (code.isEmpty) {
|
if (code.isEmpty) {
|
||||||
_showError('Insere o código da turma');
|
_showError('Insere o código da disciplina');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ class _JoinClassPageState extends ConsumerState<JoinClassPage> {
|
|||||||
final userRole = await AuthService.getUserRole(currentUser.uid);
|
final userRole = await AuthService.getUserRole(currentUser.uid);
|
||||||
if (userRole != 'student') {
|
if (userRole != 'student') {
|
||||||
setState(() => _isLoading = false);
|
setState(() => _isLoading = false);
|
||||||
_showError('Apenas alunos podem entrar em turmas por código.');
|
_showError('Apenas alunos podem entrar em disciplinas por código.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ class _JoinClassPageState extends ConsumerState<JoinClassPage> {
|
|||||||
currentUser.uid,
|
currentUser.uid,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Procurar turma pelo código
|
// Procurar disciplina pelo código
|
||||||
final classQuery = await FirebaseFirestore.instance
|
final classQuery = await FirebaseFirestore.instance
|
||||||
.collection('classes')
|
.collection('classes')
|
||||||
.where('code', isEqualTo: code)
|
.where('code', isEqualTo: code)
|
||||||
@@ -62,7 +62,7 @@ class _JoinClassPageState extends ConsumerState<JoinClassPage> {
|
|||||||
|
|
||||||
if (classQuery.docs.isEmpty) {
|
if (classQuery.docs.isEmpty) {
|
||||||
setState(() => _isLoading = false);
|
setState(() => _isLoading = false);
|
||||||
_showError('Código de turma inválido');
|
_showError('Código de disciplina inválido');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,20 +70,20 @@ class _JoinClassPageState extends ConsumerState<JoinClassPage> {
|
|||||||
final classId = classDoc.id;
|
final classId = classDoc.id;
|
||||||
final classSchoolClassId = classDoc.data()['schoolClassId'] as String?;
|
final classSchoolClassId = classDoc.data()['schoolClassId'] as String?;
|
||||||
|
|
||||||
// Verificar se o aluno está autorizado a entrar nesta turma
|
// Verificar se o aluno está autorizado a entrar nesta disciplina
|
||||||
// O schoolClassId do aluno deve corresponder ao schoolClassId da disciplina
|
// O schoolClassId do aluno deve corresponder ao schoolClassId da disciplina
|
||||||
if (studentSchoolClassId == null ||
|
if (studentSchoolClassId == null ||
|
||||||
classSchoolClassId == null ||
|
classSchoolClassId == null ||
|
||||||
studentSchoolClassId != classSchoolClassId) {
|
studentSchoolClassId != classSchoolClassId) {
|
||||||
setState(() => _isLoading = false);
|
setState(() => _isLoading = false);
|
||||||
_showError(
|
_showError(
|
||||||
'Não tens permissão para entrar nesta turma.\n'
|
'Não tens permissão para entrar nesta disciplina.\n'
|
||||||
'O teu professor ainda não te adicionou a esta disciplina.',
|
'O teu professor ainda não te adicionou a esta disciplina.',
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verificar se já está inscrito nesta turma
|
// Verificar se já está inscrito nesta disciplina
|
||||||
final existingEnrollment = await FirebaseFirestore.instance
|
final existingEnrollment = await FirebaseFirestore.instance
|
||||||
.collection('enrollments')
|
.collection('enrollments')
|
||||||
.where('classId', isEqualTo: classId)
|
.where('classId', isEqualTo: classId)
|
||||||
@@ -93,7 +93,7 @@ class _JoinClassPageState extends ConsumerState<JoinClassPage> {
|
|||||||
|
|
||||||
if (existingEnrollment.docs.isNotEmpty) {
|
if (existingEnrollment.docs.isNotEmpty) {
|
||||||
setState(() => _isLoading = false);
|
setState(() => _isLoading = false);
|
||||||
_showError('Já estás inscrito nesta turma');
|
_showError('Já estás inscrito nesta disciplina');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ class _JoinClassPageState extends ConsumerState<JoinClassPage> {
|
|||||||
children: [
|
children: [
|
||||||
Icon(Icons.check_circle, color: Colors.white),
|
Icon(Icons.check_circle, color: Colors.white),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
const Text('Entraste na turma com sucesso!'),
|
const Text('Entraste na disciplina com sucesso!'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
backgroundColor: colorScheme.primary,
|
backgroundColor: colorScheme.primary,
|
||||||
@@ -136,7 +136,7 @@ class _JoinClassPageState extends ConsumerState<JoinClassPage> {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() => _isLoading = false);
|
setState(() => _isLoading = false);
|
||||||
_showError('Erro ao entrar na turma: $e');
|
_showError('Erro ao entrar na disciplina: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ class _JoinClassPageState extends ConsumerState<JoinClassPage> {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Entrar numa Turma',
|
'Entrar numa Disciplina',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: colorScheme.onSurface,
|
color: colorScheme.onSurface,
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
@@ -272,7 +272,7 @@ class _JoinClassPageState extends ConsumerState<JoinClassPage> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
Text(
|
Text(
|
||||||
'Insere o código da turma',
|
'Insere o código da disciplina',
|
||||||
style: theme.textTheme.headlineSmall
|
style: theme.textTheme.headlineSmall
|
||||||
?.copyWith(
|
?.copyWith(
|
||||||
color: colorScheme.onSurface,
|
color: colorScheme.onSurface,
|
||||||
@@ -331,7 +331,7 @@ class _JoinClassPageState extends ConsumerState<JoinClassPage> {
|
|||||||
_buildInstructionItem(
|
_buildInstructionItem(
|
||||||
context,
|
context,
|
||||||
'1.',
|
'1.',
|
||||||
'Pedir ao professor o código da turma',
|
'Pedir ao professor o código da disciplina',
|
||||||
colorScheme,
|
colorScheme,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
@@ -345,7 +345,7 @@ class _JoinClassPageState extends ConsumerState<JoinClassPage> {
|
|||||||
_buildInstructionItem(
|
_buildInstructionItem(
|
||||||
context,
|
context,
|
||||||
'3.',
|
'3.',
|
||||||
'Clicar em "Entrar na Turma" para confirmar',
|
'Clicar em "Entrar na Disciplina" para confirmar',
|
||||||
colorScheme,
|
colorScheme,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -445,7 +445,7 @@ class _JoinClassPageState extends ConsumerState<JoinClassPage> {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(
|
||||||
'Entrar na Turma',
|
'Entrar na Disciplina',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
@@ -541,7 +541,7 @@ class _JoinClassPageState extends ConsumerState<JoinClassPage> {
|
|||||||
Icon(Icons.help_outline, color: colorScheme.primary),
|
Icon(Icons.help_outline, color: colorScheme.primary),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(
|
||||||
'Ajuda - Código da Turma',
|
'Ajuda - Código da Disciplina',
|
||||||
style: TextStyle(color: colorScheme.onSurface),
|
style: TextStyle(color: colorScheme.onSurface),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -551,7 +551,7 @@ class _JoinClassPageState extends ConsumerState<JoinClassPage> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'O código da turma é um código único de 6 caracteres que o teu professor cria para cada turma.',
|
'O código da disciplina é um código único de 6 caracteres que o teu professor cria para cada disciplina.',
|
||||||
style: TextStyle(color: colorScheme.onSurfaceVariant),
|
style: TextStyle(color: colorScheme.onSurfaceVariant),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../../../dashboard/presentation/widgets/teacher_classes_list_widget.dart';
|
import '../../../dashboard/presentation/widgets/teacher_classes_list_widget.dart';
|
||||||
|
|
||||||
/// Página dedicada para o professor ver todas as suas turmas
|
/// Página dedicada para o professor ver todas as suas disciplinas
|
||||||
/// Reutiliza o TeacherClassesListWidget existente
|
/// Reutiliza o TeacherClassesListWidget existente
|
||||||
class TeacherAllClassesPage extends StatelessWidget {
|
class TeacherAllClassesPage extends StatelessWidget {
|
||||||
const TeacherAllClassesPage({super.key});
|
const TeacherAllClassesPage({super.key});
|
||||||
@@ -18,7 +18,7 @@ class TeacherAllClassesPage extends StatelessWidget {
|
|||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
),
|
),
|
||||||
title: const Text(
|
title: const Text(
|
||||||
'As Minhas Turmas',
|
'As Minhas Disciplinas',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
@@ -30,10 +30,7 @@ class TeacherAllClassesPage extends StatelessWidget {
|
|||||||
padding: EdgeInsets.all(24.0),
|
padding: EdgeInsets.all(24.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [TeacherClassesListWidget(), SizedBox(height: 40)],
|
||||||
TeacherClassesListWidget(),
|
|
||||||
SizedBox(height: 40),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -78,8 +78,7 @@ class DashboardActionCard extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final titleColor = useGradient ? Colors.white : cs.onSurface;
|
final titleColor = useGradient ? Colors.white : cs.onSurface;
|
||||||
final subtitleColor =
|
final subtitleColor = useGradient ? Colors.white : cs.onSurfaceVariant;
|
||||||
useGradient ? Colors.white : cs.onSurfaceVariant;
|
|
||||||
final iconBgColor = useGradient
|
final iconBgColor = useGradient
|
||||||
? Colors.white.withOpacity(0.2)
|
? Colors.white.withOpacity(0.2)
|
||||||
: cs.primary.withOpacity(0.1);
|
: cs.primary.withOpacity(0.1);
|
||||||
@@ -246,7 +245,7 @@ class DashboardActionCard extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Surface-styled vertical card (Quiz, Criar Turma, etc.).
|
/// Surface-styled vertical card (Quiz, Criar Disciplina, etc.).
|
||||||
class DashboardActionCardSurface extends StatelessWidget {
|
class DashboardActionCardSurface extends StatelessWidget {
|
||||||
const DashboardActionCardSurface({
|
const DashboardActionCardSurface({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -291,7 +290,8 @@ class DashboardActionCardSurface extends StatelessWidget {
|
|||||||
minHeight: minHeight,
|
minHeight: minHeight,
|
||||||
useGradient: false,
|
useGradient: false,
|
||||||
iconSize: iconSize,
|
iconSize: iconSize,
|
||||||
leadingIcon: leadingWidget ??
|
leadingIcon:
|
||||||
|
leadingWidget ??
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ class _ProfileSectionWidgetState extends State<ProfileSectionWidget> {
|
|||||||
final achievements = results[1] as List<Achievement>;
|
final achievements = results[1] as List<Achievement>;
|
||||||
|
|
||||||
// Obter conquistas desbloqueadas recentemente
|
// Obter conquistas desbloqueadas recentemente
|
||||||
final unlockedAchievementIds = stats?.unlockedAchievements
|
final unlockedAchievementIds =
|
||||||
.map((ua) => ua.achievementId)
|
stats?.unlockedAchievements.map((ua) => ua.achievementId).toSet() ??
|
||||||
.toSet() ?? {};
|
{};
|
||||||
|
|
||||||
final recentUnlocked = achievements
|
final recentUnlocked = achievements
|
||||||
.where((a) => unlockedAchievementIds.contains(a.id))
|
.where((a) => unlockedAchievementIds.contains(a.id))
|
||||||
@@ -291,11 +291,11 @@ class _ProfileSectionWidgetState extends State<ProfileSectionWidget> {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
.animate()
|
.animate()
|
||||||
.slideY(
|
.fadeIn(
|
||||||
duration: const Duration(milliseconds: 800),
|
duration: const Duration(milliseconds: 300),
|
||||||
curve: Curves.easeOut,
|
curve: Curves.easeOut,
|
||||||
)
|
)
|
||||||
.then(delay: const Duration(milliseconds: 400));
|
.then(delay: const Duration(milliseconds: 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAchievementItem(
|
Widget _buildAchievementItem(
|
||||||
@@ -314,9 +314,7 @@ class _ProfileSectionWidgetState extends State<ProfileSectionWidget> {
|
|||||||
color: color.withValues(alpha: 0.1),
|
color: color.withValues(alpha: 0.1),
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(child: Icon(icon, color: color, size: 16)),
|
||||||
child: Icon(icon, color: color, size: 16),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -349,37 +347,54 @@ class _ProfileSectionWidgetState extends State<ProfileSectionWidget> {
|
|||||||
|
|
||||||
IconData _getIconData(String iconName) {
|
IconData _getIconData(String iconName) {
|
||||||
switch (iconName) {
|
switch (iconName) {
|
||||||
case 'emoji_events': return Icons.emoji_events;
|
case 'emoji_events':
|
||||||
case 'school': return Icons.school;
|
return Icons.emoji_events;
|
||||||
case 'local_fire_department': return Icons.local_fire_department;
|
case 'school':
|
||||||
case 'schedule': return Icons.schedule;
|
return Icons.school;
|
||||||
case 'trending_up': return Icons.trending_up;
|
case 'local_fire_department':
|
||||||
case 'military_tech': return Icons.military_tech;
|
return Icons.local_fire_department;
|
||||||
case 'workspace_premium': return Icons.workspace_premium;
|
case 'schedule':
|
||||||
case 'psychology': return Icons.psychology;
|
return Icons.schedule;
|
||||||
case 'lightbulb': return Icons.lightbulb;
|
case 'trending_up':
|
||||||
case 'star': return Icons.star;
|
return Icons.trending_up;
|
||||||
case 'speed': return Icons.speed;
|
case 'military_tech':
|
||||||
default: return Icons.star;
|
return Icons.military_tech;
|
||||||
|
case 'workspace_premium':
|
||||||
|
return Icons.workspace_premium;
|
||||||
|
case 'psychology':
|
||||||
|
return Icons.psychology;
|
||||||
|
case 'lightbulb':
|
||||||
|
return Icons.lightbulb;
|
||||||
|
case 'star':
|
||||||
|
return Icons.star;
|
||||||
|
case 'speed':
|
||||||
|
return Icons.speed;
|
||||||
|
default:
|
||||||
|
return Icons.star;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Color _getRarityColor(String rarity) {
|
Color _getRarityColor(String rarity) {
|
||||||
switch (rarity) {
|
switch (rarity) {
|
||||||
case 'common': return Colors.grey;
|
case 'common':
|
||||||
case 'rare': return Colors.blue;
|
return Colors.grey;
|
||||||
case 'epic': return Colors.purple;
|
case 'rare':
|
||||||
case 'legendary': return Colors.orange;
|
return Colors.blue;
|
||||||
default: return Colors.grey;
|
case 'epic':
|
||||||
|
return Colors.purple;
|
||||||
|
case 'legendary':
|
||||||
|
return Colors.orange;
|
||||||
|
default:
|
||||||
|
return Colors.grey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getProgressMessage() {
|
String _getProgressMessage() {
|
||||||
if (_userStats == null) return 'Continue estudando!';
|
if (_userStats == null) return 'Continue estudando!';
|
||||||
|
|
||||||
final streak = _userStats!.currentStreak;
|
final streak = _userStats!.currentStreak;
|
||||||
final studyTime = _userStats!.totalStudyTime;
|
final studyTime = _userStats!.totalStudyTime;
|
||||||
|
|
||||||
if (streak >= 7) return 'Incrível streak! 🔥';
|
if (streak >= 7) return 'Incrível streak! 🔥';
|
||||||
if (studyTime >= 300) return 'Dedicação exemplar! 📚';
|
if (studyTime >= 300) return 'Dedicação exemplar! 📚';
|
||||||
if (streak >= 3) return 'Bom progresso! 📈';
|
if (streak >= 3) return 'Bom progresso! 📈';
|
||||||
@@ -388,10 +403,10 @@ class _ProfileSectionWidgetState extends State<ProfileSectionWidget> {
|
|||||||
|
|
||||||
String _getProgressComparison() {
|
String _getProgressComparison() {
|
||||||
if (_userStats == null) return 'Comece sua jornada de estudos';
|
if (_userStats == null) return 'Comece sua jornada de estudos';
|
||||||
|
|
||||||
final weeklyTime = _userStats!.weeklyStudyTime;
|
final weeklyTime = _userStats!.weeklyStudyTime;
|
||||||
final concepts = _userStats!.masteredConcepts.length;
|
final concepts = _userStats!.masteredConcepts.length;
|
||||||
|
|
||||||
if (weeklyTime >= 180) return 'Você está 15% acima da média esta semana';
|
if (weeklyTime >= 180) return 'Você está 15% acima da média esta semana';
|
||||||
if (concepts >= 3) return 'Domine $concepts conceitos esta semana';
|
if (concepts >= 3) return 'Domine $concepts conceitos esta semana';
|
||||||
if (weeklyTime >= 60) return 'Bom tempo de estudo esta semana';
|
if (weeklyTime >= 60) return 'Bom tempo de estudo esta semana';
|
||||||
|
|||||||
@@ -10,10 +10,7 @@ import '../../../../core/services/auth_service.dart';
|
|||||||
class ProgressHeroWidget extends StatefulWidget {
|
class ProgressHeroWidget extends StatefulWidget {
|
||||||
final String userName;
|
final String userName;
|
||||||
|
|
||||||
const ProgressHeroWidget({
|
const ProgressHeroWidget({super.key, required this.userName});
|
||||||
super.key,
|
|
||||||
required this.userName,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ProgressHeroWidget> createState() => _ProgressHeroWidgetState();
|
State<ProgressHeroWidget> createState() => _ProgressHeroWidgetState();
|
||||||
@@ -28,11 +25,11 @@ class _ProgressHeroWidgetState extends State<ProgressHeroWidget> {
|
|||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
return _buildLoadingState();
|
return _buildLoadingState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snapshot.hasError) {
|
if (snapshot.hasError) {
|
||||||
return _buildErrorState();
|
return _buildErrorState();
|
||||||
}
|
}
|
||||||
|
|
||||||
final userStats = snapshot.data;
|
final userStats = snapshot.data;
|
||||||
return _buildContent(userStats);
|
return _buildContent(userStats);
|
||||||
},
|
},
|
||||||
@@ -71,10 +68,10 @@ class _ProgressHeroWidgetState extends State<ProgressHeroWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildContent(UserStats? userStats) {
|
Widget _buildContent(UserStats? userStats) {
|
||||||
|
|
||||||
final streakDays = userStats?.currentStreak ?? 0;
|
final streakDays = userStats?.currentStreak ?? 0;
|
||||||
final overallProgress = _calculateOverallProgress(userStats);
|
final overallProgress = _calculateOverallProgress(userStats);
|
||||||
final masteredConcepts = userStats?.masteredConcepts.map((c) => c.conceptName).toList() ?? [];
|
final masteredConcepts =
|
||||||
|
userStats?.masteredConcepts.map((c) => c.conceptName).toList() ?? [];
|
||||||
final studyTimeMinutes = userStats?.totalStudyTime ?? 0;
|
final studyTimeMinutes = userStats?.totalStudyTime ?? 0;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
@@ -236,9 +233,6 @@ class _ProgressHeroWidgetState extends State<ProgressHeroWidget> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
).animate().scale(
|
|
||||||
duration: const Duration(milliseconds: 600),
|
|
||||||
curve: Curves.elasticOut,
|
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
@@ -324,8 +318,8 @@ class _ProgressHeroWidgetState extends State<ProgressHeroWidget> {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
.animate()
|
.animate()
|
||||||
.slideX(
|
.fadeIn(
|
||||||
duration: const Duration(milliseconds: 800),
|
duration: const Duration(milliseconds: 300),
|
||||||
curve: Curves.easeOut,
|
curve: Curves.easeOut,
|
||||||
)
|
)
|
||||||
.then(delay: const Duration(milliseconds: 200)),
|
.then(delay: const Duration(milliseconds: 200)),
|
||||||
|
|||||||
@@ -4,138 +4,198 @@ import 'package:go_router/go_router.dart';
|
|||||||
import '../../../classes/presentation/pages/join_class_page.dart';
|
import '../../../classes/presentation/pages/join_class_page.dart';
|
||||||
import 'dashboard_action_card.dart';
|
import 'dashboard_action_card.dart';
|
||||||
|
|
||||||
/// Quick access cards for Tutor IA and Quiz
|
/// Quick access cards for Student Dashboard with horizontal scrollable row
|
||||||
class QuickAccessWidget extends StatelessWidget {
|
class QuickAccessWidget extends StatelessWidget {
|
||||||
const QuickAccessWidget({super.key});
|
const QuickAccessWidget({super.key});
|
||||||
|
|
||||||
|
/// Mesmas dimensões dos cards em "Ações Rápidas" do professor.
|
||||||
|
static const double _scrollCardWidth = 200;
|
||||||
|
static const double _scrollRowHeight = 150;
|
||||||
|
static const double _cardMinHeight = 150;
|
||||||
|
static const EdgeInsets _cardPadding = EdgeInsets.all(16);
|
||||||
|
static const double _titleFontSize = 16;
|
||||||
|
static const double _subtitleFontSize = 13;
|
||||||
|
static const double _iconSize = 24;
|
||||||
|
static const double _iconPadding = 10;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final cards = [
|
||||||
|
_buildTutorIACard(context),
|
||||||
|
_buildQuizCard(context),
|
||||||
|
_buildAchievementsCard(context),
|
||||||
|
_buildQuizManagementCard(context),
|
||||||
|
];
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
InkWell(
|
||||||
'Acesso Rápido',
|
onTap: () => _showQuickAccessList(context),
|
||||||
style: TextStyle(
|
borderRadius: BorderRadius.circular(8),
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
child: Padding(
|
||||||
fontSize: 20,
|
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
|
||||||
fontWeight: FontWeight.bold,
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Acesso Rápido',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Icon(
|
||||||
|
Icons.expand_more,
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 12),
|
||||||
Column(
|
IntrinsicHeight(
|
||||||
children: [
|
child: SingleChildScrollView(
|
||||||
IntrinsicHeight(
|
scrollDirection: Axis.horizontal,
|
||||||
child: Row(
|
clipBehavior: Clip.none,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
padding: const EdgeInsets.only(right: 16),
|
||||||
children: [
|
child: Row(
|
||||||
Expanded(
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
flex: 2,
|
children: [
|
||||||
child: _buildTutorIACard(context),
|
SizedBox(width: _scrollCardWidth, child: cards[0]),
|
||||||
),
|
const SizedBox(width: 12),
|
||||||
const SizedBox(width: 16),
|
SizedBox(width: _scrollCardWidth, child: cards[1]),
|
||||||
Expanded(
|
const SizedBox(width: 12),
|
||||||
flex: 2,
|
SizedBox(width: _scrollCardWidth, child: cards[2]),
|
||||||
child: _buildQuizCard(context),
|
const SizedBox(width: 12),
|
||||||
),
|
SizedBox(width: _scrollCardWidth, child: cards[3]),
|
||||||
const SizedBox(width: 16),
|
],
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: _buildAchievementsCard(context),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
_buildQuizManagementCard(context),
|
|
||||||
const SizedBox(height: 16),
|
// Entrar numa Disciplina (full width)
|
||||||
_buildJoinClassCard(context),
|
_buildJoinClassCard(context),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.animate()
|
.animate()
|
||||||
.slideY(
|
.fadeIn(
|
||||||
duration: const Duration(milliseconds: 800),
|
duration: const Duration(milliseconds: 300),
|
||||||
curve: Curves.easeOut,
|
curve: Curves.easeOut,
|
||||||
)
|
)
|
||||||
.then(delay: const Duration(milliseconds: 200));
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildTutorIACard(BuildContext context) {
|
|
||||||
return DashboardActionCard(
|
|
||||||
title: 'Tutor IA',
|
|
||||||
subtitle: 'Assistente de estudos',
|
|
||||||
icon: Icons.psychology,
|
|
||||||
useGradient: true,
|
|
||||||
minHeight: 150,
|
|
||||||
onTap: () => context.go('/ai-tutor'),
|
|
||||||
)
|
|
||||||
.animate()
|
|
||||||
.scale(
|
|
||||||
duration: const Duration(milliseconds: 600),
|
|
||||||
curve: Curves.elasticOut,
|
|
||||||
)
|
|
||||||
.then(delay: const Duration(milliseconds: 100));
|
.then(delay: const Duration(milliseconds: 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildTutorIACard(BuildContext context) {
|
||||||
|
return ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
child:
|
||||||
|
DashboardActionCard(
|
||||||
|
title: 'Tutor IA',
|
||||||
|
subtitle: 'Assistente de estudos',
|
||||||
|
icon: Icons.psychology,
|
||||||
|
useGradient: true,
|
||||||
|
minHeight: _cardMinHeight,
|
||||||
|
iconSize: _iconSize,
|
||||||
|
iconPadding: _iconPadding,
|
||||||
|
titleFontSize: _titleFontSize,
|
||||||
|
subtitleFontSize: _subtitleFontSize,
|
||||||
|
padding: _cardPadding,
|
||||||
|
onTap: () => context.go('/ai-tutor'),
|
||||||
|
)
|
||||||
|
.animate()
|
||||||
|
.fadeIn(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeOut,
|
||||||
|
)
|
||||||
|
.then(delay: const Duration(milliseconds: 100)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildQuizCard(BuildContext context) {
|
Widget _buildQuizCard(BuildContext context) {
|
||||||
final cs = Theme.of(context).colorScheme;
|
return ClipRRect(
|
||||||
return DashboardActionCardSurface(
|
borderRadius: BorderRadius.circular(16),
|
||||||
title: 'Quiz',
|
child:
|
||||||
subtitle: 'Testa os teus conhecimentos',
|
DashboardActionCardSurface(
|
||||||
icon: Icons.quiz,
|
title: 'Quiz',
|
||||||
minHeight: 150,
|
subtitle: 'Testa os teus conhecimentos',
|
||||||
iconColor: cs.secondary,
|
icon: Icons.quiz,
|
||||||
onTap: () => context.go('/quiz'),
|
minHeight: _cardMinHeight,
|
||||||
)
|
titleFontSize: _titleFontSize,
|
||||||
.animate()
|
subtitleFontSize: _subtitleFontSize,
|
||||||
.scale(
|
iconSize: _iconSize,
|
||||||
duration: const Duration(milliseconds: 600),
|
padding: _cardPadding,
|
||||||
curve: Curves.elasticOut,
|
onTap: () => context.go('/quiz'),
|
||||||
)
|
)
|
||||||
.then(delay: const Duration(milliseconds: 200));
|
.animate()
|
||||||
|
.fadeIn(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeOut,
|
||||||
|
)
|
||||||
|
.then(delay: const Duration(milliseconds: 150)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAchievementsCard(BuildContext context) {
|
Widget _buildAchievementsCard(BuildContext context) {
|
||||||
final cs = Theme.of(context).colorScheme;
|
return ClipRRect(
|
||||||
return DashboardActionCardSurface(
|
borderRadius: BorderRadius.circular(16),
|
||||||
title: 'Conquistas',
|
child:
|
||||||
subtitle: 'Ver medals',
|
DashboardActionCardSurface(
|
||||||
icon: Icons.emoji_events,
|
title: 'Conquistas',
|
||||||
minHeight: 150,
|
subtitle: 'Ver medals',
|
||||||
iconColor: Colors.amber,
|
icon: Icons.emoji_events,
|
||||||
onTap: () => context.go('/student/achievements'),
|
minHeight: _cardMinHeight,
|
||||||
)
|
titleFontSize: _titleFontSize,
|
||||||
.animate()
|
subtitleFontSize: _subtitleFontSize,
|
||||||
.scale(
|
iconSize: _iconSize,
|
||||||
duration: const Duration(milliseconds: 600),
|
padding: _cardPadding,
|
||||||
curve: Curves.elasticOut,
|
iconColor: Colors.amber,
|
||||||
)
|
onTap: () => context.go('/student/achievements'),
|
||||||
.then(delay: const Duration(milliseconds: 200));
|
)
|
||||||
|
.animate()
|
||||||
|
.fadeIn(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeOut,
|
||||||
|
)
|
||||||
|
.then(delay: const Duration(milliseconds: 200)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildQuizManagementCard(BuildContext context) {
|
Widget _buildQuizManagementCard(BuildContext context) {
|
||||||
final cs = Theme.of(context).colorScheme;
|
final cs = Theme.of(context).colorScheme;
|
||||||
return DashboardActionCardSurface(
|
return ClipRRect(
|
||||||
title: 'Gerenciar Quizzes',
|
borderRadius: BorderRadius.circular(16),
|
||||||
subtitle: 'Ver histórico ou eliminar',
|
child:
|
||||||
icon: Icons.manage_history,
|
DashboardActionCardSurface(
|
||||||
minHeight: 80,
|
title: 'Gerenciar Quizzes',
|
||||||
iconColor: cs.tertiary,
|
subtitle: 'Ver histórico ou eliminar',
|
||||||
onTap: () => context.go('/quiz-management'),
|
icon: Icons.manage_history,
|
||||||
)
|
minHeight: _cardMinHeight,
|
||||||
.animate()
|
titleFontSize: _titleFontSize,
|
||||||
.slideY(
|
subtitleFontSize: _subtitleFontSize,
|
||||||
duration: const Duration(milliseconds: 800),
|
iconSize: _iconSize,
|
||||||
curve: Curves.easeOut,
|
padding: _cardPadding,
|
||||||
)
|
iconColor: cs.tertiary,
|
||||||
.then(delay: const Duration(milliseconds: 200));
|
onTap: () => context.go('/quiz-management'),
|
||||||
|
)
|
||||||
|
.animate()
|
||||||
|
.fadeIn(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeOut,
|
||||||
|
)
|
||||||
|
.then(delay: const Duration(milliseconds: 250)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildJoinClassCard(BuildContext context) {
|
Widget _buildJoinClassCard(BuildContext context) {
|
||||||
return DashboardActionCard(
|
return DashboardActionCard(
|
||||||
title: 'Entrar numa Turma',
|
title: 'Entrar numa Disciplina',
|
||||||
subtitle: 'Junta-te a uma turma com o código',
|
subtitle: 'Junta-te a uma disciplina com o código',
|
||||||
icon: Icons.group_add,
|
icon: Icons.group_add,
|
||||||
layout: DashboardActionCardLayout.horizontal,
|
layout: DashboardActionCardLayout.horizontal,
|
||||||
minHeight: 0,
|
minHeight: 0,
|
||||||
@@ -147,10 +207,193 @@ class QuickAccessWidget extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.animate()
|
.animate()
|
||||||
.scale(
|
.fadeIn(
|
||||||
duration: const Duration(milliseconds: 600),
|
duration: const Duration(milliseconds: 300),
|
||||||
curve: Curves.elasticOut,
|
curve: Curves.easeOut,
|
||||||
)
|
)
|
||||||
.then(delay: const Duration(milliseconds: 300));
|
.then(delay: const Duration(milliseconds: 300));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _showQuickAccessList(BuildContext context) {
|
||||||
|
final items = [
|
||||||
|
_QuickAccessItem(
|
||||||
|
title: 'Tutor IA',
|
||||||
|
subtitle: 'Assistente de estudos',
|
||||||
|
icon: Icons.psychology,
|
||||||
|
useGradient: true,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
context.go('/ai-tutor');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
_QuickAccessItem(
|
||||||
|
title: 'Quiz',
|
||||||
|
subtitle: 'Testa os teus conhecimentos',
|
||||||
|
icon: Icons.quiz,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
context.go('/quiz');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
_QuickAccessItem(
|
||||||
|
title: 'Conquistas',
|
||||||
|
subtitle: 'Ver medals',
|
||||||
|
icon: Icons.emoji_events,
|
||||||
|
iconColor: Colors.amber,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
context.go('/student/achievements');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
_QuickAccessItem(
|
||||||
|
title: 'Gerenciar Quizzes',
|
||||||
|
subtitle: 'Ver histórico ou eliminar',
|
||||||
|
icon: Icons.manage_history,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
context.go('/quiz-management');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
_QuickAccessItem(
|
||||||
|
title: 'Entrar numa Disciplina',
|
||||||
|
subtitle: 'Junta-te a uma disciplina com o código',
|
||||||
|
icon: Icons.group_add,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (_) => const JoinClassPage()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
shape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||||
|
),
|
||||||
|
builder: (context) => DraggableScrollableSheet(
|
||||||
|
initialChildSize: 0.6,
|
||||||
|
minChildSize: 0.3,
|
||||||
|
maxChildSize: 0.9,
|
||||||
|
expand: false,
|
||||||
|
builder: (context, scrollController) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.only(top: 8),
|
||||||
|
width: 40,
|
||||||
|
height: 4,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey[300],
|
||||||
|
borderRadius: BorderRadius.circular(2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: Text(
|
||||||
|
'Acesso Rápido',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
controller: scrollController,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
itemCount: items.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final item = items[index];
|
||||||
|
return Card(
|
||||||
|
margin: const EdgeInsets.only(bottom: 12),
|
||||||
|
elevation: 0,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
side: BorderSide(
|
||||||
|
color: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.outline.withOpacity(0.2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: ListTile(
|
||||||
|
leading: Container(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: item.useGradient
|
||||||
|
? Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.primary.withOpacity(0.1)
|
||||||
|
: (item.iconColor ??
|
||||||
|
Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.secondary)
|
||||||
|
.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
item.icon,
|
||||||
|
color: item.useGradient
|
||||||
|
? Theme.of(context).colorScheme.primary
|
||||||
|
: (item.iconColor ??
|
||||||
|
Theme.of(context).colorScheme.secondary),
|
||||||
|
size: 24,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
item.title,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
item.subtitle,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.onSurfaceVariant,
|
||||||
|
fontSize: 13,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
trailing: Icon(
|
||||||
|
Icons.arrow_forward_ios,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
size: 16,
|
||||||
|
),
|
||||||
|
onTap: item.onTap,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _QuickAccessItem {
|
||||||
|
final String title;
|
||||||
|
final String subtitle;
|
||||||
|
final IconData icon;
|
||||||
|
final bool useGradient;
|
||||||
|
final Color? iconColor;
|
||||||
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
_QuickAccessItem({
|
||||||
|
required this.title,
|
||||||
|
required this.subtitle,
|
||||||
|
required this.icon,
|
||||||
|
this.useGradient = false,
|
||||||
|
this.iconColor,
|
||||||
|
required this.onTap,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,21 @@
|
|||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
import '../../../../core/services/auth_service.dart';
|
import '../../../../core/services/auth_service.dart';
|
||||||
|
|
||||||
/// Widget para listar as turmas onde o aluno está inscrito
|
/// Widget para listar as disciplinas onde o aluno está inscrito
|
||||||
class StudentClassesListWidget extends StatelessWidget {
|
class StudentClassesListWidget extends StatefulWidget {
|
||||||
const StudentClassesListWidget({super.key});
|
const StudentClassesListWidget({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StudentClassesListWidget> createState() =>
|
||||||
|
_StudentClassesListWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _StudentClassesListWidgetState extends State<StudentClassesListWidget> {
|
||||||
|
List<DocumentSnapshot>? _enrollments;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final currentUser = AuthService.currentUser;
|
final currentUser = AuthService.currentUser;
|
||||||
@@ -22,7 +31,8 @@ class StudentClassesListWidget extends StatelessWidget {
|
|||||||
.orderBy('joinedAt', descending: true)
|
.orderBy('joinedAt', descending: true)
|
||||||
.snapshots(),
|
.snapshots(),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
if (snapshot.connectionState == ConnectionState.waiting &&
|
||||||
|
_enrollments == null) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
@@ -33,17 +43,20 @@ class StudentClassesListWidget extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snapshot.hasError) {
|
if (snapshot.hasError && _enrollments == null) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|
||||||
final enrollments = snapshot.data?.docs ?? [];
|
final enrollments = snapshot.data?.docs ?? _enrollments ?? [];
|
||||||
|
if (snapshot.data?.docs != null) {
|
||||||
|
_enrollments = snapshot.data?.docs;
|
||||||
|
}
|
||||||
|
|
||||||
if (enrollments.isEmpty) {
|
if (enrollments.isEmpty) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Ainda não entraste em nenhuma turma.',
|
'Ainda não entraste em nenhuma disciplina.',
|
||||||
style: TextStyle(color: Colors.grey[600], fontSize: 14),
|
style: TextStyle(color: Colors.grey[600], fontSize: 14),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -52,11 +65,30 @@ class StudentClassesListWidget extends StatelessWidget {
|
|||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
InkWell(
|
||||||
'As Minhas Turmas',
|
onTap: () => _showClassesList(context, enrollments),
|
||||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
borderRadius: BorderRadius.circular(8),
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
child: Padding(
|
||||||
fontWeight: FontWeight.bold,
|
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'As Minhas Disciplinas',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Icon(
|
||||||
|
Icons.expand_more,
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
@@ -93,6 +125,7 @@ class StudentClassesListWidget extends StatelessWidget {
|
|||||||
Widget _buildClassCard(DocumentSnapshot enrollmentDoc) {
|
Widget _buildClassCard(DocumentSnapshot enrollmentDoc) {
|
||||||
final enrollmentData = enrollmentDoc.data() as Map<String, dynamic>;
|
final enrollmentData = enrollmentDoc.data() as Map<String, dynamic>;
|
||||||
final classId = enrollmentData['classId'] as String? ?? '';
|
final classId = enrollmentData['classId'] as String? ?? '';
|
||||||
|
final enrollmentId = enrollmentDoc.id;
|
||||||
|
|
||||||
if (classId.isEmpty) {
|
if (classId.isEmpty) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
@@ -133,60 +166,341 @@ class StudentClassesListWidget extends StatelessWidget {
|
|||||||
final className = classData['name'] as String? ?? 'Sem nome';
|
final className = classData['name'] as String? ?? 'Sem nome';
|
||||||
final classCode = classData['code'] as String? ?? '----';
|
final classCode = classData['code'] as String? ?? '----';
|
||||||
|
|
||||||
return Container(
|
return GestureDetector(
|
||||||
width: 200,
|
onTap: () => _showRemoveClassDialog(context, enrollmentId, className),
|
||||||
constraints: const BoxConstraints(minHeight: 150),
|
child: Container(
|
||||||
padding: const EdgeInsets.all(16),
|
width: 200,
|
||||||
decoration: BoxDecoration(
|
constraints: const BoxConstraints(minHeight: 150),
|
||||||
color: Theme.of(context).colorScheme.surface,
|
padding: const EdgeInsets.all(16),
|
||||||
borderRadius: BorderRadius.circular(16),
|
decoration: BoxDecoration(
|
||||||
boxShadow: [
|
color: Theme.of(context).colorScheme.surface,
|
||||||
BoxShadow(
|
borderRadius: BorderRadius.circular(16),
|
||||||
color: Theme.of(context).colorScheme.shadow.withOpacity(0.05),
|
boxShadow: [
|
||||||
blurRadius: 10,
|
BoxShadow(
|
||||||
offset: const Offset(0, 4),
|
color: Theme.of(context).colorScheme.shadow.withOpacity(0.05),
|
||||||
),
|
blurRadius: 10,
|
||||||
],
|
offset: const Offset(0, 4),
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(10),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context).colorScheme.primary.withOpacity(0.1),
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
),
|
||||||
child: Icon(
|
],
|
||||||
Icons.school,
|
),
|
||||||
color: Theme.of(context).colorScheme.primary,
|
child: Column(
|
||||||
size: 24,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.primary.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
Icons.school,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
size: 24,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 12),
|
||||||
const SizedBox(height: 12),
|
Text(
|
||||||
Text(
|
className,
|
||||||
className,
|
style: TextStyle(
|
||||||
style: TextStyle(
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
fontSize: 16,
|
||||||
fontSize: 16,
|
fontWeight: FontWeight.bold,
|
||||||
fontWeight: FontWeight.bold,
|
),
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
maxLines: 2,
|
const SizedBox(height: 4),
|
||||||
overflow: TextOverflow.ellipsis,
|
Text(
|
||||||
),
|
'Código: $classCode',
|
||||||
const SizedBox(height: 4),
|
style: TextStyle(
|
||||||
Text(
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
'Código: $classCode',
|
fontSize: 13,
|
||||||
style: TextStyle(
|
),
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
||||||
fontSize: 13,
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _showClassesList(
|
||||||
|
BuildContext context,
|
||||||
|
List<DocumentSnapshot> enrollments,
|
||||||
|
) {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
shape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||||
|
),
|
||||||
|
builder: (context) => DraggableScrollableSheet(
|
||||||
|
initialChildSize: 0.6,
|
||||||
|
minChildSize: 0.3,
|
||||||
|
maxChildSize: 0.9,
|
||||||
|
expand: false,
|
||||||
|
builder: (context, scrollController) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.only(top: 8),
|
||||||
|
width: 40,
|
||||||
|
height: 4,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey[300],
|
||||||
|
borderRadius: BorderRadius.circular(2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: Text(
|
||||||
|
'As Minhas Disciplinas',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
controller: scrollController,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
itemCount: enrollments.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return _buildClassListTile(context, enrollments[index]);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildClassListTile(
|
||||||
|
BuildContext context,
|
||||||
|
DocumentSnapshot enrollmentDoc,
|
||||||
|
) {
|
||||||
|
final enrollmentData = enrollmentDoc.data() as Map<String, dynamic>;
|
||||||
|
final classId = enrollmentData['classId'] as String? ?? '';
|
||||||
|
final enrollmentId = enrollmentDoc.id;
|
||||||
|
|
||||||
|
if (classId.isEmpty) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
|
||||||
|
return FutureBuilder<DocumentSnapshot>(
|
||||||
|
future: FirebaseFirestore.instance
|
||||||
|
.collection('classes')
|
||||||
|
.doc(classId)
|
||||||
|
.get(),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (!snapshot.hasData || !snapshot.data!.exists) {
|
||||||
|
return const Card(
|
||||||
|
child: ListTile(
|
||||||
|
leading: CircularProgressIndicator(),
|
||||||
|
title: Text('Carregando...'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final classData = snapshot.data!.data() as Map<String, dynamic>;
|
||||||
|
final className = classData['name'] as String? ?? 'Sem nome';
|
||||||
|
final classCode = classData['code'] as String? ?? '----';
|
||||||
|
|
||||||
|
return Card(
|
||||||
|
margin: const EdgeInsets.only(bottom: 12),
|
||||||
|
elevation: 0,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
side: BorderSide(
|
||||||
|
color: Theme.of(context).colorScheme.outline.withOpacity(0.2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: ListTile(
|
||||||
|
leading: Container(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.primary.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
Icons.school,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
size: 24,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
className,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
'Código: $classCode',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
fontSize: 13,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
trailing: Icon(
|
||||||
|
Icons.delete_outline,
|
||||||
|
color: Theme.of(context).colorScheme.error,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
onTap: () =>
|
||||||
|
_showRemoveClassDialog(context, enrollmentId, className),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showRemoveClassDialog(
|
||||||
|
BuildContext context,
|
||||||
|
String enrollmentId,
|
||||||
|
String className,
|
||||||
|
) {
|
||||||
|
final textController = TextEditingController();
|
||||||
|
bool isConfirmEnabled = false;
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => StatefulBuilder(
|
||||||
|
builder: (context, setDialogState) {
|
||||||
|
return AlertDialog(
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
title: const Text('Sair da disciplina'),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Para confirmar que queres sair da disciplina "$className", escreve o nome desta disciplina:',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextField(
|
||||||
|
controller: textController,
|
||||||
|
onChanged: (value) {
|
||||||
|
setDialogState(() {
|
||||||
|
isConfirmEnabled = value.trim() == className.trim();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Nome da disciplina',
|
||||||
|
filled: true,
|
||||||
|
fillColor: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.surfaceContainerHighest,
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
borderSide: BorderSide.none,
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
borderSide: BorderSide.none,
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'Esta ação não pode ser desfeita.',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.error,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: Text(
|
||||||
|
'Cancelar',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: isConfirmEnabled
|
||||||
|
? () async {
|
||||||
|
Navigator.pop(context);
|
||||||
|
await _removeEnrollment(enrollmentId);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.error,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
disabledBackgroundColor: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.error.withOpacity(0.3),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const Text('Sair'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _removeEnrollment(String enrollmentId) async {
|
||||||
|
try {
|
||||||
|
await FirebaseFirestore.instance
|
||||||
|
.collection('enrollments')
|
||||||
|
.doc(enrollmentId)
|
||||||
|
.delete();
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: const Text('Saíste da disciplina com sucesso'),
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('Erro ao sair da disciplina: $e'),
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,311 +1,243 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
||||||
|
|
||||||
import '../../../../core/theme/app_theme_extension.dart';
|
import '../../../../core/theme/app_theme_extension.dart';
|
||||||
import 'package:flutter_animate/flutter_animate.dart';
|
|
||||||
import '../../../../core/services/auth_service.dart';
|
import '../../../../core/services/auth_service.dart';
|
||||||
import '../../../../core/services/gamification_service.dart';
|
|
||||||
import '../../../../core/models/class_stats.dart';
|
|
||||||
|
|
||||||
/// Analytics preview section for teacher dashboard
|
/// Analytics preview section for teacher dashboard
|
||||||
class TeacherAnalyticsPreviewWidget extends StatefulWidget {
|
class TeacherAnalyticsPreviewWidget extends StatelessWidget {
|
||||||
const TeacherAnalyticsPreviewWidget({super.key});
|
const TeacherAnalyticsPreviewWidget({super.key});
|
||||||
|
|
||||||
@override
|
|
||||||
State<TeacherAnalyticsPreviewWidget> createState() => _TeacherAnalyticsPreviewWidgetState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _TeacherAnalyticsPreviewWidgetState extends State<TeacherAnalyticsPreviewWidget> {
|
|
||||||
List<ClassStats> _classStats = [];
|
|
||||||
List<StudentRanking> _topStudents = [];
|
|
||||||
bool _loading = true;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_loadAnalyticsData();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _loadAnalyticsData() async {
|
|
||||||
try {
|
|
||||||
final user = AuthService.currentUser;
|
|
||||||
if (user == null) return;
|
|
||||||
|
|
||||||
// Obter turmas do professor
|
|
||||||
final classesSnapshot = await FirebaseFirestore.instance
|
|
||||||
.collection('classes')
|
|
||||||
.where('teacherId', isEqualTo: user.uid)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
final classStatsList = <ClassStats>[];
|
|
||||||
|
|
||||||
for (final classDoc in classesSnapshot.docs) {
|
|
||||||
final classId = classDoc.id;
|
|
||||||
// Forçar atualização para obter dados mais recentes
|
|
||||||
final stats = await GamificationService.getClassStats(classId, forceRefresh: true);
|
|
||||||
if (stats != null) {
|
|
||||||
classStatsList.add(stats);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obter melhores alunos de todas as turmas
|
|
||||||
final allTopStudents = <StudentRanking>[];
|
|
||||||
for (final classStats in classStatsList) {
|
|
||||||
final ranking = await GamificationService.getClassRanking(classStats.classId);
|
|
||||||
allTopStudents.addAll(ranking.take(3)); // Top 3 de cada turma
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ordenar por score e pegar os melhores
|
|
||||||
allTopStudents.sort((a, b) => b.overallScore.compareTo(a.overallScore));
|
|
||||||
final topStudents = allTopStudents.take(4).toList();
|
|
||||||
|
|
||||||
if (mounted) {
|
|
||||||
setState(() {
|
|
||||||
_classStats = classStatsList;
|
|
||||||
_topStudents = topStudents;
|
|
||||||
_loading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
print('Error loading analytics data: $e');
|
|
||||||
if (mounted) {
|
|
||||||
setState(() {
|
|
||||||
_loading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int get totalStudents => _classStats.fold(0, (sum, stats) => sum + stats.totalStudents);
|
|
||||||
int get activeStudents => _classStats.fold(0, (sum, stats) => sum + stats.activeStudents);
|
|
||||||
double get averageProgress {
|
|
||||||
if (_classStats.isEmpty) return 0.0;
|
|
||||||
final totalProgress = _classStats.fold(0.0, (sum, stats) => sum + stats.averageProgress);
|
|
||||||
return totalProgress / _classStats.length;
|
|
||||||
}
|
|
||||||
int get studentsNeedingSupport => _classStats.fold(0, (sum, stats) => sum + stats.studentsNeedingSupport.length);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (_loading) {
|
|
||||||
return const Center(child: CircularProgressIndicator());
|
|
||||||
}
|
|
||||||
|
|
||||||
final user = AuthService.currentUser;
|
final user = AuthService.currentUser;
|
||||||
final userName = user?.displayName ?? 'Professor';
|
final userName = user?.displayName ?? 'Professor';
|
||||||
final userEmail = user?.email ?? '';
|
final userEmail = user?.email ?? '';
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.only(top: 24),
|
margin: const EdgeInsets.only(top: 24),
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.all(20),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Theme.of(context).colorScheme.outline.withOpacity(0.2),
|
color: Theme.of(context).colorScheme.outline.withOpacity(0.2),
|
||||||
),
|
),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Theme.of(context).colorScheme.shadow.withOpacity(0.05),
|
color: Theme.of(context).colorScheme.shadow.withOpacity(0.05),
|
||||||
blurRadius: 10,
|
blurRadius: 10,
|
||||||
offset: const Offset(0, 4),
|
offset: const Offset(0, 4),
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
child: Column(
|
],
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// Profile Header
|
||||||
|
Row(
|
||||||
children: [
|
children: [
|
||||||
// Profile Header
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: 48,
|
|
||||||
height: 48,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
gradient: LinearGradient(
|
|
||||||
colors: [
|
|
||||||
AppThemeExtras.of(context).actionCardGradientStart,
|
|
||||||
AppThemeExtras.of(context).actionCardGradientEnd,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(24),
|
|
||||||
),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.school,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 24,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 16),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
userName,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 2),
|
|
||||||
SingleChildScrollView(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
userEmail,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(
|
|
||||||
context,
|
|
||||||
).colorScheme.onSurfaceVariant,
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (userEmail.length > 20) ...[
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Icon(
|
|
||||||
Icons.more_horiz,
|
|
||||||
color: Theme.of(
|
|
||||||
context,
|
|
||||||
).colorScheme.onSurfaceVariant,
|
|
||||||
size: 16,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
|
|
||||||
// Quick Stats Row
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
_buildQuickStat(
|
|
||||||
icon: Icons.check_circle,
|
|
||||||
label: 'Alunos Ativos',
|
|
||||||
value: '$activeStudents/$totalStudents',
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
_buildQuickStat(
|
|
||||||
icon: Icons.warning_amber,
|
|
||||||
label: 'Precisam Apoio',
|
|
||||||
value: '$studentsNeedingSupport',
|
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
_buildQuickStat(
|
|
||||||
icon: Icons.emoji_events,
|
|
||||||
label: 'Média Turma',
|
|
||||||
value: '${(averageProgress * 100).toInt()}%',
|
|
||||||
color: Theme.of(
|
|
||||||
context,
|
|
||||||
).colorScheme.primary.withValues(alpha: 0.8),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
|
|
||||||
// Top Performing Students Preview
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.leaderboard,
|
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Text(
|
|
||||||
'Melhores Desempenhos',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
|
|
||||||
// Student List Preview
|
|
||||||
..._topStudents.map((student) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 8),
|
|
||||||
child: _buildStudentPerformanceItem(
|
|
||||||
context,
|
|
||||||
student.studentName,
|
|
||||||
student.overallScore.toInt(),
|
|
||||||
_getScoreColor(student.overallScore),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
|
|
||||||
// Content Quality Alert
|
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(16),
|
width: 48,
|
||||||
|
height: 48,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
gradient: LinearGradient(
|
||||||
borderRadius: BorderRadius.circular(12),
|
colors: [
|
||||||
border: Border.all(
|
AppThemeExtras.of(context).actionCardGradientStart,
|
||||||
color: Theme.of(
|
AppThemeExtras.of(context).actionCardGradientEnd,
|
||||||
context,
|
],
|
||||||
).colorScheme.outline.withOpacity(0.2),
|
|
||||||
),
|
),
|
||||||
|
borderRadius: BorderRadius.circular(24),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: const Icon(Icons.school, color: Colors.white, size: 24),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Text(
|
||||||
Icons.info_outline,
|
userName,
|
||||||
color: Theme.of(context).colorScheme.primary,
|
style: TextStyle(
|
||||||
size: 20,
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(height: 2),
|
||||||
Expanded(
|
SingleChildScrollView(
|
||||||
child: Column(
|
scrollDirection: Axis.horizontal,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Qualidade do Conteúdo',
|
userEmail,
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 2),
|
|
||||||
Text(
|
|
||||||
'${_classStats.fold(0, (sum, stats) => sum + stats.totalContent)} conteúdos • $studentsNeedingSupport alunos precisam de apoio',
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(
|
color: Theme.of(
|
||||||
context,
|
context,
|
||||||
).colorScheme.onSurfaceVariant,
|
).colorScheme.onSurfaceVariant,
|
||||||
fontSize: 12,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (userEmail.length > 20) ...[
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Icon(
|
||||||
|
Icons.more_horiz,
|
||||||
|
color: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.onSurfaceVariant,
|
||||||
|
size: 16,
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.secondary.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
Icons.settings,
|
||||||
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
const SizedBox(height: 20),
|
||||||
.animate()
|
|
||||||
.slideY(
|
// Quick Stats Row
|
||||||
duration: const Duration(milliseconds: 800),
|
Row(
|
||||||
curve: Curves.easeOut,
|
children: [
|
||||||
)
|
_buildQuickStat(
|
||||||
.then(delay: const Duration(milliseconds: 400));
|
icon: Icons.check_circle,
|
||||||
|
label: 'Alunos Ativos',
|
||||||
|
value: '18/24',
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
_buildQuickStat(
|
||||||
|
icon: Icons.warning_amber,
|
||||||
|
label: 'Precisam Apoio',
|
||||||
|
value: '3',
|
||||||
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
_buildQuickStat(
|
||||||
|
icon: Icons.emoji_events,
|
||||||
|
label: 'Média Disciplina',
|
||||||
|
value: '72%',
|
||||||
|
color: Theme.of(context).colorScheme.primary.withOpacity(0.8),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
|
// Top Performing Students Preview
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.leaderboard,
|
||||||
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
'Melhores Desempenhos',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
|
||||||
|
// Student List Preview
|
||||||
|
_buildStudentPerformanceItem(
|
||||||
|
context,
|
||||||
|
'Ana Silva',
|
||||||
|
95,
|
||||||
|
Theme.of(context).colorScheme.tertiary,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
_buildStudentPerformanceItem(
|
||||||
|
context,
|
||||||
|
'João Costa',
|
||||||
|
88,
|
||||||
|
Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
_buildStudentPerformanceItem(
|
||||||
|
context,
|
||||||
|
'Maria Santos',
|
||||||
|
82,
|
||||||
|
Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
_buildStudentPerformanceItem(
|
||||||
|
context,
|
||||||
|
'Pedro Lima',
|
||||||
|
45,
|
||||||
|
Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
|
// Content Quality Alert
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(
|
||||||
|
color: Theme.of(context).colorScheme.outline.withOpacity(0.2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.info_outline,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Qualidade do Conteúdo',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Text(
|
||||||
|
'12 conteúdos verificados • 2 pendentes de revisão',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildQuickStat({
|
Widget _buildQuickStat({
|
||||||
@@ -401,11 +333,4 @@ class _TeacherAnalyticsPreviewWidgetState extends State<TeacherAnalyticsPreviewW
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color _getScoreColor(double score) {
|
|
||||||
if (score >= 80) return Theme.of(context).colorScheme.tertiary;
|
|
||||||
if (score >= 60) return Theme.of(context).colorScheme.primary;
|
|
||||||
if (score >= 40) return Theme.of(context).colorScheme.secondary;
|
|
||||||
return Theme.of(context).colorScheme.error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
import '../../../../core/services/auth_service.dart';
|
import '../../../../core/services/auth_service.dart';
|
||||||
import '../../../classes/presentation/pages/class_students_page.dart';
|
import '../../../classes/presentation/pages/class_students_page.dart';
|
||||||
|
|
||||||
/// Widget para listar as turmas criadas pelo professor
|
/// Widget para listar as disciplinas criadas pelo professor
|
||||||
class TeacherClassesListWidget extends StatelessWidget {
|
class TeacherClassesListWidget extends StatelessWidget {
|
||||||
const TeacherClassesListWidget({super.key});
|
const TeacherClassesListWidget({super.key});
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ class TeacherClassesListWidget extends StatelessWidget {
|
|||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Ainda não criaste nenhuma turma.',
|
'Ainda não criaste nenhuma disciplina.',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
@@ -57,7 +57,7 @@ class TeacherClassesListWidget extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'As Minhas Turmas',
|
'As Minhas Disciplinas',
|
||||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_animate/flutter_animate.dart';
|
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
|
||||||
import '../../../../core/theme/app_theme_extension.dart';
|
import '../../../../core/theme/app_theme_extension.dart';
|
||||||
@@ -11,10 +10,7 @@ import '../../../../core/services/auth_service.dart';
|
|||||||
class TeacherHeroWidget extends StatefulWidget {
|
class TeacherHeroWidget extends StatefulWidget {
|
||||||
final String userName;
|
final String userName;
|
||||||
|
|
||||||
const TeacherHeroWidget({
|
const TeacherHeroWidget({super.key, required this.userName});
|
||||||
super.key,
|
|
||||||
required this.userName,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<TeacherHeroWidget> createState() => _TeacherHeroWidgetState();
|
State<TeacherHeroWidget> createState() => _TeacherHeroWidgetState();
|
||||||
@@ -35,18 +31,21 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
|
|||||||
final user = AuthService.currentUser;
|
final user = AuthService.currentUser;
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
|
||||||
// Obter turmas do professor
|
// Obter disciplinas do professor
|
||||||
final classesSnapshot = await FirebaseFirestore.instance
|
final classesSnapshot = await FirebaseFirestore.instance
|
||||||
.collection('classes')
|
.collection('classes')
|
||||||
.where('teacherId', isEqualTo: user.uid)
|
.where('teacherId', isEqualTo: user.uid)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
final classStatsList = <ClassStats>[];
|
final classStatsList = <ClassStats>[];
|
||||||
|
|
||||||
for (final classDoc in classesSnapshot.docs) {
|
for (final classDoc in classesSnapshot.docs) {
|
||||||
final classId = classDoc.id;
|
final classId = classDoc.id;
|
||||||
// Forçar atualização para obter dados mais recentes
|
// Forçar atualização para obter dados mais recentes
|
||||||
final stats = await GamificationService.getClassStats(classId, forceRefresh: true);
|
final stats = await GamificationService.getClassStats(
|
||||||
|
classId,
|
||||||
|
forceRefresh: true,
|
||||||
|
);
|
||||||
if (stats != null) {
|
if (stats != null) {
|
||||||
classStatsList.add(stats);
|
classStatsList.add(stats);
|
||||||
}
|
}
|
||||||
@@ -68,23 +67,31 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int get totalStudents => _classStats.fold(0, (sum, stats) => sum + stats.totalStudents);
|
int get totalStudents =>
|
||||||
int get activeQuizzes => _classStats.fold(0, (sum, stats) => sum + stats.activeQuizzes);
|
_classStats.fold(0, (sum, stats) => sum + stats.totalStudents);
|
||||||
int get uploadedContent => _classStats.fold(0, (sum, stats) => sum + stats.totalContent);
|
int get activeQuizzes =>
|
||||||
|
_classStats.fold(0, (sum, stats) => sum + stats.activeQuizzes);
|
||||||
|
int get uploadedContent =>
|
||||||
|
_classStats.fold(0, (sum, stats) => sum + stats.totalContent);
|
||||||
double get classAverageProgress {
|
double get classAverageProgress {
|
||||||
if (_classStats.isEmpty) return 0.0;
|
if (_classStats.isEmpty) return 0.0;
|
||||||
final totalProgress = _classStats.fold(0.0, (sum, stats) => sum + stats.averageProgress);
|
final totalProgress = _classStats.fold(
|
||||||
|
0.0,
|
||||||
|
(sum, stats) => sum + stats.averageProgress,
|
||||||
|
);
|
||||||
final average = totalProgress / _classStats.length;
|
final average = totalProgress / _classStats.length;
|
||||||
|
|
||||||
print('=== UI PROGRESS DEBUG ===');
|
print('=== UI PROGRESS DEBUG ===');
|
||||||
print('Number of classes: ${_classStats.length}');
|
print('Number of classes: ${_classStats.length}');
|
||||||
for (int i = 0; i < _classStats.length; i++) {
|
for (int i = 0; i < _classStats.length; i++) {
|
||||||
print('Class ${i + 1}: ${_classStats[i].className} - ${_classStats[i].averageProgress} (${(_classStats[i].averageProgress * 100).toInt()}%)');
|
print(
|
||||||
|
'Class ${i + 1}: ${_classStats[i].className} - ${_classStats[i].averageProgress} (${(_classStats[i].averageProgress * 100).toInt()}%)',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
print('Total progress sum: $totalProgress');
|
print('Total progress sum: $totalProgress');
|
||||||
print('Calculated average: $average (${(average * 100).toInt()}%)');
|
print('Calculated average: $average (${(average * 100).toInt()}%)');
|
||||||
print('=== END UI PROGRESS DEBUG ===');
|
print('=== END UI PROGRESS DEBUG ===');
|
||||||
|
|
||||||
return average;
|
return average;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +116,7 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Visão Geral da Turma',
|
'Visão Geral da Disciplina',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
@@ -186,7 +193,7 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
|
|||||||
children: [
|
children: [
|
||||||
const Flexible(
|
const Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Progresso Médio da Turma',
|
'Progresso Médio da Disciplina',
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@@ -198,7 +205,8 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
|
|||||||
),
|
),
|
||||||
Builder(
|
Builder(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
final displayValue = (classAverageProgress * 100).toInt();
|
final displayValue = (classAverageProgress * 100)
|
||||||
|
.toInt();
|
||||||
print('=== RENDER DEBUG ===');
|
print('=== RENDER DEBUG ===');
|
||||||
print('classAverageProgress: $classAverageProgress');
|
print('classAverageProgress: $classAverageProgress');
|
||||||
print('displayValue: $displayValue%');
|
print('displayValue: $displayValue%');
|
||||||
@@ -264,66 +272,53 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
).animate().scale(
|
|
||||||
duration: const Duration(milliseconds: 600),
|
|
||||||
curve: Curves.elasticOut,
|
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
// Recent Activity
|
// Recent Activity
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.all(20),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Theme.of(
|
color: Theme.of(context).colorScheme.outline.withOpacity(0.2),
|
||||||
context,
|
),
|
||||||
).colorScheme.outline.withOpacity(0.2),
|
boxShadow: [
|
||||||
),
|
BoxShadow(
|
||||||
boxShadow: [
|
color: Theme.of(context).colorScheme.shadow.withOpacity(0.05),
|
||||||
BoxShadow(
|
blurRadius: 10,
|
||||||
color: Theme.of(
|
offset: const Offset(0, 4),
|
||||||
context,
|
|
||||||
).colorScheme.shadow.withOpacity(0.05),
|
|
||||||
blurRadius: 10,
|
|
||||||
offset: const Offset(0, 4),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
child: Column(
|
],
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Icon(
|
||||||
children: [
|
Icons.trending_up,
|
||||||
Icon(
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
Icons.trending_up,
|
size: 20,
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
),
|
||||||
size: 20,
|
const SizedBox(width: 8),
|
||||||
),
|
Text(
|
||||||
const SizedBox(width: 8),
|
'Atividade Recente',
|
||||||
Text(
|
style: TextStyle(
|
||||||
'Atividade Recente',
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
style: TextStyle(
|
fontSize: 16,
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 16,
|
),
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
|
||||||
..._buildRecentActivities(),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
const SizedBox(height: 12),
|
||||||
.animate()
|
..._buildRecentActivities(),
|
||||||
.slideX(
|
],
|
||||||
duration: const Duration(milliseconds: 800),
|
),
|
||||||
curve: Curves.easeOut,
|
),
|
||||||
)
|
|
||||||
.then(delay: const Duration(milliseconds: 200)),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -368,46 +363,54 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
|
|||||||
|
|
||||||
List<Widget> _buildRecentActivities() {
|
List<Widget> _buildRecentActivities() {
|
||||||
final activities = <Widget>[];
|
final activities = <Widget>[];
|
||||||
|
|
||||||
if (_classStats.isEmpty) {
|
if (_classStats.isEmpty) {
|
||||||
activities.add(_buildActivityItem(
|
activities.add(
|
||||||
context,
|
_buildActivityItem(
|
||||||
'Nenhuma atividade recente',
|
context,
|
||||||
'Comece criando turmas e conteúdos',
|
'Nenhuma atividade recente',
|
||||||
Theme.of(context).colorScheme.onSurfaceVariant,
|
'Comece criando disciplinas e conteúdos',
|
||||||
));
|
Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
);
|
||||||
return activities;
|
return activities;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adicionar atividades baseadas nas estatísticas das turmas
|
// Adicionar atividades baseadas nas estatísticas das disciplinas
|
||||||
for (final stats in _classStats.take(3)) {
|
for (final stats in _classStats.take(3)) {
|
||||||
if (stats.activeQuizzes > 0) {
|
if (stats.activeQuizzes > 0) {
|
||||||
activities.add(_buildActivityItem(
|
activities.add(
|
||||||
context,
|
_buildActivityItem(
|
||||||
'${stats.activeQuizzes} quizzes ativos em ${stats.className}',
|
context,
|
||||||
'Recente',
|
'${stats.activeQuizzes} quizzes ativos em ${stats.className}',
|
||||||
Theme.of(context).colorScheme.primary,
|
'Recente',
|
||||||
));
|
Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
);
|
||||||
activities.add(const SizedBox(height: 8));
|
activities.add(const SizedBox(height: 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stats.studentsNeedingSupport.isNotEmpty) {
|
if (stats.studentsNeedingSupport.isNotEmpty) {
|
||||||
activities.add(_buildActivityItem(
|
activities.add(
|
||||||
context,
|
_buildActivityItem(
|
||||||
'${stats.studentsNeedingSupport.length} alunos precisam de apoio em ${stats.className}',
|
context,
|
||||||
'Ver analytics',
|
'${stats.studentsNeedingSupport.length} alunos precisam de apoio em ${stats.className}',
|
||||||
Theme.of(context).colorScheme.error,
|
'Ver analytics',
|
||||||
));
|
Theme.of(context).colorScheme.error,
|
||||||
|
),
|
||||||
|
);
|
||||||
activities.add(const SizedBox(height: 8));
|
activities.add(const SizedBox(height: 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stats.totalContent > 0) {
|
if (stats.totalContent > 0) {
|
||||||
activities.add(_buildActivityItem(
|
activities.add(
|
||||||
context,
|
_buildActivityItem(
|
||||||
'${stats.totalContent} conteúdos disponíveis em ${stats.className}',
|
context,
|
||||||
'Atualizado',
|
'${stats.totalContent} conteúdos disponíveis em ${stats.className}',
|
||||||
Theme.of(context).colorScheme.secondary,
|
'Atualizado',
|
||||||
));
|
Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
);
|
||||||
activities.add(const SizedBox(height: 8));
|
activities.add(const SizedBox(height: 8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -417,14 +420,16 @@ class _TeacherHeroWidgetState extends State<TeacherHeroWidget> {
|
|||||||
activities.removeLast();
|
activities.removeLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
return activities.isEmpty ? [
|
return activities.isEmpty
|
||||||
_buildActivityItem(
|
? [
|
||||||
context,
|
_buildActivityItem(
|
||||||
'Nenhuma atividade recente',
|
context,
|
||||||
'Comece criando turmas e conteúdos',
|
'Nenhuma atividade recente',
|
||||||
Theme.of(context).colorScheme.onSurfaceVariant,
|
'Comece criando disciplinas e conteúdos',
|
||||||
)
|
Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
] : activities;
|
),
|
||||||
|
]
|
||||||
|
: activities;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildActivityItem(
|
Widget _buildActivityItem(
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import 'dart:math';
|
|||||||
|
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_animate/flutter_animate.dart';
|
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
import '../../../../core/services/auth_service.dart';
|
import '../../../../core/services/auth_service.dart';
|
||||||
@@ -21,7 +20,7 @@ class TeacherQuickActionsWidget extends StatefulWidget {
|
|||||||
class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
|
class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
|
||||||
bool _isCreatingClass = false;
|
bool _isCreatingClass = false;
|
||||||
|
|
||||||
/// Mesmas dimensões dos cards em "As Minhas Turmas".
|
/// Mesmas dimensões dos cards em "As Minhas Disciplinas".
|
||||||
static const double _scrollCardWidth = 200;
|
static const double _scrollCardWidth = 200;
|
||||||
static const double _scrollRowHeight = 150;
|
static const double _scrollRowHeight = 150;
|
||||||
static const double _cardMinHeight = 150;
|
static const double _cardMinHeight = 150;
|
||||||
@@ -41,68 +40,52 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
|
|||||||
];
|
];
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Ações Rápidas',
|
'Ações Rápidas',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: _scrollRowHeight,
|
height: _scrollRowHeight,
|
||||||
child: ListView.separated(
|
child: ListView.separated(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
clipBehavior: Clip.none,
|
clipBehavior: Clip.none,
|
||||||
padding: const EdgeInsets.only(right: 16),
|
padding: const EdgeInsets.only(right: 16),
|
||||||
itemCount: cards.length,
|
itemCount: cards.length,
|
||||||
separatorBuilder: (_, __) => const SizedBox(width: 12),
|
separatorBuilder: (_, __) => const SizedBox(width: 12),
|
||||||
itemBuilder: (context, index) => SizedBox(
|
itemBuilder: (context, index) =>
|
||||||
width: _scrollCardWidth,
|
SizedBox(width: _scrollCardWidth, child: cards[index]),
|
||||||
child: cards[index],
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
);
|
||||||
],
|
|
||||||
)
|
|
||||||
.animate()
|
|
||||||
.slideY(
|
|
||||||
duration: const Duration(milliseconds: 800),
|
|
||||||
curve: Curves.easeOut,
|
|
||||||
)
|
|
||||||
.then(delay: const Duration(milliseconds: 200));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildUploadContentCard(BuildContext context) {
|
Widget _buildUploadContentCard(BuildContext context) {
|
||||||
return ClipRRect(
|
return ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
child: DashboardActionCard(
|
child: DashboardActionCard(
|
||||||
title: 'Upload Conteúdo',
|
title: 'Upload Conteúdo',
|
||||||
subtitle: 'PDFs, textos, imagens',
|
subtitle: 'PDFs, textos, imagens',
|
||||||
icon: Icons.upload_file,
|
icon: Icons.upload_file,
|
||||||
useGradient: true,
|
useGradient: true,
|
||||||
minHeight: _cardMinHeight,
|
minHeight: _cardMinHeight,
|
||||||
iconSize: _iconSize,
|
iconSize: _iconSize,
|
||||||
iconPadding: _iconPadding,
|
iconPadding: _iconPadding,
|
||||||
titleFontSize: _titleFontSize,
|
titleFontSize: _titleFontSize,
|
||||||
subtitleFontSize: _subtitleFontSize,
|
subtitleFontSize: _subtitleFontSize,
|
||||||
padding: _cardPadding,
|
padding: _cardPadding,
|
||||||
onTap: () => Navigator.push(
|
onTap: () => Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(builder: (_) => const TeacherMaterialsPage()),
|
||||||
builder: (_) => const TeacherMaterialsPage(),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
)
|
|
||||||
.animate()
|
|
||||||
.scale(
|
|
||||||
duration: const Duration(milliseconds: 600),
|
|
||||||
curve: Curves.elasticOut,
|
|
||||||
)
|
|
||||||
.then(delay: const Duration(milliseconds: 100)),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,53 +93,41 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
|
|||||||
return ClipRRect(
|
return ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
child: DashboardActionCardSurface(
|
child: DashboardActionCardSurface(
|
||||||
title: 'Criar Quiz',
|
title: 'Criar Quiz',
|
||||||
subtitle: 'Avaliações interativas',
|
subtitle: 'Avaliações interativas',
|
||||||
icon: Icons.quiz,
|
icon: Icons.quiz,
|
||||||
minHeight: _cardMinHeight,
|
minHeight: _cardMinHeight,
|
||||||
titleFontSize: _titleFontSize,
|
titleFontSize: _titleFontSize,
|
||||||
subtitleFontSize: _subtitleFontSize,
|
subtitleFontSize: _subtitleFontSize,
|
||||||
iconSize: _iconSize,
|
iconSize: _iconSize,
|
||||||
padding: _cardPadding,
|
padding: _cardPadding,
|
||||||
onTap: () => context.go('/teacher/quiz/create'),
|
onTap: () => context.go('/teacher/quiz/create'),
|
||||||
)
|
),
|
||||||
.animate()
|
|
||||||
.scale(
|
|
||||||
duration: const Duration(milliseconds: 600),
|
|
||||||
curve: Curves.elasticOut,
|
|
||||||
)
|
|
||||||
.then(delay: const Duration(milliseconds: 200)),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildViewAnalyticsCard(BuildContext context) {
|
Widget _buildViewAnalyticsCard(BuildContext context) {
|
||||||
final cs = Theme.of(context).colorScheme;
|
final cs = Theme.of(context).colorScheme;
|
||||||
return DashboardActionCardSurface(
|
return DashboardActionCardSurface(
|
||||||
title: 'Analytics',
|
title: 'Analytics',
|
||||||
subtitle: 'Desempenho da turma',
|
subtitle: 'Desempenho da disciplina',
|
||||||
icon: Icons.analytics,
|
icon: Icons.analytics,
|
||||||
minHeight: _cardMinHeight,
|
minHeight: _cardMinHeight,
|
||||||
titleFontSize: _titleFontSize,
|
titleFontSize: _titleFontSize,
|
||||||
subtitleFontSize: _subtitleFontSize,
|
subtitleFontSize: _subtitleFontSize,
|
||||||
iconSize: _iconSize,
|
iconSize: _iconSize,
|
||||||
padding: _cardPadding,
|
padding: _cardPadding,
|
||||||
iconColor: cs.primary,
|
iconColor: cs.primary,
|
||||||
leadingWidget: Container(
|
leadingWidget: Container(
|
||||||
padding: const EdgeInsets.all(_iconPadding),
|
padding: const EdgeInsets.all(_iconPadding),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: cs.primary.withOpacity(0.1),
|
color: cs.primary.withOpacity(0.1),
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
),
|
),
|
||||||
child: Icon(Icons.analytics, color: cs.primary, size: _iconSize),
|
child: Icon(Icons.analytics, color: cs.primary, size: _iconSize),
|
||||||
),
|
),
|
||||||
onTap: () => context.go('/teacher/analytics'),
|
onTap: () => context.go('/teacher/analytics'),
|
||||||
)
|
);
|
||||||
.animate()
|
|
||||||
.scale(
|
|
||||||
duration: const Duration(milliseconds: 600),
|
|
||||||
curve: Curves.elasticOut,
|
|
||||||
)
|
|
||||||
.then(delay: const Duration(milliseconds: 400));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildCreateClassCard(BuildContext context) {
|
Widget _buildCreateClassCard(BuildContext context) {
|
||||||
@@ -164,41 +135,35 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
|
|||||||
return ClipRRect(
|
return ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
child: DashboardActionCardSurface(
|
child: DashboardActionCardSurface(
|
||||||
title: 'Criar Turma',
|
title: 'Criar Disciplina',
|
||||||
subtitle: 'Gerar código de acesso',
|
subtitle: 'Gerar código de acesso',
|
||||||
icon: Icons.school,
|
icon: Icons.school,
|
||||||
minHeight: _cardMinHeight,
|
minHeight: _cardMinHeight,
|
||||||
titleFontSize: _titleFontSize,
|
titleFontSize: _titleFontSize,
|
||||||
subtitleFontSize: _subtitleFontSize,
|
subtitleFontSize: _subtitleFontSize,
|
||||||
iconSize: _iconSize,
|
iconSize: _iconSize,
|
||||||
padding: _cardPadding,
|
padding: _cardPadding,
|
||||||
iconColor: cs.primary,
|
iconColor: cs.primary,
|
||||||
onTapDisabled: _isCreatingClass,
|
onTapDisabled: _isCreatingClass,
|
||||||
onTap: () => _showCreateClassDialog(context),
|
onTap: () => _showCreateClassDialog(context),
|
||||||
leadingWidget: Container(
|
leadingWidget: Container(
|
||||||
padding: const EdgeInsets.all(_iconPadding),
|
padding: const EdgeInsets.all(_iconPadding),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: cs.primary.withOpacity(0.1),
|
color: cs.primary.withOpacity(0.1),
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
),
|
),
|
||||||
child: _isCreatingClass
|
child: _isCreatingClass
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
width: _iconSize,
|
width: _iconSize,
|
||||||
height: _iconSize,
|
height: _iconSize,
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
strokeWidth: 2,
|
strokeWidth: 2,
|
||||||
color: cs.primary,
|
color: cs.primary,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Icon(Icons.school, color: cs.primary, size: _iconSize),
|
: Icon(Icons.school, color: cs.primary, size: _iconSize),
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
.animate()
|
|
||||||
.scale(
|
|
||||||
duration: const Duration(milliseconds: 600),
|
|
||||||
curve: Curves.elasticOut,
|
|
||||||
)
|
|
||||||
.then(delay: const Duration(milliseconds: 150)),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +253,7 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
'Turma:',
|
'Ano letivo:',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
@@ -308,7 +273,7 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Text(
|
Text(
|
||||||
'A carregar turmas...',
|
'A carregar disciplinas...',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(
|
color: Theme.of(
|
||||||
context,
|
context,
|
||||||
@@ -347,7 +312,7 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
hint: Text(
|
hint: Text(
|
||||||
'Seleciona a turma',
|
'Seleciona o ano letivo',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(
|
color: Theme.of(
|
||||||
context,
|
context,
|
||||||
@@ -447,7 +412,7 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
|
|||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(
|
content: Text(
|
||||||
'Turma "$className" criada com sucesso! Código: $classCode',
|
'Disciplina "$className" criada com sucesso! Código: $classCode',
|
||||||
),
|
),
|
||||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||||
behavior: SnackBarBehavior.floating,
|
behavior: SnackBarBehavior.floating,
|
||||||
@@ -461,7 +426,7 @@ class _TeacherQuickActionsWidgetState extends State<TeacherQuickActionsWidget> {
|
|||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text('Erro ao criar turma: $e'),
|
content: Text('Erro ao criar disciplina: $e'),
|
||||||
backgroundColor: Colors.red,
|
backgroundColor: Colors.red,
|
||||||
behavior: SnackBarBehavior.floating,
|
behavior: SnackBarBehavior.floating,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
|
|||||||
@@ -46,11 +46,8 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text(
|
title: const Text(
|
||||||
'Materiais da Turma',
|
'Materiais da Disciplina',
|
||||||
style: TextStyle(
|
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
backgroundColor: const Color(0xFF82C9BD),
|
backgroundColor: const Color(0xFF82C9BD),
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
@@ -88,10 +85,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
begin: Alignment.topCenter,
|
begin: Alignment.topCenter,
|
||||||
end: Alignment.bottomCenter,
|
end: Alignment.bottomCenter,
|
||||||
colors: [
|
colors: [Color(0xFF82C9BD), Color(0xFFF8F9FA)],
|
||||||
Color(0xFF82C9BD),
|
|
||||||
Color(0xFFF8F9FA),
|
|
||||||
],
|
|
||||||
stops: [0.0, 0.4],
|
stops: [0.0, 0.4],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -101,9 +95,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
return const Center(
|
return const Center(
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(color: Color(0xFF82C9BD)),
|
||||||
color: Color(0xFF82C9BD),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,13 +160,19 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
itemCount: materials.length,
|
itemCount: materials.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final material = materials[index].data() as Map<String, dynamic>;
|
final material =
|
||||||
|
materials[index].data() as Map<String, dynamic>;
|
||||||
final fileName = material['fileName'] ?? 'Ficheiro sem nome';
|
final fileName = material['fileName'] ?? 'Ficheiro sem nome';
|
||||||
final createdAt = material['createdAt'] as Timestamp?;
|
final createdAt = material['createdAt'] as Timestamp?;
|
||||||
// Inferir tipo pela extensão do filename
|
// Inferir tipo pela extensão do filename
|
||||||
final extension = path.extension(fileName).toLowerCase();
|
final extension = path.extension(fileName).toLowerCase();
|
||||||
final fileType = extension == '.pdf' ? 'pdf' :
|
final fileType = extension == '.pdf'
|
||||||
(extension == '.jpg' || extension == '.jpeg' || extension == '.png') ? 'image' : 'other';
|
? 'pdf'
|
||||||
|
: (extension == '.jpg' ||
|
||||||
|
extension == '.jpeg' ||
|
||||||
|
extension == '.png')
|
||||||
|
? 'image'
|
||||||
|
: 'other';
|
||||||
|
|
||||||
final docId = materials[index].id;
|
final docId = materials[index].id;
|
||||||
final url = material['url'] as String?;
|
final url = material['url'] as String?;
|
||||||
@@ -204,9 +202,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
builder: (context) => Container(
|
builder: (context) => Container(
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.vertical(
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||||
top: Radius.circular(20),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@@ -291,10 +287,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: color.withOpacity(0.05),
|
color: color.withOpacity(0.05),
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
border: Border.all(
|
border: Border.all(color: color.withOpacity(0.2), width: 1),
|
||||||
color: color.withOpacity(0.2),
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -305,11 +298,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
color: color.withOpacity(0.1),
|
color: color.withOpacity(0.1),
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(icon, color: color, size: 24),
|
||||||
icon,
|
|
||||||
color: color,
|
|
||||||
size: 24,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -327,19 +316,12 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
const SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
Text(
|
Text(
|
||||||
subtitle,
|
subtitle,
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 13, color: Colors.grey[600]),
|
||||||
fontSize: 13,
|
|
||||||
color: Colors.grey[600],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Icon(
|
Icon(Icons.arrow_forward_ios, color: Colors.grey[400], size: 16),
|
||||||
Icons.arrow_forward_ios,
|
|
||||||
color: Colors.grey[400],
|
|
||||||
size: 16,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -424,7 +406,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carregar as turmas do professor
|
// Carregar as disciplinas do professor
|
||||||
List<Map<String, String>> teacherClasses = [];
|
List<Map<String, String>> teacherClasses = [];
|
||||||
try {
|
try {
|
||||||
final snapshot = await _firestore
|
final snapshot = await _firestore
|
||||||
@@ -440,7 +422,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
|
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
|
|
||||||
// Se o professor não tem turmas, fazer upload sem associar turma
|
// Se o professor não tem disciplinas, fazer upload sem associar disciplina
|
||||||
if (teacherClasses.isEmpty) {
|
if (teacherClasses.isEmpty) {
|
||||||
await _uploadFile(
|
await _uploadFile(
|
||||||
filePath: filePath,
|
filePath: filePath,
|
||||||
@@ -450,7 +432,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mostrar diálogo de seleção de turma
|
// Mostrar diálogo de seleção de disciplina
|
||||||
String? selectedClassId = await showDialog<String>(
|
String? selectedClassId = await showDialog<String>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (dialogContext) {
|
builder: (dialogContext) {
|
||||||
@@ -461,7 +443,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
),
|
),
|
||||||
title: const Text(
|
title: const Text(
|
||||||
'Escolher Turma',
|
'Escolher Disciplina',
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
content: Column(
|
content: Column(
|
||||||
@@ -469,7 +451,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text(
|
||||||
'Seleciona a turma que terá acesso a este material:',
|
'Seleciona a disciplina que terá acesso a este material:',
|
||||||
style: TextStyle(fontSize: 14),
|
style: TextStyle(fontSize: 14),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
@@ -501,7 +483,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
vertical: 10,
|
vertical: 10,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
hint: const Text('Seleciona a turma'),
|
hint: const Text('Seleciona a disciplina'),
|
||||||
items: teacherClasses
|
items: teacherClasses
|
||||||
.map(
|
.map(
|
||||||
(c) => DropdownMenuItem<String>(
|
(c) => DropdownMenuItem<String>(
|
||||||
@@ -510,8 +492,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
.toList(),
|
.toList(),
|
||||||
onChanged: (value) =>
|
onChanged: (value) => setDialogState(() => picked = value),
|
||||||
setDialogState(() => picked = value),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -763,9 +744,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
return Card(
|
return Card(
|
||||||
margin: const EdgeInsets.only(bottom: 12),
|
margin: const EdgeInsets.only(bottom: 12),
|
||||||
elevation: 2,
|
elevation: 2,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
),
|
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
contentPadding: const EdgeInsets.symmetric(
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
horizontal: 16,
|
horizontal: 16,
|
||||||
@@ -778,11 +757,7 @@ class _TeacherMaterialsPageState extends State<TeacherMaterialsPage> {
|
|||||||
color: iconColor.withOpacity(0.1),
|
color: iconColor.withOpacity(0.1),
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(iconData, color: iconColor, size: 28),
|
||||||
iconData,
|
|
||||||
color: iconColor,
|
|
||||||
size: 28,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
fileName,
|
fileName,
|
||||||
|
|||||||
@@ -70,14 +70,16 @@ class _QuizListPageState extends State<QuizListPage>
|
|||||||
.collection('enrollments')
|
.collection('enrollments')
|
||||||
.where('studentId', isEqualTo: uid)
|
.where('studentId', isEqualTo: uid)
|
||||||
.get();
|
.get();
|
||||||
Logger.info('Enrollments found for student $uid: ${enrollSnap.docs.length}');
|
Logger.info(
|
||||||
|
'Enrollments found for student $uid: ${enrollSnap.docs.length}',
|
||||||
|
);
|
||||||
|
|
||||||
final classIds = enrollSnap.docs
|
final classIds = enrollSnap.docs
|
||||||
.map((d) => d.data()['classId'] as String?)
|
.map((d) => d.data()['classId'] as String?)
|
||||||
.whereType<String>()
|
.whereType<String>()
|
||||||
.toSet();
|
.toSet();
|
||||||
Logger.info('ClassIds from enrollments: $classIds');
|
Logger.info('ClassIds from enrollments: $classIds');
|
||||||
|
|
||||||
if (classIds.isEmpty) {
|
if (classIds.isEmpty) {
|
||||||
Logger.info('No classIds found for student, returning empty');
|
Logger.info('No classIds found for student, returning empty');
|
||||||
if (mounted) setState(() => _loadingTeacherQuizzes = false);
|
if (mounted) setState(() => _loadingTeacherQuizzes = false);
|
||||||
@@ -85,7 +87,10 @@ class _QuizListPageState extends State<QuizListPage>
|
|||||||
}
|
}
|
||||||
// Obter também os teacherIds (fallback para quizzes sem classIds)
|
// Obter também os teacherIds (fallback para quizzes sem classIds)
|
||||||
final classSnaps = await Future.wait(
|
final classSnaps = await Future.wait(
|
||||||
classIds.map((id) => FirebaseFirestore.instance.collection('classes').doc(id).get()),
|
classIds.map(
|
||||||
|
(id) =>
|
||||||
|
FirebaseFirestore.instance.collection('classes').doc(id).get(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
final teacherIds = classSnaps
|
final teacherIds = classSnaps
|
||||||
.where((d) => d.exists)
|
.where((d) => d.exists)
|
||||||
@@ -98,7 +103,7 @@ class _QuizListPageState extends State<QuizListPage>
|
|||||||
// Simplificar: tentar query básica primeiro
|
// Simplificar: tentar query básica primeiro
|
||||||
final classIdList = classIds.toList();
|
final classIdList = classIds.toList();
|
||||||
final batches = <Future<QuerySnapshot>>[];
|
final batches = <Future<QuerySnapshot>>[];
|
||||||
|
|
||||||
// Query 1: por teacherId (mais simples e compatível)
|
// Query 1: por teacherId (mais simples e compatível)
|
||||||
if (teacherIds.isNotEmpty) {
|
if (teacherIds.isNotEmpty) {
|
||||||
Logger.info('Executing simple teacherIds query with: $teacherIds');
|
Logger.info('Executing simple teacherIds query with: $teacherIds');
|
||||||
@@ -111,7 +116,7 @@ class _QuizListPageState extends State<QuizListPage>
|
|||||||
batches.add(query.get());
|
batches.add(query.get());
|
||||||
Logger.info('Added teacherIds batch query: $batch');
|
Logger.info('Added teacherIds batch query: $batch');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query 2: por classIds (se a primeira não retornar resultados)
|
// Query 2: por classIds (se a primeira não retornar resultados)
|
||||||
if (classIdList.isNotEmpty) {
|
if (classIdList.isNotEmpty) {
|
||||||
Logger.info('Executing classIds query with: $classIdList');
|
Logger.info('Executing classIds query with: $classIdList');
|
||||||
@@ -153,18 +158,19 @@ class _QuizListPageState extends State<QuizListPage>
|
|||||||
final allQuizzes = allSnap.docs
|
final allQuizzes = allSnap.docs
|
||||||
.map((d) => {'id': d.id, ...d.data() as Map<String, dynamic>})
|
.map((d) => {'id': d.id, ...d.data() as Map<String, dynamic>})
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
// Filtrar manualmente para testar
|
// Filtrar manualmente para testar
|
||||||
final filteredQuizzes = allQuizzes.where((quiz) {
|
final filteredQuizzes = allQuizzes.where((quiz) {
|
||||||
final quizTeacherId = quiz['teacherId'] as String?;
|
final quizTeacherId = quiz['teacherId'] as String?;
|
||||||
final quizClassIds = (quiz['classIds'] as List?)?.cast<String>() ?? [];
|
final quizClassIds =
|
||||||
return teacherIds.contains(quizTeacherId) ||
|
(quiz['classIds'] as List?)?.cast<String>() ?? [];
|
||||||
quizClassIds.any((cid) => classIds.contains(cid));
|
return teacherIds.contains(quizTeacherId) ||
|
||||||
|
quizClassIds.any((cid) => classIds.contains(cid));
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
Logger.info('Manual filtered quizzes: ${filteredQuizzes.length}');
|
Logger.info('Manual filtered quizzes: ${filteredQuizzes.length}');
|
||||||
Logger.info('=== END ALL QUIZZES NO FILTER ===');
|
Logger.info('=== END ALL QUIZZES NO FILTER ===');
|
||||||
|
|
||||||
// Usar este resultado temporariamente para debug
|
// Usar este resultado temporariamente para debug
|
||||||
if (filteredQuizzes.isNotEmpty) {
|
if (filteredQuizzes.isNotEmpty) {
|
||||||
Logger.info('Using manually filtered quizzes for UI');
|
Logger.info('Using manually filtered quizzes for UI');
|
||||||
@@ -183,7 +189,7 @@ class _QuizListPageState extends State<QuizListPage>
|
|||||||
// Executar queries e processar resultados
|
// Executar queries e processar resultados
|
||||||
final results = await Future.wait(batches);
|
final results = await Future.wait(batches);
|
||||||
Logger.info('Query batches completed: ${results.length} results');
|
Logger.info('Query batches completed: ${results.length} results');
|
||||||
|
|
||||||
// deduplicar por id (pode aparecer em múltiplos batches)
|
// deduplicar por id (pode aparecer em múltiplos batches)
|
||||||
final seen = <String>{};
|
final seen = <String>{};
|
||||||
final quizzes = results
|
final quizzes = results
|
||||||
@@ -191,13 +197,17 @@ class _QuizListPageState extends State<QuizListPage>
|
|||||||
.where((d) => seen.add(d.id))
|
.where((d) => seen.add(d.id))
|
||||||
.map((d) => {'id': d.id, ...d.data() as Map<String, dynamic>})
|
.map((d) => {'id': d.id, ...d.data() as Map<String, dynamic>})
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
Logger.info('Final quizzes after deduplication: ${quizzes.length}');
|
Logger.info('Final quizzes after deduplication: ${quizzes.length}');
|
||||||
for (final quiz in quizzes.take(3)) {
|
for (final quiz in quizzes.take(3)) {
|
||||||
Logger.info('Quiz sample: ${quiz['materialName']} - classIds: ${quiz['classIds']} - teacherId: ${quiz['teacherId']}');
|
Logger.info(
|
||||||
|
'Quiz sample: ${quiz['materialName']} - classIds: ${quiz['classIds']} - teacherId: ${quiz['teacherId']}',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
Logger.info('Updating UI state: _teacherQuizzes.length = ${quizzes.length}');
|
Logger.info(
|
||||||
|
'Updating UI state: _teacherQuizzes.length = ${quizzes.length}',
|
||||||
|
);
|
||||||
setState(() {
|
setState(() {
|
||||||
_teacherQuizzes = quizzes;
|
_teacherQuizzes = quizzes;
|
||||||
_loadingTeacherQuizzes = false;
|
_loadingTeacherQuizzes = false;
|
||||||
@@ -558,7 +568,7 @@ class _QuizListPageState extends State<QuizListPage>
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
'Inscreve-te numa turma para aceder aos PDFs do professor.',
|
'Inscreve-te numa disciplina para aceder aos PDFs do professor.',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: cs.onSurfaceVariant.withOpacity(0.7),
|
color: cs.onSurfaceVariant.withOpacity(0.7),
|
||||||
@@ -1233,7 +1243,7 @@ class _TeacherQuizInteractiveSheetState
|
|||||||
'total': widget.questions.length,
|
'total': widget.questions.length,
|
||||||
'submittedAt': FieldValue.serverTimestamp(),
|
'submittedAt': FieldValue.serverTimestamp(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Registrar atividade no sistema de gamificação
|
// Registrar atividade no sistema de gamificação
|
||||||
await GamificationService.recordQuizActivity(
|
await GamificationService.recordQuizActivity(
|
||||||
user.uid,
|
user.uid,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
.collection('users')
|
.collection('users')
|
||||||
.doc(user.uid)
|
.doc(user.uid)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
if (userDoc.exists) {
|
if (userDoc.exists) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_userRole = userDoc.data()?['role'] ?? '';
|
_userRole = userDoc.data()?['role'] ?? '';
|
||||||
@@ -49,7 +49,7 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
|
||||||
Query query;
|
Query query;
|
||||||
|
|
||||||
if (_userRole == 'teacher') {
|
if (_userRole == 'teacher') {
|
||||||
// Professor: ver todos os quizzes criados
|
// Professor: ver todos os quizzes criados
|
||||||
query = FirebaseFirestore.instance
|
query = FirebaseFirestore.instance
|
||||||
@@ -59,7 +59,10 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
} else {
|
} else {
|
||||||
// Aluno: ver quizzes criados pelo próprio aluno + conceitos dominados
|
// Aluno: ver quizzes criados pelo próprio aluno + conceitos dominados
|
||||||
final results = await Future.wait([
|
final results = await Future.wait([
|
||||||
FirebaseFirestore.instance.collection('userStats').doc(user.uid).get(),
|
FirebaseFirestore.instance
|
||||||
|
.collection('userStats')
|
||||||
|
.doc(user.uid)
|
||||||
|
.get(),
|
||||||
FirebaseFirestore.instance
|
FirebaseFirestore.instance
|
||||||
.collection('quizHistory')
|
.collection('quizHistory')
|
||||||
.doc(user.uid)
|
.doc(user.uid)
|
||||||
@@ -67,12 +70,12 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
.orderBy('createdAt', descending: true)
|
.orderBy('createdAt', descending: true)
|
||||||
.get(),
|
.get(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
final userStatsSnapshot = results[0] as DocumentSnapshot;
|
final userStatsSnapshot = results[0] as DocumentSnapshot;
|
||||||
final studentQuizzesSnapshot = results[1] as QuerySnapshot;
|
final studentQuizzesSnapshot = results[1] as QuerySnapshot;
|
||||||
|
|
||||||
List<Map<String, dynamic>> quizList = [];
|
List<Map<String, dynamic>> quizList = [];
|
||||||
|
|
||||||
// Adicionar quizzes criados pelo aluno
|
// Adicionar quizzes criados pelo aluno
|
||||||
for (final doc in studentQuizzesSnapshot.docs) {
|
for (final doc in studentQuizzesSnapshot.docs) {
|
||||||
final data = Map<String, dynamic>.from(doc.data() as Map);
|
final data = Map<String, dynamic>.from(doc.data() as Map);
|
||||||
@@ -81,15 +84,17 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
data['type'] = 'created';
|
data['type'] = 'created';
|
||||||
quizList.add(data);
|
quizList.add(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adicionar conceitos dominados
|
// Adicionar conceitos dominados
|
||||||
if (userStatsSnapshot.exists) {
|
if (userStatsSnapshot.exists) {
|
||||||
final stats = userStatsSnapshot.data() as Map<String, dynamic>?;
|
final stats = userStatsSnapshot.data() as Map<String, dynamic>?;
|
||||||
if (stats != null) {
|
if (stats != null) {
|
||||||
final masteredConcepts = (stats['masteredConcepts'] as List<dynamic>?)
|
final masteredConcepts =
|
||||||
?.map((c) => Map<String, dynamic>.from(c as Map))
|
(stats['masteredConcepts'] as List<dynamic>?)
|
||||||
.toList() ?? [];
|
?.map((c) => Map<String, dynamic>.from(c as Map))
|
||||||
|
.toList() ??
|
||||||
|
[];
|
||||||
|
|
||||||
for (final concept in masteredConcepts) {
|
for (final concept in masteredConcepts) {
|
||||||
quizList.add({
|
quizList.add({
|
||||||
'id': concept['conceptName'] ?? '',
|
'id': concept['conceptName'] ?? '',
|
||||||
@@ -102,7 +107,7 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_quizHistory = quizList;
|
_quizHistory = quizList;
|
||||||
_loading = false;
|
_loading = false;
|
||||||
@@ -111,13 +116,16 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final snapshot = await query.get();
|
final snapshot = await query.get();
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_quizHistory = snapshot.docs.map((doc) {
|
_quizHistory = snapshot.docs
|
||||||
final data = Map<String, dynamic>.from(doc.data() as Map);
|
.map((doc) {
|
||||||
data['id'] = doc.id;
|
final data = Map<String, dynamic>.from(doc.data() as Map);
|
||||||
return data;
|
data['id'] = doc.id;
|
||||||
}).cast<Map<String, dynamic>>().toList();
|
return data;
|
||||||
|
})
|
||||||
|
.cast<Map<String, dynamic>>()
|
||||||
|
.toList();
|
||||||
_loading = false;
|
_loading = false;
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -132,21 +140,27 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
try {
|
try {
|
||||||
String confirmMessage;
|
String confirmMessage;
|
||||||
String successMessage;
|
String successMessage;
|
||||||
|
|
||||||
if (_userRole == 'teacher') {
|
if (_userRole == 'teacher') {
|
||||||
confirmMessage = 'Tem certeza que deseja eliminar o quiz "$quizTitle"? Esta ação não pode ser desfeita.';
|
confirmMessage =
|
||||||
|
'Tem certeza que deseja eliminar o quiz "$quizTitle"? Esta ação não pode ser desfeita.';
|
||||||
successMessage = 'Quiz eliminado com sucesso!';
|
successMessage = 'Quiz eliminado com sucesso!';
|
||||||
} else {
|
} else {
|
||||||
if (type == 'created') {
|
if (type == 'created') {
|
||||||
confirmMessage = 'Tem certeza que deseja eliminar seu quiz "$quizTitle"?';
|
confirmMessage =
|
||||||
|
'Tem certeza que deseja eliminar seu quiz "$quizTitle"?';
|
||||||
successMessage = 'Quiz eliminado com sucesso!';
|
successMessage = 'Quiz eliminado com sucesso!';
|
||||||
} else {
|
} else {
|
||||||
confirmMessage = 'Tem certeza que deseja remover o conceito "$quizTitle" do seu histórico?';
|
confirmMessage =
|
||||||
|
'Tem certeza que deseja remover o conceito "$quizTitle" do seu histórico?';
|
||||||
successMessage = 'Conceito removido com sucesso!';
|
successMessage = 'Conceito removido com sucesso!';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final confirmed = await _showDeleteConfirmation(quizTitle, confirmMessage);
|
final confirmed = await _showDeleteConfirmation(
|
||||||
|
quizTitle,
|
||||||
|
confirmMessage,
|
||||||
|
);
|
||||||
if (!confirmed) return;
|
if (!confirmed) return;
|
||||||
|
|
||||||
if (_userRole == 'teacher') {
|
if (_userRole == 'teacher') {
|
||||||
@@ -155,13 +169,13 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
.collection('teacherQuizzes')
|
.collection('teacherQuizzes')
|
||||||
.doc(quizId)
|
.doc(quizId)
|
||||||
.delete();
|
.delete();
|
||||||
|
|
||||||
// Também eliminar do histórico de alunos
|
// Também eliminar do histórico de alunos
|
||||||
final historySnapshot = await FirebaseFirestore.instance
|
final historySnapshot = await FirebaseFirestore.instance
|
||||||
.collection('quizHistory')
|
.collection('quizHistory')
|
||||||
.where('quizId', isEqualTo: quizId)
|
.where('quizId', isEqualTo: quizId)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
for (final doc in historySnapshot.docs) {
|
for (final doc in historySnapshot.docs) {
|
||||||
await doc.reference.delete();
|
await doc.reference.delete();
|
||||||
}
|
}
|
||||||
@@ -186,26 +200,30 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
.collection('userStats')
|
.collection('userStats')
|
||||||
.doc(user.uid)
|
.doc(user.uid)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
if (userStatsDoc.exists) {
|
if (userStatsDoc.exists) {
|
||||||
final userStats = userStatsDoc.data() as Map<String, dynamic>;
|
final userStats = userStatsDoc.data() as Map<String, dynamic>;
|
||||||
final masteredConcepts = (userStats['masteredConcepts'] as List<dynamic>?)
|
final masteredConcepts =
|
||||||
?.map((c) => Map<String, dynamic>.from(c as Map))
|
(userStats['masteredConcepts'] as List<dynamic>?)
|
||||||
.toList() ?? [];
|
?.map((c) => Map<String, dynamic>.from(c as Map))
|
||||||
|
.toList() ??
|
||||||
|
[];
|
||||||
|
|
||||||
// Encontrar o conceito específico para remover
|
// Encontrar o conceito específico para remover
|
||||||
final conceptToRemove = masteredConcepts.firstWhere(
|
final conceptToRemove = masteredConcepts.firstWhere(
|
||||||
(c) => c['conceptName'] == quizId,
|
(c) => c['conceptName'] == quizId,
|
||||||
orElse: () => {},
|
orElse: () => {},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (conceptToRemove.isNotEmpty) {
|
if (conceptToRemove.isNotEmpty) {
|
||||||
await FirebaseFirestore.instance
|
await FirebaseFirestore.instance
|
||||||
.collection('userStats')
|
.collection('userStats')
|
||||||
.doc(user.uid)
|
.doc(user.uid)
|
||||||
.update({
|
.update({
|
||||||
'masteredConcepts': FieldValue.arrayRemove([conceptToRemove])
|
'masteredConcepts': FieldValue.arrayRemove([
|
||||||
});
|
conceptToRemove,
|
||||||
|
]),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -213,7 +231,7 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_loadQuizHistory(); // Recarregar lista
|
_loadQuizHistory(); // Recarregar lista
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
@@ -239,7 +257,9 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
final result = await showDialog<bool>(
|
final result = await showDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => AlertDialog(
|
builder: (context) => AlertDialog(
|
||||||
title: Text(_userRole == 'teacher' ? 'Eliminar Quiz' : 'Confirmar Eliminação'),
|
title: Text(
|
||||||
|
_userRole == 'teacher' ? 'Eliminar Quiz' : 'Confirmar Eliminação',
|
||||||
|
),
|
||||||
content: Text(message),
|
content: Text(message),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
@@ -264,15 +284,25 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: cs.surface,
|
backgroundColor: cs.surface,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(_userRole == 'teacher' ? 'Gerenciar Quizzes' : 'Meu Histórico'),
|
title: Text(
|
||||||
|
_userRole == 'teacher' ? 'Gerenciar Quizzes' : 'Meu Histórico',
|
||||||
|
),
|
||||||
backgroundColor: cs.surface,
|
backgroundColor: cs.surface,
|
||||||
foregroundColor: cs.onSurface,
|
foregroundColor: cs.onSurface,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: const Icon(Icons.arrow_back),
|
icon: const Icon(Icons.arrow_back),
|
||||||
onPressed: () => context.go(_userRole == 'teacher'
|
onPressed: () {
|
||||||
? '/teacher-dashboard'
|
if (Navigator.of(context).canPop()) {
|
||||||
: '/student-dashboard'),
|
Navigator.of(context).pop();
|
||||||
|
} else {
|
||||||
|
context.go(
|
||||||
|
_userRole == 'teacher'
|
||||||
|
? '/teacher-dashboard'
|
||||||
|
: '/student-dashboard',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Container(
|
body: Container(
|
||||||
@@ -280,34 +310,31 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
begin: Alignment.topCenter,
|
begin: Alignment.topCenter,
|
||||||
end: Alignment.bottomCenter,
|
end: Alignment.bottomCenter,
|
||||||
colors: [
|
colors: [cs.primary.withValues(alpha: 0.05), cs.surface],
|
||||||
cs.primary.withValues(alpha: 0.05),
|
|
||||||
cs.surface,
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: _loading
|
child: _loading
|
||||||
? const Center(child: CircularProgressIndicator())
|
? const Center(child: CircularProgressIndicator())
|
||||||
: _quizHistory.isEmpty
|
: _quizHistory.isEmpty
|
||||||
? _buildEmptyState()
|
? _buildEmptyState()
|
||||||
: ListView.builder(
|
: ListView.builder(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
itemCount: _quizHistory.length,
|
itemCount: _quizHistory.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final quiz = _quizHistory[index];
|
final quiz = _quizHistory[index];
|
||||||
return _buildQuizCard(quiz)
|
return _buildQuizCard(quiz)
|
||||||
.animate()
|
.animate()
|
||||||
.slideX(duration: const Duration(milliseconds: 300))
|
.slideX(duration: const Duration(milliseconds: 300))
|
||||||
.then(delay: Duration(milliseconds: index * 50));
|
.then(delay: Duration(milliseconds: index * 50));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildEmptyState() {
|
Widget _buildEmptyState() {
|
||||||
final cs = Theme.of(context).colorScheme;
|
final cs = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
return Center(
|
return Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(32),
|
padding: const EdgeInsets.all(32),
|
||||||
@@ -315,13 +342,17 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
_userRole == 'teacher' ? Icons.quiz_outlined : Icons.history_edu_outlined,
|
_userRole == 'teacher'
|
||||||
|
? Icons.quiz_outlined
|
||||||
|
: Icons.history_edu_outlined,
|
||||||
size: 64,
|
size: 64,
|
||||||
color: cs.onSurfaceVariant,
|
color: cs.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
_userRole == 'teacher' ? 'Nenhum quiz criado' : 'Nenhum quiz no histórico',
|
_userRole == 'teacher'
|
||||||
|
? 'Nenhum quiz criado'
|
||||||
|
: 'Nenhum quiz no histórico',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: cs.onSurface,
|
color: cs.onSurface,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
@@ -331,13 +362,10 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
_userRole == 'teacher'
|
_userRole == 'teacher'
|
||||||
? 'Crie seu primeiro quiz para começar!'
|
? 'Crie seu primeiro quiz para começar!'
|
||||||
: 'Complete alguns quizzes para ver seu histórico aqui.',
|
: 'Complete alguns quizzes para ver seu histórico aqui.',
|
||||||
style: TextStyle(
|
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 14),
|
||||||
color: cs.onSurfaceVariant,
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -348,7 +376,7 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
|
|
||||||
Widget _buildQuizCard(Map<String, dynamic> quiz) {
|
Widget _buildQuizCard(Map<String, dynamic> quiz) {
|
||||||
final cs = Theme.of(context).colorScheme;
|
final cs = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.only(bottom: 12),
|
margin: const EdgeInsets.only(bottom: 12),
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
@@ -405,11 +433,12 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => _deleteQuiz(quiz['id'], quiz['title'] ?? 'Quiz', quiz['type'] ?? 'unknown'),
|
onPressed: () => _deleteQuiz(
|
||||||
icon: Icon(
|
quiz['id'],
|
||||||
Icons.delete_outline,
|
quiz['title'] ?? 'Quiz',
|
||||||
color: Colors.red,
|
quiz['type'] ?? 'unknown',
|
||||||
),
|
),
|
||||||
|
icon: Icon(Icons.delete_outline, color: Colors.red),
|
||||||
tooltip: _userRole == 'teacher' ? 'Eliminar Quiz' : 'Remover',
|
tooltip: _userRole == 'teacher' ? 'Eliminar Quiz' : 'Remover',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -420,13 +449,16 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
spacing: 4,
|
spacing: 4,
|
||||||
children: (quiz['classIds'] as List<dynamic>).map((classId) {
|
children: (quiz['classIds'] as List<dynamic>).map((classId) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8,
|
||||||
|
vertical: 4,
|
||||||
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: cs.primaryContainer,
|
color: cs.primaryContainer,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Turma: $classId',
|
'Disciplina: $classId',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: cs.onPrimaryContainer,
|
color: cs.onPrimaryContainer,
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
@@ -443,7 +475,7 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
|
|
||||||
String _formatDate(dynamic date) {
|
String _formatDate(dynamic date) {
|
||||||
if (date == null) return 'Data desconhecida';
|
if (date == null) return 'Data desconhecida';
|
||||||
|
|
||||||
DateTime dateTime;
|
DateTime dateTime;
|
||||||
if (date is Timestamp) {
|
if (date is Timestamp) {
|
||||||
dateTime = date.toDate();
|
dateTime = date.toDate();
|
||||||
@@ -452,7 +484,7 @@ class _QuizManagementPageState extends State<QuizManagementPage> {
|
|||||||
} else {
|
} else {
|
||||||
return 'Data desconhecida';
|
return 'Data desconhecida';
|
||||||
}
|
}
|
||||||
|
|
||||||
return '${dateTime.day}/${dateTime.month}/${dateTime.year}';
|
return '${dateTime.day}/${dateTime.month}/${dateTime.year}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ class _QuizQuestion {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
'q': question,
|
'q': question,
|
||||||
'opts': options,
|
'opts': options,
|
||||||
'ans': correctIndex,
|
'ans': correctIndex,
|
||||||
'exp': explanation,
|
'exp': explanation,
|
||||||
};
|
};
|
||||||
|
|
||||||
static _QuizQuestion? fromMap(dynamic e) {
|
static _QuizQuestion? fromMap(dynamic e) {
|
||||||
if (e is! Map) return null;
|
if (e is! Map) return null;
|
||||||
@@ -38,7 +38,12 @@ class _QuizQuestion {
|
|||||||
final exp = e['exp'] as String? ?? '';
|
final exp = e['exp'] as String? ?? '';
|
||||||
if (q == null || opts == null || ans == null) return null;
|
if (q == null || opts == null || ans == null) return null;
|
||||||
if (opts.length < 2 || ans < 0 || ans >= opts.length) return null;
|
if (opts.length < 2 || ans < 0 || ans >= opts.length) return null;
|
||||||
return _QuizQuestion(question: q, options: opts, correctIndex: ans, explanation: exp);
|
return _QuizQuestion(
|
||||||
|
question: q,
|
||||||
|
options: opts,
|
||||||
|
correctIndex: ans,
|
||||||
|
explanation: exp,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,17 +103,33 @@ class _TeacherQuizPageState extends State<TeacherQuizPage>
|
|||||||
Future<void> _loadMaterials() async {
|
Future<void> _loadMaterials() async {
|
||||||
try {
|
try {
|
||||||
final uid = FirebaseAuth.instance.currentUser?.uid;
|
final uid = FirebaseAuth.instance.currentUser?.uid;
|
||||||
if (uid == null) { if (mounted) setState(() => _loadingMaterials = false); return; }
|
if (uid == null) {
|
||||||
|
if (mounted) setState(() => _loadingMaterials = false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
final snap = await FirebaseFirestore.instance
|
final snap = await FirebaseFirestore.instance
|
||||||
.collection('materials')
|
.collection('materials')
|
||||||
.where('teacherId', isEqualTo: uid)
|
.where('teacherId', isEqualTo: uid)
|
||||||
.orderBy('createdAt', descending: true)
|
.orderBy('createdAt', descending: true)
|
||||||
.get();
|
.get();
|
||||||
final mats = snap.docs
|
final mats = snap.docs
|
||||||
.where((d) => (d.data()['fileName'] as String? ?? '').toLowerCase().endsWith('.pdf'))
|
.where(
|
||||||
.map((d) => {'id': d.id, 'name': d.data()['fileName'] as String? ?? 'Material'})
|
(d) => (d.data()['fileName'] as String? ?? '')
|
||||||
|
.toLowerCase()
|
||||||
|
.endsWith('.pdf'),
|
||||||
|
)
|
||||||
|
.map(
|
||||||
|
(d) => {
|
||||||
|
'id': d.id,
|
||||||
|
'name': d.data()['fileName'] as String? ?? 'Material',
|
||||||
|
},
|
||||||
|
)
|
||||||
.toList();
|
.toList();
|
||||||
if (mounted) setState(() { _materials = mats; _loadingMaterials = false; });
|
if (mounted)
|
||||||
|
setState(() {
|
||||||
|
_materials = mats;
|
||||||
|
_loadingMaterials = false;
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Logger.error('Teacher quiz load materials: $e');
|
Logger.error('Teacher quiz load materials: $e');
|
||||||
if (mounted) setState(() => _loadingMaterials = false);
|
if (mounted) setState(() => _loadingMaterials = false);
|
||||||
@@ -118,7 +139,10 @@ class _TeacherQuizPageState extends State<TeacherQuizPage>
|
|||||||
Future<void> _loadHistory() async {
|
Future<void> _loadHistory() async {
|
||||||
try {
|
try {
|
||||||
final uid = FirebaseAuth.instance.currentUser?.uid;
|
final uid = FirebaseAuth.instance.currentUser?.uid;
|
||||||
if (uid == null) { if (mounted) setState(() => _loadingHistory = false); return; }
|
if (uid == null) {
|
||||||
|
if (mounted) setState(() => _loadingHistory = false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
final snap = await FirebaseFirestore.instance
|
final snap = await FirebaseFirestore.instance
|
||||||
.collection('teacherQuizzes')
|
.collection('teacherQuizzes')
|
||||||
.where('teacherId', isEqualTo: uid)
|
.where('teacherId', isEqualTo: uid)
|
||||||
@@ -126,7 +150,11 @@ class _TeacherQuizPageState extends State<TeacherQuizPage>
|
|||||||
.limit(30)
|
.limit(30)
|
||||||
.get();
|
.get();
|
||||||
final list = snap.docs.map((d) => {'id': d.id, ...d.data()}).toList();
|
final list = snap.docs.map((d) => {'id': d.id, ...d.data()}).toList();
|
||||||
if (mounted) setState(() { _history = list; _loadingHistory = false; });
|
if (mounted)
|
||||||
|
setState(() {
|
||||||
|
_history = list;
|
||||||
|
_loadingHistory = false;
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Logger.error('Teacher quiz load history: $e');
|
Logger.error('Teacher quiz load history: $e');
|
||||||
if (mounted) setState(() => _loadingHistory = false);
|
if (mounted) setState(() => _loadingHistory = false);
|
||||||
@@ -163,7 +191,8 @@ class _TeacherQuizPageState extends State<TeacherQuizPage>
|
|||||||
final questions = _parseQuizJson(raw);
|
final questions = _parseQuizJson(raw);
|
||||||
|
|
||||||
if (questions.isEmpty) {
|
if (questions.isEmpty) {
|
||||||
if (mounted) _showSnack('Não foi possível gerar o quiz. Tenta novamente.');
|
if (mounted)
|
||||||
|
_showSnack('Não foi possível gerar o quiz. Tenta novamente.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,16 +271,14 @@ class _TeacherQuizPageState extends State<TeacherQuizPage>
|
|||||||
),
|
),
|
||||||
body: TabBarView(
|
body: TabBarView(
|
||||||
controller: _tabController,
|
controller: _tabController,
|
||||||
children: [
|
children: [_buildMaterialsTab(cs), _buildHistoryTab(cs)],
|
||||||
_buildMaterialsTab(cs),
|
|
||||||
_buildHistoryTab(cs),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildMaterialsTab(ColorScheme cs) {
|
Widget _buildMaterialsTab(ColorScheme cs) {
|
||||||
if (_loadingMaterials) return const Center(child: CircularProgressIndicator());
|
if (_loadingMaterials)
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
if (_materials.isEmpty) {
|
if (_materials.isEmpty) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@@ -259,13 +286,25 @@ class _TeacherQuizPageState extends State<TeacherQuizPage>
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.folder_open, size: 64, color: cs.onSurfaceVariant.withValues(alpha: 0.4)),
|
Icon(
|
||||||
|
Icons.folder_open,
|
||||||
|
size: 64,
|
||||||
|
color: cs.onSurfaceVariant.withValues(alpha: 0.4),
|
||||||
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text('Sem PDFs carregados.', style: TextStyle(color: cs.onSurfaceVariant, fontSize: 16)),
|
Text(
|
||||||
|
'Sem PDFs carregados.',
|
||||||
|
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 16),
|
||||||
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text('Faz upload de um PDF nos teus materiais primeiro.',
|
Text(
|
||||||
textAlign: TextAlign.center,
|
'Faz upload de um PDF nos teus materiais primeiro.',
|
||||||
style: TextStyle(color: cs.onSurfaceVariant.withValues(alpha: 0.7), fontSize: 13)),
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
color: cs.onSurfaceVariant.withValues(alpha: 0.7),
|
||||||
|
fontSize: 13,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -278,7 +317,9 @@ class _TeacherQuizPageState extends State<TeacherQuizPage>
|
|||||||
itemBuilder: (context, i) {
|
itemBuilder: (context, i) {
|
||||||
final mat = _materials[i];
|
final mat = _materials[i];
|
||||||
final isGenerating = _generatingForId == mat['id'];
|
final isGenerating = _generatingForId == mat['id'];
|
||||||
final name = (mat['name'] ?? 'Material').replaceAll('.pdf', '').replaceAll('_', ' ');
|
final name = (mat['name'] ?? 'Material')
|
||||||
|
.replaceAll('.pdf', '')
|
||||||
|
.replaceAll('_', ' ');
|
||||||
return _MaterialCard(
|
return _MaterialCard(
|
||||||
name: name,
|
name: name,
|
||||||
isGenerating: isGenerating,
|
isGenerating: isGenerating,
|
||||||
@@ -290,7 +331,8 @@ class _TeacherQuizPageState extends State<TeacherQuizPage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildHistoryTab(ColorScheme cs) {
|
Widget _buildHistoryTab(ColorScheme cs) {
|
||||||
if (_loadingHistory) return const Center(child: CircularProgressIndicator());
|
if (_loadingHistory)
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
if (_history.isEmpty) {
|
if (_history.isEmpty) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@@ -298,10 +340,16 @@ class _TeacherQuizPageState extends State<TeacherQuizPage>
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.history, size: 64, color: cs.onSurfaceVariant.withValues(alpha: 0.4)),
|
Icon(
|
||||||
|
Icons.history,
|
||||||
|
size: 64,
|
||||||
|
color: cs.onSurfaceVariant.withValues(alpha: 0.4),
|
||||||
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text('Ainda não criaste nenhum quiz.',
|
Text(
|
||||||
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 16)),
|
'Ainda não criaste nenhum quiz.',
|
||||||
|
style: TextStyle(color: cs.onSurfaceVariant, fontSize: 16),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -328,10 +376,19 @@ class _TeacherQuizPageState extends State<TeacherQuizPage>
|
|||||||
color: cs.surface,
|
color: cs.surface,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
border: Border.all(color: cs.outline.withValues(alpha: 0.15)),
|
border: Border.all(color: cs.outline.withValues(alpha: 0.15)),
|
||||||
boxShadow: [BoxShadow(color: cs.shadow.withValues(alpha: 0.05), blurRadius: 8, offset: const Offset(0, 2))],
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: cs.shadow.withValues(alpha: 0.05),
|
||||||
|
blurRadius: 8,
|
||||||
|
offset: const Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16,
|
||||||
|
vertical: 8,
|
||||||
|
),
|
||||||
leading: Container(
|
leading: Container(
|
||||||
width: 44,
|
width: 44,
|
||||||
height: 44,
|
height: 44,
|
||||||
@@ -341,12 +398,21 @@ class _TeacherQuizPageState extends State<TeacherQuizPage>
|
|||||||
),
|
),
|
||||||
child: Icon(Icons.quiz, color: cs.primary, size: 22),
|
child: Icon(Icons.quiz, color: cs.primary, size: 22),
|
||||||
),
|
),
|
||||||
title: Text(name,
|
title: Text(
|
||||||
maxLines: 2,
|
name,
|
||||||
overflow: TextOverflow.ellipsis,
|
maxLines: 2,
|
||||||
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 14, color: cs.onSurface)),
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 14,
|
||||||
|
color: cs.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
subtitle: dateStr.isNotEmpty
|
subtitle: dateStr.isNotEmpty
|
||||||
? Text(dateStr, style: TextStyle(fontSize: 12, color: cs.onSurfaceVariant))
|
? Text(
|
||||||
|
dateStr,
|
||||||
|
style: TextStyle(fontSize: 12, color: cs.onSurfaceVariant),
|
||||||
|
)
|
||||||
: null,
|
: null,
|
||||||
trailing: Icon(Icons.bar_chart, color: cs.onSurfaceVariant),
|
trailing: Icon(Icons.bar_chart, color: cs.onSurfaceVariant),
|
||||||
onTap: () => _showResultsPopup(item),
|
onTap: () => _showResultsPopup(item),
|
||||||
@@ -375,7 +441,12 @@ class _MaterialCard extends StatelessWidget {
|
|||||||
final bool isGenerating;
|
final bool isGenerating;
|
||||||
final VoidCallback? onTap;
|
final VoidCallback? onTap;
|
||||||
final ColorScheme cs;
|
final ColorScheme cs;
|
||||||
const _MaterialCard({required this.name, required this.isGenerating, required this.onTap, required this.cs});
|
const _MaterialCard({
|
||||||
|
required this.name,
|
||||||
|
required this.isGenerating,
|
||||||
|
required this.onTap,
|
||||||
|
required this.cs,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -384,7 +455,13 @@ class _MaterialCard extends StatelessWidget {
|
|||||||
color: cs.surface,
|
color: cs.surface,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
border: Border.all(color: cs.outline.withValues(alpha: 0.15)),
|
border: Border.all(color: cs.outline.withValues(alpha: 0.15)),
|
||||||
boxShadow: [BoxShadow(color: cs.shadow.withValues(alpha: 0.05), blurRadius: 8, offset: const Offset(0, 2))],
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: cs.shadow.withValues(alpha: 0.05),
|
||||||
|
blurRadius: 8,
|
||||||
|
offset: const Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
@@ -397,17 +474,28 @@ class _MaterialCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Icon(Icons.picture_as_pdf, color: cs.secondary, size: 22),
|
child: Icon(Icons.picture_as_pdf, color: cs.secondary, size: 22),
|
||||||
),
|
),
|
||||||
title: Text(name,
|
title: Text(
|
||||||
maxLines: 2,
|
name,
|
||||||
overflow: TextOverflow.ellipsis,
|
maxLines: 2,
|
||||||
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 14, color: cs.onSurface)),
|
overflow: TextOverflow.ellipsis,
|
||||||
subtitle: Text('Gerar quiz com IA',
|
style: TextStyle(
|
||||||
style: TextStyle(fontSize: 12, color: cs.onSurfaceVariant)),
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 14,
|
||||||
|
color: cs.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
'Gerar quiz com IA',
|
||||||
|
style: TextStyle(fontSize: 12, color: cs.onSurfaceVariant),
|
||||||
|
),
|
||||||
trailing: isGenerating
|
trailing: isGenerating
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
width: 24,
|
width: 24,
|
||||||
height: 24,
|
height: 24,
|
||||||
child: CircularProgressIndicator(strokeWidth: 2.5, color: cs.primary),
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2.5,
|
||||||
|
color: cs.primary,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: Icon(Icons.auto_awesome, color: cs.primary, size: 26),
|
: Icon(Icons.auto_awesome, color: cs.primary, size: 26),
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
@@ -445,14 +533,16 @@ class _QuizEditorPageState extends State<_QuizEditorPage> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
// cópia editável
|
// cópia editável
|
||||||
_questions = widget.questions
|
_questions = widget.questions
|
||||||
.map((q) => _QuizQuestion(
|
.map(
|
||||||
question: q.question,
|
(q) => _QuizQuestion(
|
||||||
options: List<String>.from(q.options),
|
question: q.question,
|
||||||
correctIndex: q.correctIndex,
|
options: List<String>.from(q.options),
|
||||||
explanation: q.explanation,
|
correctIndex: q.correctIndex,
|
||||||
))
|
explanation: q.explanation,
|
||||||
|
),
|
||||||
|
)
|
||||||
.toList();
|
.toList();
|
||||||
// selecionar todas as turmas por defeito
|
// selecionar todas as disciplinas por defeito
|
||||||
for (final c in widget.availableClasses) {
|
for (final c in widget.availableClasses) {
|
||||||
if (c['id'] != null) _selectedClassIds.add(c['id']!);
|
if (c['id'] != null) _selectedClassIds.add(c['id']!);
|
||||||
}
|
}
|
||||||
@@ -460,12 +550,14 @@ class _QuizEditorPageState extends State<_QuizEditorPage> {
|
|||||||
|
|
||||||
void _addBlankQuestion() {
|
void _addBlankQuestion() {
|
||||||
setState(() {
|
setState(() {
|
||||||
_questions.add(_QuizQuestion(
|
_questions.add(
|
||||||
question: '',
|
_QuizQuestion(
|
||||||
options: ['A) ', 'B) ', 'C) ', 'D) '],
|
question: '',
|
||||||
correctIndex: 0,
|
options: ['A) ', 'B) ', 'C) ', 'D) '],
|
||||||
explanation: '',
|
correctIndex: 0,
|
||||||
));
|
explanation: '',
|
||||||
|
),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,7 +580,10 @@ class _QuizEditorPageState extends State<_QuizEditorPage> {
|
|||||||
Logger.error('Error publishing teacher quiz: $e');
|
Logger.error('Error publishing teacher quiz: $e');
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('Erro ao publicar: $e'), behavior: SnackBarBehavior.floating),
|
SnackBar(
|
||||||
|
content: Text('Erro ao publicar: $e'),
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -514,10 +609,20 @@ class _QuizEditorPageState extends State<_QuizEditorPage> {
|
|||||||
_saving
|
_saving
|
||||||
? const Padding(
|
? const Padding(
|
||||||
padding: EdgeInsets.only(right: 16),
|
padding: EdgeInsets.only(right: 16),
|
||||||
child: Center(child: SizedBox(width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2))),
|
child: Center(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
child: CircularProgressIndicator(strokeWidth: 2),
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: TextButton.icon(
|
: TextButton.icon(
|
||||||
onPressed: (widget.availableClasses.isEmpty || _selectedClassIds.isNotEmpty) ? _publish : null,
|
onPressed:
|
||||||
|
(widget.availableClasses.isEmpty ||
|
||||||
|
_selectedClassIds.isNotEmpty)
|
||||||
|
? _publish
|
||||||
|
: null,
|
||||||
icon: const Icon(Icons.publish),
|
icon: const Icon(Icons.publish),
|
||||||
label: const Text('Publicar'),
|
label: const Text('Publicar'),
|
||||||
),
|
),
|
||||||
@@ -525,7 +630,7 @@ class _QuizEditorPageState extends State<_QuizEditorPage> {
|
|||||||
),
|
),
|
||||||
body: ListView.builder(
|
body: ListView.builder(
|
||||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 32),
|
padding: const EdgeInsets.fromLTRB(16, 16, 16, 32),
|
||||||
itemCount: _questions.length + 2, // +1 turmas header +1 add button
|
itemCount: _questions.length + 2, // +1 disciplinas header +1 add button
|
||||||
itemBuilder: (context, i) {
|
itemBuilder: (context, i) {
|
||||||
if (i == 0) return _buildClassSelector(cs);
|
if (i == 0) return _buildClassSelector(cs);
|
||||||
if (i == _questions.length + 1) {
|
if (i == _questions.length + 1) {
|
||||||
@@ -537,7 +642,9 @@ class _QuizEditorPageState extends State<_QuizEditorPage> {
|
|||||||
label: const Text('Adicionar Pergunta'),
|
label: const Text('Adicionar Pergunta'),
|
||||||
style: OutlinedButton.styleFrom(
|
style: OutlinedButton.styleFrom(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -569,7 +676,13 @@ class _QuizEditorPageState extends State<_QuizEditorPage> {
|
|||||||
color: cs.surface,
|
color: cs.surface,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
border: Border.all(color: cs.outline.withValues(alpha: 0.2)),
|
border: Border.all(color: cs.outline.withValues(alpha: 0.2)),
|
||||||
boxShadow: [BoxShadow(color: cs.shadow.withValues(alpha: 0.05), blurRadius: 8, offset: const Offset(0, 2))],
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: cs.shadow.withValues(alpha: 0.05),
|
||||||
|
blurRadius: 8,
|
||||||
|
offset: const Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -578,8 +691,14 @@ class _QuizEditorPageState extends State<_QuizEditorPage> {
|
|||||||
children: [
|
children: [
|
||||||
Icon(Icons.groups, color: cs.primary, size: 20),
|
Icon(Icons.groups, color: cs.primary, size: 20),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text('Turmas com acesso',
|
Text(
|
||||||
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: cs.onSurface)),
|
'Disciplinas com acesso',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: cs.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
@@ -591,21 +710,39 @@ class _QuizEditorPageState extends State<_QuizEditorPage> {
|
|||||||
final name = c['name'] ?? id;
|
final name = c['name'] ?? id;
|
||||||
final selected = _selectedClassIds.contains(id);
|
final selected = _selectedClassIds.contains(id);
|
||||||
return FilterChip(
|
return FilterChip(
|
||||||
label: Text(name, style: TextStyle(fontSize: 13, color: selected ? cs.onPrimary : cs.onSurface)),
|
label: Text(
|
||||||
|
name,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color: selected ? cs.onPrimary : cs.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
selected: selected,
|
selected: selected,
|
||||||
onSelected: (v) => setState(() => v ? _selectedClassIds.add(id) : _selectedClassIds.remove(id)),
|
onSelected: (v) => setState(
|
||||||
|
() => v
|
||||||
|
? _selectedClassIds.add(id)
|
||||||
|
: _selectedClassIds.remove(id),
|
||||||
|
),
|
||||||
selectedColor: cs.primary,
|
selectedColor: cs.primary,
|
||||||
checkmarkColor: cs.onPrimary,
|
checkmarkColor: cs.onPrimary,
|
||||||
backgroundColor: cs.surfaceContainerHighest.withValues(alpha: 0.5),
|
backgroundColor: cs.surfaceContainerHighest.withValues(
|
||||||
side: BorderSide(color: selected ? cs.primary : cs.outline.withValues(alpha: 0.3)),
|
alpha: 0.5,
|
||||||
|
),
|
||||||
|
side: BorderSide(
|
||||||
|
color: selected
|
||||||
|
? cs.primary
|
||||||
|
: cs.outline.withValues(alpha: 0.3),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
if (_selectedClassIds.isEmpty)
|
if (_selectedClassIds.isEmpty)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 8),
|
padding: const EdgeInsets.only(top: 8),
|
||||||
child: Text('Seleciona pelo menos uma turma.',
|
child: Text(
|
||||||
style: TextStyle(fontSize: 12, color: cs.error)),
|
'Seleciona pelo menos uma disciplina.',
|
||||||
|
style: TextStyle(fontSize: 12, color: cs.error),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -621,7 +758,13 @@ class _QuestionEditor extends StatefulWidget {
|
|||||||
final ColorScheme cs;
|
final ColorScheme cs;
|
||||||
final VoidCallback onChanged;
|
final VoidCallback onChanged;
|
||||||
final VoidCallback? onDelete;
|
final VoidCallback? onDelete;
|
||||||
const _QuestionEditor({required this.index, required this.question, required this.cs, required this.onChanged, this.onDelete});
|
const _QuestionEditor({
|
||||||
|
required this.index,
|
||||||
|
required this.question,
|
||||||
|
required this.cs,
|
||||||
|
required this.onChanged,
|
||||||
|
this.onDelete,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<_QuestionEditor> createState() => _QuestionEditorState();
|
State<_QuestionEditor> createState() => _QuestionEditorState();
|
||||||
@@ -638,7 +781,9 @@ class _QuestionEditorState extends State<_QuestionEditor> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
_qCtrl = TextEditingController(text: widget.question.question);
|
_qCtrl = TextEditingController(text: widget.question.question);
|
||||||
_expCtrl = TextEditingController(text: widget.question.explanation);
|
_expCtrl = TextEditingController(text: widget.question.explanation);
|
||||||
_optCtrl = widget.question.options.map((o) => TextEditingController(text: o)).toList();
|
_optCtrl = widget.question.options
|
||||||
|
.map((o) => TextEditingController(text: o))
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -666,7 +811,13 @@ class _QuestionEditorState extends State<_QuestionEditor> {
|
|||||||
color: cs.surface,
|
color: cs.surface,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
border: Border.all(color: cs.outline.withValues(alpha: 0.2)),
|
border: Border.all(color: cs.outline.withValues(alpha: 0.2)),
|
||||||
boxShadow: [BoxShadow(color: cs.shadow.withValues(alpha: 0.05), blurRadius: 8, offset: const Offset(0, 2))],
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: cs.shadow.withValues(alpha: 0.05),
|
||||||
|
blurRadius: 8,
|
||||||
|
offset: const Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
@@ -686,29 +837,48 @@ class _QuestionEditorState extends State<_QuestionEditor> {
|
|||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text('${widget.index + 1}',
|
child: Text(
|
||||||
style: TextStyle(fontSize: 13, fontWeight: FontWeight.bold, color: cs.primary)),
|
'${widget.index + 1}',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: cs.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
widget.question.question.isEmpty ? 'Pergunta ${widget.index + 1}' : widget.question.question,
|
widget.question.question.isEmpty
|
||||||
|
? 'Pergunta ${widget.index + 1}'
|
||||||
|
: widget.question.question,
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: cs.onSurface),
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: cs.onSurface,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (widget.onDelete != null)
|
if (widget.onDelete != null)
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.delete_outline, color: cs.error, size: 18),
|
icon: Icon(
|
||||||
|
Icons.delete_outline,
|
||||||
|
color: cs.error,
|
||||||
|
size: 18,
|
||||||
|
),
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
constraints: const BoxConstraints(),
|
constraints: const BoxConstraints(),
|
||||||
onPressed: widget.onDelete,
|
onPressed: widget.onDelete,
|
||||||
tooltip: 'Remover',
|
tooltip: 'Remover',
|
||||||
),
|
),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Icon(_expanded ? Icons.expand_less : Icons.expand_more, color: cs.onSurfaceVariant),
|
Icon(
|
||||||
|
_expanded ? Icons.expand_less : Icons.expand_more,
|
||||||
|
color: cs.onSurfaceVariant,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -746,31 +916,59 @@ class _QuestionEditorState extends State<_QuestionEditor> {
|
|||||||
margin: const EdgeInsets.only(right: 8),
|
margin: const EdgeInsets.only(right: 8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
color: isCorrect ? cs.primary : cs.surfaceContainerHighest,
|
color: isCorrect
|
||||||
border: Border.all(color: isCorrect ? cs.primary : cs.outline.withValues(alpha: 0.3)),
|
? cs.primary
|
||||||
|
: cs.surfaceContainerHighest,
|
||||||
|
border: Border.all(
|
||||||
|
color: isCorrect
|
||||||
|
? cs.primary
|
||||||
|
: cs.outline.withValues(alpha: 0.3),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: isCorrect
|
child: isCorrect
|
||||||
? Icon(Icons.check, size: 16, color: cs.onPrimary)
|
? Icon(
|
||||||
|
Icons.check,
|
||||||
|
size: 16,
|
||||||
|
color: cs.onPrimary,
|
||||||
|
)
|
||||||
: Center(
|
: Center(
|
||||||
child: Text(String.fromCharCode(65 + i),
|
child: Text(
|
||||||
style: TextStyle(fontSize: 12, color: cs.onSurfaceVariant)),
|
String.fromCharCode(65 + i),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: cs.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(child: _textField(_optCtrl[i], cs, hint: 'Opção ${String.fromCharCode(65 + i)}')),
|
Expanded(
|
||||||
|
child: _textField(
|
||||||
|
_optCtrl[i],
|
||||||
|
cs,
|
||||||
|
hint: 'Opção ${String.fromCharCode(65 + i)}',
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
Text('Toca no círculo para marcar a correcta',
|
Text(
|
||||||
style: TextStyle(fontSize: 11, color: cs.onSurfaceVariant)),
|
'Toca no círculo para marcar a correcta',
|
||||||
|
style: TextStyle(fontSize: 11, color: cs.onSurfaceVariant),
|
||||||
|
),
|
||||||
|
|
||||||
const SizedBox(height: 14),
|
const SizedBox(height: 14),
|
||||||
|
|
||||||
// Explicação
|
// Explicação
|
||||||
_label('Explicação (quando erra)', cs),
|
_label('Explicação (quando erra)', cs),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
_textField(_expCtrl, cs, maxLines: 3, hint: 'Explica porque esta é a resposta correcta...'),
|
_textField(
|
||||||
|
_expCtrl,
|
||||||
|
cs,
|
||||||
|
maxLines: 3,
|
||||||
|
hint: 'Explica porque esta é a resposta correcta...',
|
||||||
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
|
|
||||||
Align(
|
Align(
|
||||||
@@ -790,28 +988,47 @@ class _QuestionEditorState extends State<_QuestionEditor> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _label(String text, ColorScheme cs) => Text(text,
|
Widget _label(String text, ColorScheme cs) => Text(
|
||||||
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: cs.onSurfaceVariant));
|
text,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: cs.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
Widget _textField(TextEditingController ctrl, ColorScheme cs, {int maxLines = 1, String? hint}) =>
|
Widget _textField(
|
||||||
TextField(
|
TextEditingController ctrl,
|
||||||
controller: ctrl,
|
ColorScheme cs, {
|
||||||
maxLines: maxLines,
|
int maxLines = 1,
|
||||||
style: TextStyle(fontSize: 14, color: cs.onSurface),
|
String? hint,
|
||||||
decoration: InputDecoration(
|
}) => TextField(
|
||||||
hintText: hint,
|
controller: ctrl,
|
||||||
hintStyle: TextStyle(color: cs.onSurfaceVariant.withValues(alpha: 0.5), fontSize: 13),
|
maxLines: maxLines,
|
||||||
filled: true,
|
style: TextStyle(fontSize: 14, color: cs.onSurface),
|
||||||
fillColor: cs.surfaceContainerHighest.withValues(alpha: 0.5),
|
decoration: InputDecoration(
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
hintText: hint,
|
||||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none),
|
hintStyle: TextStyle(
|
||||||
enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none),
|
color: cs.onSurfaceVariant.withValues(alpha: 0.5),
|
||||||
focusedBorder: OutlineInputBorder(
|
fontSize: 13,
|
||||||
borderRadius: BorderRadius.circular(10),
|
),
|
||||||
borderSide: BorderSide(color: cs.primary, width: 1.5),
|
filled: true,
|
||||||
),
|
fillColor: cs.surfaceContainerHighest.withValues(alpha: 0.5),
|
||||||
),
|
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||||
);
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
borderSide: BorderSide.none,
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
borderSide: BorderSide.none,
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
borderSide: BorderSide(color: cs.primary, width: 1.5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Popup de resultados por aluno ────────────────────────────────────────────
|
// ─── Popup de resultados por aluno ────────────────────────────────────────────
|
||||||
@@ -851,9 +1068,13 @@ class _StudentResultsDialogState extends State<_StudentResultsDialog> {
|
|||||||
String studentName = data['studentName'] as String? ?? 'Aluno';
|
String studentName = data['studentName'] as String? ?? 'Aluno';
|
||||||
if (studentId != null && studentName == 'Aluno') {
|
if (studentId != null && studentName == 'Aluno') {
|
||||||
try {
|
try {
|
||||||
final userDoc = await FirebaseFirestore.instance.collection('users').doc(studentId).get();
|
final userDoc = await FirebaseFirestore.instance
|
||||||
|
.collection('users')
|
||||||
|
.doc(studentId)
|
||||||
|
.get();
|
||||||
if (userDoc.exists) {
|
if (userDoc.exists) {
|
||||||
studentName = userDoc.data()?['displayName'] as String? ??
|
studentName =
|
||||||
|
userDoc.data()?['displayName'] as String? ??
|
||||||
userDoc.data()?['name'] as String? ??
|
userDoc.data()?['name'] as String? ??
|
||||||
studentName;
|
studentName;
|
||||||
}
|
}
|
||||||
@@ -861,7 +1082,11 @@ class _StudentResultsDialogState extends State<_StudentResultsDialog> {
|
|||||||
}
|
}
|
||||||
results.add({...data, 'studentName': studentName});
|
results.add({...data, 'studentName': studentName});
|
||||||
}
|
}
|
||||||
if (mounted) setState(() { _results = results; _loading = false; });
|
if (mounted)
|
||||||
|
setState(() {
|
||||||
|
_results = results;
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Logger.error('Error loading quiz submissions: $e');
|
Logger.error('Error loading quiz submissions: $e');
|
||||||
if (mounted) setState(() => _loading = false);
|
if (mounted) setState(() => _loading = false);
|
||||||
@@ -884,7 +1109,9 @@ class _StudentResultsDialogState extends State<_StudentResultsDialog> {
|
|||||||
padding: const EdgeInsets.fromLTRB(20, 20, 12, 16),
|
padding: const EdgeInsets.fromLTRB(20, 20, 12, 16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: cs.primary.withValues(alpha: 0.08),
|
color: cs.primary.withValues(alpha: 0.08),
|
||||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(20)),
|
borderRadius: const BorderRadius.vertical(
|
||||||
|
top: Radius.circular(20),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -895,7 +1122,11 @@ class _StudentResultsDialogState extends State<_StudentResultsDialog> {
|
|||||||
widget.quizTitle,
|
widget.quizTitle,
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15, color: cs.onSurface),
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 15,
|
||||||
|
color: cs.onSurface,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
@@ -909,69 +1140,101 @@ class _StudentResultsDialogState extends State<_StudentResultsDialog> {
|
|||||||
// Body
|
// Body
|
||||||
Flexible(
|
Flexible(
|
||||||
child: _loading
|
child: _loading
|
||||||
? const Center(child: Padding(padding: EdgeInsets.all(32), child: CircularProgressIndicator()))
|
? const Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(32),
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
)
|
||||||
: _results.isEmpty
|
: _results.isEmpty
|
||||||
? Center(
|
? Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(32),
|
padding: const EdgeInsets.all(32),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Nenhum aluno submeteu este quiz ainda.',
|
'Nenhum aluno submeteu este quiz ainda.',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(color: cs.onSurfaceVariant),
|
style: TextStyle(color: cs.onSurfaceVariant),
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: ListView.separated(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
||||||
shrinkWrap: true,
|
|
||||||
itemCount: _results.length,
|
|
||||||
separatorBuilder: (_, __) => const SizedBox(height: 8),
|
|
||||||
itemBuilder: (_, i) {
|
|
||||||
final r = _results[i];
|
|
||||||
final score = r['score'] as int? ?? 0;
|
|
||||||
final total = r['total'] as int? ?? 1;
|
|
||||||
final pct = (score / total * 100).round();
|
|
||||||
final Color c = pct >= 80
|
|
||||||
? const Color(0xFF10B981)
|
|
||||||
: pct >= 50
|
|
||||||
? const Color(0xFFF59E0B)
|
|
||||||
: const Color(0xFFEF4444);
|
|
||||||
final ts = r['submittedAt'];
|
|
||||||
String dateStr = '';
|
|
||||||
if (ts is Timestamp) {
|
|
||||||
final dt = ts.toDate();
|
|
||||||
dateStr = '${dt.day.toString().padLeft(2, '0')}/${dt.month.toString().padLeft(2, '0')}/${dt.year}';
|
|
||||||
}
|
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: c.withValues(alpha: 0.07),
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
border: Border.all(color: c.withValues(alpha: 0.2)),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(r['studentName'] as String,
|
|
||||||
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 14, color: cs.onSurface)),
|
|
||||||
if (dateStr.isNotEmpty)
|
|
||||||
Text(dateStr,
|
|
||||||
style: TextStyle(fontSize: 11, color: cs.onSurfaceVariant)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text('$score/$total',
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16, color: c)),
|
|
||||||
const SizedBox(width: 6),
|
|
||||||
Text('($pct%)', style: TextStyle(fontSize: 12, color: c)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: ListView.separated(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16,
|
||||||
|
vertical: 12,
|
||||||
|
),
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemCount: _results.length,
|
||||||
|
separatorBuilder: (_, __) => const SizedBox(height: 8),
|
||||||
|
itemBuilder: (_, i) {
|
||||||
|
final r = _results[i];
|
||||||
|
final score = r['score'] as int? ?? 0;
|
||||||
|
final total = r['total'] as int? ?? 1;
|
||||||
|
final pct = (score / total * 100).round();
|
||||||
|
final Color c = pct >= 80
|
||||||
|
? const Color(0xFF10B981)
|
||||||
|
: pct >= 50
|
||||||
|
? const Color(0xFFF59E0B)
|
||||||
|
: const Color(0xFFEF4444);
|
||||||
|
final ts = r['submittedAt'];
|
||||||
|
String dateStr = '';
|
||||||
|
if (ts is Timestamp) {
|
||||||
|
final dt = ts.toDate();
|
||||||
|
dateStr =
|
||||||
|
'${dt.day.toString().padLeft(2, '0')}/${dt.month.toString().padLeft(2, '0')}/${dt.year}';
|
||||||
|
}
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 14,
|
||||||
|
vertical: 10,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: c.withValues(alpha: 0.07),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(color: c.withValues(alpha: 0.2)),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
r['studentName'] as String,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 14,
|
||||||
|
color: cs.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (dateStr.isNotEmpty)
|
||||||
|
Text(
|
||||||
|
dateStr,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
color: cs.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'$score/$total',
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 16,
|
||||||
|
color: c,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Text(
|
||||||
|
'($pct%)',
|
||||||
|
style: TextStyle(fontSize: 12, color: c),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user