<?php
session_start();
include "Connection.php"; 
include "Quiz.php";

$db = new Database(); 
$con =  $db->connect();

$quiz = new Quiz($con); 
$lang = $_SESSION["lang"];

if(isset($_POST["difficulty"])){
    $dif = $_POST["difficulty"];
    $dif *= 3;  
    $questions = $quiz->getQuestions($dif, $lang);
    echo json_encode($questions); 
}else if(isset($_POST["points"])){
    $points = $_POST["points"];
    $points = $points * 10;
    $result = $quiz->setExperience($_SESSION["id_user"],$points);
    echo $result; 
}else{
    echo "400";
}

$db->close($con);
?>