304 lines
8.9 KiB
Dart
304 lines
8.9 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
|
|
/// Entité représentant une évaluation d'aide dans le système de solidarité
|
|
///
|
|
/// Cette entité encapsule toutes les informations relatives à l'évaluation
|
|
/// d'une demande d'aide ou d'une proposition d'aide.
|
|
class EvaluationAide extends Equatable {
|
|
/// Identifiant unique de l'évaluation
|
|
final String id;
|
|
|
|
/// Identifiant de la demande d'aide évaluée
|
|
final String demandeAideId;
|
|
|
|
/// Identifiant de la proposition d'aide (si applicable)
|
|
final String? propositionAideId;
|
|
|
|
/// Identifiant de l'évaluateur
|
|
final String evaluateurId;
|
|
|
|
/// Nom de l'évaluateur
|
|
final String nomEvaluateur;
|
|
|
|
/// Type d'évaluateur
|
|
final TypeEvaluateur typeEvaluateur;
|
|
|
|
/// Note globale (1 à 5)
|
|
final double noteGlobale;
|
|
|
|
/// Note pour le délai de réponse
|
|
final double? noteDelaiReponse;
|
|
|
|
/// Note pour la communication
|
|
final double? noteCommunication;
|
|
|
|
/// Note pour le professionnalisme
|
|
final double? noteProfessionnalisme;
|
|
|
|
/// Note pour le respect des engagements
|
|
final double? noteRespectEngagements;
|
|
|
|
/// Notes détaillées par critère
|
|
final Map<String, double> notesDetaillees;
|
|
|
|
/// Commentaire principal
|
|
final String commentairePrincipal;
|
|
|
|
/// Points positifs
|
|
final String? pointsPositifs;
|
|
|
|
/// Points d'amélioration
|
|
final String? pointsAmelioration;
|
|
|
|
/// Recommandations
|
|
final String? recommandations;
|
|
|
|
/// Indique si l'évaluateur recommande cette aide
|
|
final bool? recommande;
|
|
|
|
/// Date de création de l'évaluation
|
|
final DateTime dateCreation;
|
|
|
|
/// Date de modification
|
|
final DateTime dateModification;
|
|
|
|
/// Date de vérification (si applicable)
|
|
final DateTime? dateVerification;
|
|
|
|
/// Identifiant du vérificateur
|
|
final String? verificateurId;
|
|
|
|
/// Statut de l'évaluation
|
|
final StatutEvaluation statut;
|
|
|
|
/// Nombre de signalements reçus
|
|
final int nombreSignalements;
|
|
|
|
/// Score de qualité calculé automatiquement
|
|
final double scoreQualite;
|
|
|
|
/// Indique si l'évaluation a été modifiée
|
|
final bool estModifie;
|
|
|
|
/// Indique si l'évaluation est vérifiée
|
|
final bool estVerifiee;
|
|
|
|
/// Données personnalisées
|
|
final Map<String, dynamic> donneesPersonnalisees;
|
|
|
|
const EvaluationAide({
|
|
required this.id,
|
|
required this.demandeAideId,
|
|
this.propositionAideId,
|
|
required this.evaluateurId,
|
|
required this.nomEvaluateur,
|
|
required this.typeEvaluateur,
|
|
required this.noteGlobale,
|
|
this.noteDelaiReponse,
|
|
this.noteCommunication,
|
|
this.noteProfessionnalisme,
|
|
this.noteRespectEngagements,
|
|
this.notesDetaillees = const {},
|
|
required this.commentairePrincipal,
|
|
this.pointsPositifs,
|
|
this.pointsAmelioration,
|
|
this.recommandations,
|
|
this.recommande,
|
|
required this.dateCreation,
|
|
required this.dateModification,
|
|
this.dateVerification,
|
|
this.verificateurId,
|
|
this.statut = StatutEvaluation.active,
|
|
this.nombreSignalements = 0,
|
|
required this.scoreQualite,
|
|
this.estModifie = false,
|
|
this.estVerifiee = false,
|
|
this.donneesPersonnalisees = const {},
|
|
});
|
|
|
|
/// Calcule la note moyenne des critères détaillés
|
|
double get noteMoyenneDetaillees {
|
|
if (notesDetaillees.isEmpty) return noteGlobale;
|
|
|
|
double somme = notesDetaillees.values.fold(0.0, (a, b) => a + b);
|
|
return somme / notesDetaillees.length;
|
|
}
|
|
|
|
/// Indique si l'évaluation est positive (note >= 4)
|
|
bool get estPositive => noteGlobale >= 4.0;
|
|
|
|
/// Indique si l'évaluation est négative (note <= 2)
|
|
bool get estNegative => noteGlobale <= 2.0;
|
|
|
|
/// Obtient le niveau de satisfaction textuel
|
|
String get niveauSatisfaction {
|
|
if (noteGlobale >= 4.5) return 'Excellent';
|
|
if (noteGlobale >= 4.0) return 'Très bien';
|
|
if (noteGlobale >= 3.0) return 'Bien';
|
|
if (noteGlobale >= 2.0) return 'Moyen';
|
|
return 'Insuffisant';
|
|
}
|
|
|
|
/// Obtient la couleur associée à la note
|
|
String get couleurNote {
|
|
if (noteGlobale >= 4.0) return '#4CAF50'; // Vert
|
|
if (noteGlobale >= 3.0) return '#FF9800'; // Orange
|
|
return '#F44336'; // Rouge
|
|
}
|
|
|
|
/// Indique si l'évaluation peut être modifiée
|
|
bool get peutEtreModifiee {
|
|
return statut == StatutEvaluation.active &&
|
|
!estVerifiee &&
|
|
nombreSignalements < 3;
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
id,
|
|
demandeAideId,
|
|
propositionAideId,
|
|
evaluateurId,
|
|
nomEvaluateur,
|
|
typeEvaluateur,
|
|
noteGlobale,
|
|
noteDelaiReponse,
|
|
noteCommunication,
|
|
noteProfessionnalisme,
|
|
noteRespectEngagements,
|
|
notesDetaillees,
|
|
commentairePrincipal,
|
|
pointsPositifs,
|
|
pointsAmelioration,
|
|
recommandations,
|
|
recommande,
|
|
dateCreation,
|
|
dateModification,
|
|
dateVerification,
|
|
verificateurId,
|
|
statut,
|
|
nombreSignalements,
|
|
scoreQualite,
|
|
estModifie,
|
|
estVerifiee,
|
|
donneesPersonnalisees,
|
|
];
|
|
|
|
EvaluationAide copyWith({
|
|
String? id,
|
|
String? demandeAideId,
|
|
String? propositionAideId,
|
|
String? evaluateurId,
|
|
String? nomEvaluateur,
|
|
TypeEvaluateur? typeEvaluateur,
|
|
double? noteGlobale,
|
|
double? noteDelaiReponse,
|
|
double? noteCommunication,
|
|
double? noteProfessionnalisme,
|
|
double? noteRespectEngagements,
|
|
Map<String, double>? notesDetaillees,
|
|
String? commentairePrincipal,
|
|
String? pointsPositifs,
|
|
String? pointsAmelioration,
|
|
String? recommandations,
|
|
bool? recommande,
|
|
DateTime? dateCreation,
|
|
DateTime? dateModification,
|
|
DateTime? dateVerification,
|
|
String? verificateurId,
|
|
StatutEvaluation? statut,
|
|
int? nombreSignalements,
|
|
double? scoreQualite,
|
|
bool? estModifie,
|
|
bool? estVerifiee,
|
|
Map<String, dynamic>? donneesPersonnalisees,
|
|
}) {
|
|
return EvaluationAide(
|
|
id: id ?? this.id,
|
|
demandeAideId: demandeAideId ?? this.demandeAideId,
|
|
propositionAideId: propositionAideId ?? this.propositionAideId,
|
|
evaluateurId: evaluateurId ?? this.evaluateurId,
|
|
nomEvaluateur: nomEvaluateur ?? this.nomEvaluateur,
|
|
typeEvaluateur: typeEvaluateur ?? this.typeEvaluateur,
|
|
noteGlobale: noteGlobale ?? this.noteGlobale,
|
|
noteDelaiReponse: noteDelaiReponse ?? this.noteDelaiReponse,
|
|
noteCommunication: noteCommunication ?? this.noteCommunication,
|
|
noteProfessionnalisme: noteProfessionnalisme ?? this.noteProfessionnalisme,
|
|
noteRespectEngagements: noteRespectEngagements ?? this.noteRespectEngagements,
|
|
notesDetaillees: notesDetaillees ?? this.notesDetaillees,
|
|
commentairePrincipal: commentairePrincipal ?? this.commentairePrincipal,
|
|
pointsPositifs: pointsPositifs ?? this.pointsPositifs,
|
|
pointsAmelioration: pointsAmelioration ?? this.pointsAmelioration,
|
|
recommandations: recommandations ?? this.recommandations,
|
|
recommande: recommande ?? this.recommande,
|
|
dateCreation: dateCreation ?? this.dateCreation,
|
|
dateModification: dateModification ?? this.dateModification,
|
|
dateVerification: dateVerification ?? this.dateVerification,
|
|
verificateurId: verificateurId ?? this.verificateurId,
|
|
statut: statut ?? this.statut,
|
|
nombreSignalements: nombreSignalements ?? this.nombreSignalements,
|
|
scoreQualite: scoreQualite ?? this.scoreQualite,
|
|
estModifie: estModifie ?? this.estModifie,
|
|
estVerifiee: estVerifiee ?? this.estVerifiee,
|
|
donneesPersonnalisees: donneesPersonnalisees ?? this.donneesPersonnalisees,
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Énumération des types d'évaluateur
|
|
enum TypeEvaluateur {
|
|
beneficiaire('Bénéficiaire', 'person', '#2196F3'),
|
|
proposant('Proposant', 'volunteer_activism', '#4CAF50'),
|
|
evaluateurOfficial('Évaluateur officiel', 'verified_user', '#9C27B0'),
|
|
administrateur('Administrateur', 'admin_panel_settings', '#FF5722');
|
|
|
|
const TypeEvaluateur(this.libelle, this.icone, this.couleur);
|
|
|
|
final String libelle;
|
|
final String icone;
|
|
final String couleur;
|
|
}
|
|
|
|
/// Énumération des statuts d'évaluation
|
|
enum StatutEvaluation {
|
|
active('Active', 'check_circle', '#4CAF50'),
|
|
signalee('Signalée', 'flag', '#FF9800'),
|
|
masquee('Masquée', 'visibility_off', '#F44336'),
|
|
supprimee('Supprimée', 'delete', '#9E9E9E');
|
|
|
|
const StatutEvaluation(this.libelle, this.icone, this.couleur);
|
|
|
|
final String libelle;
|
|
final String icone;
|
|
final String couleur;
|
|
}
|
|
|
|
/// Classe représentant les statistiques d'évaluations
|
|
class StatistiquesEvaluation extends Equatable {
|
|
final double noteMoyenne;
|
|
final int nombreEvaluations;
|
|
final Map<int, int> repartitionNotes;
|
|
final double pourcentagePositives;
|
|
final double pourcentageRecommandations;
|
|
final DateTime derniereMiseAJour;
|
|
|
|
const StatistiquesEvaluation({
|
|
required this.noteMoyenne,
|
|
required this.nombreEvaluations,
|
|
required this.repartitionNotes,
|
|
required this.pourcentagePositives,
|
|
required this.pourcentageRecommandations,
|
|
required this.derniereMiseAJour,
|
|
});
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
noteMoyenne,
|
|
nombreEvaluations,
|
|
repartitionNotes,
|
|
pourcentagePositives,
|
|
pourcentageRecommandations,
|
|
derniereMiseAJour,
|
|
];
|
|
}
|