Coisas
This commit is contained in:
@@ -2119,16 +2119,99 @@ class _QuizListPageState extends State<QuizListPage>
|
||||
);
|
||||
}
|
||||
|
||||
final groups = _groupHistoryByDiscipline();
|
||||
final filteredItems = items.where((item) {
|
||||
final cid = item['classId'] as String?;
|
||||
return groups.containsKey(cid) && cid != null;
|
||||
}).toList();
|
||||
// Handle selected discipline for AI-generated quizzes
|
||||
if (_selectedHistoryDisciplineId != null) {
|
||||
final groups = _groupHistoryByDiscipline();
|
||||
final disciplineItems = groups[_selectedHistoryDisciplineId] ?? [];
|
||||
// Filter only AI-generated quizzes (teacherQuizId == null)
|
||||
final aiDisciplineItems = disciplineItems
|
||||
.where((q) => q['teacherQuizId'] == null)
|
||||
.toList();
|
||||
final disciplineName =
|
||||
_historyClassNames[_selectedHistoryDisciplineId] ??
|
||||
_selectedHistoryDisciplineId!;
|
||||
|
||||
if (filteredItems.isEmpty) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: cs.onSurface),
|
||||
onPressed: () =>
|
||||
setState(() => _selectedHistoryDisciplineId = null),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
disciplineName,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: cs.onSurface,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${aiDisciplineItems.length} quiz${aiDisciplineItems.length != 1 ? 'zes' : ''}',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: cs.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
_buildHistoryList(
|
||||
cs,
|
||||
aiDisciplineItems,
|
||||
isTeacherQuizzes: false,
|
||||
),
|
||||
if (_isSelectionMode && _selectedQuizIds.isNotEmpty)
|
||||
Positioned(
|
||||
bottom: 16,
|
||||
right: 16,
|
||||
child: FloatingActionButton.extended(
|
||||
onPressed: _deleteSelectedQuizzes,
|
||||
backgroundColor: Colors.red,
|
||||
icon: const Icon(Icons.delete),
|
||||
label: Text('Eliminar (${_selectedQuizIds.length})'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// Group only AI-generated quizzes by discipline
|
||||
final aiItems = items.where((q) => q['teacherQuizId'] == null).toList();
|
||||
|
||||
// Filter groups to only include disciplines with AI-generated quizzes
|
||||
final aiGroups = <String, List<Map<String, dynamic>>>{};
|
||||
for (final item in aiItems) {
|
||||
final cid = item['classId'] as String?;
|
||||
final groupId = (cid != null && _historyClassNames.containsKey(cid))
|
||||
? cid
|
||||
: '__geral__';
|
||||
aiGroups.putIfAbsent(groupId, () => []).add(item);
|
||||
}
|
||||
|
||||
if (aiGroups.isEmpty) {
|
||||
return Stack(
|
||||
children: [
|
||||
_buildHistoryList(cs, items, isTeacherQuizzes: isTeacherQuizzes),
|
||||
_buildHistoryList(cs, aiItems, isTeacherQuizzes: isTeacherQuizzes),
|
||||
if (_isSelectionMode && _selectedQuizIds.isNotEmpty)
|
||||
Positioned(
|
||||
bottom: 16,
|
||||
@@ -2144,7 +2227,7 @@ class _QuizListPageState extends State<QuizListPage>
|
||||
);
|
||||
}
|
||||
|
||||
final realDisciplineIds = groups.keys
|
||||
final realDisciplineIds = aiGroups.keys
|
||||
.where((k) => k != '__geral__' && _historyClassNames.containsKey(k))
|
||||
.toList();
|
||||
|
||||
@@ -2176,7 +2259,7 @@ class _QuizListPageState extends State<QuizListPage>
|
||||
itemBuilder: (context, i) {
|
||||
final dId = realDisciplineIds[i];
|
||||
final dName = _historyClassNames[dId] ?? dId;
|
||||
final count = groups[dId]!.length;
|
||||
final count = aiGroups[dId]!.length;
|
||||
return InkWell(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
onTap: () => setState(() => _selectedHistoryDisciplineId = dId),
|
||||
|
||||
Reference in New Issue
Block a user