forked from firka/firka
ref: cache system rewrite
This commit is contained in:
@@ -3,7 +3,6 @@ library kreta_api;
|
||||
export 'src/api_response.dart';
|
||||
export 'src/endpoints.dart';
|
||||
export 'src/exceptions/token.dart';
|
||||
export 'src/model/all_lessons.dart';
|
||||
export 'src/model/class_group.dart';
|
||||
export 'src/model/generic.dart';
|
||||
export 'src/model/grade.dart';
|
||||
@@ -17,3 +16,4 @@ export 'src/model/subject.dart';
|
||||
export 'src/model/test.dart';
|
||||
export 'src/model/timetable.dart';
|
||||
export 'src/resp/token_grant.dart';
|
||||
export 'src/model/dkt_subject.dart';
|
||||
|
||||
@@ -34,7 +34,7 @@ class KretaEndpoints {
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
static String getStudentUrl(String iss) =>
|
||||
static String getStudent(String iss) =>
|
||||
"${kreta(iss)}/ellenorzo/v3/sajat/TanuloAdatlap";
|
||||
|
||||
static String getClassGroups(String iss) =>
|
||||
@@ -49,9 +49,6 @@ class KretaEndpoints {
|
||||
static String getGrades(String iss, [DateTime? from, DateTime? to]) =>
|
||||
"${kreta(iss)}/ellenorzo/v3/sajat/Ertekelesek${dateQuery(from, to)}";
|
||||
|
||||
static String getSubjectAvg(String iss, String studyGroupId) =>
|
||||
"${kreta(iss)}/ellenorzo/v3/sajat/Ertekelesek/Atlagok/TantargyiAtlagok?oktatasiNevelesiFeladatUid=$studyGroupId&oktatasiNevelesiFeladatUid=$studyGroupId";
|
||||
|
||||
static String getClassGroupAvg(String iss, String studyGroupId) =>
|
||||
"${kreta(iss)}/ellenorzo/v3/sajat/Ertekelesek/Atlagok/OsztalyAtlagok?oktatasiNevelesiFeladatUid=$studyGroupId&oktatasiNevelesiFeladatUid=$studyGroupId";
|
||||
|
||||
@@ -67,6 +64,6 @@ class KretaEndpoints {
|
||||
static String getTests(String iss, [DateTime? from, DateTime? to]) =>
|
||||
"${kreta(iss)}/ellenorzo/v3/sajat/BejelentettSzamonkeresek${dateQuery(from, to)}";
|
||||
|
||||
static String getLessons(String iss) =>
|
||||
static String getDktSubjects(String iss) =>
|
||||
"${kreta(iss)}/dktapi/intezmenyek/munkaterek/tanulok";
|
||||
}
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class AllLessons {
|
||||
final String schoolId;
|
||||
final String yearId;
|
||||
final dynamic classId;
|
||||
final String? className;
|
||||
final bool classWorkspace;
|
||||
final dynamic groupId;
|
||||
final String? groupName;
|
||||
final bool groupWorkspace;
|
||||
final String groupWorkspaceName;
|
||||
final dynamic subjectId;
|
||||
final String subjectName;
|
||||
final dynamic teacherId;
|
||||
final String teacherGuid;
|
||||
final String teacherName;
|
||||
final dynamic teacherAnnoId;
|
||||
final dynamic annoId;
|
||||
final String? languageId;
|
||||
final dynamic subjectCategoryId;
|
||||
final String subjectCategoryName;
|
||||
final dynamic typeId;
|
||||
final String typeName;
|
||||
final dynamic gradeTypeId;
|
||||
final String gradeTypeName;
|
||||
final dynamic taskPlaceId;
|
||||
final String taskPlaceName;
|
||||
final dynamic teacherAvatarTypeId;
|
||||
final String teacherAvatarTypePath;
|
||||
final dynamic taskGroupId;
|
||||
|
||||
const AllLessons({
|
||||
required this.schoolId,
|
||||
required this.yearId,
|
||||
this.classId,
|
||||
this.className,
|
||||
required this.classWorkspace,
|
||||
this.groupId,
|
||||
this.groupName,
|
||||
required this.groupWorkspace,
|
||||
required this.groupWorkspaceName,
|
||||
required this.subjectId,
|
||||
required this.subjectName,
|
||||
required this.teacherId,
|
||||
required this.teacherGuid,
|
||||
required this.teacherName,
|
||||
this.teacherAnnoId,
|
||||
this.annoId,
|
||||
this.languageId,
|
||||
required this.subjectCategoryId,
|
||||
required this.subjectCategoryName,
|
||||
required this.typeId,
|
||||
required this.typeName,
|
||||
required this.gradeTypeId,
|
||||
required this.gradeTypeName,
|
||||
required this.taskPlaceId,
|
||||
required this.taskPlaceName,
|
||||
required this.teacherAvatarTypeId,
|
||||
required this.teacherAvatarTypePath,
|
||||
this.taskGroupId,
|
||||
});
|
||||
|
||||
factory AllLessons.fromJson(Map<String, dynamic> json) => AllLessons(
|
||||
schoolId: json['intezmenyId']?.toString() ?? '',
|
||||
yearId: json['tanevId']?.toString() ?? '',
|
||||
classId: json['osztalyId'],
|
||||
className: json['osztalyNev']?.toString(),
|
||||
classWorkspace: json['osztalyMunkaTer'] == true,
|
||||
groupId: json['csoportId'],
|
||||
groupName: json['csoportNev']?.toString(),
|
||||
groupWorkspace: json['csoportMunkaTer'] == true,
|
||||
groupWorkspaceName: json['osztalyCsoportNev']?.toString() ?? '',
|
||||
subjectId: json['tantargyId'],
|
||||
subjectName: json['tantargyNev']?.toString() ?? '',
|
||||
teacherId: json['alkalmazottId'],
|
||||
teacherGuid: json['alkalmazottGuid']?.toString() ?? '',
|
||||
teacherName: json['alkalmazottNev']?.toString() ?? '',
|
||||
teacherAnnoId: json['alkalmazottUzenoFalId'],
|
||||
annoId: json['uzenoFalId'],
|
||||
languageId: json['nyelvId']?.toString(),
|
||||
subjectCategoryId: json['tantargyKategoriaId'],
|
||||
subjectCategoryName: json['tantargyKategoriaNev']?.toString() ?? '',
|
||||
typeId: json['tipusId'],
|
||||
typeName: json['tipusNev']?.toString() ?? '',
|
||||
gradeTypeId: json['evfolyamTipusId'],
|
||||
gradeTypeName: json['evfolyamTipusNev']?.toString() ?? '',
|
||||
taskPlaceId: json['feladatEllatasiHelyId'],
|
||||
taskPlaceName: json['feladatEllatasiHelyNev']?.toString() ?? '',
|
||||
teacherAvatarTypeId: json['alkalmazottAvatarTipusId'],
|
||||
teacherAvatarTypePath: json['alkalmazottAvatarEleres']?.toString() ?? '',
|
||||
taskGroupId: json['oraiFeladatGroupId'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'intezmenyId': schoolId,
|
||||
'tanevId': yearId,
|
||||
'osztalyId': classId,
|
||||
'osztalyNev': className,
|
||||
'osztalyMunkaTer': classWorkspace,
|
||||
'csoportId': groupId,
|
||||
'csoportNev': groupName,
|
||||
'csoportMunkaTer': groupWorkspace,
|
||||
'osztalyCsoportNev': groupWorkspaceName,
|
||||
'tantargyId': subjectId,
|
||||
'tantargyNev': subjectName,
|
||||
'alkalmazottId': teacherId,
|
||||
'alkalmazottGuid': teacherGuid,
|
||||
'alkalmazottNev': teacherName,
|
||||
'alkalmazottUzenoFalId': teacherAnnoId,
|
||||
'uzenoFalId': annoId,
|
||||
'nyelvId': languageId,
|
||||
'tantargyKategoriaId': subjectCategoryId,
|
||||
'tantargyKategoriaNev': subjectCategoryName,
|
||||
'tipusId': typeId,
|
||||
'tipusNev': typeName,
|
||||
'evfolyamTipusId': gradeTypeId,
|
||||
'evfolyamTipusNev': gradeTypeName,
|
||||
'feladatEllatasiHelyId': taskPlaceId,
|
||||
'feladatEllatasiHelyNev': taskPlaceName,
|
||||
'alkalmazottAvatarTipusId': teacherAvatarTypeId,
|
||||
'alkalmazottAvatarEleres': teacherAvatarTypePath,
|
||||
'oraiFeladatGroupId': taskGroupId,
|
||||
};
|
||||
}
|
||||
|
||||
List<AllLessons> lessonsFromJson(String str) =>
|
||||
List<AllLessons>.from(json.decode(str).map((x) => AllLessons.fromJson(x)));
|
||||
|
||||
String lessonsToJson(List<AllLessons> data) =>
|
||||
json.encode(List<dynamic>.from(data.map((x) => x.toJson())));
|
||||
@@ -11,7 +11,7 @@ class ClassGroup extends NameUid {
|
||||
final bool isActive;
|
||||
final String type;
|
||||
|
||||
const ClassGroup({
|
||||
ClassGroup({
|
||||
required super.uid,
|
||||
required super.name,
|
||||
required this.headTeacher,
|
||||
@@ -59,7 +59,7 @@ class SubjectAverage extends UidObj {
|
||||
final double? weightedSum;
|
||||
final double? weightedCount;
|
||||
|
||||
const SubjectAverage({
|
||||
SubjectAverage({
|
||||
required super.uid,
|
||||
required this.subject,
|
||||
this.average,
|
||||
@@ -88,7 +88,7 @@ class ClassGroupSubjectAverage extends UidObj {
|
||||
final double? studentAverage;
|
||||
final double? classGroupAverage;
|
||||
|
||||
const ClassGroupSubjectAverage({
|
||||
ClassGroupSubjectAverage({
|
||||
required super.uid,
|
||||
required this.subject,
|
||||
this.classGroupAverage,
|
||||
|
||||
33
kreta_api/lib/src/model/dkt_subject.dart
Normal file
33
kreta_api/lib/src/model/dkt_subject.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'generic.dart';
|
||||
|
||||
class DktSubject extends Identifiable {
|
||||
final int id;
|
||||
final String name;
|
||||
final String teacherName;
|
||||
final int? classGroupId; // null = whole class
|
||||
final String groupName; // if group null then class name
|
||||
final String? languageCode; // ISO 639-1:2002; null = non-language subject
|
||||
final int typeId; // 0 = not removed
|
||||
|
||||
DktSubject({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.teacherName,
|
||||
required this.typeId,
|
||||
this.languageCode,
|
||||
this.classGroupId,
|
||||
required this.groupName,
|
||||
});
|
||||
|
||||
factory DktSubject.fromJson(Map<String, dynamic> json) {
|
||||
return DktSubject(
|
||||
id: json["tantargyId"],
|
||||
name: json["tantargyNev"],
|
||||
teacherName: json["alkalmazottNev"],
|
||||
classGroupId: json["csoportId"],
|
||||
groupName: json["osztalyCsoportNev"],
|
||||
typeId: json["tipusId"],
|
||||
languageCode: json["nyelvId"],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ class NameUidDesc extends NameUid {
|
||||
static final EMPTY = NameUidDesc(name: "", uid: "", description: "");
|
||||
final String description;
|
||||
|
||||
const NameUidDesc({
|
||||
NameUidDesc({
|
||||
required super.uid,
|
||||
required super.name,
|
||||
required this.description,
|
||||
@@ -33,7 +33,7 @@ class NameUidDesc extends NameUid {
|
||||
class NameUid extends UidObj {
|
||||
final String name;
|
||||
|
||||
const NameUid({required super.uid, required this.name});
|
||||
NameUid({required super.uid, required this.name});
|
||||
|
||||
factory NameUid.fromJson(Map<String, dynamic> json) {
|
||||
return NameUid(uid: json['Uid'], name: json['Nev']);
|
||||
@@ -44,15 +44,21 @@ class NameUid extends UidObj {
|
||||
}
|
||||
}
|
||||
|
||||
class UidObj {
|
||||
class UidObj extends Identifiable {
|
||||
final String uid;
|
||||
|
||||
const UidObj({required this.uid});
|
||||
UidObj({required this.uid});
|
||||
|
||||
factory UidObj.fromJson(Map<String, dynamic> json) {
|
||||
return UidObj(uid: json['Uid']);
|
||||
}
|
||||
|
||||
/// Extracts numeric id from composite key
|
||||
/// but sometimes (i.e. "Uid" : "Magatartás" in Grade.subject)
|
||||
/// not, then it uses it's hashcode, be careful!
|
||||
@override
|
||||
int get id => int.tryParse(uid.split(",").first) ?? uid.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UidObj('
|
||||
@@ -61,6 +67,10 @@ class UidObj {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Identifiable {
|
||||
int get id;
|
||||
}
|
||||
|
||||
extension ToUidObj on Map<String, dynamic> {
|
||||
UidObj? uid(String key) {
|
||||
final value = this[key];
|
||||
|
||||
@@ -16,10 +16,10 @@ class Grade extends UidObj {
|
||||
final String strValue;
|
||||
final int? weightPercentage;
|
||||
final String? shortStrValue;
|
||||
final UidObj? classGroup;
|
||||
final UidObj classGroup;
|
||||
final int sortIndex;
|
||||
|
||||
const Grade({
|
||||
Grade({
|
||||
required super.uid,
|
||||
required this.recordDate,
|
||||
required this.creationDate,
|
||||
@@ -35,7 +35,7 @@ class Grade extends UidObj {
|
||||
required this.strValue,
|
||||
this.weightPercentage,
|
||||
this.shortStrValue,
|
||||
this.classGroup,
|
||||
required this.classGroup,
|
||||
required this.sortIndex,
|
||||
});
|
||||
|
||||
@@ -58,7 +58,7 @@ class Grade extends UidObj {
|
||||
strValue: json['SzovegesErtek'],
|
||||
weightPercentage: json['SulySzazalekErteke'],
|
||||
shortStrValue: json['SzovegesErtekelesRovidNev'],
|
||||
classGroup: json.uid('OsztalyCsoport'),
|
||||
classGroup: json.uid('OsztalyCsoport')!,
|
||||
sortIndex: json['SortIndex'],
|
||||
);
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class Grade extends UidObj {
|
||||
'SzovegesErtek': strValue,
|
||||
'SulySzazalekErteke': weightPercentage,
|
||||
'SzovegesErtekelesRovidNev': shortStrValue,
|
||||
'OsztalyCsoport': classGroup != null ? {'Uid': classGroup!.uid} : null,
|
||||
'OsztalyCsoport': classGroup,
|
||||
'SortIndex': sortIndex,
|
||||
};
|
||||
}
|
||||
@@ -103,7 +103,7 @@ class Grade extends UidObj {
|
||||
'strValue: "$strValue", '
|
||||
'weightPercentage: ${weightPercentage ?? 'null'}, '
|
||||
'shortStrValue: "${shortStrValue ?? 'null'}", '
|
||||
'classGroup: ${classGroup ?? 'null'}, '
|
||||
'classGroup: ${classGroup}, '
|
||||
'sortIndex: $sortIndex'
|
||||
')';
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ class Guardian extends NameUid {
|
||||
final bool isLegalRepresentative;
|
||||
final String? phoneNumber;
|
||||
|
||||
const Guardian({
|
||||
Guardian({
|
||||
required this.email,
|
||||
required this.isLegalRepresentative,
|
||||
required super.name,
|
||||
|
||||
@@ -16,7 +16,7 @@ class Homework extends UidObj {
|
||||
final UidObj classGroup;
|
||||
final bool canAttach;
|
||||
|
||||
const Homework({
|
||||
Homework({
|
||||
required super.uid,
|
||||
required this.subject,
|
||||
required this.subjectName,
|
||||
|
||||
@@ -5,7 +5,7 @@ class Institution extends UidObj {
|
||||
final String shortName;
|
||||
final List<SystemModule> systemModuleList;
|
||||
|
||||
const Institution({
|
||||
Institution({
|
||||
required this.customizationSettings,
|
||||
required this.shortName,
|
||||
required this.systemModuleList,
|
||||
|
||||
@@ -7,7 +7,7 @@ abstract class MessageItem extends UidObj {
|
||||
final String contentHTML;
|
||||
final String contentText;
|
||||
|
||||
const MessageItem({
|
||||
MessageItem({
|
||||
required super.uid,
|
||||
required this.title,
|
||||
required this.author,
|
||||
@@ -25,7 +25,7 @@ class NoticeBoardItem extends MessageItem {
|
||||
@override
|
||||
DateTime get date => validFrom;
|
||||
|
||||
const NoticeBoardItem({
|
||||
NoticeBoardItem({
|
||||
required super.uid,
|
||||
required super.title,
|
||||
required super.author,
|
||||
@@ -66,7 +66,7 @@ class InfoBoardItem extends MessageItem {
|
||||
final DateTime createdAt;
|
||||
final NameUidDesc type;
|
||||
|
||||
const InfoBoardItem({
|
||||
InfoBoardItem({
|
||||
required super.uid,
|
||||
required super.title,
|
||||
required super.author,
|
||||
|
||||
@@ -15,7 +15,7 @@ class Omission extends UidObj {
|
||||
final NameUidDesc? proofType;
|
||||
final UidObj? classGroup;
|
||||
|
||||
const Omission({
|
||||
Omission({
|
||||
required super.uid,
|
||||
required this.subject,
|
||||
required this.lesson,
|
||||
|
||||
@@ -21,7 +21,7 @@ class Student extends NameUid {
|
||||
|
||||
final Institution institution;
|
||||
|
||||
const Student({
|
||||
Student({
|
||||
required this.addressDataList,
|
||||
required this.bankAccount,
|
||||
required this.birthdate,
|
||||
|
||||
@@ -3,14 +3,12 @@ import 'generic.dart';
|
||||
class Subject extends NameUid {
|
||||
final NameUidDesc category;
|
||||
final int sortIndex;
|
||||
final String? teacherName;
|
||||
|
||||
const Subject({
|
||||
Subject({
|
||||
required super.uid,
|
||||
required super.name,
|
||||
required this.category,
|
||||
required this.sortIndex,
|
||||
this.teacherName,
|
||||
});
|
||||
|
||||
factory Subject.fromJson(Map<String, dynamic> json) {
|
||||
@@ -19,20 +17,9 @@ class Subject extends NameUid {
|
||||
name: json['Nev'],
|
||||
category: json.nameUidDesc('Kategoria')!,
|
||||
sortIndex: json['SortIndex'],
|
||||
teacherName: json['alkalmazottNev'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'Uid': uid,
|
||||
'Nev': name,
|
||||
'Kategoria': category.toJson(),
|
||||
'SortIndex': sortIndex,
|
||||
'alkalmazottNev': teacherName,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Subject('
|
||||
@@ -40,7 +27,6 @@ class Subject extends NameUid {
|
||||
'name: "$name", '
|
||||
'category: $category, '
|
||||
'sortIndex: $sortIndex, '
|
||||
'nameOfTeacher: $teacherName'
|
||||
')';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class Test extends UidObj {
|
||||
final NameUidDesc method;
|
||||
final UidObj classGroup;
|
||||
|
||||
const Test({
|
||||
Test({
|
||||
required super.uid,
|
||||
required this.date,
|
||||
required this.reportDate,
|
||||
|
||||
@@ -14,7 +14,7 @@ class Lesson extends NameUid {
|
||||
final String? theme;
|
||||
final String? roomName;
|
||||
final NameUidDesc type;
|
||||
final NameUidDesc? studentPresence;
|
||||
final NameUidDesc? studentPresence; // required?
|
||||
final NameUidDesc state;
|
||||
final String? substituteTeacher;
|
||||
final String? homeworkUid;
|
||||
@@ -31,7 +31,7 @@ class Lesson extends NameUid {
|
||||
final DateTime createdAt;
|
||||
final DateTime lastModifiedAt;
|
||||
|
||||
const Lesson({
|
||||
Lesson({
|
||||
required super.uid,
|
||||
required this.date,
|
||||
required this.start,
|
||||
|
||||
Reference in New Issue
Block a user