1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-30 08:31:09 +02:00

First week fixes

This commit is contained in:
Yohann D'ANELLO
2020-05-05 01:06:57 +02:00
parent a064cc1817
commit 132481fda0
22 changed files with 541 additions and 59 deletions

View File

@ -30,8 +30,12 @@ class NewTournament {
public $time_inscription;
public $date_solutions;
public $time_solutions;
public $date_syntheses;
public $time_syntheses;
public $date_syntheses;
public $time_syntheses;
public $date_solutions_2;
public $time_solutions_2;
public $date_syntheses_2;
public $time_syntheses_2;
public $description;
public $final;
public $tournament;
@ -72,7 +76,9 @@ class NewTournament {
ensure(dateWellFormed($this->date_end), "La date de fin n'est pas valide.");
ensure(dateWellFormed($this->date_inscription . " " . $this->time_inscription), "La date de clôture des inscriptions n'est pas valide.");
ensure(dateWellFormed($this->date_solutions . " " . $this->time_solutions), "La date limite de remise des solutions n'est pas valide.");
ensure(dateWellFormed($this->date_syntheses . " " . $this->time_syntheses), "La date limite de remise des notes de synthèse n'est pas valide.");
ensure(dateWellFormed($this->date_syntheses . " " . $this->time_syntheses), "La date limite de remise des notes de synthèse pour le tour 1 n'est pas valide.");
ensure(dateWellFormed($this->date_solutions_2 . " " . $this->time_solutions_2), "La date limite de visibilité des solutions du tour 2 n'est pas valide.");
ensure(dateWellFormed($this->date_syntheses . " " . $this->time_syntheses), "La date limite de remise des notes de synthèse pour le tour 2 n'est pas valide.");
$this->final = $this->final ? 1 : 0;
@ -84,10 +90,13 @@ class NewTournament {
global $DB, $YEAR;
$req = $DB->prepare("INSERT INTO `tournaments` (`name`, `size`, `place`, `price`, `description`,
`date_start`, `date_end`, `date_inscription`, `date_solutions`, `date_syntheses`, `final`, `year`)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
`date_start`, `date_end`, `date_inscription`, `date_solutions`, `date_syntheses`,
`date_solutions_2`, `date_syntheses_2`, `final`, `year`)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
$req->execute([$this->name, $this->size, $this->place, $this->price, $this->description, $this->date_start, $this->date_end,
"$this->date_inscription $this->time_inscription", "$this->date_solutions $this->time_solutions", "$this->date_syntheses $this->time_syntheses", $this->final ? 1 : 0, $YEAR]);
"$this->date_inscription $this->time_inscription", "$this->date_solutions $this->time_solutions",
"$this->date_syntheses $this->time_syntheses", "$this->date_solutions_2 $this->time_solutions_2",
"$this->date_syntheses_2 $this->time_syntheses_2", $this->final ? 1 : 0, $YEAR]);
$this->tournament = Tournament::fromName($this->name);

View File

