1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-06-24 17:00:31 +02:00

Suppression de contenu inutile pour les correspondances

This commit is contained in:
galaxyoyo
2019-09-11 18:41:45 +02:00
parent 07e7b94f5c
commit 340be7faf5
34 changed files with 86 additions and 1985 deletions

View File

@ -5,7 +5,7 @@ class Document
private $file_id;
private $user_id;
private $team_id;
private $tournament_id;
private $problem;
private $type;
private $uploaded_at;
private $version;
@ -37,7 +37,7 @@ class Document
$this->file_id = $data["file_id"];
$this->user_id = $data["user"];
$this->team_id = $data["team"];
$this->tournament_id = $data["tournament"];
$this->problem = $data["problem"];
$this->type = DocumentType::fromName($data["type"]);
$this->uploaded_at = $data["uploaded_at"];
$this->version = isset($data["version"]) ? $data["version"] : 1;
@ -58,9 +58,9 @@ class Document
return $this->team_id;
}
public function getTournamentId()
public function getProblem()
{
return $this->tournament_id;
return $this->problem;
}
public function getType()
@ -77,242 +77,48 @@ class Document
{
return $this->version;
}
}
class Solution
{
private $file_id;
private $team_id;
private $tournament_id;
private $problem;
private $uploaded_at;
private $version;
private function __construct() {}
public static function fromId($id)
public function getAllDocuments($problem)
{
global $DB;
$req = $DB->prepare("SELECT * FROM `solutions` WHERE `file_id` = ?;");
$req->execute([htmlspecialchars($id)]);
$data = $req->fetch();
$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 ORDER BY `t1`.`type`;");
if ($data === false)
return null;
$docs = [];
return self::fromData($data);
}
while (($data = $req->fetch()) !== false)
$docs[] = Document::fromData($data);
public static function fromData($data)
{
$sol = new Solution();
$sol->fill($data);
return $sol;
}
private function fill($data)
{
$this->file_id = $data["file_id"];
$this->team_id = $data["team"];
$this->tournament_id = $data["tournament"];
$this->problem = $data["problem"];
$this->uploaded_at = $data["uploaded_at"];
$this->version = isset($data["version"]) ? $data["version"] : 1;
}
public function getFileId()
{
return $this->file_id;
}
public function getTeamId()
{
return $this->team_id;
}
public function getTournamentId()
{
return $this->tournament_id;
}
public function getProblem()
{
return $this->problem;
}
public function getUploadedAt()
{
return $this->uploaded_at;
}
public function getVersion()
{
return $this->version;
}
}
class Synthesis
{
private $file_id;
private $team_id;
private $tournament_id;
private $dest;
private $uploaded_at;
private $version;
private function __construct() {}
public static function fromId($id)
{
global $DB;
$req = $DB->prepare("SELECT * FROM `syntheses` WHERE `file_id` = ?;");
$req->execute([htmlspecialchars($id)]);
$data = $req->fetch();
if ($data === false)
return null;
return self::fromData($data);
}
public static function fromData($data)
{
$synthese = new Synthesis();
$synthese->fill($data);
return $synthese;
}
private function fill($data)
{
$this->file_id = $data["file_id"];
$this->team_id = $data["team"];
$this->tournament_id = $data["tournament"];
$this->dest = DestType::fromName($data["dest"]);
$this->uploaded_at = $data["uploaded_at"];
$this->version = isset($data["version"]) ? $data["version"] : 1;
}
public function getFileId()
{
return $this->file_id;
}
public function getTeamId()
{
return $this->team_id;
}
public function getTournamentId()
{
return $this->tournament_id;
}
public function getDest()
{
return $this->dest;
}
public function getUploadedAt()
{
return $this->uploaded_at;
}
public function getVersion()
{
return $this->version;
}
}
class DestType
{
const DEFENSEUR = 0;
const OPPOSANT = 1;
const RAPPORTEUR = 2;
public static function getTranslatedName($status) {
switch ($status) {
case self::OPPOSANT:
return "Opposant";
case self::RAPPORTEUR:
return "Rapporteur";
default:
return "Défenseur";
}
}
public static function getName($status) {
switch ($status) {
case self::OPPOSANT:
return "OPPOSANT";
case self::RAPPORTEUR:
return "RAPPORTEUR";
default:
return "DEFENSEUR";
}
}
public static function fromName($name) {
switch ($name) {
case "OPPOSANT":
return self::OPPOSANT;
case "RAPPORTEUR":
return self::RAPPORTEUR;
default:
return self::DEFENSEUR;
}
return $docs;
}
}
class DocumentType
{
const PARENTAL_CONSENT = 0;
const PHOTO_CONSENT = 1;
const SANITARY_PLUG = 2;
const SOLUTION = 3;
const SYNTHESIS = 4;
const PHOTO_CONSENT = 0;
public static function getTranslatedName($type) {
switch ($type) {
case self::PARENTAL_CONSENT:
return "Autorisation parentale";
case self::PHOTO_CONSENT:
return "Autorisation de droit à l'image";
case self::SANITARY_PLUG:
return "Fiche sanitaire";
case self::SOLUTION:
return "Solution";
default:
return "Note de synthèse";
return "Autorisation de droit à l'image";
}
}
public static function getName($type) {
switch ($type) {
case self::PARENTAL_CONSENT:
return "PARENTAL_CONSENT";
case self::PHOTO_CONSENT:
return "PHOTO_CONSENT";
case self::SANITARY_PLUG:
return "SANITARY_PLUG";
case self::SOLUTION:
return "SOLUTION";
default:
return "SYNTHESIS";
return "PHOTO_CONSENT";
}
}
public static function fromName($name) {
switch ($name) {
case "PARENTAL_CONSENT":
return self::PARENTAL_CONSENT;
case "PHOTO_CONSENT":
return self::PHOTO_CONSENT;
case "SANITARY_PLUG":
return self::SANITARY_PLUG;
case "SOLUTION":
return self::SOLUTION;
default:
return self::SYNTHESIS;
return self::PHOTO_CONSENT;
}
}
}