Esempio n. 1
0
 function __construct($questionNum)
 {
     $this->allAnswers = array();
     $this->correctAns = Answer::loadCorrect($questionNum);
     global $conn;
     $sql = "SELECT * FROM `answers` WHERE game_id ='" . $_SESSION["game_id"] . "' AND questionNum='" . $_SESSION["questionNumber"] . "' order by submitTime DESC";
     //echo $sql;
     $result = $conn->query($sql);
     if ($result) {
         while ($row = $result->fetch_assoc()) {
             $lat1 = $row["lat"];
             $long1 = $row["longg"];
             $ans = $row["answer"];
             $user_id = $row["user_id"];
             $qID = $row["id"];
             $points = $row["points"];
             if ($points == null) {
                 $points = 0;
             }
             $color = $row["color"];
             $this->allAnswers[$user_id] = Answer::addUser($qID, new LatLong($lat1, $long1), $ans, $user_id, $this->correctAns, $points, $color);
             //$submitTime= $row["submitTime"];
             //$miles=round(LatLong::distance($lat,$long,$lat1,$long1,"M"));
             //echo "<bR>user: "******" was : ".$miles ." miles away.  Submitted at time " . $submitTime ;
         }
     }
     $this->awardPoints();
     //Question::alertUsers("-1");
     //echo "loc is ".$this->correctAns->location->lat;
 }
Esempio n. 2
0
session_start();
$whitelist = array('lat', 'long', 'answer', 'questionNumber');
require '../controller/dbsettings.php';
if ($lat == "") {
    $lat = 0;
}
if ($long == "") {
    $long = 0;
}
$color = User::getColor();
//die ($color);
if ($_SESSION["user_id"] == 0) {
    die("Sorry this shouldnt happen - tell me about it...");
}
$correct = Answer::loadCorrect($questionNumber);
//place currently is true or false if they could submit (meaning 1st time)
//die ($questionNumber);
//echo $sql;
//die();
$game = Game::findGame();
if ($game->type == "geo" || $game->type == "places" || $game->type == "pt") {
    $distanceAway = LatLong::findDistance($correct->location, new LatLong($lat, $long));
} else {
    $distanceAway = abs($answer - $correct->value);
}
if ($answer > 100000) {
    $distanceAway = round($distanceAway, -5);
}
//die ($questionNumber);
$questionNumberSite = $game->round;