1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-29 23:51:09 +02:00

Améliorations du code

This commit is contained in:
Yohann
2019-09-08 01:35:05 +02:00
committed by galaxyoyo
parent 3cc66ef783
commit a25ec69ae9
23 changed files with 558 additions and 457 deletions

View File

@ -8,18 +8,19 @@ if (!isset($_SESSION["team"]))
* @var Tournament $tournament
*/
$team = $_SESSION["team"];
$tournament = Tournament::fromId($team->isSelectedForFinal() ? $FINAL->getId() : $team->getTournamentId());
$tournament = Tournament::fromId($team->getTournamentId());
if (isset($_POST["send_solution"])) {
$error_message = saveSolution();
}
/** @noinspection SqlAggregates */
$solutions_req = $DB->prepare("SELECT `file_id`, `problem`, COUNT(`problem`) AS `version` FROM `solutions` WHERE `team` = ? AND `tournament` = ? GROUP BY `problem` ORDER BY `problem`, `uploaded_at` DESC;");
$solutions_req->execute([$team->getId(), $tournament->getId()]);
$solutions = $tournament->getAllSolutions($team->getId());
$solutions_final = null;
if ($team->isSelectedForFinal())
$solutions_final = $FINAL->getAllSolutions($team->getId());
function saveSolution() {
global $LOCAL_PATH, $DB, $team, $tournament;
global $LOCAL_PATH, $DB, $team, $tournament, $FINAL;
try {
$problem = $_POST["problem"];
@ -55,7 +56,7 @@ function saveSolution() {
return "Une erreur est survenue lors de l'envoi du fichier.";
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`) VALUES (?, ?, ?, ?);");
$req->execute([$id, $team->getId(), $tournament->getId(), $problem]);
$req->execute([$id, $team->getId(), $team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId(), $problem]);
return false;
}