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:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user