Skip to content

Commit

Permalink
Fix status parsing of multiple year UCs (#953)
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisDuarte1 authored Sep 20, 2023
2 parents 263f2d2 + b15861a commit a39c706
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions uni/lib/controller/parsers/parser_course_units.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,37 +52,36 @@ List<CourseUnit> 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('&nbsp;', ' ').trim();
status = row.children[7 + i].innerHtml.replaceAll('&nbsp;', ' ').trim();
if (status != '') {
break;
final status =
row.children[7 + i].innerHtml.replaceAll('&nbsp;', ' ').trim();
final grade =
row.children[6 + i].innerHtml.replaceAll('&nbsp;', ' ').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;
Expand Down

0 comments on commit a39c706

Please sign in to comment.