1,6 → 1,7 |
package org.tela_botanica.del.client.services; |
|
import java.util.ArrayList; |
import java.util.Iterator; |
import java.util.List; |
import java.util.Map; |
import java.util.Set; |
25,15 → 26,28 |
return pairesVotes; |
} |
|
public static int getNombreTotalVotants(PropositionDetermination proposition) { |
int nbVotants = 0; |
List<PropositionDetermination> votes = proposition.getObservation().getPropositionDeterminations(); |
Iterator<PropositionDetermination> itVotes = votes.iterator(); |
while (itVotes.hasNext()) { |
PropositionDetermination propositionCourante = itVotes.next(); |
nbVotants += propositionCourante.getVotesDeterminations().size(); |
} |
return nbVotants; |
} |
|
public static MoyenneVote calculerVoteDetermination(PropositionDetermination propositionDetermination) { |
|
int nbVotants = getNombreTotalVotants(propositionDetermination); |
Map<String,VoteDetermination> votes = propositionDetermination.getVotesDeterminations(); |
int nbVotes = votes.size(); |
|
double scoreVoteIdentifie = 0; |
double scoreVoteAnonyme = 0; |
|
double scoreVote = 0; |
|
|
if(votes.size() > 0) { |
Set<String> cles = votes.keySet(); |
|
43,14 → 57,14 |
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; |
scoreVoteIdentifie += valeurVote; |
//nbVotants += 2; |
} else { |
scoreVoteAnonyme += valeurVote; |
} |
} |
|
scoreVote = ((scoreVoteAnonyme + scoreVoteIdentifie)/(nbVotes))*100; |
scoreVote = ((scoreVoteAnonyme + scoreVoteIdentifie)/(nbVotants))*100; |
} else { |
scoreVote = -1; |
} |