function getNumberAchievements()
{
    include 'config.php';
    $username = getUserNameFromId($_GET['id']);
    $query = mysql_query("SELECT * FROM achievement_entries WHERE username = '******'");
    return mysql_num_rows($query);
}
 /**
  * private function creating a new SentWork object
  *
  * @param int $uploader_id
  * @param string $title
  * @param string $description
  * @param string $author
  * @param string $filename
  * @param int $filesize
  * @param array $recipient_ids
  */
 public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
 {
     $dropbox_cnf = getDropboxConf();
     $_course = api_get_course_info();
     // Call constructor of Dropbox_Work object
     $this->Dropbox_Work($uploader_id, $title, $description, $author, $filename, $filesize);
     $course_id = api_get_course_int_id();
     // Do sanity checks on recipient_ids array & property fillin
     // The sanity check for ex-coursemembers is already done in base constructor
     settype($uploader_id, 'integer') or die(get_lang('GeneralError') . ' (code 208)');
     // Set $uploader_id to correct type
     $justSubmit = false;
     if (is_int($recipient_ids)) {
         $justSubmit = true;
         $recipient_ids = array($recipient_ids + $this->id);
     } elseif (count($recipient_ids) == 0) {
         $justSubmit = true;
         $recipient_ids = array($uploader_id);
     }
     if (!is_array($recipient_ids) || count($recipient_ids) == 0) {
         die(get_lang('GeneralError') . ' (code 209)');
     }
     foreach ($recipient_ids as $rec) {
         if (empty($rec)) {
             die(get_lang('GeneralError') . ' (code 210)');
         }
         //if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course
         //this check is done when validating submitted data
         $this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec));
     }
     $table_post = $dropbox_cnf['tbl_post'];
     $table_person = $dropbox_cnf['tbl_person'];
     $session_id = api_get_session_id();
     $uploader_id = $this->uploader_id;
     $user = api_get_user_id();
     // Insert data in dropbox_post and dropbox_person table for each recipient
     foreach ($this->recipients as $rec) {
         $file_id = (int) $this->id;
         $user_id = (int) $rec['id'];
         $sql = "INSERT INTO {$table_post} (c_id, file_id, dest_user_id, session_id)\n                    VALUES ({$course_id}, {$file_id}, {$user_id}, {$session_id})";
         $result = Database::query($sql);
         // If work already exists no error is generated
         /**
          * Poster is already added when work is created - not so good to split logic
          */
         if ($user_id != $user) {
             // Insert entries into person table
             $sql = "INSERT INTO {$table_person} (c_id, file_id, user_id)\n                        VALUES ({$course_id}, {$file_id}, {$user_id})";
             // Do not add recipient in person table if mailing zip or just upload.
             if (!$justSubmit) {
                 $result = Database::query($sql);
                 // If work already exists no error is generated
             }
         }
         // Update item_property table for each recipient
         if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) {
             $ownerid = getUserOwningThisMailing($ownerid);
         }
         if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) {
             $recipid = $ownerid;
             // mailing file recipient = mailing id, not a person
         }
         api_item_property_update($_course, TOOL_DROPBOX, $this->id, 'DropboxFileAdded', $ownerid, null, $recipid);
     }
 }
<?php

// Inialize session
session_start();
// Load config
include '../../../config.php';
// Get username from id
$userName = getUserNameFromId($_GET['id']);
// Return info
echo $userName;
function getUserNameFromId($id)
{
    // Load user info
    $userData = mysql_query("SELECT * FROM users");
    // Search for user id and return name
    while ($row = mysql_fetch_array($userData)) {
        if ($row['id'] == $id) {
            return $row['username'];
        }
    }
}
Beispiel #4
0
<?php

