From f42b7585965c5d663ee0da30e698fcf5e19d3e39 Mon Sep 17 00:00:00 2001 From: HandsomeRomanian Date: Mon, 18 Sep 2023 14:31:07 -0400 Subject: [PATCH 1/3] =?UTF-8?q?Ajout=20code=20programe=20baccalaureat=20in?= =?UTF-8?q?formatique=20distribu=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/constants/programs_credits.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/core/constants/programs_credits.dart b/lib/core/constants/programs_credits.dart index 186b4aed7..c065f205a 100644 --- a/lib/core/constants/programs_credits.dart +++ b/lib/core/constants/programs_credits.dart @@ -7,9 +7,7 @@ class ProgramCredits { "6556": 117, "6557": 118, "7086": 116, - // TODO: Ajouter le code lorsque le programme sera en vigeur - // (https://www.etsmtl.ca/etudes/premier-cycle/Baccalaureat-informatique-distribuee) - // "À venir" : 90", + "6646": 90, "5766": 30, "4567": 30, "4412": 30, From de4efb3c5c47f70d3240674641ea3df99251b50a Mon Sep 17 00:00:00 2001 From: HandsomeRomanian Date: Mon, 18 Sep 2023 15:14:06 -0400 Subject: [PATCH 2/3] define program by the number of registered credits --- lib/core/viewmodels/profile_viewmodel.dart | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/core/viewmodels/profile_viewmodel.dart b/lib/core/viewmodels/profile_viewmodel.dart index 853cd9754..cf1a67fa5 100644 --- a/lib/core/viewmodels/profile_viewmodel.dart +++ b/lib/core/viewmodels/profile_viewmodel.dart @@ -51,21 +51,27 @@ class ProfileViewModel extends FutureViewModel> { int percentage = 0; if (programList.isNotEmpty) { + Program currentProgram = programList.first; + for (final program in programList) { + if (int.parse(program.registeredCredits) > + int.parse(currentProgram.registeredCredits)) { + currentProgram = program; + } + } final int numberOfCreditsCompleted = - int.parse(programList[programList.length - 1].accumulatedCredits); - final String code = programList[programList.length - 1].code; + int.parse(currentProgram.accumulatedCredits); + final String code = currentProgram.code; bool foundMatch = false; programCredits.programsCredits.forEach((key, value) { - if (key == code || - programList[programList.length - 1].name.startsWith(key)) { + if (key == code || currentProgram.name.startsWith(key)) { percentage = (numberOfCreditsCompleted / value * 100).round(); foundMatch = true; } }); if (!foundMatch) { - final String programName = programList[programList.length - 1].name; + final String programName = currentProgram.name; analyticsService.logEvent("profile_view", 'The program $programName (code: $code) does not match any program'); percentage = 0; From 89290471b7e43f54973155f8b8df255adcd73d98 Mon Sep 17 00:00:00 2001 From: HandsomeRomanian Date: Mon, 18 Sep 2023 16:23:29 -0400 Subject: [PATCH 3/3] Sort list entries to have main program first. --- lib/core/viewmodels/profile_viewmodel.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/core/viewmodels/profile_viewmodel.dart b/lib/core/viewmodels/profile_viewmodel.dart index cf1a67fa5..7128d93ca 100644 --- a/lib/core/viewmodels/profile_viewmodel.dart +++ b/lib/core/viewmodels/profile_viewmodel.dart @@ -97,6 +97,8 @@ class ProfileViewModel extends FutureViewModel> { } _programList.sort((a, b) => b.status.compareTo(a.status)); + _programList + .sort((a, b) => a.registeredCredits.compareTo(b.registeredCredits)); return _programList; }