# contexte
Choix des noms de mentions
https://fr.wikipedia.org/wiki/Jugement_majoritaire
vs
https://en.wikipedia.org/wiki/Jugement_majoritaire
|index|fr|en|
|-----|--|--|
|0|Très Bien|Excellent|
|1|Bien|Very Good|
|2|Assez Bien|Good|
|3|Passable|Acceptable|
|4|Insuffisant|Poor|
|5|A Rejeter|Reject|
# Recherche des projets de code autours du jugement majoritaire sur githbu
|source|info|interet|
|------------------|-----------------------------|-------------|
|https://github.com/MieuxVoter/mieuxvoter.fr||18/20|
|https://github.com/CitoyensDeDemain/JugementMajoritaire|Il y a un algo, mais pas de format de donnée, données hardcodées / API et pas de procédure d'install|11/20|
|https://github.com/flaviencathala/jugement-majoritaire-daml|Smart contract|10/20|
|https://github.com/ostix360/JugementMajoritaire|Où est l'algo ?|2/20|
|https://github.com/AlexJade23/JugementMajoritaire|RAS VIDE|1/20|
|
# https://mieuxvoter.fr/en
C'est la référence, les théoriciens du vote majoritaire ont été invités à participer à l'élaboration de ce site.
Par contre pour trouver la librairie de base...
https://github.com/MieuxVoter/mieuxvoter.fr
image docker
https://app.mieuxvoter.fr/en/votes/ult-kxm-vzcr
https://app.mieuxvoter.fr/en/results/ult-kxm-vzcr
https://app.mieuxvoter.fr/en/admin/ult-kxm-vzcr/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZG1pbiI6dHJ1ZSwiZWxlY3Rpb24iOiJ1bHRreG12emNyIn0.TzkM380pk0eVo8_iHJGYANxlapVbp5Z3jxLQSzqLpRM
https://app.mieuxvoter.fr/fr/votes/ult-kxm-vzcr : même en français 'Very good' ...
Obligation de noter tous les participants.
## Librairie python
https://github.com/MieuxVoter/majority-judgment-library-python
Très courte ( ./majority_judgment/__init__.py 145 lignes )
```
>>> from majority_judgment import majority_judgment
>>> data = {
... 'Pizza': [!, 0, 3, 0, 2, 0, 3, 1, 2, 3],
... 'Chips': [0, 1, 0, 2, 1, 2, 2, 3, 2, 3],
... 'Pasta': [0, 1, 0, 1, 2, 1, 3, 2, 3, 3],
... 'Bread': [0, 1, 2, 1, 1, 2, 1, 2, 2, 3],
... }
>>> majority_judgment(data, reverse=False)
{'Chips': 0, 'Pasta': 1, 'Pizza': 2, 'Bread': 3}
```
(!) ?
/!\ Attention à l'ordre : par défaut le plus grand est le meilleur , il faut utiliser reverse=True pour l'inverser.
## API REST python
https://github.com/MieuxVoter/majority-judgment-api-python
License: GNU aGPLV3 / CECILL variant affero compliant
|postgres||
|python| >= 3.11 |
serveur uvicorn
```
uvicorn app.main:app --reload --env-file .env.local
```
profiles :
|core| if you only need the backend and database|
|dashboard| if you only need Metabase|
|image| if you only need to store images|
|backup| for restic|
Election Candidat Grade Vote
# david chavalarias
https://github.com/davidchavalarias/jugement-majoritaire
Dans le cadre d'une soutenance en 2014 le projet n'a pas été maintenu ni forké.
Une application sous symfony2 ( php Doctrine )
mysql / apache
./Polytech/Bundle/JMBundle
Algorithme principal :
```
public function statsAction($idElection)
{
$em = $this->getDoctrine()->getManager();
$currentElections = $em->getRepository('PolytechJMBundle:Election')->findCurrentElections();
$election = $em->getRepository('PolytechJMBundle:Election')->find($idElection);
if($election->getFinished() == false)
{
return $this->redirect($this->generateUrl('polytech_jm_index'));
}
$candidats = $em->getRepository('PolytechJMBundle:Candidat')->findByElection($election->getId());
$mentions = $em->getRepository('PolytechJMBundle:Mention')->findByElection($election->getId());
$nbrVotes = array();
$indMentionMaj = array();
$nbVMention = array();
foreach($candidats as $cand)
{
$n = $em->getRepository('PolytechJMBundle:Vote')->countVotesByCandidat($cand->getId());
$nbrVotes[$cand->getNom()] = $n[1];
$nbrVotesMentionTmp = array();
$pourcentageMention = array();
foreach($mentions as $m)
{
$temp = $em->getRepository('PolytechJMBundle:Vote')->countVotesByCandidatAndMention($cand->getId(), $m->getId());
$nbrVotesMentionTmp[$m->getNom()] = $temp[1];
if($nbrVotes[$cand->getNom()] == 0)
{
$pourcentageMention[$m->getNom()] = 0;
}
else
{
$pourcentageMention[$m->getNom()] = $nbrVotesMentionTmp[$m->getNom()]*100/$nbrVotes[$cand->getNom()];
}
}
$p_maj = 0;
$i_maj = 0;
$plus = 0;
foreach($mentions as $m){
$p_maj +=$pourcentageMention[$m->getNom()];
$i_maj += 1;
if($p_maj < 50)
{
$plus += $pourcentageMention[$m->getNom()];
}
if($p_maj >= 50) break;
}
$moins = 100-($plus+$pourcentageMention[$m->getNom()]);
$nbVMention[$cand->getNom()] = $nbrVotesMentionTmp;
if(!isset($indMentionMaj[$i_maj]))
{
$indMentionMaj[$i_maj]=array();
}
if($plus >= $moins)
{
if(!isset($indMentionMaj[$i_maj][0]))
{
$indMentionMaj[$i_maj][0] = array();
}
$indMentionMaj[$i_maj][0][$cand->getNom()] = $plus;
}
else
{
if(!isset($indMentionMaj[$i_maj][1]))
{
$indMentionMaj[$i_maj][1] = array();
}
$indMentionMaj[$i_maj][1][$cand->getNom()] = $moins;
}
}
//asort($indMentionMaj);
ksort($indMentionMaj);
foreach($indMentionMaj as &$indV)
{
if(isset($indV[0]))
{
arsort($indV[0]);
}
if(isset($indV[1]))
{
asort($indV[1]);
}
}
return $this->render('PolytechJMBundle:Default:stats.html.twig', array('currentElections' => $currentElections, 'election' => $election, 'nbVMention' => $nbVMention, 'mentions' => $mentions, 'indMentionMaj' => $indMentionMaj, 'nbC' => count($candidats)));
}
```
# Ringayend
2016
https://github.com/Ringayend/Jugement-Majoritaire
Le site utilisant ce code n'existe plus : n'existe https://jugement-majoritaire.herokuapp.com
Site php simple, pas de framework postgres uniquement, en direct ( https://www.php.net/manual/en/function.pg-query.php pas d'ORM )
Permet l'export en excel
```
plhardy@t540p:~/clients/astrolabe/nextcloud/poll/existant/Ringayend.Jugement-Majoritaire.$ cat models/JM.sql
DROP TABLE ELECTEUR;
DROP TABLE CANDIDAT;
DROP TABLE BULLETIN;
CREATE TABLE ELECTEUR (
IDENTIFIANT varchar(255),
NOM varchar(255),
PRENOM varchar(255),
DONE boolean,
ADMIN boolean,
PASSWORD varchar(255),
CONSTRAINT electeur_pk primary key (IDENTIFIANT)
);
CREATE TABLE CANDIDAT (
ID bigserial,
NAME varchar(255) constraint nameCandidat not null,
TB bigint,
B bigint,
AB bigint,
P bigint,
I bigint,
AR bigint,
CONSTRAINT candidat_pk primary key (ID)
);
CREATE TABLE BULLETIN(
IDENTIFIANT varchar(255),
ID bigserial,
TB bigint,
B bigint,
AB bigint,
P bigint,
I bigint,
AR bigint,
constraint bulletin_pk primary key (IDENTIFIANT,ID),
CONSTRAINT bulletin_fk1 FOREIGN KEY (IDENTIFIANT) REFERENCES ELECTEUR(IDENTIFIANT),
CONSTRAINT bulletin_fk2 FOREIGN KEY (ID) REFERENCES CANDIDAT(ID)
);
```
```
```
Les mentions sont codées en dur : TB,B,AB,P,I,AR
resultat ?
```
Nom
Très Bien
Bien
Assez Bien
Passable
Insuffisant
À rejeter
Mention finale
Pourcentage des mentions supérieures