-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcourse_evaluation.dart
202 lines (179 loc) · 7.17 KB
/
course_evaluation.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
// Package imports:
import 'package:xml/xml.dart';
/// Data-class that represent an evaluation which happened during a course
class CourseEvaluation {
final String courseGroup;
/// Title of the evaluation (ex: Laboratoire 1)
final String title;
/// Date on which the evaluation should happen (can also be the date on which
/// the mark was enter in the system)
final DateTime? targetDate;
/// Mark obtained by the student on the evaluation
/// (ex: 24)
final double? mark;
/// On how much the evaluation is corrected (ex: 30)
final double correctedEvaluationOutOfFormatted;
/// On how much the evaluation is corrected included bonus (ex: 30,0+20)
final String correctedEvaluationOutOf;
/// Weight of the evaluation on the course (ex: 12.5)
final double weight;
/// Average mark of the students on this evaluation (ex: 30)
final double? passMark;
/// Standard deviation of the evaluation
final double? standardDeviation;
/// Median of the evaluation
final double? median;
/// Percentile rank of the student on this evaluation
final int? percentileRank;
/// Is the mark of the evaluation published
final bool published;
/// Message given by the teacher
final String teacherMessage;
/// Is this evaluation ignored in the final grade
final bool ignore;
double get markInPercent => mark! / correctedEvaluationOutOfFormatted;
/// Weighted grade of the evaluation
/// (ex: Mark of 25/50 and 10% weight => 5/10 weighted grade)
double? get weightedGrade =>
mark == null || correctedEvaluationOutOfFormatted == 0.0 || weight == 0.0
? null
: (mark! / correctedEvaluationOutOfFormatted) * weight;
CourseEvaluation(
{required this.courseGroup,
required this.title,
required this.weight,
required this.published,
required this.teacherMessage,
required this.ignore,
required this.correctedEvaluationOutOf,
this.mark,
this.passMark,
this.standardDeviation,
this.median,
this.percentileRank,
this.targetDate})
: correctedEvaluationOutOfFormatted = correctedEvaluationOutOf.isNotEmpty
? double.parse(
correctedEvaluationOutOf.split("+").first.replaceAll(",", "."))
: 0.0;
/// Used to create a new [CourseEvaluation] instance from a [XMLElement].
factory CourseEvaluation.fromXml(XmlElement node) => CourseEvaluation(
courseGroup: node.getElement('coursGroupe')!.innerText,
title: node.getElement('nom')!.innerText,
mark: node.getElement('note')!.innerText.isNotEmpty
? double.parse(
node.getElement('note')!.innerText.replaceAll(",", "."))
: null,
correctedEvaluationOutOf:
node.getElement('corrigeSur')!.innerText.replaceAll(",", "."),
weight: double.parse(
node.getElement('ponderation')!.innerText.replaceAll(",", ".")),
passMark: node.getElement('moyenne')!.innerText.isNotEmpty
? double.parse(
node.getElement('moyenne')!.innerText.replaceAll(",", "."))
: null,
standardDeviation: node.getElement('ecartType')!.innerText.isNotEmpty
? double.parse(
node.getElement('ecartType')!.innerText.replaceAll(",", "."))
: null,
median: node.getElement('mediane')!.innerText.isNotEmpty
? double.parse(
node.getElement('mediane')!.innerText.replaceAll(",", "."))
: null,
percentileRank: node.getElement('rangCentile')!.innerText.isNotEmpty
? int.parse(node.getElement('rangCentile')!.innerText)
: null,
published: node.getElement('publie')!.innerText == "Oui",
teacherMessage: node.getElement('messageDuProf')!.innerText,
ignore: node.getElement('ignoreDuCalcul')!.innerText == "Oui",
targetDate: node.getElement('dateCible')!.innerText.isNotEmpty
? DateTime.parse(node.getElement('dateCible')!.innerText)
: null);
/// Used to create [CourseEvaluation] instance from a JSON file
factory CourseEvaluation.fromJson(Map<String, dynamic> map) =>
CourseEvaluation(
courseGroup: map["courseGroup"] as String,
title: map["title"] as String,
mark: map["mark"] as double?,
correctedEvaluationOutOf: map["correctedEvaluationOutOf"] as String,
weight: map["weight"] as double,
passMark: map["passMark"] as double?,
standardDeviation: map["standardDeviation"] as double?,
median: map["median"] as double?,
percentileRank: map["percentileRank"] as int?,
published: map["published"] as bool,
teacherMessage: map["teacherMessage"] as String,
ignore: map["ignore"] as bool,
targetDate: map["targetDate"] == null
? null
: DateTime.parse(map["targetDate"] as String));
Map<String, dynamic> toJson() => {
'courseGroup': courseGroup,
'title': title,
'mark': mark,
'correctedEvaluationOutOf': correctedEvaluationOutOf,
'weight': weight,
'passMark': passMark,
'standardDeviation': standardDeviation,
'median': median,
'percentileRank': percentileRank,
'published': published,
'teacherMessage': teacherMessage,
'ignore': ignore,
'targetDate': targetDate?.toString(),
};
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is CourseEvaluation &&
runtimeType == other.runtimeType &&
courseGroup == other.courseGroup &&
title == other.title &&
targetDate == other.targetDate &&
mark == other.mark &&
correctedEvaluationOutOf == other.correctedEvaluationOutOf &&
correctedEvaluationOutOfFormatted ==
other.correctedEvaluationOutOfFormatted &&
weight == other.weight &&
passMark == other.passMark &&
standardDeviation == other.standardDeviation &&
median == other.median &&
percentileRank == other.percentileRank &&
published == other.published &&
teacherMessage == other.teacherMessage &&
ignore == other.ignore;
@override
int get hashCode =>
courseGroup.hashCode ^
title.hashCode ^
targetDate.hashCode ^
mark.hashCode ^
correctedEvaluationOutOf.hashCode ^
correctedEvaluationOutOfFormatted.hashCode ^
weight.hashCode ^
passMark.hashCode ^
standardDeviation.hashCode ^
median.hashCode ^
percentileRank.hashCode ^
published.hashCode ^
teacherMessage.hashCode ^
ignore.hashCode;
@override
String toString() {
return 'Evaluation{'
'courseGroup: $courseGroup, '
'title: $title, '
'targetDate: $targetDate, '
'mark: $mark, '
'correctedEvaluationOutOf: $correctedEvaluationOutOf, '
'correctedEvaluationOutOfFormatted: $correctedEvaluationOutOfFormatted, '
'weight: $weight, '
'passMark: $passMark, '
'standardDeviation: $standardDeviation, '
'median: $median, '
'percentileRank: $percentileRank, '
'published: $published, '
'teacherMessage: $teacherMessage, '
'ignore: $ignore}';
}
}