diff --git a/uni/lib/controller/parsers/parser_course_units.dart b/uni/lib/controller/parsers/parser_course_units.dart index 179ba7b77..8131dc51b 100644 --- a/uni/lib/controller/parsers/parser_course_units.dart +++ b/uni/lib/controller/parsers/parser_course_units.dart @@ -52,37 +52,36 @@ List parseCourseUnitsAndCourseAverage( final codeName = row.children[2].children[0].innerHtml; final name = row.children[3].children[0].innerHtml; final ects = row.children[5].innerHtml.replaceAll(',', '.'); - String? grade; - String? status; + var yearIncrement = -1; for (var i = 0;; i += 2) { if (row.children.length <= 6 + i) { break; } yearIncrement++; - grade = row.children[6 + i].innerHtml.replaceAll(' ', ' ').trim(); - status = row.children[7 + i].innerHtml.replaceAll(' ', ' ').trim(); - if (status != '') { - break; + final status = + row.children[7 + i].innerHtml.replaceAll(' ', ' ').trim(); + final grade = + row.children[6 + i].innerHtml.replaceAll(' ', ' ').trim(); + + if (status.isEmpty) { + continue; } - } - if (yearIncrement < 0) { - continue; - } - final courseUnit = CourseUnit( - schoolYear: - '${firstSchoolYear + yearIncrement}/${firstSchoolYear + yearIncrement + 1}', - occurrId: int.parse(occurId), - abbreviation: codeName, - status: status, - grade: grade, - ects: double.parse(ects), - name: name, - curricularYear: int.parse(year), - semesterCode: semester, - ); - courseUnits.add(courseUnit); + final courseUnit = CourseUnit( + schoolYear: + '${firstSchoolYear + yearIncrement}/${firstSchoolYear + yearIncrement + 1}', + occurrId: int.parse(occurId), + abbreviation: codeName, + status: status, + grade: grade, + ects: double.parse(ects), + name: name, + curricularYear: int.parse(year), + semesterCode: semester, + ); + courseUnits.add(courseUnit); + } } return courseUnits;