-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcourse_review.dart
104 lines (89 loc) · 3.01 KB
/
course_review.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// FLUTTER / DART / THIRD-PARTIES
// Package imports:
import 'package:xml/xml.dart';
/// Data-class that represent a course evaluation.
class CourseReview {
/// Course acronym (ex: LOG430)
final String acronym;
/// Course group, on which group the student is registered
final String group;
/// Name of the professor
final String teacherName;
/// Date when the evaluation start.
final DateTime startAt;
/// When the evaluation end.
final DateTime endAt;
/// Type of the evaluation
final String type;
/// Is the evaluation completed
final bool isCompleted;
CourseReview(
{required this.acronym,
required this.group,
required this.teacherName,
required this.type,
required this.startAt,
required this.endAt,
required this.isCompleted});
/// Used to create a new [CourseReview] instance from a [XMLElement].
factory CourseReview.fromXmlNode(XmlElement node) => CourseReview(
acronym: node.getElement('Sigle')!.innerText,
group: node.getElement('Groupe')!.innerText,
teacherName: node.getElement('Enseignant')!.innerText,
type: node.getElement('TypeEvaluation')!.innerText,
startAt:
DateTime.parse(node.getElement('DateDebutEvaluation')!.innerText),
endAt: DateTime.parse(node.getElement('DateFinEvaluation')!.innerText),
isCompleted:
node.getElement('EstComplete')!.innerText.toLowerCase() == 'true');
/// Used to create [CourseReview] instance from a JSON file
factory CourseReview.fromJson(Map<String, dynamic> map) => CourseReview(
acronym: map['acronym'] as String,
group: map['group'] as String,
teacherName: map['teacherName'] as String,
type: map['type'] as String,
startAt: DateTime.parse(map['startAt'] as String),
endAt: DateTime.parse(map['endAt'] as String),
isCompleted: map['isCompleted'] as bool);
Map<String, dynamic> toJson() => {
'acronym': acronym,
'group': group,
'teacherName': teacherName,
'type': type,
'startAt': startAt.toString(),
'endAt': endAt.toString(),
'isCompleted': isCompleted,
};
@override
String toString() {
return 'CourseReview{'
'acronym: $acronym, '
'group: $group, '
'teacherName: $teacherName, '
'type: $type, '
'startAt: $startAt, '
'endAt: $endAt, '
'isCompleted: $isCompleted}';
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is CourseReview &&
runtimeType == other.runtimeType &&
acronym == other.acronym &&
group == other.group &&
teacherName == other.teacherName &&
startAt == other.startAt &&
endAt == other.endAt &&
type == other.type &&
isCompleted == other.isCompleted;
@override
int get hashCode =>
acronym.hashCode ^
group.hashCode ^
teacherName.hashCode ^
startAt.hashCode ^
endAt.hashCode ^
type.hashCode ^
isCompleted.hashCode;
}