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:
Hamza-Ayed
2026-09-09 01:06:35 +03:00
parent 8183e53b86
commit 0a2ca71cb4
13 changed files with 440 additions and 41 deletions
@@ -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) {