Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ PHP, Perl, MySQL and Postgres _ Volleyball Tournament Teams

Posted by: gary84 Oct 10 2015, 09:04 PM

would someone be interested in writing this in php. i'm toying with the idea of learning enough php to do it myself but it seems pretty advanced.

app name: RRAP
description: rank, randomize, alternate-pick
purpose: php webpage to create tournament teams
filename: vb_config.txt
fields: parameter, value
order: meaningless
filename: vb_players.txt
fields: playerID,fullname,gender,rank
order: meaningless
323,Rosetta Slaugh,M,1.2 A
342,Mumson Fikes,M,1.2 A
466,Louie Waite,M,1.2 A
377,Eustolia Hilt,M,1.2 A
304,Tyesha Delany,M,1.2 A
313,Vella Widrick,M,1.2 A
87,Lawanna Duffel,M,1.1 A +
467,Nicola Barreras,M,1.1 A +
238,Anamaria Swink,F,2.1 B+
409,Barb Mertes,M,1.2 A
305,Cristine Lago,M,3.2 C
420,Deonna Fabrizio,F,3.1 C+
404,Esteban Auslander,M,2.1 B+
378,Filiberto Cerda,M,2.1 B+
518,Fred Barber,M,1.2 A
280,Hedwig Glover,F,2.1 B+
514,Israel Rosa,M,2.2 B
98,Jasper Lipka,F,2.1 B+
23,Jenice Thibert,F,2.1 B+
406,Jule Seefeldt,M,2.2 B
320,Lahoma Nimmons,F,3.1 C+
357,Lucy Jamal,M,2.2 B
303,Lynnette Nino,F,2.2 B
32,Marcelino Halberg,M,2.1 B+
318,Mechelle Stouffer,F,2.2 B
92,Noel Krom,F,4 D
384,Rosalyn Barfield,M,2.1 B+
516,Sammy Hammond,M,2.1 B+
246,Sharla Lachapelle,M,1.2 A
380,Tarah Landgraf,M,2.1 B+
283,Tayna Kirsch,M,2.1 B+
70,Zelma Shott,F,2.2 B
filename: vb_signedin.txt
fields: fullname,role
order: TeamCaptains in order of weakest-to-strongest. Player order meaningless.
Mumson Fikes,TC
Louie Waite,TC
Tyesha Delany,TC
Vella Widrick,TC
Barb Mertes,TC
Cristine Lago,player
Deonna Fabrizio,player
Esteban Auslander,player
Filiberto Cerda,player
Fred Barbe,player
Hedwig Glover,player
Israel Rosa,player
Jasper Lipka,player
Jenice Thibert,player
Jule Seefeldt,player
Lucy Jamal,player
Lynnette Nino,player
Marcelino Halberg,player
Rosalyn Barfield,player
Zelma Shott,player
user guide

1. use ftp to edit the 3 files described above.
2. navigate to webpage and click "RUN".
3. read contents of tall wide RESULT TEST BOX on webpage to see results.
4. if needed, click "RUN" repeatedly to replace contents of RESULT TEST BOX.

there are 2 genders: M;F.
there are 7 ranks: 1.1 A+; 1.2 A; 2.1 B+; 2.2 B; 3.1 C+; 3.2 C; 4 D.

distribute team captains, one per team, where team 1 has the weakest captain.
when distributing players, always alternate the team picking order: 1,2,3,4,4,3,2,1,1,2,3,4 (the 4th captain gets the 4th and 5th pick).
randomize all players within their gender and rank.
distribute male players.
distribute female players.
show results.
output sample, as shown in RESULT TEST BOX

1,1,Mumson Fikes, TC
1,2,Fred Barbe
1,3,Hedwig Glover
1,4,Jasper Lipka
2,1,Louie Waite, TC
2,2,Marcelino Halberg
2,3,Cristine Lago
2,4,Jenice Thibert
3,1,Tyesha Delany, TC
3,2,Esteban Auslander
3,3,Jule Seefeldt
3,4,Zelma Shott
4,1,Vella Widrick, TC
4,2,Rosalyn Barfield
4,3,Israel Rosa
4,4,Lynnette Nino
5,1,Barb Mertes, TC
5,2,Filiberto Cerda
5,3,Lucy Jamal
5,4,Deonna Fabrizio

Posted by: GroverParkGeorge Oct 10 2015, 09:45 PM

Before someone takes on a project like this, it helps to be clear on expectations and assumptions.

Have you established a budget for this project? Do you have a rough estimate of the time required? Do you have an hourly rate in mind which you're willing to pay?

Do you already have a domain and web presence on which to host the finished pages? Do you plan to integrate it into an existing site?

How will security be handled? Is this open to the public?

Will teams or members be able to make changes, or only the site owner?

What long term storage is needed? I.e. is a database required?

Posted by: Jeff B. Oct 11 2015, 06:46 AM

... and to add to George's list of clarifications, what "skill level" will you be targeting? That is, will the folks using this be experienced data-entry types or will they have trouble knowing how to turn on a computer?

Posted by: gary84 Dec 30 2015, 12:27 PM

