Command line application and PHP library, providing an election engine with a high-level interface. Native support 20+ voting methods, easy to extend. Support simple elections with ease or billions of votes in low resource environment. Intensively tested and highly polyvalent.
use CondorcetPHP\Condorcet\Condorcet;
use CondorcetPHP\Condorcet\Election;
use CondorcetPHP\Condorcet\Candidate;
use CondorcetPHP\Condorcet\CondorcetUtil;
use CondorcetPHP\Condorcet\Vote;
require_once ("./vendor/autoload.php");
Condorcet::setDefaultMethod('Schulze');
$election = new Election ();
$votes = $em->getRepository('Entities\Vote')->findBy(['categoryId' => $_GET['id']]);
foreach ($votes as $vote){
$result[] = $vote->getVote();
$vote1 = new Vote ( $vote->getVote() );
$election->addVote($vote1);
}
print_r($election->countVotes ());
print("<br />");
foreach ($election->getResult('Schulze') as $rank => $candidates) :
echo 'Rank ' . $rank . ': ';
echo implode(', ', $candidates);
echo '<br />';
endforeach;
echo 'Schulze winner is : ' . $election->getWinner('Schulze')->getName() . '<br />';
//print_r($result);
This $vote->getVote() returns votes from db with this format:
Brass Birmingham = Scythe > Concordia = Gaia Project = On Mars > Power Grid = Terraforming Mars > A Feast for Odin = Everdell = Spirit Island = Through the Ages > Terra Mystica = Wingspan > Gloomhaven
I get:
Uncaught CondorcetPHP\Condorcet\Throwable\CondorcetException: [20]: You need to specify one or more candidates before voting (line: /home2/phplicen/public_html/shultze/vendor/julien-boudry/condorcet/lib/Election.php:320) thrown in vendor/julien-boudry/condorcet/lib/Election.php on line 320
Does this mean that I should define each individual candidate items again? why for getting the final result I should define individual candidates again?
I have this:
This
$vote->getVote()
returns votes from db with this format:Brass Birmingham = Scythe > Concordia = Gaia Project = On Mars > Power Grid = Terraforming Mars > A Feast for Odin = Everdell = Spirit Island = Through the Ages > Terra Mystica = Wingspan > Gloomhaven
I get: Uncaught CondorcetPHP\Condorcet\Throwable\CondorcetException: [20]: You need to specify one or more candidates before voting (line: /home2/phplicen/public_html/shultze/vendor/julien-boudry/condorcet/lib/Election.php:320) thrown in vendor/julien-boudry/condorcet/lib/Election.php on line 320
Does this mean that I should define each individual candidate items again? why for getting the final result I should define individual candidates again?