mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-01-05 23:02:26 +00:00
Corrections mineurs
This commit is contained in:
parent
371605d265
commit
2b1bb79efb
@ -84,8 +84,8 @@ class Document
|
||||
{
|
||||
global $DB;
|
||||
$req = $DB->query("SELECT * FROM `documents` AS `t1` "
|
||||
. "INNER JOIN (SELECT `user`, `type`, `problem`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `problem`, `type`, `user`) `t2` "
|
||||
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`type` = `t2`.`type` AND `t1`.`problem` = `t2`.`problem` "
|
||||
. "INNER JOIN (SELECT `user`, `problem`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `problem`, `user`) `t2` "
|
||||
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`problem` = `t2`.`problem` "
|
||||
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`problem` = $problem " . ($team_id >= 0 ? "AND `team` = $team_id" : "") . " ORDER BY `t1`.`type`;");
|
||||
|
||||
$docs = [];
|
||||
|
@ -247,9 +247,9 @@ class User
|
||||
{
|
||||
global $DB;
|
||||
$req = $DB->query("SELECT * FROM `documents` AS `t1` "
|
||||
. "INNER JOIN (SELECT `user`, `type`, `problem`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `problem`, `type`, `user`) `t2` "
|
||||
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`type` = `t2`.`type` AND `t1`.`problem` = `t2`.`problem` "
|
||||
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`problem` = $problem AND `t1`.`user` = $this->id ORDER BY `t1`.`type`;");
|
||||
. "INNER JOIN (SELECT `user`, `problem`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `problem`, `user`) `t2` "
|
||||
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`problem` = `t2`.`problem` "
|
||||
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`problem` = $problem AND `t1`.`user` = $this->id;");
|
||||
|
||||
$docs = [];
|
||||
|
||||
|
@ -33,7 +33,7 @@ if (isset($_POST["team_edit"])) {
|
||||
}
|
||||
|
||||
if (isset($_POST["request_validation"])) {
|
||||
if (!canValidate($team)) {
|
||||
if (!canValidate($_SESSION["team"])) {
|
||||
$has_error = true;
|
||||
$error_message = "Votre équipe ne peut pas demander la validation : il manque soit des participants, soit des documents.";
|
||||
}
|
||||
@ -73,12 +73,10 @@ if (isset($_GET["publish_videos"])) {
|
||||
class SendDocument
|
||||
{
|
||||
private $file;
|
||||
private $type;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->file = $_FILES["document"];
|
||||
$this->type = strtoupper(htmlspecialchars($_POST["type"]));
|
||||
}
|
||||
|
||||
public function makeVerifications()
|
||||
@ -102,9 +100,9 @@ class SendDocument
|
||||
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 `documents`(`file_id`, `user`, `team`, `problem`, `type`)
|
||||
VALUES (?, ?, ?, ?, ?);");
|
||||
$req->execute([$id, $_SESSION["user_id"], $_SESSION["team"]->getId(), $_SESSION["team"]->getProblem(), $this->type]);
|
||||
$req = $DB->prepare("INSERT INTO `documents`(`file_id`, `user`, `team`, `problem`)
|
||||
VALUES (?, ?, ?, ?);");
|
||||
$req->execute([$id, $_SESSION["user_id"], $_SESSION["team"]->getId(), $_SESSION["team"]->getProblem()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,8 +94,8 @@ function canValidate(Team $team)
|
||||
$can_validate &= $team->getParticipants()[2] != null;
|
||||
|
||||
if ($team->getEncadrantId() != null) {
|
||||
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `problem` = ? AND `type` = ?;");
|
||||
$req->execute([$team->getEncadrantId(), $team->getProblem(), "PHOTO_CONSENT"]);
|
||||
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `problem` = ?;");
|
||||
$req->execute([$team->getEncadrantId(), $team->getProblem()]);
|
||||
$d = $req->fetch();
|
||||
$can_validate &= $d["version"] > 0;
|
||||
}
|
||||
@ -104,8 +104,8 @@ function canValidate(Team $team)
|
||||
if ($team->getParticipants()[$i] === NULL)
|
||||
continue;
|
||||
|
||||
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `problem` = ? AND `type` = ?;");
|
||||
$req->execute([$team->getParticipants()[$i], $team->getProblem(), "PHOTO_CONSENT"]);
|
||||
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `problem` = ?;");
|
||||
$req->execute([$team->getParticipants()[$i], $team->getProblem()]);
|
||||
$d = $req->fetch();
|
||||
$can_validate &= $d["version"] > 0;
|
||||
}
|
||||
|
@ -133,14 +133,20 @@ require_once "header.php";
|
||||
<?php
|
||||
$can_validate = canValidate($team);
|
||||
if ($can_validate) { ?>
|
||||
<hr />
|
||||
<form method="post">
|
||||
<input class="form-control" type="checkbox" name="engage" id="engage"/> <label for="engage">Je m'engage à
|
||||
participer à l'intégralité des Correspondances</label><br/>
|
||||
<label for="engage">Je m'engage à participer à l'intégralité des Correspondances</label>
|
||||
<input class="form-control" type="checkbox" name="engage" id="engage"/>
|
||||
<input class="btn btn-primary btn-lg btn-block" type="submit" name="request_validation"
|
||||
value="Demander la validation"/>
|
||||
</form>
|
||||
<?php } ?>
|
||||
<?php } else if (Phase::getCurrentPhase() >= Phase::PHASE1) { ?>
|
||||
<?php }
|
||||
elseif ($team->getValidationStatus() == ValidationStatus::WAITING) { ?>
|
||||
<div class="alert alert-warning">
|
||||
Votre équipe est en attente de validation.
|
||||
</div>
|
||||
<?php } elseif (Phase::getCurrentPhase() >= Phase::PHASE1) { ?>
|
||||
<hr/>
|
||||
<h2>Déroulement du tournoi</h2>
|
||||
<?php if ($video != null) { ?>
|
||||
|
@ -47,7 +47,6 @@ CREATE TABLE IF NOT EXISTS `documents` (
|
||||
`user` int(11) NOT NULL,
|
||||
`team` int(11) NOT NULL,
|
||||
`problem` int(11) NOT NULL,
|
||||
`type` varchar(64) NOT NULL,
|
||||
`uploaded_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`file_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
Loading…
Reference in New Issue
Block a user