test 4 verificaiton d'un index de vote invalide

+ correction php
This commit is contained in:
philippe lhardy
2025-06-23 10:21:28 +02:00
parent 502ea0aeaf
commit b7d7fdf8a3
4 changed files with 95 additions and 1 deletions

87
samples/4.json Normal file
View File

@@ -0,0 +1,87 @@
{
"candidats":{
"A":"albert",
"B":"Beatrice",
"C":"Chloé",
"D":"Deborah",
"E":"Eric",
"F":"Francçois",
"G":"Gisèle",
"H":"Hugo"
},
"votants":{
"decompte":11
},
"mentions":[
"Très Bien",
"Bien",
"Assez Bien",
"Passable",
"Insuffisant",
"A rejeter"
],
"votation":
{
"date":"14 juin 2025",
"lieu":"liffré",
"votes":[
{
"A":1,
"C":2,
"D":3
},
{
"B":1,
"C":2,
"E":3
},
{
"A":1,
"C":2,
"F":3
},
{
"G":1,
"C":2,
"D":3
},
{
"A":1,
"G":2,
"E":3
},
{
"E":1,
"C":2,
"D":3
},
{
"E":1,
"C":2,
"D":3
},
{
"A":1,
"D":2
},
{
"A":5,
"C":2,
"D":3
},
{
"A":4,
"B":6
},
{
"A":1,
"C":2,
"D":3,
"B":4,
"E":3,
"F":4,
"G":0
}
]
}
}

6
samples/README.md Normal file
View File

@@ -0,0 +1,6 @@
https://www4.artisanlogiciel.net/dokuwiki/doku.php?id=artlog:clients:astrolabe:nextcloud_poll:nextcloud_poll_jugement_majoritaire
./check.sh 1
./check.sh 2
./check.sh 3
./check.sh 4

View File

@@ -23,3 +23,4 @@ then
fi
python3 parse_sample.py $json_file
php parse_sample.php $json_file

View File

@@ -57,7 +57,7 @@ foreach ($votes as $vote) {
foreach ( $vote as $candidat => $mention ) {
if ($mention > $default_mention or $mention < 0) {
$mention = $default_mention;
$warnings.append("index de mention invalide, soit la liste des mentions est erronnée soit la mention dans le vote est erronée");
array_push($warnings,"index de mention invalide, soit la liste des mentions est erronnée soit la mention dans le vote est erronée");
}
if ( array_key_exists($candidat,$collect)) {
if ( array_key_exists($mention,$collect[$candidat])) {