Subversion Repositories eFlore/Applications.del

Rev

Rev 966 | Rev 1124 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 966 Rev 1098
Line 26... Line 26...
26
	}
26
	}
Line 27... Line 27...
27
	
27
	
Line 28... Line 28...
28
	public static MoyenneVote calculerVoteDetermination(PropositionDetermination propositionDetermination) {
28
	public static MoyenneVote calculerVoteDetermination(PropositionDetermination propositionDetermination) {
-
 
29
		
-
 
30
		Map<String,VoteDetermination> votes = propositionDetermination.getVotesDeterminations();
-
 
31
		int nbVotes = votes.size();
-
 
32
		double scoreVoteIdentifie = 0;
29
		
33
		double scoreVoteAnonyme = 0;
Line 30... Line 34...
30
		Map<String,VoteDetermination> votes = propositionDetermination.getVotesDeterminations();
34
		
31
		int scoreVote = 0;
35
		double scoreVote = 0;
-
 
36
		
32
		
37
		if(votes.size() > 0) {
-
 
38
			Set<String> cles = votes.keySet();
33
		if(votes.size() > 0) {
39
 
-
 
40
			for (String cle : cles) {
-
 
41
				String  idAuteur = cle;
-
 
42
				int valeurVote = votes.get(cle).getVote();
-
 
43
				if(estUnAuteurIdentifie(idAuteur)) {
-
 
44
					// un votant identifiant compte comme deux votants supplémentaires
-
 
45
					// il a donc un vote 3 fois supérieur
-
 
46
					scoreVoteIdentifie += 3*valeurVote;
-
 
47
					nbVotes += 2;
34
			Set<String> cles = votes.keySet();
48
				} else {
Line 35... Line 49...
35
			for (String cle : cles) {
49
					scoreVoteAnonyme += valeurVote;
36
				scoreVote += votes.get(cle).getVote();
50
				}
37
			}
51
			}
38
			
52
			
Line 39... Line 53...
39
			scoreVote = (scoreVote*100)/votes.size();
53
			scoreVote = ((scoreVoteAnonyme + scoreVoteIdentifie)/(nbVotes))*100;
-
 
54
		} else {
-
 
55
			scoreVote = -1;
-
 
56
		}
-
 
57
		
-
 
58
		return new MoyenneVote((new Double(scoreVote)).intValue(), propositionDetermination);
-
 
59
	}
-
 
60
	
-
 
61
	private static boolean estUnAuteurIdentifie(String idAuteur) {
-
 
62
		boolean estIdentifie = true;
-
 
63
	    try {
40
		} else {
64
	        int intIdAuteur = Integer.parseInt(idAuteur);
41
			scoreVote = -1;
65
	    } catch (NumberFormatException nfe) {