This software generates a list of names in a random order, suitable for use in an election. It is particularly envisaged for use with BOB as the final output of information can be directly copied into BOB's configuration files.
The randomness is generated by placing the names of the candidates in an array (a list) and then shuffling their order a random number of times (between 100 and 500 times per candidate). This should be sufficiently random for most elections.
It is also possible to turn the random function off, if you would simply like to generate the BOB input file.
Please note that this software contains no checking functions and so you must manually check every stage before proceeding to the next. No guarantees are made as to the compatibility of the final data with BOB.
How many elections are you running?
Enter the number of candidates; the number of posts to fill and each election\'s name.';
echo 'Only count actual candidates (“RON”—Re–open Nominations can be added at the next stage).
';
echo 'If you are adding a referendum, enter one candidate and one post. Any name given to a referendum will not be shown on the final ballot as the question is considered sufficient.
';
echo '';
$i=1; //Probably not needed but a double check that this variable is reset!
}elseif ($_POST['stage']==2){ //Stage 2
echo 'Enter the names of the candidates or referenda questions.
';
echo 'If the election is a referendum, enter the question as the candidate\'s name and then tick the box marked "Referendum"
';
echo 'If your candidates have electoral labels or party affiliations, which should appear on the ballot paper, then you may add them after their name, with a suitable deliniating symbol. Although names or questions of any length are theoretically possible, you may have difficulties if the labels are over 60 characters long (at which point thy may go over a line–break).
';
echo '';
}elseif ($_POST['stage']==3){ //Stage three
echo 'The Ballot Data
';
echo 'For use with BOB, the data that needs to be inserted into the Configuration file is located between the two hoizontal lines.
';
echo '
';
for ($i=1; $i<=$_POST['number_elections']; $i++) //Loop through each election
{
echo $_POST['posts_election'.$i]."
"; //Number of posts to be elected-- first piece of data that BOB requires
$_POST['referendum'.$i] = (isSet ($_POST['referendum'.$i]) ? $_POST['referendum'.$i] : ''); // Ensure the value is set
if ($_POST['referendum'.$i]!='yes'){ //If it is not a referendum then echo the name of the election
echo $_POST['name_election'.$i]."
";
}
$candidatesarray=array(); //Create an array for the candidates
$candidates_election=$_POST['candidates_election'.$i];
for ($j=1; $j<=$candidates_election; $j++) //Loop through each candidate
{
$currentcandidate=$_POST['election'.$i.'_candidate'.$j];
if ($_POST['referendum'.$i]=='yes'){ //If referendum then the text "Referendum: " needs to be added before the name of each "candidate"
$currentcandidate='Referendum: '.$currentcandidate;
}
array_push ($candidatesarray,$currentcandidate); //Add current candidates to array
$currentcandidate=NULL; //Clear the variable
if ($_POST['randomise'.$i]=='yes'){ //If Candidates need to be in a random order then...
$rand=rand(100,500); //Generate a random number between 100 and 500
for ($k=1; $k<=$rand; $k++){ //Repeat the shuffle a random number of times (as set above). This is probably not needed but helps appease those who are wary of computer randomness.
shuffle ($candidatesarray); //Shuffle the array containing the names
}
}
}
foreach ($candidatesarray as $candidatesarray) { //For each name in the array
echo "$candidatesarray
"; //Print the name of the candidate (in a random order)
}
$candidatesarray=NULL; //Clear the variable
if (isSet ($_POST['ron'.$i]) && ($_POST['ron'.$i]=='yes')){ //If RON is needed...
echo 'Re-Open Nominations (RON)
'; //...then add
}
$_POST['referendum'.$i] = (isSet ($_POST['referendum'.$i]) ? $_POST['referendum'.$i] : ''); // Ensure the value is set
if ($_POST['referendum'.$i]=='yes'){ //If referendum then add the necessary word
echo 'referendum
';
}
echo '
'; //Add one line space
}
echo "ENDOFDATA"; //"ENDOFDATA" needed at the end.
echo "
";
echo "
";
echo "Please double–check this data by hand. Then you may wish to enter it into BOB.
";
}
?>