maybe finished teacher rename
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import 'package:filcnaplo/utils/format.dart';
|
||||
import 'category.dart';
|
||||
import 'subject.dart';
|
||||
import 'teacher.dart';
|
||||
|
||||
class Grade {
|
||||
Map? json;
|
||||
String id;
|
||||
DateTime date;
|
||||
GradeValue value;
|
||||
String teacher;
|
||||
Teacher teacher;
|
||||
String description;
|
||||
GradeType type;
|
||||
String groupId;
|
||||
@@ -38,23 +39,35 @@ class Grade {
|
||||
factory Grade.fromJson(Map json) {
|
||||
return Grade(
|
||||
id: json["Uid"] ?? "",
|
||||
date: json["KeszitesDatuma"] != null ? DateTime.parse(json["KeszitesDatuma"]).toLocal() : DateTime(0),
|
||||
date: json["KeszitesDatuma"] != null
|
||||
? DateTime.parse(json["KeszitesDatuma"]).toLocal()
|
||||
: DateTime(0),
|
||||
value: GradeValue(
|
||||
json["SzamErtek"] ?? 0,
|
||||
json["SzovegesErtek"] ?? "",
|
||||
json["SzovegesErtekelesRovidNev"] ?? "",
|
||||
json["SulySzazalekErteke"] ?? 0,
|
||||
percentage: json["ErtekFajta"] != null ? json["ErtekFajta"]["Uid"] == "3,Szazalekos" : false,
|
||||
percentage: json["ErtekFajta"] != null
|
||||
? json["ErtekFajta"]["Uid"] == "3,Szazalekos"
|
||||
: false,
|
||||
),
|
||||
teacher: (json["ErtekeloTanarNeve"] ?? "").trim(),
|
||||
teacher: Teacher.fromString((json["ErtekeloTanarNeve"] ?? "").trim()),
|
||||
description: json["Tema"] ?? "",
|
||||
type: json["Tipus"] != null ? Category.getGradeType(json["Tipus"]["Nev"]) : GradeType.unknown,
|
||||
type: json["Tipus"] != null
|
||||
? Category.getGradeType(json["Tipus"]["Nev"])
|
||||
: GradeType.unknown,
|
||||
groupId: (json["OsztalyCsoport"] ?? {})["Uid"] ?? "",
|
||||
subject: Subject.fromJson(json["Tantargy"] ?? {}),
|
||||
gradeType: json["ErtekFajta"] != null ? Category.fromJson(json["ErtekFajta"]) : null,
|
||||
gradeType: json["ErtekFajta"] != null
|
||||
? Category.fromJson(json["ErtekFajta"])
|
||||
: null,
|
||||
mode: Category.fromJson(json["Mod"] ?? {}),
|
||||
writeDate: json["RogzitesDatuma"] != null ? DateTime.parse(json["RogzitesDatuma"]).toLocal() : DateTime(0),
|
||||
seenDate: json["LattamozasDatuma"] != null ? DateTime.parse(json["LattamozasDatuma"]).toLocal() : DateTime(0),
|
||||
writeDate: json["RogzitesDatuma"] != null
|
||||
? DateTime.parse(json["RogzitesDatuma"]).toLocal()
|
||||
: DateTime(0),
|
||||
seenDate: json["LattamozasDatuma"] != null
|
||||
? DateTime.parse(json["LattamozasDatuma"]).toLocal()
|
||||
: DateTime(0),
|
||||
form: (json["Jelleg"] ?? "Na") != "Na" ? json["Jelleg"] : "",
|
||||
json: json,
|
||||
);
|
||||
@@ -76,7 +89,8 @@ class GradeValue {
|
||||
set value(int v) => _value = v;
|
||||
int get value {
|
||||
String _valueName = valueName.toLowerCase().specialChars();
|
||||
if (_value == 0 && ["peldas", "jo", "valtozo", "rossz", "hanyag"].contains(_valueName)) {
|
||||
if (_value == 0 &&
|
||||
["peldas", "jo", "valtozo", "rossz", "hanyag"].contains(_valueName)) {
|
||||
switch (_valueName) {
|
||||
case "peldas":
|
||||
return 5;
|
||||
@@ -101,7 +115,8 @@ class GradeValue {
|
||||
set weight(int v) => _weight = v;
|
||||
int get weight {
|
||||
String _valueName = valueName.toLowerCase().specialChars();
|
||||
if (_value == 0 && ["peldas", "jo", "valtozo", "rossz", "hanyag"].contains(_valueName)) {
|
||||
if (_value == 0 &&
|
||||
["peldas", "jo", "valtozo", "rossz", "hanyag"].contains(_valueName)) {
|
||||
return 0;
|
||||
}
|
||||
return _weight;
|
||||
@@ -110,11 +125,23 @@ class GradeValue {
|
||||
final bool _percentage;
|
||||
bool get percentage => _percentage;
|
||||
|
||||
GradeValue(int value, String valueName, this.shortName, int weight, {bool percentage = false})
|
||||
GradeValue(int value, String valueName, this.shortName, int weight,
|
||||
{bool percentage = false})
|
||||
: _value = value,
|
||||
_valueName = valueName,
|
||||
_weight = weight,
|
||||
_percentage = percentage;
|
||||
}
|
||||
|
||||
enum GradeType { midYear, firstQ, secondQ, halfYear, thirdQ, fourthQ, endYear, levelExam, ghost, unknown }
|
||||
enum GradeType {
|
||||
midYear,
|
||||
firstQ,
|
||||
secondQ,
|
||||
halfYear,
|
||||
thirdQ,
|
||||
fourthQ,
|
||||
endYear,
|
||||
levelExam,
|
||||
ghost,
|
||||
unknown
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user