From 65a9bd8c47d65d9d2727e3dc0fc4c11b4939a193 Mon Sep 17 00:00:00 2001 From: Leander Date: Fri, 7 Apr 2017 08:34:27 +0200 Subject: [PATCH] T201704070834 --- answer.php | 6 +++--- config.inc.php | 2 +- rename.php | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/answer.php b/answer.php index 47cbe53..07fe553 100644 --- a/answer.php +++ b/answer.php @@ -18,7 +18,7 @@ $chosen_answer = (($chosen_answer === '0') || ($chosen_answer && gettype(+$chose function calculate_points($time) { $points = $time < 2000 ? 100 : 205 - 1/2 * (205 + sqrt(-3975 + 2 * $time)); - $points = $points < 1 ? 10 : intval($points * 10); + $points = $points < 1 ? 10 : round($points * 10); return $points; } @@ -56,7 +56,7 @@ if($uid == '') { } $old_high = $db->query('SELECT "score" FROM "Highscores" WHERE "Users_ID" = $1 AND "Categories_ID" = $2', array($uid, $cid))['data'][0]['score']; - $new_high = intval($old_high * 0.95 + $score * 0.05); + $new_high = round($old_high * 0.95 + $score * 0.05); $db->query('UPDATE "Highscores" SET "score" = $1 WHERE "Users_ID" = $2 AND "Categories_ID" = $3', array($new_high, $uid, $cid)); @@ -73,7 +73,7 @@ if($uid == '') { 'SELECT "highscore" FROM "Users" WHERE "ID" = $1', array($uid) )['data'][0]['highscore']; - $new_user_high = $old_user_high == 0 ? $new_points : intval($old_user_high * 0.95 + $new_points * 0.05); + $new_user_high = $old_user_high == 0 ? $new_points : round($old_user_high * 0.95 + $new_points * 0.05); $db->query('UPDATE "Users" SET "highscore" = $1 WHERE "ID" = $2', array($new_user_high, $uid)); } } diff --git a/config.inc.php b/config.inc.php index 6c92928..0568432 100644 --- a/config.inc.php +++ b/config.inc.php @@ -6,7 +6,7 @@ * Time: 09:45 */ -error_reporting(E_ALL); +//error_reporting(E_ALL); ini_set("display_errors", 1); define('DATABASE_URL', 'lamp.wlan.hwr-berlin.de'); define('DATABASE_USER', 'gr2'); diff --git a/rename.php b/rename.php index 2973783..77c9b63 100644 --- a/rename.php +++ b/rename.php @@ -26,6 +26,7 @@ if(preg_match(PATTERN, $name) != 1) { $data = array('uid' => $uid, 'name' => $name); } } + $response = Database::create_response($data, $error); print $response;