22 lines
519 B
PHP
22 lines
519 B
PHP
<?php
|
|
|
|
require_once(__DIR__ . '/Database.php');
|
|
header('Content-Type: application/json');
|
|
header('Access-Control-Allow-Origin: *');
|
|
|
|
$db = new Database();
|
|
|
|
$n = 10;
|
|
if (isset($_GET['n'])) {
|
|
$n = $_GET['n'];
|
|
}
|
|
$questions = $db->getQuestions($n);
|
|
|
|
$answers[] = array($questions['answer0'], $questions['answer1'], $questions['answer2']);
|
|
|
|
$jsonarray[] = array("id" => $questions['id'], "answers" => $answers, "solution" => $questions['solution']);
|
|
|
|
$questionsobj = json_encode($jsonarray);
|
|
echo($questionsobj);
|
|
?>
|