mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-25 22:17:29 +02:00
Correction de problèmes vis-à-vis de l'envoi et le téléchargement de fichiers
This commit is contained in:
@ -3,20 +3,23 @@
|
||||
if (!isset($_SESSION["team"]))
|
||||
require_once "server_files/403.php";
|
||||
|
||||
if (isset($_POST["send_solution"])) {
|
||||
$error_message = saveSolution();
|
||||
}
|
||||
|
||||
/** @var Team $team */
|
||||
/**
|
||||
* @var Team $team
|
||||
* @var Tournament $tournament
|
||||
*/
|
||||
$team = $_SESSION["team"];
|
||||
|
||||
$solutions_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;");
|
||||
$solutions_req->execute([$team->getId(), $_SESSION[$team->isSelectedForFinal() ? $FINAL->getId() : $team->getTournamentId()]]);
|
||||
|
||||
$tournament = Tournament::fromId($team->isSelectedForFinal() ? $FINAL->getId() : $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()]);
|
||||
|
||||
function saveSolution() {
|
||||
global $LOCAL_PATH, $DB;
|
||||
global $LOCAL_PATH, $DB, $team, $tournament;
|
||||
|
||||
try {
|
||||
$problem = $_POST["problem"];
|
||||
@ -52,7 +55,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, $_SESSION["team_id"], $_SESSION["tournament_id"], $problem]);
|
||||
$req->execute([$id, $team->getId(), $tournament->getId(), $problem]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user