<?php
header('Content-Type: application/json');

$maestroID = $_POST["maestroID"];
$playerID = $_POST["playerID"];
$writingID = $_POST["writingID"];

include "./../lib/json_builder.php";
include "./../lib/connect_db.php";

$jsonBuilder = new JsonBuilder();
$dbConnector = new DBConnector();

$isConnected = $dbConnector->connectDB();
if (!$isConnected) {
	$jsonBuilder->setErrorMessage("DB connection : failed");
	$jsonBuilder->sendResultFail();
	exit;
}


include "./../db/db_method_container.php";
include "./../db/typing_exam_collection.php";

$typingExam = new TypingExamCollection($dbConnector->getMysqli());

$highestRecordData = $typingExam->getHighestRecord($maestroID, $playerID, $writingID);
$jsonBuilder->setData("highestRecordData", $highestRecordData);

if ($highestRecordData === null) {
	$jsonBuilder->sendResultFail();
	exit;
}

$jsonBuilder->sendResultSuccess();
?>