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:
@@ -20,7 +20,9 @@ class ErrorNotebookSummary {
|
||||
});
|
||||
|
||||
factory ErrorNotebookSummary.fromJson(Map<String, dynamic> json) {
|
||||
final rawBySubject = json['by_subject'] as Map<String, dynamic>? ?? {};
|
||||
final rawBySubject = json['by_subject'] is Map
|
||||
? Map<String, dynamic>.from(json['by_subject'] as Map)
|
||||
: <String, dynamic>{};
|
||||
final bySub = <String, int>{};
|
||||
rawBySubject.forEach((k, v) {
|
||||
bySub[k] = (v is num) ? v.toInt() : 0;
|
||||
|
||||
@@ -119,6 +119,27 @@ class AuthRepository {
|
||||
throw ApiException('فشل استكمال فتح الملف الأكاديمي');
|
||||
}
|
||||
|
||||
Future<UserModel> updateStudentGrade(String gradeLevel, {String stream = 'general'}) async {
|
||||
final res = await _api.post(
|
||||
'/api/student/profile/update-grade',
|
||||
body: {
|
||||
'grade_level': gradeLevel,
|
||||
'stream': stream,
|
||||
},
|
||||
requiresAuth: true,
|
||||
);
|
||||
|
||||
if (res is Map<String, dynamic> && res['data'] != null) {
|
||||
final data = res['data'];
|
||||
if (data['user'] != null) {
|
||||
final user = UserModel.fromJson(Map<String, dynamic>.from(data['user']));
|
||||
await _storage.saveUser(user);
|
||||
return user;
|
||||
}
|
||||
}
|
||||
throw ApiException('فشل تحديث الصف الدراسي');
|
||||
}
|
||||
|
||||
Future<UserModel?> getMe() async {
|
||||
try {
|
||||
final res = await _api.get(AppConfig.meEndpoint);
|
||||
|
||||
Reference in New Issue
Block a user