<?php

session_start();
require_once('../config/database.php');
include_once '../security/session_config.php';
include_once '../security/csrf.php';
include_once '../config/properties.php';
include_once "../resources/EncryptDecrypt.php";
include_once "../resources/assessment.php";

$csrf_token = $_POST['csrf_token'];
validate_csrf_request($csrf_token);

if (isset($_POST['oid'])) {
    require("../resources/manageusers.php");

    $oid = $_POST['oid'];
    $ano = $_POST['ano'];
    $aid = $_POST['aid'];
 
    $assessment = new Assessment();

    $assessment->offering_id = $oid;
    $assessment->user_id = $_SESSION['uid'];
    $assessment->attempt_no = $ano;
    $assessment->assessment_id = $aid;
    $times = array();
    $stmt = $assessment->get_quiz_time();
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        array_push($times, $row['time']);
    }
}
echo json_encode($times);
?>

