T1703271557

This commit is contained in:
Leander
2017-03-27 15:58:06 +02:00
parent 7099d41b2f
commit 8901180d85
3 changed files with 8 additions and 5 deletions

View File

@@ -10,4 +10,5 @@
11102 - User name already exists
= start.php =
12101 - More questions wanted then existing
12101 - 0 questions wanted, no game without a question!
12102 - More questions wanted then existing

View File

@@ -51,12 +51,12 @@ class Database
case 11102:
return 'User name already exists. Please pick a different name.';
case 12101:
return 'A game without a question is not possible. Please select new game length.';
case 12102:
return 'We only have '.$values[0].' questions. Please select new game length.';
default:
return 'An unknown error occurred.';
}
}
}
?>

View File

@@ -14,9 +14,11 @@
$length = ($_GET['length'] && gettype(+$_GET['length']) == 'integer') ? +$_GET['length'] : 10;
$database = new Database();
$questions_count = $database->query('SELECT COUNT(*) FROM "Questions"')['data'][0]['count'];
if($length > $questions_count) {
if($length = 0) {
$error = 12101;
}
if($length > $questions_count) {
$error = 12102;
$values = array($questions_count);
}
$response = Database::create_response($data, $error, $values);