Update Saqel Platform: 2026-09-04 21:26:55
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../data/models/teacher_models.dart';
|
||||
import '../../data/repositories/teacher_repository.dart';
|
||||
|
||||
/**
|
||||
* ==============================================================================
|
||||
* SAQEL TEACHER STUDIO - ASSIGNMENTS & Q&A CUBIT
|
||||
* ==============================================================================
|
||||
*
|
||||
* إدارة الواجبات المدرسية وأوراق العمل وغرفة تساؤلات الطلبة:
|
||||
* - توليد وإسناد أوراق عمل مؤتمتة التصحيح بنقرة واحدة
|
||||
* - تسجيل الردود الصوتية السقراطية (Socratic Voice Replies 🎙️)
|
||||
* - تحديث فوري لحالات الشكوك والتساؤلات.
|
||||
*/
|
||||
|
||||
class TeacherQnAState {
|
||||
final List<TeacherHomeworkModel> homeworks;
|
||||
final List<StudentDoubtModel> doubts;
|
||||
final bool isLoading;
|
||||
|
||||
const TeacherQnAState({
|
||||
required this.homeworks,
|
||||
required this.doubts,
|
||||
required this.isLoading,
|
||||
});
|
||||
|
||||
TeacherQnAState copyWith({
|
||||
List<TeacherHomeworkModel>? homeworks,
|
||||
List<StudentDoubtModel>? doubts,
|
||||
bool? isLoading,
|
||||
}) {
|
||||
return TeacherQnAState(
|
||||
homeworks: homeworks ?? this.homeworks,
|
||||
doubts: doubts ?? this.doubts,
|
||||
isLoading: isLoading ?? this.isLoading,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TeacherQnACubit extends Cubit<TeacherQnAState> {
|
||||
final TeacherRepository repository;
|
||||
|
||||
TeacherQnACubit({required this.repository})
|
||||
: super(const TeacherQnAState(
|
||||
homeworks: [],
|
||||
doubts: [],
|
||||
isLoading: false,
|
||||
));
|
||||
|
||||
Future<void> loadQnA() async {
|
||||
emit(state.copyWith(isLoading: true));
|
||||
final hwList = await repository.getHomeworks();
|
||||
final doubtsList = await repository.getStudentDoubts();
|
||||
emit(state.copyWith(
|
||||
homeworks: hwList,
|
||||
doubts: doubtsList,
|
||||
isLoading: false,
|
||||
));
|
||||
}
|
||||
|
||||
void dispatchNewHomework({
|
||||
required String title,
|
||||
required String className,
|
||||
required String dueDate,
|
||||
}) {
|
||||
final newHw = TeacherHomeworkModel(
|
||||
id: 'hw-${DateTime.now().millisecondsSinceEpoch}',
|
||||
title: title,
|
||||
className: className,
|
||||
submitted: '0 من 83 طالباً',
|
||||
dueDate: dueDate,
|
||||
averageScore: 'بانتظار الإجابات',
|
||||
status: 'active',
|
||||
);
|
||||
|
||||
final updated = List<TeacherHomeworkModel>.from(state.homeworks)..insert(0, newHw);
|
||||
emit(state.copyWith(homeworks: updated));
|
||||
}
|
||||
|
||||
void recordVoiceReply(String doubtId) {
|
||||
final updated = state.doubts.map((doubt) {
|
||||
if (doubt.id == doubtId) {
|
||||
return doubt.copyWith(replied: true, voiceReply: true);
|
||||
}
|
||||
return doubt;
|
||||
}).toList();
|
||||
|
||||
emit(state.copyWith(doubts: updated));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user