//Email notification script
//Search the users in the db for anyone with at leat one game that is not picked
//Count games in week
//Count games user has picked
//compare
//If picked < games || score IS NULL) = send email
// Load Databases and Common functions
require "mysql.php";
include 'common.php';
include "functions.php";
//Site Functions
//include('include/test_include.php');
//try to guess the current week, function in get_winners
guessCurrentWeek();
$num_games = getNumberOfGames($this_season_year, $this_season_type, $this_week);
$sql = "SELECT COUNT(pick_id) as num_picks, user_id FROM picks WHERE season_year='{$this_season_year}' AND season_type='{$this_season_type}' AND week='{$this_week}' GROUP BY user_id";
$result = mysqli_query($db, $sql) or die(mysqli_error($db));
while ($user = mysqli_fetch_array($result)) {
    if ($user['num_picks'] < $num_games) {
        echo 'User ' . getUserNameFromId($db, $user['user_id']) . ' has only picked ' . $user['num_picks'] . ' of ' . $num_games . ' send her an email at ' . getUserEmailFromId($db, $user['user_id']);
        notifyUser(getUserEmailFromId($db, $user['user_id']), getUserNameFromId($db, $user['user_id']), $num_games, $user['num_picks']);
    }
}
Beispiel #5
0
function displaySeasonStandings($db, $users, $season_year, $season_types, $current_week)
{
    global $this_group_id;
    // create an invisible DIV to hold debugging info
    echo "<div id=\"DivSeasonDebugging\" style=\"display: none;\">\n";
    //$season_types = getSeasonTypes(); //get all types
    $season_wins = array();
    //initialize win placeholder
    $total_weeks = 0;
    //check if week is reconciled yet
    $sql = "SELECT user_id, COUNT(winner) as wins FROM points WHERE season_year='{$season_year}' AND group_id='{$this_group_id}' AND reconciled IS NOT NULL GROUP BY user_id ORDER BY wins DESC";
    $result = mysqli_query($db, $sql);
    $row_cnt = mysqli_num_rows($result);
    $row = mysqli_fetch_array($result, MYSQL_ASSOC);
    //  if(!is_null($row['user_id'])) { // completely unreconiled db's show num_rows of 1 because of SELECT COUNT, so check that it is real
    if (mysqli_num_rows($result) > 0) {
        //just build the $season_wins[$user_name] array from the previous DB Result
        $is_reconciled = TRUE;
        echo '<h2>DB is Reconciled so using those results.</h2>';
        print_r($row);
        do {
            //add winnders
            $this_key = getUserNameFromId($db, $row['user_id']);
            $this_val = $row['wins'];
            $total_weeks += $this_val;
            $season_wins[$this_key] = $this_val;
        } while ($row = mysqli_fetch_assoc($result));
        foreach ($users as $user) {
            $this_key = getUserNameFromId($db, $user['user_id']);
            if (!array_key_exists($this_key, $season_wins)) {
                $season_wins[$this_key] = 0;
            }
        }
        echo "<p>Season Wins:";
        print_r($season_wins);
        echo "</p>\n";
    } else {
        //try to reconcile if all games are complete for the week
        echo "Empty result";
        foreach ($users as $user) {
            $this_key = getUserNameFromId($db, $user['user_id']);
            if (!array_key_exists($this_key, $season_wins)) {
                $season_wins[$this_key] = 0;
            }
        }
        /*
           $is_reconciled = FALSE;
           
           echo '<h2>Find Winners and Reconcile DB</h2>';
           foreach($users as $user) { //set each user to 0 wins
               $season_wins[$user['user_name']] = 0;
           }
          
           foreach($season_types as $season_type) {
        
           $season_weeks = getWeeks($season_year,$season_type);
           echo "<p>Weeks this season:";
           print_r($season_weeks);
           echo "</p>\n";
           echo "<p>Current week is: $current_week";
           $total_weeks += count($season_weeks);
           echo "</p>\n";
           echo "<p>Week Count.: $total_weeks";
           echo "</p>\n";
        
           foreach($season_weeks as $week) {
               if(!allGamesFinished($season_year,$season_type,$week)) { //skip reconcil
                   echo '<h2>Week Not Over</h2>\n';
                   print_r($row);
                   foreach($users as $user) {
                       $this_key = getUserNameFromId($db,$user['user_id']);
                       if(!array_key_exists($this_key,$season_wins)) {
                           $season_wins[$this_key] = 0;
                       }
                   }
                   break;
               } else { //try to reconcile
                   echo '<h2>Find Winners and Reconcile DB</h2>';
                   foreach($users as $user) { //set each user to 0 wins
                       $season_wins[$user['user_name']] = 0;
                   }
                   echo "<p>Season Wins:";
                   print_r($season_wins);
                   echo "</p>\n";
             
                   if($week < $current_week) { //only count completed weeks
                       $num_games = getNumberOfGames($season_year,$season_type,$week);
                       $totals = array();
                       $scores = array();
         
                       foreach($users as $user) {    
                           $num_correct = getWeeklyPoints($db,$user['user_id'],$user['group_id'],$season_year,$season_type,$week);
                           $score = getWeeklyScore($db,$user['user_id'],$user['group_id'],$season_year,$season_type,$week); //returns array with gsis_id and total score
                           $this_key = $user['user_name'];
                           $this_game_id = $score[0];
                           $totals[$this_key] = $num_correct; 
                           $scores[$this_key] = $score[1];
                           echo "<p>User ".$this_key." has ".$totals[$this_key]." and a guess of score ".$scores[$this_key]." for game ".$this_game_id;
                           //print_r($score);
                           echo "</p>\n";
                           $percentage = ($num_correct / $num_games) * 100;
                       }  
           
                       echo "\n<br>Scores array<br>\n";
                       print_r($scores);
                       echo "<br>Unsorted Totals array:<br>\n";
                       print_r($totals);
        
                       arsort($totals);
        
                       $top_score = max($totals);
                       echo "\n<br>Sorted Totals array:<br>\n";
                       print_r($totals);
                       echo "\n<br>with a Top Score of $top_score<br>\n";
        
                       if(count($totals) <= 1 ) {
        
                       } elseif(current($totals) == next($totals)) { //there is a tie
                           reset($totals);
                           echo "<p>It's a tie!</p>\n";
                           do { //remove the low scores
                               if(current($totals) != $top_score) {
                                   array_pop($totals);
                               }
                           } while(next($totals));
        
                           echo "<br>Possible winners after culling:<br>\n";
                           print_r($totals);
          
                           echo "<br>Score Array:<br>\n";
                           print_r($scores);
        
                           if(isset($this_game_id)) {
                               $game_score = getGameScore($this_game_id);
                           } else {
                               $game_score = 0;
                           }
                           echo "<br>Subtract Actual Game score of $game_score.<br>\n";
             
                           foreach($scores as $u => $s) {
                               $score_diffs[$u] = abs($s - $game_score);
                           }
            
                           echo "<br>Unsorted Score Differentials:<br>\n";
                           print_r($score_diffs);
                           asort($score_diffs);
                           echo "<br>Sorted Score Differentials:<br>\n";
                           print_r($score_diffs);
                           $lowest_diff = max($score_diffs);
                           echo "<br>with a Lowest Diff of $lowest_diff<br>\n";
        
                           if(current($score_diffs) == next($score_diffs)) { //there is a another tie
                               $winner = key($score_diffs); //flip a proverbial coin
                               echo $winner." has won the second tie breaker through a random selection process.<br>\n";
                               reconcileWinners($db,$winner,$user['group_id'],$season_year,$season_type,$week,$verbose=TRUE);
                               $season_wins[$winner] += 1;
                               echo "<p>".print_r($season_wins)."</p>\n";
                           } else {
                               reset($score_diffs);
                               $winner = key($score_diffs);
                               echo $winner." has won the tie breaker with a score differential of $lowest_diff.<br>\n";
                               reconcileWinners($db,$winner,$user['group_id'],$season_year,$season_type,$week,$verbose=TRUE);
                               $season_wins[$winner] += 1;
                               echo "<p>".print_r($season_wins)."</p>\n";
                           }
        
                       } else {
                           reset($totals);
                           $winner = key($totals);
                           echo $winner." has won on picks. ";
                           //Reconcile weekly point total and flag winner in DB
                           reconcileWinners($db,$winner,$user['group_id'],$season_year,$season_type,$week,$verbose=TRUE);
                           $season_wins[$winner] += 1;
                           echo "<p>".print_r($season_wins)."</p>\n";
                       }//End Tie Determination
                    }//--End IF current week check
               } //reconcile
           }//--Week
         }//End foreach Season 
        */
    }
    //END reconciliation check
    echo "</div>\n";
    //end debug
    //Display winner graph
    //print_r($season_wins);
    //echo "<div style=\"border: 1px solid green;\">";
    echo "<div id=\"DivSeasonWins\">\n";
    if ($total_weeks > 0) {
        arsort($season_wins);
        $i = 0;
        foreach ($season_wins as $u => $w) {
            $p = $w / $total_weeks * 100;
            $p = round($p);
            echo "<div class=\"progress-label\">" . substr($u, 0, 12) . "</div><div class=\"progress\">\n";
            echo "\t<div class=\"progress-bar";
            if ($i == 0 && $p > 0) {
                echo " progress-bar-success";
            }
            echo "\" role=\"progressbar\" aria-valuenow=\"{$p}\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"min-width: 2em; width: {$p}%\">\n\n            {$w} ({$w}/{$total_weeks}, {$p}%)\n\n            </div>\n\n            </div>\n";
            $i++;
        }
        echo "</div>\n";
        echo "<div id=\"DivSeasonDollars\" style=\"position: absolute; visibility: hidden;\">\n";
        // each user bar should go from -34 to max
        //$i=0;
        $anty = 2;
        foreach ($season_wins as $u => $w) {
            //starting balance = weeks*anty
            //total pot = users * weeks * anty
            //winnings = (wins * users * anty) - (total_weeks*anty)
            $starting_anty = $total_weeks * $anty;
            $starting_balance = $starting_anty * -1;
            $max_winnings = $total_weeks * count($users) * $anty;
            $max_balance = $max_winnings - $starting_anty;
            $winnings = $w * count($users) * $anty;
            $current_balance = $starting_balance + $winnings;
            $winnings_p = $winnings / $max_winnings * 100;
            $break_even_p = $starting_anty / $max_winnings * 100;
            echo "<div class=\"progress-label\">" . substr($u, 0, 12) . "</div><div class=\"progress\">\n";
            if ($winnings_p > $break_even_p) {
                echo "<div class=\"progress-bar progress-bar-danger\" role=\"progressbar\" style=\"min-width: 2em; width: {$break_even_p}%\"></div>\n";
                $whats_left = $winnings_p - $break_even_p;
                echo "<div class=\"progress-bar progress-bar-success\" role=\"progressbar\" style=\"min-width: 2em; width: {$whats_left}%\">&#36;{$current_balance}</div>\n";
            } else {
                echo "<div class=\"progress-bar progress-bar-danger\" role=\"progressbar\" style=\"min-width: 2em; width: {$winnings_p}%\">&#36;{$current_balance}</div>\n";
            }
            echo "</div>\n";
        }
        //echo "</div>";
    } else {
        echo "<p>Season Standings will be available after the end of this week.</p>";
    }
    echo "</div>\n";
    //calculateWinnings($users,$weeks,$wins,$anty)
}
/**
 * @return array|null|string
 */
