Skip to content

Commit

Permalink
Calculate course abbreviation when not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
Process-ing committed Feb 6, 2025
1 parent b885864 commit 7d28374
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/uni_app/lib/view/academic_path/courses_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ class CoursesPageState extends State<CoursesPage> {
return year;
}

String _getCourseAbbreviation(Course course) {
if (course.abbreviation != null) {
return course.abbreviation!;
}

if (course.name == null) {
return '???';
}

return course.name!
.replaceAll('Licenciatura', 'Licenciatura.')
.replaceAll('Mestrado', 'Mestrado.')
.replaceAll('Doutoramento', 'Doutoramento.')
.replaceAll(RegExp('[^A-Z.]'), '');
}

@override
Widget build(BuildContext context) {
return Padding(
Expand All @@ -60,7 +76,7 @@ class CoursesPageState extends State<CoursesPage> {
child: CourseSelection(
courseInfos: courses.map((course) {
return CourseInfo(
abbreviation: course.abbreviation ?? '???',
abbreviation: _getCourseAbbreviation(course),
enrollmentYear: course.firstEnrollment!,
conclusionYear: _getConclusionYear(course),
);
Expand Down

0 comments on commit 7d28374

Please sign in to comment.