finished grade importing and exporting totally

This commit is contained in:
Kima
2024-06-16 21:32:27 +02:00
parent dd8a4430a9
commit c0dd84c665
4 changed files with 139 additions and 32 deletions

View File

@@ -1,6 +1,7 @@
// ignore_for_file: no_leading_underscores_for_local_identifiers
import 'package:refilc/utils/format.dart';
import 'package:uuid/uuid.dart';
import 'category.dart';
import 'subject.dart';
import 'teacher.dart';
@@ -75,6 +76,40 @@ class Grade {
);
}
factory Grade.fromExportJson(Map json) {
return Grade(
id: const Uuid().v4(),
date: json["date"] != null ? DateTime.parse(json["date"]) : DateTime(0),
value: GradeValue(
json["value"] ?? 0,
json["value_name"] ?? "",
json["value_name"] ?? "",
json["weight"] ?? 0,
percentage: false,
),
teacher: Teacher.fromString((json["teacher"] ?? "").trim()),
description: json["description"] ?? "",
type: json["type"] != null
? Category.getGradeType(json["type"]
.replaceAll("midYear", "evkozi_jegy_ertekeles")
.replaceAll("halfYear", "felevi_jegy_ertekeles")
.replaceAll("endYear", "evvegi_jegy_ertekeles"))
: GradeType.unknown,
groupId: const Uuid().v4(),
subject: GradeSubject(
id: const Uuid().v4(),
category: Category.fromJson({}),
name: json["subject"] ?? ""),
mode: Category.fromJson({}),
writeDate:
json["date"] != null ? DateTime.parse(json["date"]) : DateTime(0),
seenDate:
json["date"] != null ? DateTime.parse(json["date"]) : DateTime(0),
form: "",
json: json,
);
}
bool compareTo(dynamic other) {
if (runtimeType != other.runtimeType) return false;