diff --git a/firka/lib/helpers/api/model/class_group.dart b/firka/lib/helpers/api/model/class_group.dart index a7fec3e7..d4fe2b79 100644 --- a/firka/lib/helpers/api/model/class_group.dart +++ b/firka/lib/helpers/api/model/class_group.dart @@ -7,6 +7,7 @@ class ClassGroup { final UidObj? substituteHeadTeacher; final NameUidDesc studyGroup; final int? studyGroupSortIndex; + final NameUidDesc? studyTask; final bool isActive; final String type; @@ -17,6 +18,7 @@ class ClassGroup { required this.substituteHeadTeacher, required this.studyGroup, required this.studyGroupSortIndex, + required this.studyTask, required this.isActive, required this.type}); @@ -32,6 +34,9 @@ class ClassGroup { : null, studyGroup: NameUidDesc.fromJson(json['OktatasNevelesiKategoria']), studyGroupSortIndex: json['OktatasNevelesiKategoriaSortIndex'], + studyTask: json['OktatasNevelesiFeladat'] != null + ? NameUidDesc.fromJson(json['OktatasNevelesiFeladat']) + : null, isActive: json['IsAktiv'], type: json['Tipus']); } @@ -45,6 +50,7 @@ class ClassGroup { 'substituteHeadTeacher: $substituteHeadTeacher, ' 'studyGroup: $studyGroup, ' 'studyGroupSortIndex: $studyGroupSortIndex, ' + 'studyTask: $studyTask, ' 'isActive: $isActive, ' 'type: "$type"' ')'; @@ -53,19 +59,53 @@ class ClassGroup { class SubjectAverage { final String uid; + final String name; + final String? teacherName; + final String subjectCategoryId; + final String subjectCategoryName; + final String subjectCategoryDescription; + final double? average; + final double? weightedSum; + final double? weightedCount; + final int sortIndex; - SubjectAverage({required this.uid}); + SubjectAverage({ + required this.uid, + required this.name, + this.teacherName, + required this.subjectCategoryId, + required this.subjectCategoryName, + required this.subjectCategoryDescription, + this.average, + this.weightedSum, + this.weightedCount, + required this.sortIndex, + }); factory SubjectAverage.fromJson(Map json) { + final tantargy = json['Tantargy'] ?? {}; + final kategori = tantargy['Kategoria'] ?? {}; + return SubjectAverage( - uid: json['Uid'], + uid: json['Uid'] ?? '', + name: tantargy['Nev'] ?? '', + teacherName: json['TeacherName'], + subjectCategoryId: kategori['Uid'] ?? '', + subjectCategoryName: kategori['Nev'] ?? '', + subjectCategoryDescription: kategori['Leiras'] ?? '', + average: json['Atlag'] != null ? (json['Atlag'] as num).toDouble() : null, + weightedSum: json['SulyozottOsztalyzatOsszege'] != null + ? (json['SulyozottOsztalyzatOsszege'] as num).toDouble() + : null, + weightedCount: json['SulyozottOsztalyzatSzama'] != null + ? (json['SulyozottOsztalyzatSzama'] as num).toDouble() + : null, + sortIndex: tantargy['SortIndex'] ?? 0, ); } @override String toString() { - return 'SubjectAverage(' - 'uid: "$uid"' - ')'; + return 'SubjectAverage(uid: "$uid", name: "$name", category: "$subjectCategoryName", average: $average)'; } }