Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update profil page #833

Merged
merged 22 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"profile_first_name": "First Name",
"profile_last_name": "Last Name",
"profile_permanent_code": "Permanent Code",
"profile_balance": "Balance",
"profile_balance": "My balance",
"profile_code_program": "Code",
"profile_average_program": "Average",
"profile_number_accumulated_credits_program": "Accumulated Credits",
Expand All @@ -152,6 +152,9 @@
"profile_number_failed_courses_program": "Failed Courses",
"profile_number_equivalent_courses_program": "Equivalent Courses",
"profile_status_program": "Status",
"profile_program_completion": "Program completion",
"profile_program_completion_not_available": "N/A",
"profile_other_programs": "Other Programs",

"ets_security_title": "Security",
"ets_monets_title": "MonÉTS",
Expand Down
5 changes: 4 additions & 1 deletion l10n/intl_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"profile_first_name": "Prénom",
"profile_last_name": "Nom de famille",
"profile_permanent_code": "Code permanent",
"profile_balance": "Solde",
"profile_balance": "Votre solde",
"profile_code_program": "Code",
"profile_average_program": "Moyenne",
"profile_number_accumulated_credits_program": "Crédits complétés",
Expand All @@ -152,6 +152,9 @@
"profile_number_failed_courses_program": "Cours échoués",
"profile_number_equivalent_courses_program": "Cours d'équivalence",
"profile_status_program": "Statut",
"profile_program_completion": "Complétion du programme",
"profile_program_completion_not_available": "ND",
"profile_other_programs": "Autres Programmes",

"ets_security_title": "Sécurité",
"ets_monets_title": "MonÉTS",
Expand Down
25 changes: 25 additions & 0 deletions lib/core/constants/programs_credits.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class ProgramCredits {
Map<String, int> programsCredits = {
"7625": 117,
"7694": 115,
"7084": 116,
"7684": 115,
"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",
"5766": 30,
"4567": 30,
"4412": 30,
"4563": 30,
"4684": 30,
"4329": 30,
"4288": 30,
"Maîtrise": 45,
"Programme court": 15,
"Certificat": 30,
"DESS": 30,
};
}
1 change: 0 additions & 1 deletion lib/core/managers/course_repository.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// FLUTTER / DART / THIRD-PARTIES
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:logger/logger.dart';

Expand Down
37 changes: 37 additions & 0 deletions lib/core/viewmodels/profile_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,27 @@ import 'package:stacked/stacked.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

// SERVICES
import 'package:notredame/core/services/analytics_service.dart';

// MANAGERS
import 'package:notredame/core/managers/user_repository.dart';

// MODELS
import 'package:ets_api_clients/models.dart';

// CONSTANTS
import 'package:notredame/core/constants/programs_credits.dart';

// OTHERS
import 'package:notredame/locator.dart';

class ProfileViewModel extends FutureViewModel<List<Program>> {
/// Load the user
final UserRepository _userRepository = locator<UserRepository>();

final AnalyticsService analyticsService = locator<AnalyticsService>();

/// Localization class of the application.
final AppIntl _appIntl;

Expand All @@ -38,6 +46,35 @@ class ProfileViewModel extends FutureViewModel<List<Program>> {

ProfileViewModel({@required AppIntl intl}) : _appIntl = intl;

double get programProgression {
final ProgramCredits programCredits = ProgramCredits();
int percentage = 0;

if (programList.isNotEmpty) {
final int numberOfCreditsCompleted =
int.parse(programList[programList.length - 1].accumulatedCredits);
final String code = programList[programList.length - 1].code;
bool foundMatch = false;

programCredits.programsCredits.forEach((key, value) {
if (key == code ||
programList[programList.length - 1].name.startsWith(key)) {
percentage = (numberOfCreditsCompleted / value * 100).round();
foundMatch = true;
}
});

if (!foundMatch) {
final String programName = programList[programList.length - 1].name;
analyticsService.logEvent("profile_view",
'The program $programName (code: $code) does not match any program');
percentage = 0;
}
}

return percentage.toDouble();
}

@override
// ignore: type_annotate_public_apis
void onError(error) {
Expand Down
Loading