function store_add_dropbox()
{
    $_course = api_get_course_info();
    $_user = api_get_user_info();
    $dropbox_cnf = getDropboxConf();
    // Validating the form data
    // there are no recipients selected
    if (!isset($_POST['recipients']) || count($_POST['recipients']) <= 0) {
        return get_lang('YouMustSelectAtLeastOneDestinee');
    } else {
        // Check if all the recipients are valid
        $thisIsAMailing = false;
        $thisIsJustUpload = false;
        foreach ($_POST['recipients'] as $rec) {
            if ($rec == 'mailing') {
                $thisIsAMailing = true;
            } elseif ($rec == 'upload') {
                $thisIsJustUpload = true;
            } elseif (strpos($rec, 'user_') === 0 && !isCourseMember(substr($rec, strlen('user_')))) {
                return get_lang('InvalideUserDetected');
            } elseif (strpos($rec, 'group_') !== 0 && strpos($rec, 'user_') !== 0) {
                return get_lang('InvalideGroupDetected');
            }
        }
    }
    // we are doing a mailing but an additional recipient is selected
    if ($thisIsAMailing && count($_POST['recipients']) != 1) {
        return get_lang('MailingSelectNoOther');
    }
    // we are doing a just upload but an additional recipient is selected.
    // note: why can't this be valid? It is like sending a document to yourself AND to a different person (I do this quite often with my e-mails)
    if ($thisIsJustUpload && count($_POST['recipients']) != 1) {
        return get_lang('MailingJustUploadSelectNoOther');
    }
    if (empty($_FILES['file']['name'])) {
        $error = true;
        return get_lang('NoFileSpecified');
    }
    // are we overwriting a previous file or sending a new one
    $dropbox_overwrite = false;
    if (isset($_POST['cb_overwrite']) && $_POST['cb_overwrite']) {
        $dropbox_overwrite = true;
    }
    // doing the upload
    $dropbox_filename = $_FILES['file']['name'];
    $dropbox_filesize = $_FILES['file']['size'];
    $dropbox_filetype = $_FILES['file']['type'];
    $dropbox_filetmpname = $_FILES['file']['tmp_name'];
    // check if the filesize does not exceed the allowed size.
    if ($dropbox_filesize <= 0 || $dropbox_filesize > $dropbox_cnf['maxFilesize']) {
        return get_lang('DropboxFileTooBig');
        // TODO: The "too big" message does not fit in the case of uploading zero-sized file.
    }
    // check if the file is actually uploaded
    if (!is_uploaded_file($dropbox_filetmpname)) {
        // check user fraud : no clean error msg.
        return get_lang('TheFileIsNotUploaded');
    }
    $upload_ok = process_uploaded_file($_FILES['file'], true);
    if (!$upload_ok) {
        return null;
    }
    // Try to add an extension to the file if it hasn't got one
    $dropbox_filename = add_ext_on_mime($dropbox_filename, $dropbox_filetype);
    // Replace dangerous characters
    $dropbox_filename = replace_dangerous_char($dropbox_filename);
    // Transform any .php file in .phps fo security
    $dropbox_filename = php2phps($dropbox_filename);
    //filter extension
    if (!filter_extension($dropbox_filename)) {
        return get_lang('UplUnableToSaveFileFilteredExtension');
    }
    // set title
    $dropbox_title = $dropbox_filename;
    // set author
    if (!isset($_POST['authors'])) {
        $_POST['authors'] = getUserNameFromId($_user['user_id']);
    }
    // note: I think we could better migrate everything from here on to separate functions: store_new_dropbox, store_new_mailing, store_just_upload
    if ($dropbox_overwrite) {
        $dropbox_person = new Dropbox_Person($_user['user_id'], api_is_course_admin(), api_is_course_tutor());
        foreach ($dropbox_person->sentWork as $w) {
            if ($w->title == $dropbox_filename) {
                if ($w->recipients[0]['id'] > dropbox_cnf('mailingIdBase') xor $thisIsAMailing) {
                    return get_lang('MailingNonMailingError');
                }
                if ($w->recipients[0]['id'] == $_user['user_id'] xor $thisIsJustUpload) {
                    return get_lang('MailingJustUploadSelectNoOther');
                }
                $dropbox_filename = $w->filename;
                $found = true;
                // note: do we still need this?
                break;
            }
        }
    } else {
        // rename file to login_filename_uniqueId format
        $dropbox_filename = getLoginFromId($_user['user_id']) . "_" . $dropbox_filename . "_" . uniqid('');
    }
    // creating the array that contains all the users who will receive the file
    $new_work_recipients = array();
    foreach ($_POST['recipients'] as $rec) {
        if (strpos($rec, 'user_') === 0) {
            $new_work_recipients[] = substr($rec, strlen('user_'));
        } elseif (strpos($rec, 'group_') === 0) {
            $userList = GroupManager::get_subscribed_users(substr($rec, strlen('group_')));
            foreach ($userList as $usr) {
                if (!in_array($usr['user_id'], $new_work_recipients) && $usr['user_id'] != $_user['user_id']) {
                    $new_work_recipients[] = $usr['user_id'];
                }
            }
        }
    }
    @move_uploaded_file($dropbox_filetmpname, dropbox_cnf('sysPath') . '/' . $dropbox_filename);
    $b_send_mail = api_get_course_setting('email_alert_on_new_doc_dropbox');
    if ($b_send_mail) {
        foreach ($new_work_recipients as $recipient_id) {
            $recipent_temp = UserManager::get_user_info_by_id($recipient_id);
            $additionalParameters = array('smsType' => ClockworksmsPlugin::NEW_FILE_SHARED_COURSE_BY, 'userId' => $recipient_id, 'courseTitle' => $_course['title'], 'userUsername' => $recipent_temp['username']);
            api_mail_html(api_get_person_name($recipent_temp['firstname'] . ' ' . $recipent_temp['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $recipent_temp['email'], get_lang('NewDropboxFileUploaded'), get_lang('NewDropboxFileUploadedContent') . ' ' . api_get_path(WEB_CODE_PATH) . 'dropbox/index.php?cidReq=' . $_course['sysCode'] . "\n\n" . api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS) . "\n" . get_lang('Email') . " : " . $_user['mail'], api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_user['mail'], null, null, null, $additionalParameters);
        }
    }
    new Dropbox_SentWork($_user['user_id'], $dropbox_title, $_POST['description'], strip_tags($_POST['authors']), $dropbox_filename, $dropbox_filesize, $new_work_recipients);
    Security::clear_token();
    return get_lang('FileUploadSucces');
}
 if (!$error) {
     // Try to add an extension to the file if it hasn't got one
     $dropbox_filename = add_ext_on_mime($dropbox_filename, $dropbox_filetype);
     // Replace dangerous characters
     $dropbox_filename = api_replace_dangerous_char($dropbox_filename);
     // Transform any .php file in .phps fo security
     $dropbox_filename = php2phps($dropbox_filename);
     if (!filter_extension($dropbox_filename)) {
         $error = true;
         $errormsg = get_lang('UplUnableToSaveFileFilteredExtension');
     } else {
         // set title
         $dropbox_title = $dropbox_filename;
         // set author
         if ($_POST['authors'] == '') {
             $_POST['authors'] = getUserNameFromId($_user['user_id']);
         }
         if ($dropbox_overwrite) {
             $dropbox_person = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor);
             foreach ($dropbox_person->sentWork as $w) {
                 if ($w->title == $dropbox_filename) {
                     if ($w->recipients[0]['id'] > dropbox_cnf('mailingIdBase') xor $thisIsAMailing) {
                         $error = true;
                         $errormsg = get_lang('MailingNonMailingError');
                     }
                     if ($w->recipients[0]['id'] == $_user['user_id'] xor $thisIsJustUpload) {
                         $error = true;
                         $errormsg = get_lang('MailingJustUploadSelectNoOther');
                     }
                     $dropbox_filename = $w->filename;
                     $found = true;
Beispiel #8
0
echo "Picks reconciled. ";
//--RECONCILE WIINERS
//get all non-reconciled PICKS
// Get all of the users picks
$sql = "SELECT season_year, season_type, week, group_id FROM points WHERE reconciled IS NULL";
$result = mysqli_query($db, $sql) or die(mysqli_error($db));
while ($row = mysqli_fetch_array($result)) {
    extract($row, EXTR_PREFIX_ALL, "this");
    if (allGamesFinished($this_season_year, $this_season_type, $this_week)) {
        //determine winner and reconcile
        // echo '<h2>Find Winners and Reconcile DB</h2>';
        //Sum all user points and scores and put them into an array with the user_name as the key
        $sql = "SELECT user_id, SUM(points) as sum_points, SUM(score) as sum_scores FROM picks WHERE season_year=" . $this_season_year . " AND season_type='" . $this_season_type . "' AND week=" . $this_week . " GROUP BY user_id ORDER BY sum_points DESC";
        $result = mysqli_query($db, $sql) or die(mysqli_error($db));
        while ($row = mysqli_fetch_array($result)) {
            $user_name = getUserNameFromId($db, $row['user_id']);
            $total_points[$user_name] = $row['sum_points'];
            $total_scores[$user_name] = $row['sum_scores'];
        }
        // echo "<p>Results Sorted by Most Points:</p>";
        print_r($total_points);
        //check for a tie
        $most_points = max($total_points);
        $possible_winners = 0;
        foreach ($total_points as $p) {
            if ($p == $most_points) {
                $possible_winners++;
            }
        }
        if ($possible_winners > 1) {
            //there is a tie