Fix student grade registration: set grade_10 as default, add auto-heal for legacy tawjihi_2008, add student grade selector and update-grade API
This commit is contained in:
@@ -169,6 +169,22 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateGrade(String gradeLevel, {String stream = 'general'}) async {
|
||||
final currentState = state;
|
||||
if (currentState is! Authenticated) return;
|
||||
AppLogger.log('Updating student grade to $gradeLevel ($stream)...', tag: 'AUTH_CUBIT');
|
||||
emit(AuthLoading());
|
||||
try {
|
||||
final updatedUser = await _authRepo.updateStudentGrade(gradeLevel, stream: stream);
|
||||
AppLogger.log('Grade updated successfully -> ${updatedUser.gradeLevel}', tag: 'AUTH_CUBIT');
|
||||
emit(Authenticated(user: updatedUser, activeRole: 'student'));
|
||||
} catch (e) {
|
||||
AppLogger.error('Update Grade Exception', error: e, tag: 'AUTH_CUBIT');
|
||||
emit(AuthError(e.toString()));
|
||||
emit(currentState);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> switchRole(String newRole) async {
|
||||
final currentState = state;
|
||||
if (currentState is Authenticated) {
|
||||
|
||||
@@ -93,7 +93,8 @@ class VideoPlaybackCubit extends Cubit<VideoPlaybackState> {
|
||||
final storageKey = _getLessonStorageKey(lesson);
|
||||
|
||||
try {
|
||||
var playback = await _repo.getLessonPlayback(lesson.markdownFilePath ?? lesson.id, subjectId: subject?.id);
|
||||
final cleanKey = (lesson.markdownFilePath ?? lesson.id).replaceAll(RegExp(r'\.md$'), '');
|
||||
var playback = await _repo.getLessonPlayback(cleanKey, subjectId: subject?.id);
|
||||
if (playback.videoUrl.isEmpty) {
|
||||
throw StateError('لم يربط الخادم فيديو R2 بهذا الدرس بعد.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user