Skip to content

Commit 48cd672

Browse files
committed
fix(marks): When total is not given marks will be calculated accordingly
1 parent 8d6235e commit 48cd672

1 file changed

Lines changed: 41 additions & 2 deletions

File tree

lib/pages/marks.dart

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class _MarksState extends State<Marks> {
3232

3333
final Map<String, String> body = {
3434
"Enrollment": "",
35-
"Semester": selectedSemester!
35+
"Semester": selectedSemester!,
3636
};
3737

3838
try {
@@ -41,7 +41,46 @@ class _MarksState extends State<Marks> {
4141
if (response.statusCode == 200) {
4242
setState(() {
4343
marksData = List<Map<String, dynamic>>.from(
44-
response.data["InternalMarksList"]);
44+
(response.data["InternalMarksList"] as List).map((course) {
45+
final courseMap = Map<String, dynamic>.from(course);
46+
47+
double total = 0.0;
48+
double maxMarks = 100;
49+
50+
double mte1 =
51+
double.tryParse(courseMap['MTE1']?.toString() ?? "0") ?? 0;
52+
double mte2 =
53+
double.tryParse(courseMap['MTE2']?.toString() ?? "0") ?? 0;
54+
double cws =
55+
double.tryParse(courseMap['CWS']?.toString() ?? "0") ?? 0;
56+
double ete =
57+
double.tryParse(courseMap['ETE']?.toString() ?? "0") ?? 0;
58+
double prs =
59+
double.tryParse(courseMap['PRS']?.toString() ?? "0") ?? 0;
60+
61+
if (courseMap['Total'] == "-") {
62+
if (prs > 0) {
63+
total = prs;
64+
maxMarks = 60;
65+
} else if (mte1 > 0 && mte2 > 0) {
66+
total = mte1 + mte2 + cws + ete;
67+
maxMarks = 100; // 40 + 20 + 40
68+
} else if (mte1 > 0) {
69+
total = mte1 + cws + ete;
70+
maxMarks = 100; // 30 + 30 + 40
71+
}
72+
} else {
73+
total = double.tryParse(courseMap['Total']?.toString() ?? "0") ?? 0;
74+
}
75+
76+
courseMap['RESESSION'] = courseMap['RESESSION'] ?? "-";
77+
78+
return {
79+
...courseMap,
80+
'Total': total,
81+
'MaxMarks': maxMarks,
82+
};
83+
}));
4584
isLoading = false;
4685
});
4786
} else {

0 commit comments

Comments
 (0)