T201704070834
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -26,6 +26,7 @@ if(preg_match(PATTERN, $name) != 1) {
|
||||
$data = array('uid' => $uid, 'name' => $name);
|
||||
}
|
||||
}
|
||||
|
||||
$response = Database::create_response($data, $error);
|
||||
print $response;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user