require_once 'tools/constant/Config.php';
require_once 'tools/db/queries.php';
include 'pages/header/correction_header.php';
$obj_utils = new DbUtils();
$tool = new Tool($dbUtils);
$obj_utils->connect();
// Load current course
$course = $obj_utils->getCourse();
if (HTTP_RESQUEST::exist("actionType") && HTTP_RESQUEST::post("actionType") == 'changeResults') {
    $newHour = HTTP_RESQUEST::post("newHour");
    $newMin = HTTP_RESQUEST::post("newMin");
    $newSec = HTTP_RESQUEST::post("newSec");
    if (is_numeric($newHour) && is_numeric($newMin) && is_numeric($newSec)) {
        $resultId = HTTP_RESQUEST::post("resultId");
        $course = HTTP_RESQUEST::post("course");
        $obj_utils->updateResultTime($resultId, $course, $newHour, $newMin, $newSec);
    } else {
        ?>
		<script>alert("veuillez entrer une valeur numérique pour les champs ");</script>
		<?php 
    }
} else {
    if (HTTP_RESQUEST::exist("actionType") && HTTP_RESQUEST::post("actionType") == 'changeCourse') {
        $course = HTTP_RESQUEST::post("changeCourse");
    }
}
?>
<form action="./index.php?page=correction/correction_results.php" method="post" id="changeCourseForm">
	<select name="changeCourse" onchange="document.getElementById('changeCourseForm').submit();">
		<?php 
foreach (Config::$courses as $currentCourse) {