firka_wear: sync API models from firka (Lesson, Grade, Subject, generic)
This commit is contained in:
@@ -3,12 +3,22 @@ class NameUidDesc {
|
||||
final String? name;
|
||||
final String? description;
|
||||
|
||||
NameUidDesc(
|
||||
{required this.uid, required this.name, required this.description});
|
||||
NameUidDesc({
|
||||
required this.uid,
|
||||
required this.name,
|
||||
required this.description,
|
||||
});
|
||||
|
||||
factory NameUidDesc.fromJson(Map<String, dynamic> json) {
|
||||
return NameUidDesc(
|
||||
uid: json['Uid'], name: json['Nev'], description: json['Leiras']);
|
||||
uid: json['Uid'],
|
||||
name: json['Nev'],
|
||||
description: json['Leiras'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {'Uid': uid, 'Nev': name, 'Leiras': description};
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -25,16 +35,14 @@ class NameUid {
|
||||
final String uid;
|
||||
final String name;
|
||||
|
||||
NameUid({
|
||||
required this.uid,
|
||||
required this.name,
|
||||
});
|
||||
NameUid({required this.uid, required this.name});
|
||||
|
||||
factory NameUid.fromJson(Map<String, dynamic> json) {
|
||||
return NameUid(
|
||||
uid: json['Uid'],
|
||||
name: json['Nev'],
|
||||
);
|
||||
return NameUid(uid: json['Uid'], name: json['Nev']);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {'Uid': uid, 'Nev': name};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,9 +52,7 @@ class UidObj {
|
||||
UidObj({required this.uid});
|
||||
|
||||
factory UidObj.fromJson(Map<String, dynamic> json) {
|
||||
return UidObj(
|
||||
uid: json['Uid'],
|
||||
);
|
||||
return UidObj(uid: json['Uid']);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -20,38 +20,47 @@ class Grade {
|
||||
final UidObj? classGroup;
|
||||
final int sortIndex;
|
||||
|
||||
Grade(
|
||||
{required this.uid,
|
||||
required this.recordDate,
|
||||
required this.creationDate,
|
||||
this.ackDate,
|
||||
required this.subject,
|
||||
this.topic,
|
||||
required this.type,
|
||||
this.mode,
|
||||
required this.valueType,
|
||||
required this.teacher,
|
||||
this.kind,
|
||||
this.numericValue,
|
||||
required this.strValue,
|
||||
this.weightPercentage,
|
||||
this.shortStrValue,
|
||||
this.classGroup,
|
||||
required this.sortIndex});
|
||||
Grade({
|
||||
required this.uid,
|
||||
required this.recordDate,
|
||||
required this.creationDate,
|
||||
this.ackDate,
|
||||
required this.subject,
|
||||
this.topic,
|
||||
required this.type,
|
||||
this.mode,
|
||||
required this.valueType,
|
||||
required this.teacher,
|
||||
this.kind,
|
||||
this.numericValue,
|
||||
required this.strValue,
|
||||
this.weightPercentage,
|
||||
this.shortStrValue,
|
||||
this.classGroup,
|
||||
required this.sortIndex,
|
||||
});
|
||||
|
||||
factory Grade.fromJson(Map<String, dynamic> json) {
|
||||
return Grade(
|
||||
uid: json['Uid'],
|
||||
recordDate: DateTime.parse(json['RogzitesDatuma']),
|
||||
creationDate: DateTime.parse(json['KeszitesDatuma']),
|
||||
recordDate: DateTime.parse(json['RogzitesDatuma']).toLocal(),
|
||||
creationDate: DateTime.parse(json['KeszitesDatuma']).toLocal(),
|
||||
ackDate: json['LattamozasDatuma'] != null
|
||||
? DateTime.parse(json['LattamozasDatuma'])
|
||||
? DateTime.parse(json['LattamozasDatuma']).toLocal()
|
||||
: null,
|
||||
subject: Subject.fromJson(json['Tantargy']),
|
||||
subject: Subject.fromJson(
|
||||
Map<String, dynamic>.from(json['Tantargy'] as Map),
|
||||
),
|
||||
topic: json['Tema'],
|
||||
type: NameUidDesc.fromJson(json['Tipus']),
|
||||
mode: json['Mod'] != null ? NameUidDesc.fromJson(json['Mod']) : null,
|
||||
valueType: NameUidDesc.fromJson(json['ErtekFajta']),
|
||||
type: NameUidDesc.fromJson(
|
||||
Map<String, dynamic>.from(json['Tipus'] as Map),
|
||||
),
|
||||
mode: json['Mod'] != null
|
||||
? NameUidDesc.fromJson(Map<String, dynamic>.from(json['Mod'] as Map))
|
||||
: null,
|
||||
valueType: NameUidDesc.fromJson(
|
||||
Map<String, dynamic>.from(json['ErtekFajta'] as Map),
|
||||
),
|
||||
teacher: json['ErtekeloTanarNeve'],
|
||||
kind: json['Kind'],
|
||||
numericValue: json['SzamErtek'],
|
||||
@@ -59,12 +68,36 @@ class Grade {
|
||||
weightPercentage: json['SulySzazalekErteke'],
|
||||
shortStrValue: json['SzovegesErtekelesRovidNev'],
|
||||
classGroup: json['OsztalyCsoport'] != null
|
||||
? UidObj.fromJson(json['OsztalyCsoport'])
|
||||
? UidObj.fromJson(
|
||||
Map<String, dynamic>.from(json['OsztalyCsoport'] as Map),
|
||||
)
|
||||
: null,
|
||||
sortIndex: json['SortIndex'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'Uid': uid,
|
||||
'RogzitesDatuma': recordDate.toUtc().toIso8601String(),
|
||||
'KeszitesDatuma': creationDate.toUtc().toIso8601String(),
|
||||
'LattamozasDatuma': ackDate?.toUtc().toIso8601String(),
|
||||
'Tantargy': subject.toJson(),
|
||||
'Tema': topic,
|
||||
'Tipus': type.toJson(),
|
||||
'Mod': mode?.toJson(),
|
||||
'ErtekFajta': valueType.toJson(),
|
||||
'ErtekeloTanarNeve': teacher,
|
||||
'Kind': kind,
|
||||
'SzamErtek': numericValue,
|
||||
'SzovegesErtek': strValue,
|
||||
'SulySzazalekErteke': weightPercentage,
|
||||
'SzovegesErtekelesRovidNev': shortStrValue,
|
||||
'OsztalyCsoport': classGroup != null ? {'Uid': classGroup!.uid} : null,
|
||||
'SortIndex': sortIndex,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Grade('
|
||||
|
||||
@@ -1,23 +1,40 @@
|
||||
import 'generic.dart';
|
||||
import 'package:firka_wear/helpers/api/model/generic.dart';
|
||||
|
||||
class Subject {
|
||||
final String uid;
|
||||
final String name;
|
||||
final NameUidDesc category;
|
||||
final int sortIndex;
|
||||
final String? teacherName;
|
||||
|
||||
Subject(
|
||||
{required this.uid,
|
||||
required this.name,
|
||||
required this.category,
|
||||
required this.sortIndex});
|
||||
Subject({
|
||||
required this.uid,
|
||||
required this.name,
|
||||
required this.category,
|
||||
required this.sortIndex,
|
||||
this.teacherName,
|
||||
});
|
||||
|
||||
factory Subject.fromJson(Map<String, dynamic> json) {
|
||||
return Subject(
|
||||
uid: json['Uid'],
|
||||
name: json['Nev'],
|
||||
category: NameUidDesc.fromJson(json['Kategoria']),
|
||||
sortIndex: json['SortIndex']);
|
||||
uid: json['Uid'],
|
||||
name: json['Nev'],
|
||||
category: NameUidDesc.fromJson(
|
||||
Map<String, dynamic>.from(json['Kategoria'] as Map),
|
||||
),
|
||||
sortIndex: json['SortIndex'],
|
||||
teacherName: json['alkalmazottNev'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'Uid': uid,
|
||||
'Nev': name,
|
||||
'Kategoria': category.toJson(),
|
||||
'SortIndex': sortIndex,
|
||||
'alkalmazottNev': teacherName,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -26,7 +43,8 @@ class Subject {
|
||||
'uid: "$uid", '
|
||||
'name: "$name", '
|
||||
'category: $category, '
|
||||
'sortIndex: $sortIndex'
|
||||
'sortIndex: $sortIndex, '
|
||||
'teacherName: $teacherName'
|
||||
')';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,32 +66,43 @@ class Lesson {
|
||||
|
||||
factory Lesson.fromJson(Map<String, dynamic> json) {
|
||||
var attachments = List<NameUid>.empty(growable: true);
|
||||
var rawAttachments = json['Csatolmanyok'];
|
||||
var rawAttachments = json['Csatolmanyok'] as List<dynamic>? ?? [];
|
||||
|
||||
for (var attachment in rawAttachments) {
|
||||
attachments.add(NameUid.fromJson(attachment));
|
||||
attachments.add(
|
||||
NameUid.fromJson(Map<String, dynamic>.from(attachment as Map)),
|
||||
);
|
||||
}
|
||||
return Lesson(
|
||||
uid: json['Uid'],
|
||||
date: json['Datum'],
|
||||
start: DateTime.parse(json['KezdetIdopont']),
|
||||
end: DateTime.parse(json['VegIdopont']),
|
||||
start: DateTime.parse(json['KezdetIdopont']).toLocal(),
|
||||
end: DateTime.parse(json['VegIdopont']).toLocal(),
|
||||
name: json['Nev'],
|
||||
lessonNumber: json['Oraszam'],
|
||||
lessonSeqNumber: json['OraEvesSorszama'],
|
||||
classGroup: json['OsztalyCsoport'] != null
|
||||
? NameUid.fromJson(json['OsztalyCsoport'])
|
||||
? NameUid.fromJson(
|
||||
Map<String, dynamic>.from(json['OsztalyCsoport'] as Map),
|
||||
)
|
||||
: null,
|
||||
teacher: json['TanarNeve'],
|
||||
subject:
|
||||
json['Tantargy'] != null ? Subject.fromJson(json['Tantargy']) : null,
|
||||
subject: json['Tantargy'] != null
|
||||
? Subject.fromJson(Map<String, dynamic>.from(json['Tantargy'] as Map))
|
||||
: null,
|
||||
theme: json['Tema'],
|
||||
roomName: json['TeremNeve'],
|
||||
type: NameUidDesc.fromJson(json['Tipus']),
|
||||
type: NameUidDesc.fromJson(
|
||||
Map<String, dynamic>.from(json['Tipus'] as Map),
|
||||
),
|
||||
studentPresence: json['TanuloJelenlet'] != null
|
||||
? NameUidDesc.fromJson(json['TanuloJelenlet'])
|
||||
? NameUidDesc.fromJson(
|
||||
Map<String, dynamic>.from(json['TanuloJelenlet'] as Map),
|
||||
)
|
||||
: null,
|
||||
state: NameUidDesc.fromJson(json['Allapot']),
|
||||
state: NameUidDesc.fromJson(
|
||||
Map<String, dynamic>.from(json['Allapot'] as Map),
|
||||
),
|
||||
substituteTeacher: json['HelyettesTanarNeve'],
|
||||
homeworkUid: json['HaziFeladatUid'],
|
||||
taskGroupUid: json['FeladatGroupUid'],
|
||||
@@ -105,13 +116,48 @@ class Lesson {
|
||||
digitalPlatformType: json['DigitalisPlatformTipus'],
|
||||
digitalSupportDeviceTypeList:
|
||||
json['DigitalisTamogatoEszkozTipusList'] != null
|
||||
? List<String>.from(json['DigitalisTamogatoEszkozTipusList'])
|
||||
: List<String>.empty(),
|
||||
createdAt: DateTime.parse(json['Letrehozas']),
|
||||
lastModifiedAt: DateTime.parse(json['UtolsoModositas']),
|
||||
? List<String>.from(json['DigitalisTamogatoEszkozTipusList'])
|
||||
: List<String>.empty(),
|
||||
createdAt: DateTime.parse(json['Letrehozas']).toLocal(),
|
||||
lastModifiedAt: DateTime.parse(json['UtolsoModositas']).toLocal(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final rawAttachments = attachments.map((e) => e.toJson()).toList();
|
||||
return {
|
||||
'Uid': uid,
|
||||
'Datum': date,
|
||||
'KezdetIdopont': start.toIso8601String(),
|
||||
'VegIdopont': end.toIso8601String(),
|
||||
'Nev': name,
|
||||
'Oraszam': lessonNumber,
|
||||
'OraEvesSorszama': lessonSeqNumber,
|
||||
'OsztalyCsoport': classGroup?.toJson(),
|
||||
'TanarNeve': teacher,
|
||||
'Tantargy': subject?.toJson(),
|
||||
'Tema': theme,
|
||||
'TeremNeve': roomName,
|
||||
'Tipus': type.toJson(),
|
||||
'TanuloJelenlet': studentPresence?.toJson(),
|
||||
'Allapot': state.toJson(),
|
||||
'HelyettesTanarNeve': substituteTeacher,
|
||||
'HaziFeladatUid': homeworkUid,
|
||||
'FeladatGroupUid': taskGroupUid,
|
||||
'NyelviFeladatGroupUid': languageTaskGroupUid,
|
||||
'BejelentettSzamonkeresUid': assessmentUid,
|
||||
'IsTanuloHaziFeladatEnabled': canStudentEditHomework,
|
||||
'IsHaziFeladatMegoldva': isHomeworkComplete,
|
||||
'Csatolmanyok': rawAttachments,
|
||||
'IsDigitalisOra': isDigitalLesson,
|
||||
'DigitalisEszkozTipus': digitalDeviceList,
|
||||
'DigitalisPlatformTipus': digitalPlatformType,
|
||||
'DigitalisTamogatoEszkozTipusList': digitalSupportDeviceTypeList,
|
||||
'Letrehozas': createdAt.toIso8601String(),
|
||||
'UtolsoModositas': lastModifiedAt.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Lesson('
|
||||
|
||||
Reference in New Issue
Block a user