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

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

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());

$rankingRecordArray = $typingExam->getRankingRecordHour($maestroID, $writingID, $date, $time);
$jsonBuilder->setData("rankingHour", $rankingRecordArray);
$rankingMinusRecordArray = $typingExam->getRankingMinusRecordHour($maestroID, $writingID, $date, $time);
$jsonBuilder->setData("rankingMinusHour", $rankingMinusRecordArray);

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

$jsonBuilder->sendResultSuccess();
?>