1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-21 17:58:24 +02:00

Utilisation des nouvelles classes, amélioration du code

This commit is contained in:
galaxyoyo
2019-09-07 01:33:05 +02:00
parent b5d567e364
commit bffaf4b360
30 changed files with 472 additions and 440 deletions

View File

@ -2,23 +2,27 @@
require_once "../config.php";
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ORGANIZER && $_SESSION["role"] != Role::ADMIN)
require_once "../403.php";
$trigram = htmlspecialchars($_GET["trigram"]);
$team = Team::fromTrigram($trigram);
if ($team === null)
require_once "../404.php";
if (isset($_POST["validate"])) {
$DB->exec("UPDATE `teams` SET `validation_status` = 'VALIDATED' WHERE `trigram` = '$trigram' AND `year` = $YEAR;");
$team->setValidationStatus(ValidationStatus::VALIDATED);
}
$team_data = $DB->query("SELECT * FROM `teams` WHERE `trigram` = '$trigram' AND `year` = $YEAR;")->fetch();
if (isset($_POST["select"])) {
$DB->exec("UPDATE `teams` SET `final_selection` = true, `validation_status` = 'NOT_READY' WHERE `trigram` = '$trigram' AND `year` = $YEAR;");
$team_data["validation_status"] = "NOT_READY";
$team_data["final_selection"] = true;
$final_id = $_SESSION["final_id"];
$team_id = $team_data["id"];
$team->selectForFinal(true);
$team->setValidationStatus(ValidationStatus::NOT_READY);
$_SESSION["final"] = Tournament::getFinalTournament();
$sols_req = $DB->prepare("SELECT `file_id`, `problem`, COUNT(`problem`) AS `version` FROM `solutions` WHERE `team` = ? AND `tournament` = ? GROUP BY `problem`, `uploaded_at` ORDER BY `problem`, `uploaded_at` DESC;");
$sols_req->execute([$team_data["id"], $team_data["tournament"]]);
$sols_req->execute([$team->getId(), $team->getTournamentId()]);
while (($sol_data = $sols_req->fetch()) !== false) {
$old_id = $sol_data["file_id"];
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
@ -35,11 +39,11 @@ if (isset($_POST["select"])) {
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`)
VALUES (?, ?, ?, ?);");
$req->execute([$id, $team_id, $_SESSION["final_id"], $sol_data["problem"]]);
$req->execute([$id, $team->getId(), $_SESSION["final_id"], $sol_data["problem"]]);
}
$syntheses_req = $DB->prepare("SELECT `file_id`, `dest`, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `team` = ? AND `tournament` = ? GROUP BY `dest`, `uploaded_at` ORDER BY `dest`, `uploaded_at` DESC;");
$syntheses_req->execute([$team_data["id"], $team_data["tournament"]]);
$syntheses_req->execute([$team->getId(), $team->getTournamentId()]);
while (($synthese_data = $syntheses_req->fetch()) !== false) {
$old_id = $synthese_data["file_id"];
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
@ -55,23 +59,20 @@ if (isset($_POST["select"])) {
copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id");
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
$req->execute([$id, $team_id, $_SESSION["final_id"], $synthese_data["dest"]]);
$req->execute([$id, $team->getId(), $_SESSION["final"]->getId(), $synthese_data["dest"]]);
}
}
if ($team_data === false)
require_once "../404.php";
$tournament_data = $DB->query("SELECT `name`, `date_start` FROM `tournaments` WHERE `id` = '" . $team_data["tournament"] . "' AND `year` = '$YEAR';")->fetch();
$documents_req = $DB->prepare("SELECT `file_id`, `user`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `team` = ? AND `tournament` = ? GROUP BY `user`, `type` ORDER BY `user`, `type` ASC, MAX(`uploaded_at`) DESC;");
$documents_req->execute([$team_data["id"], $team_data["tournament"]]);
$documents_req->execute([$team->getId(), $team->getId()]);
if ($team_data["final_selection"]) {
if ($team->isSelectedForFinal()) {
$documents_final_req = $DB->prepare("SELECT `file_id`, `user`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `team` = ? AND `tournament` != ? GROUP BY `user`, `type` ORDER BY `user`, `type` ASC, MAX(`uploaded_at`) DESC;");
$documents_final_req->execute([$team_data["id"], $_SESSION["final_id"]]);
$documents_final_req->execute([$team->getId(), $_SESSION["final"]->getId()]);
}
$tournament = Tournament::fromId($team->getTournamentId());
require_once "../views/header.php";
require_once "../views/equipe.php";
require_once "../views/footer.php";