@ -37,7 +37,7 @@ elseif (isset($_POST["unvalidate"])) {
if (isset($_POST["select"])) {
$team->selectForFinal(true);
$team->setValidationStatus(ValidationStatus::NOT_READY);
# $team->setValidationStatus(ValidationStatus::NOT_READY);
$sols = $tournament->getAllSolutions($team->getId());
/** @var Solution $sol */
foreach ($sols as $sol) {
@ -49,7 +49,7 @@ if (isset($_POST["select"])) {
copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id");
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`) VALUES (?, ?, ?, ?);");
$req->execute([$id, $team->getId(), $FINAL->getId(), $sol->getFileId()]);
$req->execute([$id, $team->getId(), $FINAL->getId(), $sol->getProblem()]);
}
}
@ -86,6 +86,19 @@ if (isset($_POST["select_tournament"])) {
$tournament = $new_tournament;
}
if (isset($_POST["delete_team"])) {
foreach ($team->getEncadrants() as $encadrant_id) {
quitTeam($encadrant_id);
}
foreach ($team->getParticipants() as $participant_id) {
quitTeam($participant_id);
}
header("Location: /");
return;
}
class EditTeam
{
public $name;
@ -136,4 +149,25 @@ $documents_final = null;
if ($team->isSelectedForFinal())
$documents_final = $FINAL->getAllDocuments($team->getId());
$emails = [];
if ($_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN) {
foreach ($team->getEncadrants() as $encadrant_id) {
$encadrant = User::fromId($encadrant_id);
if ($encadrant != null) {
$emails[] = $encadrant->getEmail();
}
}
foreach ($team->getParticipants() as $participant_id) {
$participant = User::fromId($participant_id);
if ($participant != null) {
$emails[] = $participant->getEmail();
if ($participant->getResponsibleEmail() != null) {
$emails[] = $participant->getResponsibleEmail();
}
}
}
}
require_once "server_files/views/equipe.php";

View File

@ -23,7 +23,8 @@ if ($user === null)
require_once "server_files/404.php";
if ($team != null) {
$documents = $user->getAllDocuments($team->getTournamentId());
$documents = $user->getAllDocuments($team->getTournamentId());
$documents_final = $user->getAllDocuments($FINAL->getId());
$payment = $user->getPayment();
$tournament = Tournament::fromId($team->getTournamentId());
}

View File

@ -47,6 +47,94 @@ if (isset($_POST["request_validation"])) {
}
}
$DUMPS = [
["TKT", 6, "PGA", 3, "IRD", 1],
["OUI", 8, "LEP", 1, "REX", 7],
["ASP", 1, "ABC", 3, "TDP", 6],
["GIF", 8, "ETM", 1, "LPC", 3],
["MST", 6, "LQF", 1, "WAL", 2],
];
$DUMPS_2 = [
["TKT", 4, "PGA", 1, "IRD", 6],
["LEP", 6, "OUI", 5, "REX", 8],
["ASP", 5, "ABC", 8, "TDP", 4],
["ETM", 8, "LPC", 4, "GIF", 6],
["MST", 5, "LQF", 4, "WAL", 8],
];
foreach ($DUMPS as $dump) {
$team1 = Team::fromTrigram($dump[0]);
$team2 = Team::fromTrigram($dump[2]);
$team3 = Team::fromTrigram($dump[4]);
$problem1 = $dump[1];
$problem2 = $dump[3];
$problem3 = $dump[5];
$req1 = $DB->prepare("SELECT * FROM `solutions` WHERE `team` = ? AND `problem` = ? ORDER BY uploaded_at DESC LIMIT 1");
$req1->execute([$team1->getId(), $problem1]);
$data1 = $req1->fetch();
$sol1 = Solution::fromData($data1);
$req2 = $DB->prepare("SELECT * FROM `solutions` WHERE `team` = ? AND `problem` = ? ORDER BY uploaded_at DESC LIMIT 1");
$req2->execute([$team2->getId(), $problem2]);
$data2 = $req2->fetch();
$sol2 = Solution::fromData($data2);
$req3 = $DB->prepare("SELECT * FROM `solutions` WHERE `team` = ? AND `problem` = ? ORDER BY uploaded_at DESC LIMIT 1");
$req3->execute([$team3->getId(), $problem3]);
$data3 = $req3->fetch();
$sol3 = Solution::fromData($data3);
$req1 = $DB->prepare("UPDATE `teams` SET `opposed_problem` = ?, `rapported_problem` = ? WHERE `id` = ?;");
$req1->execute([$sol2->getFileId(), $sol3->getFileId(), $team1->getId()]);
$req2 = $DB->prepare("UPDATE `teams` SET `opposed_problem` = ?, `rapported_problem` = ? WHERE `id` = ?;");
$req2->execute([$sol3->getFileId(), $sol1->getFileId(), $team2->getId()]);
$req3 = $DB->prepare("UPDATE `teams` SET `opposed_problem` = ?, `rapported_problem` = ? WHERE `id` = ?;");
$req3->execute([$sol1->getFileId(), $sol2->getFileId(), $team3->getId()]);
}
foreach ($DUMPS_2 as $dump) {
$team1 = Team::fromTrigram($dump[0]);
$team2 = Team::fromTrigram($dump[2]);
$team3 = Team::fromTrigram($dump[4]);
$problem1 = $dump[1];
$problem2 = $dump[3];
$problem3 = $dump[5];
$req1 = $DB->prepare("SELECT * FROM `solutions` WHERE `team` = ? AND `problem` = ? ORDER BY uploaded_at DESC LIMIT 1");
$req1->execute([$team1->getId(), $problem1]);
$data1 = $req1->fetch();
$sol1 = Solution::fromData($data1);
$req2 = $DB->prepare("SELECT * FROM `solutions` WHERE `team` = ? AND `problem` = ? ORDER BY uploaded_at DESC LIMIT 1");
$req2->execute([$team2->getId(), $problem2]);
$data2 = $req2->fetch();
$sol2 = Solution::fromData($data2);
$req3 = $DB->prepare("SELECT * FROM `solutions` WHERE `team` = ? AND `problem` = ? ORDER BY uploaded_at DESC LIMIT 1");
$req3->execute([$team3->getId(), $problem3]);
$data3 = $req3->fetch();
$sol3 = Solution::fromData($data3);
$req1 = $DB->prepare("UPDATE `teams` SET `opposed_problem_2` = ?, `rapported_problem_2` = ? WHERE `id` = ?;");
$req1->execute([$sol2->getFileId(), $sol3->getFileId(), $team1->getId()]);
$req2 = $DB->prepare("UPDATE `teams` SET `opposed_problem_2` = ?, `rapported_problem_2` = ? WHERE `id` = ?;");
$req2->execute([$sol3->getFileId(), $sol1->getFileId(), $team2->getId()]);
$req3 = $DB->prepare("UPDATE `teams` SET `opposed_problem_2` = ?, `rapported_problem_2` = ? WHERE `id` = ?;");
$req3->execute([$sol1->getFileId(), $sol2->getFileId(), $team3->getId()]);
}
$req = $DB->prepare("SELECT opposed_problem, rapported_problem, opposed_problem_2, rapported_problem_2 FROM teams WHERE id = ?;");
$req->execute([$team->getId()]);
$data = $req->fetch();
$opposed_solution = Solution::fromId($data["opposed_problem"]);
$rapported_solution = Solution::fromId($data["rapported_problem"]);
$opposed_solution_2 = Solution::fromId($data["opposed_problem_2"]);
$rapported_solution_2 = Solution::fromId($data["rapported_problem_2"]);
class MyTeam
{
public $name;

View File

@ -29,19 +29,24 @@ if ($team->isSelectedForFinal())
class SaveSynthesis
{
private $dest;
private $round;
private $file;
public function __construct()
{
$this->file = $_FILES["synthese"];
$this->round = htmlspecialchars($_POST["round"]);
$this->dest = DestType::fromName(strtoupper(htmlspecialchars($_POST["dest"])));
}
public function makeVerifications()
{
global $LOCAL_PATH;
global $LOCAL_PATH, $tournament;
ensure($this->dest != DestType::DEFENSEUR, "Le destinataire est invalide.");
ensure($this->dest != DestType::DEFENSEUR, "La source est invalide.");
ensure($this->round == 1 || $this->round == 2, "Le tour est invalide.");
$now = date("Y-m-d H:i");
ensure($this->round == 1 && $now < $tournament->getSynthesesDate() || $this->round == 2 && $now < $tournament->getSynthesesDate2(), "Vous ne pouvez plus rendre de note de synthèse pour le tour $this->round.");
ensure($this->file["size"] <= 2e6, "Le fichier doit peser moins que 2 Mo.");
ensure(!$this->file["error"], "Une erreur est survenue.");
ensure(finfo_file(finfo_open(FILEINFO_MIME_TYPE), $this->file["tmp_name"]) == "application/pdf", "Le fichier doit être au format PDF.");
@ -58,8 +63,8 @@ class SaveSynthesis
if (!rename($this->file["tmp_name"], "$LOCAL_PATH/files/$id"))
throw new AssertionError("Une erreur est survenue lors de l'envoi du fichier.");
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
$req->execute([$id, $team->getId(), $team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId(), $this->dest]);
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `round`, `dest`) VALUES (?, ?, ?, ?, ?);");
$req->execute([$id, $team->getId(), $team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId(), $this->round, $this->dest]);
return false;
}

View File

@ -39,8 +39,12 @@ class UpdateTournament
public $time_inscription;
public $date_solutions;
public $time_solutions;
public $date_syntheses;
public $time_syntheses;
public $date_syntheses;
public $time_syntheses;
public $date_solutions_2;
public $time_solutions_2;
public $date_syntheses_2;
public $time_syntheses_2;
public $description;
public $final;
@ -89,7 +93,9 @@ class UpdateTournament
ensure(dateWellFormed($this->date_end), "La date de fin n'est pas valide.");
ensure(dateWellFormed($this->date_inscription . " " . $this->time_inscription), "La date de clôture des inscriptions n'est pas valide.");
ensure(dateWellFormed($this->date_solutions . " " . $this->time_solutions), "La date limite de remise des solutions n'est pas valide.");
ensure(dateWellFormed($this->date_syntheses . " " . $this->time_syntheses), "La date limite de remise des notes de synthèse n'est pas valide.");
ensure(dateWellFormed($this->date_syntheses . " " . $this->time_syntheses), "La date limite de remise des notes de synthèse pour le tour 1 n'est pas valide.");
ensure(dateWellFormed($this->date_solutions_2 . " " . $this->time_solutions_2), "La date limite de visibilité des solutions du tour 2 n'est pas valide.");
ensure(dateWellFormed($this->date_syntheses_2 . " " . $this->time_syntheses_2), "La date limite de remise des notes de synthèse pour le tour 2 n'est pas valide.");
}
public function updateTournament()
@ -104,7 +110,9 @@ class UpdateTournament
$tournament->setEndDate($this->date_end);
$tournament->setInscriptionDate("$this->date_inscription $this->time_inscription");
$tournament->setSolutionsDate("$this->date_solutions $this->time_solutions");
$tournament->setSynthesesDate("$this->date_syntheses $this->time_syntheses");
$tournament->setSynthesesDate("$this->date_syntheses $this->time_syntheses");
$tournament->setSolutionsDate2("$this->date_solutions_2 $this->time_solutions_2");
$tournament->setSynthesesDate2("$this->date_syntheses_2 $this->time_syntheses_2");
$tournament->setDescription($this->description);
foreach ($this->organizers as $organizer) {

View File

@ -34,12 +34,19 @@ if ($file !== null) {
$problem = $file->getProblem();
$name = "Problème $problem $trigram";
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId()))
require_once "server_files/403.php";
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId())) {
$req = $DB->prepare("SELECT opposed_problem, rapported_problem, opposed_problem_2, rapported_problem_2 FROM teams WHERE id = ?;");
$req->execute([$_SESSION["team"]->getId()]);
$data = $req->fetch();
if ($id != $data["opposed_problem"] && $id != $data["rapported_problem"]) {
if (date("Y-m-d H:i") < $tournament->getSolutionsDate2() || ($id != $data["opposed_problem_2"] && $id != $data["rapported_problem_2"]))
require_once "server_files/403.php";
}
}
}
else if ($type == DocumentType::SYNTHESIS) {
$dest = $file->getDest();
$name = "Note de synthèse $trigram pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur");
$name = "Note de synthèse $trigram " . ($dest == DestType::OPPOSANT ? "de l'opposant" : "du rapporteur");
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId()))
require_once "server_files/403.php";