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