Possibilité de télécharger une archive des solutions et notes de synthèse pour les organisateurs
This commit is contained in:
parent
369fb4fd5b
commit
2272a8b45d
|
@ -1,5 +1,45 @@
|
||||||
<?php include 'config.php'; ?>
|
<?php include 'config.php'; ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (isset($_POST["download_zip"])) {
|
||||||
|
$id = $_POST["tournament"];
|
||||||
|
$tournament_name = $_POST["tournament_name"];
|
||||||
|
$files_req = $DB->query("SELECT *, COUNT(`problem`) AS `version` FROM `solutions` WHERE `tournament` = '$id' GROUP BY `team`, `problem` ORDER BY `team`, `problem`, `uploaded_at` DESC;");
|
||||||
|
|
||||||
|
$zip = new ZipArchive();
|
||||||
|
|
||||||
|
$temp = tempnam("tmp", "tfjm-");
|
||||||
|
|
||||||
|
if ($zip->open($temp, ZipArchive::CREATE) !== true) {
|
||||||
|
die("Impossible de créer le fichier zip.");
|
||||||
|
}
|
||||||
|
|
||||||
|
while (($data_file = $files_req->fetch()) !== false) {
|
||||||
|
$file_id = $data_file["file_id"];
|
||||||
|
$problem = $data_file["problem"];
|
||||||
|
$version = $data_file["version"];
|
||||||
|
$team_id = $data_file["team"];
|
||||||
|
$team_data = $DB->query("SELECT `name`, `trigram` FROM `teams` WHERE `id` = '$team_id' AND `year` = $YEAR;")->fetch();
|
||||||
|
$team_name = $team_data["name"];
|
||||||
|
$team_trigram = $team_data["trigram"];
|
||||||
|
|
||||||
|
$zip->addFile("$LOCAL_PATH/files/$file_id", "Problème $problem $team_trigram.pdf");
|
||||||
|
}
|
||||||
|
|
||||||
|
$zip->close();
|
||||||
|
|
||||||
|
header("Content-Type: application/zip");
|
||||||
|
header("Content-Disposition: attachment; filename=\"Solutions du tournoi de $tournament_name.zip\"");
|
||||||
|
header("Content-Length: " . strval(filesize($temp) + 1));
|
||||||
|
|
||||||
|
readfile($temp);
|
||||||
|
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
<?php include 'header.php'; ?>
|
<?php include 'header.php'; ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
@ -22,6 +62,14 @@ while (($data_tournament = $req->fetch()) !== false) {
|
||||||
$team_trigram = $team_data["trigram"];
|
$team_trigram = $team_data["trigram"];
|
||||||
echo "Problème n°$problem de l'équipe $team_name ($team_trigram), version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
echo "Problème n°$problem de l'équipe $team_name ($team_trigram), version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<form method="POST">
|
||||||
|
<input type="hidden" name="tournament" value="<?= $id ?>" />
|
||||||
|
<input type="hidden" name="tournament_name" value="<?= $data_tournament["name"] ?>" />
|
||||||
|
<input type="submit" name="download_zip" value="Télécharger l'archive" />
|
||||||
|
</form>
|
||||||
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,5 +1,45 @@
|
||||||
<?php include 'config.php'; ?>
|
<?php include 'config.php'; ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (isset($_POST["download_zip"])) {
|
||||||
|
$id = $_POST["tournament"];
|
||||||
|
$tournament_name = $_POST["tournament_name"];
|
||||||
|
$files_req = $DB->query("SELECT *, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `tournament` = '$id' GROUP BY `team`, `dest` ORDER BY `team`, `dest`, `uploaded_at` DESC;");
|
||||||
|
|
||||||
|
$zip = new ZipArchive();
|
||||||
|
|
||||||
|
$temp = tempnam("tmp", "tfjm-");
|
||||||
|
|
||||||
|
if ($zip->open($temp, ZipArchive::CREATE) !== true) {
|
||||||
|
die("Impossible de créer le fichier zip.");
|
||||||
|
}
|
||||||
|
|
||||||
|
while (($data_file = $files_req->fetch()) !== false) {
|
||||||
|
$file_id = $data_file["file_id"];
|
||||||
|
$dest = $data_file["dest"];
|
||||||
|
$version = $data_file["version"];
|
||||||
|
$team_id = $data_file["team"];
|
||||||
|
$team_data = $DB->query("SELECT `name`, `trigram` FROM `teams` WHERE `id` = '$team_id' AND `year` = $YEAR;")->fetch();
|
||||||
|
$team_name = $team_data["name"];
|
||||||
|
$team_trigram = $team_data["trigram"];
|
||||||
|
|
||||||
|
$zip->addFile("$LOCAL_PATH/files/$file_id", "Note de synthèse $team_trigram pour " . ($dest == "OPPOSANT" ? "l'opposant" : "le rapporteur") . ".pdf");
|
||||||
|
}
|
||||||
|
|
||||||
|
$zip->close();
|
||||||
|
|
||||||
|
header("Content-Type: application/zip");
|
||||||
|
header("Content-Disposition: attachment; filename=\"Notes de syntèses du tournoi de $tournament_name.zip\"");
|
||||||
|
header("Content-Length: " . strval(filesize($temp) + 1));
|
||||||
|
|
||||||
|
readfile($temp);
|
||||||
|
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
<?php include 'header.php'; ?>
|
<?php include 'header.php'; ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
@ -23,8 +63,14 @@ while (($data_tournament = $req->fetch()) !== false) {
|
||||||
echo "Note de synthèse de l'équipe $team_name ($team_trigram) pour " . ($dest == "OPPOSANT" ? "l'opposant" : "le rapporteur")
|
echo "Note de synthèse de l'équipe $team_name ($team_trigram) pour " . ($dest == "OPPOSANT" ? "l'opposant" : "le rapporteur")
|
||||||
. ", version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
. ", version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
|
<form method="POST">
|
||||||
|
<input type="hidden" name="tournament" value="<?= $id ?>" />
|
||||||
|
<input type="hidden" name="tournament_name" value="<?= $data_tournament["name"] ?>" />
|
||||||
|
<input type="submit" name="download_zip" value="Télécharger l'archive" />
|
||||||
|
</form>
|
||||||
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php include 'footer.php'; ?>
|
<?php include 'footer.php'; ?>
|
||||||
|
|
|
@ -21,7 +21,7 @@ if (($data = $req->fetch()) === false) {
|
||||||
$data = $req->fetch();
|
$data = $req->fetch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print_r($type);
|
|
||||||
if ($data !== false) {
|
if ($data !== false) {
|
||||||
$team_data = $DB->query("SELECT `trigram` FROM `teams` WHERE `id` = " . $data["team"] . ";")->fetch();
|
$team_data = $DB->query("SELECT `trigram` FROM `teams` WHERE `id` = " . $data["team"] . ";")->fetch();
|
||||||
$tournament_data = $DB->query("SELECT `name` FROM `tournaments` WHERE `id` = " . $data["tournament"] . ";")->fetch();
|
$tournament_data = $DB->query("SELECT `name` FROM `tournaments` WHERE `id` = " . $data["tournament"] . ";")->fetch();
|
||||||
|
|
Loading…
Reference in New Issue