I chose to try to figure it out. Didn't take as long as I thought. Probably not the most optimized php ever written but it works.

The hard part was vb_teams.php that's where the randomizing logic is.

<a href="vb_rank.php">Rank List</a></br>
<a href="vb_signin.php">Signin List</a></br>
<a href="vb_teams.php">Teams</a></br>
<a href="vb_userguide.php">User Guide</a></br>
Randomly Generated Teams:</br>
$boolgenerate = TRUE;

// save displayed most-recently-generated team list
    $strwhole = stripslashes($_POST['textarea1']);
    $file = fopen("vb_teams.txt","w") or die ("error");
    fclose($file) or die ("error");
    echo "List Saved</br>";
    $boolgenerate = FALSE;}

// recall older saved team list
    $file = "vb_teams.txt";
    $strwhole = file_get_contents($file);
    echo "List Recalled</br>";
    $boolgenerate = FALSE;}

// generate fresh randomized team list    
if ($boolgenerate == TRUE){
    // input lists
    $signinlist = array_map('str_getcsv', file('vb_signin.txt'));
    $ranklist = array_map('str_getcsv', file('vb_rank_.txt'));

    // validate players on signin list are on rank list
    foreach($signinlist AS $signin){
        $boolfound = FALSE;
        foreach($ranklist AS $rank){
            if (strtolower(trim($signin[0])) == strtolower(trim($rank[2]))){
                $boolfound = TRUE;}}
        if (!$boolfound){
            echo "ERROR missing rank: $signin[0]</br>";}}
    // validate no duplicate players on signin list
    $signingroup = array();
    foreach($signinlist AS $signin){
        if ($player != ""){
    foreach($signingroup AS $signin => $qty){
        if ($qty > 1){
            echo "ERROR duplicate signin: $signin</br>";}}
    // group by rank type
    $rankgroup = array();
    foreach($ranklist AS $rank){
        if ($r != ""){
            if (!in_array($r, $rankgroup)){
                $rankgroup[] = $r;
    if ($intrank > 7){
        echo "ERROR ranks exceed 7</br>";}

    // sort rank types alphabetically

    // randomize, 1st by gender, 2nd by rank, create picklistA
    shuffle($ranklist); // randomize all players
    $picklistA = array();
    $gender = array("M","F");
    $intgender = 0;
        foreach($rankgroup as $rankloop){             // one loop per rank type  
            foreach($ranklist AS $rank){              // one loop per rank list player
                foreach($signinlist AS $signin){      // one loop per signin list player
                    if (strtolower(trim($signin[0]) != "")){
                        if (strtolower(trim($rank[2]) == trim($signin[0]))){   // is player ranked
                            if (trim($rank[0]) == $gender[$intgender]){        // do males then females
                                if (strtolower(trim($rank[1])) == $rankloop){  // do one rank type
                                    if (strtolower(trim($signin[1])) != "tc"){ // exclude captains
                                        $picklistA[] = trim($rank[2]);}}}}}}}} // append to picklist
    while ($intgender <= 1);

    // create array of captains, count them, dictates qty teams
    foreach($signinlist AS $signin){
        if (strtolower(trim($signin[1])) == "tc"){
            $captain[$intcaptains] = trim($signin[0]);

    // apply alternating-order, create picklistB
    $intpickdirection = 1;
    $intteam = 0;
    $intplayer = 0;
    foreach($picklistA AS $pick){
        if ($pick!=""){    
            $picklistB[$intplayer][0] = ($intteam+1);
            $picklistB[$intplayer][1] = $intplayer;
            $picklistB[$intplayer][2] = $pick;
            if ($intpickdirection == 1){
                if ($intteam == $intcaptains){
                    $intpickdirection = 2;
                    $intteam = $intcaptains-1;}}
                $intteam = $intteam - 1;
                if ($intteam == -1){
                    $intpickdirection = 1;
                    $intteam = 0;}}
    // sort players by team number

    // display teams
    $intteam = -1;
    $indent = "&nbsp&nbsp";
    foreach($picklistB AS $pick){
        if ($pick[0]!=($intteam+1)){
            $intteam = ($pick[0]-1);
            $strwhole .= "Team ".($intteam+1)."</br>$indent$intplayer. $captain[$intteam]</br>";
        $strwhole .= "$indent$intplayer. $pick[2]</br>";
        echo "</br>";
$strwhole = str_replace("&nbsp", " ", $strwhole);
$strwhole = str_replace("</br>", "\r\n", $strwhole);

//echo "</br></br>";
//echo count($signinlist)." players on signin list</br>";
//echo count($ranklist)." players on rank list</br>";
//echo "$intrank unique ranks</br>";
//echo "rev_2015-12-26-2</br>";

<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
<input type="submit" name="savebutton" value="Save">
<input type="submit" name="recallbutton" value="Recall"></br>
<textarea rows="40" cols="35" name="textarea1"><?php echo $strwhole; ?></textarea></br>

</body></html> ( 4.19K ): 4

Posted by: gary84 Dec 30 2015, 01:06 PM

correction #1:
in the URL above, change
from /php/vb_signin.php
to /php1005/vb_signin.php