From b7d7fdf8a3c87563b3dada1e65508f5a3f6bc98e Mon Sep 17 00:00:00 2001 From: philippe lhardy Date: Mon, 23 Jun 2025 10:21:28 +0200 Subject: [PATCH] test 4 verificaiton d'un index de vote invalide + correction php --- samples/4.json | 87 ++++++++++++++++++++++++++++++++++++++++ samples/README.md | 6 +++ samples/check.sh | 1 + samples/parse_sample.php | 2 +- 4 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 samples/4.json create mode 100644 samples/README.md diff --git a/samples/4.json b/samples/4.json new file mode 100644 index 0000000..4887525 --- /dev/null +++ b/samples/4.json @@ -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 + } + ] + } +} diff --git a/samples/README.md b/samples/README.md new file mode 100644 index 0000000..5017b2f --- /dev/null +++ b/samples/README.md @@ -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 \ No newline at end of file diff --git a/samples/check.sh b/samples/check.sh index 4403ff8..10070cc 100755 --- a/samples/check.sh +++ b/samples/check.sh @@ -23,3 +23,4 @@ then fi python3 parse_sample.py $json_file +php parse_sample.php $json_file diff --git a/samples/parse_sample.php b/samples/parse_sample.php index 2c5702d..b91bc12 100644 --- a/samples/parse_sample.php +++ b/samples/parse_sample.php @@ -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])) {