$question->setType($_SESSION['values']['question']['qt']); $question->setTopic($_SESSION['values']['question']['t_id']); if ($_SESSION['values']['question']['descriptionText'] == '') { $_SESSION['values']['question']['description'] = 0; } if ($_SESSION['values']['question']['description'] == 0 && $_SESSION['values']['question']['descriptionText'] != '') { $_SESSION['values']['question']['descriptionText'] = ''; } $check = $question->checkQuestion(); if ($check == 1 && $_SESSION['values']['question']['t_id'] != '') { $topic->getTopic(); $topicArray = $topic->getTopicArray(); $question->setAllTopics($topicArray); $question->showQuestionInfos(); $answer->setQuestionType($_SESSION['values']['question']['qt']); $answer->addAnswer(); $answer->addAnswer(); $answer->setType(); } elseif ($check == 2) { echo "<meta http-equiv='refresh' content='0; url=index.php?site=collect_question&error=exists' />"; } elseif ($check == 0) { echo "<meta http-equiv='refresh' content='0; url=index.php?site=collect_question&error=missing' />"; } elseif ($check == 3) { echo " <meta http-equiv='refresh' content='0; url=index.php?site=collect_question&error=blank' />"; } break; case 'setAnswers': // Antworten setzen // Wertzuweisung $id = 0; if (isset($_REQUEST["questionId"])) {
$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; //if ($questionNumberSite!=$questionNumber) if ($questionNumberSite < 0) { header('Location: waitingScreen.php?message=' . "Submit your answer in time"); } $place = Answer::addAnswer($_SESSION["user_id"], $questionNumber, $lat, $long, $answer, $distanceAway, $color, $game->type); //NOW WE FIND THE OVERALL PERCENT PLACE THAT PERCENT DID ON THAT question_id //Answer::findPercentPlace() //echo $sql; //die(); //SOCKET SENDING MESSAGE if ($place >= 0) { $entryData = array('category' => "Game" . $_SESSION['game_id'] . $questionNumber, 'title' => stripslashes($_SESSION["name"]), 'miles' => number_format($distanceAway), 'color' => $color); $context = new ZMQContext(); $socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher'); $socket->connect("tcp://localhost:5555"); $socket->send(json_encode($entryData)); } //END SOCKET SENDING if ($distanceAway > 1000) { $distanceAway = number_format($distanceAway);
public function fillMissingAnswers() { global $conn; $allUsers = array(); $sql = "SELECT * from `users` WHERE `game_id`= '" . $_SESSION['game_id'] . "'"; $result = $conn->query($sql); //$row = $result->fetch_assoc(); //echo $sql. " rea".$result; //print_r($this->allAnswers); while ($row = $result->fetch_assoc()) { // echo $sql; $name = $row["name"]; $user_id = $row["user_id"]; $color = $row["color"]; $ans = -999; if (!array_key_exists($user_id, $this->allAnswers)) { Answer::addAnswer($user_id, $_SESSION["questionNumber"], -99, -99, $ans, -1, $color, "no"); $this->allAnswers[] = Answer::addUser($_SESSION["questionNumber"], new LatLong(-99, -99), $ans, $user_id, 0, 0, $color); } } }