28,19 → 28,43 |
public static MoyenneVote calculerVoteDetermination(PropositionDetermination propositionDetermination) { |
|
Map<String,VoteDetermination> votes = propositionDetermination.getVotesDeterminations(); |
int scoreVote = 0; |
int nbVotes = votes.size(); |
double scoreVoteIdentifie = 0; |
double scoreVoteAnonyme = 0; |
|
double scoreVote = 0; |
|
if(votes.size() > 0) { |
Set<String> cles = votes.keySet(); |
|
for (String cle : cles) { |
scoreVote += votes.get(cle).getVote(); |
String idAuteur = cle; |
int valeurVote = votes.get(cle).getVote(); |
if(estUnAuteurIdentifie(idAuteur)) { |
// un votant identifiant compte comme deux votants supplémentaires |
// il a donc un vote 3 fois supérieur |
scoreVoteIdentifie += 3*valeurVote; |
nbVotes += 2; |
} else { |
scoreVoteAnonyme += valeurVote; |
} |
} |
|
scoreVote = (scoreVote*100)/votes.size(); |
scoreVote = ((scoreVoteAnonyme + scoreVoteIdentifie)/(nbVotes))*100; |
} else { |
scoreVote = -1; |
} |
|
return new MoyenneVote(scoreVote, propositionDetermination); |
return new MoyenneVote((new Double(scoreVote)).intValue(), propositionDetermination); |
} |
|
private static boolean estUnAuteurIdentifie(String idAuteur) { |
boolean estIdentifie = true; |
try { |
int intIdAuteur = Integer.parseInt(idAuteur); |
} catch (NumberFormatException nfe) { |
estIdentifie = false; |
} |
return estIdentifie; |
} |
} |