mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-06-24 09:08:47 +02:00
Suppression de contenu inutile pour les correspondances
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -4,15 +4,12 @@ class Role
|
||||
{
|
||||
const PARTICIPANT = 0;
|
||||
const ENCADRANT = 1;
|
||||
const ORGANIZER = 2;
|
||||
const ADMIN = 3;
|
||||
const ADMIN = 2;
|
||||
|
||||
public static function getTranslatedName($role) {
|
||||
switch ($role) {
|
||||
case self::ENCADRANT:
|
||||
return "Encadrant";
|
||||
case self::ORGANIZER:
|
||||
return "Organisateur";
|
||||
case self::ADMIN:
|
||||
return "Administrateur";
|
||||
default:
|
||||
@ -24,8 +21,6 @@ class Role
|
||||
switch ($role) {
|
||||
case self::ENCADRANT:
|
||||
return "ENCADRANT";
|
||||
case self::ORGANIZER:
|
||||
return "ORGANIZER";
|
||||
case self::ADMIN:
|
||||
return "ADMIN";
|
||||
default:
|
||||
@ -37,8 +32,6 @@ class Role
|
||||
switch ($name) {
|
||||
case "ENCADRANT":
|
||||
return self::ENCADRANT;
|
||||
case "ORGANIZER":
|
||||
return self::ORGANIZER;
|
||||
case "ADMIN":
|
||||
return self::ADMIN;
|
||||
default:
|
||||
|
@ -1,357 +0,0 @@
|
||||
<?php
|
||||
|
||||
/** @noinspection SqlAggregates */
|
||||
class Tournament
|
||||
{
|
||||
private $id;
|
||||
private $name;
|
||||
private $size;
|
||||
private $place;
|
||||
private $price;
|
||||
private $description;
|
||||
private $date_start, $date_end;
|
||||
private $date_inscription;
|
||||
private $date_solutions;
|
||||
private $date_syntheses;
|
||||
private $final;
|
||||
private $organizers = [];
|
||||
private $year;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function fromId($id)
|
||||
{
|
||||
global $DB;
|
||||
$req = $DB->prepare("SELECT * FROM `tournaments` WHERE `id` = ?;");
|
||||
$req->execute([htmlspecialchars($id)]);
|
||||
$data = $req->fetch();
|
||||
|
||||
if ($data === false)
|
||||
return null;
|
||||
|
||||
$tournament = new Tournament();
|
||||
$tournament->fill($data);
|
||||
return $tournament;
|
||||
}
|
||||
|
||||
public static function fromName($name)
|
||||
{
|
||||
global $DB, $YEAR;
|
||||
$req = $DB->prepare("SELECT * FROM `tournaments` WHERE `name` = ? AND `year` = $YEAR;");
|
||||
$req->execute([htmlspecialchars($name)]);
|
||||
$data = $req->fetch();
|
||||
|
||||
if ($data === false)
|
||||
return null;
|
||||
|
||||
$tournament = new Tournament();
|
||||
$tournament->fill($data);
|
||||
return $tournament;
|
||||
}
|
||||
|
||||
public static function getFinalTournament()
|
||||
{
|
||||
global $DB, $YEAR;
|
||||
$req = $DB->query("SELECT * FROM `tournaments` WHERE `final` AND `year` = $YEAR;");
|
||||
$data = $req->fetch();
|
||||
|
||||
if ($data === false)
|
||||
return null;
|
||||
|
||||
$tournament = new Tournament();
|
||||
$tournament->fill($data);
|
||||
return $tournament;
|
||||
}
|
||||
|
||||
public static function getAllTournaments($include_final = true, $only_future = false)
|
||||
{
|
||||
global $DB, $YEAR;
|
||||
$sql = "SELECT * FROM `tournaments` WHERE ";
|
||||
if (!$include_final)
|
||||
$sql .= "`final` = 0 AND ";
|
||||
if ($only_future)
|
||||
$sql .= "`date_start` > CURRENT_DATE AND ";
|
||||
$sql .= "`year` = $YEAR ORDER BY `date_start`, `name`;";
|
||||
$req = $DB->query($sql);
|
||||
|
||||
$tournaments = [];
|
||||
|
||||
while (($data = $req->fetch()) !== false) {
|
||||
$tournament = new Tournament();
|
||||
$tournament->fill($data);
|
||||
$tournaments[] = $tournament;
|
||||
}
|
||||
|
||||
return $tournaments;
|
||||
}
|
||||
|
||||
private function fill($data)
|
||||
{
|
||||
$this->id = $data["id"];
|
||||
$this->name = $data["name"];
|
||||
$this->size = $data["size"];
|
||||
$this->place = $data["place"];
|
||||
$this->price = $data["price"];
|
||||
$this->description = $data["description"];
|
||||
$this->date_start = $data["date_start"];
|
||||
$this->date_end = $data["date_end"];
|
||||
$this->date_inscription = $data["date_inscription"];
|
||||
$this->date_solutions = $data["date_solutions"];
|
||||
$this->date_syntheses = $data["date_syntheses"];
|
||||
$this->final = $data["final"] == true;
|
||||
$this->year = $data["year"];
|
||||
|
||||
global $DB;
|
||||
$req = $DB->prepare("SELECT `organizer` FROM `organizers` WHERE `tournament` = ?;");
|
||||
$req->execute([$this->id]);
|
||||
|
||||
while (($data = $req->fetch()) !== false)
|
||||
$this->organizers[] = User::fromId($data["organizer"]);
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
global $DB;
|
||||
$this->name = $name;
|
||||
$DB->prepare("UPDATE `tournaments` SET `name` = ? WHERE `id` = ?;")->execute([$name, $this->id]);
|
||||
}
|
||||
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
public function setSize($size)
|
||||
{
|
||||
global $DB;
|
||||
$this->size = $size;
|
||||
$DB->prepare("UPDATE `tournaments` SET `size` = ? WHERE `id` = ?;")->execute([$size, $this->id]);
|
||||
}
|
||||
|
||||
public function getPlace()
|
||||
{
|
||||
return $this->place;
|
||||
}
|
||||
|
||||
public function setPlace($place)
|
||||
{
|
||||
global $DB;
|
||||
$this->place = $place;
|
||||
$DB->prepare("UPDATE `tournaments` SET `place` = ? WHERE `id` = ?;")->execute([$place, $this->id]);
|
||||
}
|
||||
|
||||
public function getPrice()
|
||||
{
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
public function setPrice($price)
|
||||
{
|
||||
global $DB;
|
||||
$this->price = $price;
|
||||
$DB->prepare("UPDATE `tournaments` SET `price` = ? WHERE `id` = ?;")->execute([$price, $this->id]);
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($desc)
|
||||
{
|
||||
global $DB;
|
||||
$this->description = $desc;
|
||||
$DB->prepare("UPDATE `tournaments` SET `description` = ? WHERE `id` = ?;")->execute([$desc, $this->id]);
|
||||
}
|
||||
|
||||
public function getStartDate()
|
||||
{
|
||||
return $this->date_start;
|
||||
}
|
||||
|
||||
public function setStartDate($date)
|
||||
{
|
||||
global $DB;
|
||||
$this->date_start = $date;
|
||||
$DB->prepare("UPDATE `tournaments` SET `date_start` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
|
||||
}
|
||||
|
||||
public function getEndDate()
|
||||
{
|
||||
return $this->date_end;
|
||||
}
|
||||
|
||||
public function setEndDate($date)
|
||||
{
|
||||
global $DB;
|
||||
$this->date_end = $date;
|
||||
$DB->prepare("UPDATE `tournaments` SET `date_end` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
|
||||
}
|
||||
|
||||
public function getInscriptionDate()
|
||||
{
|
||||
return $this->date_inscription;
|
||||
}
|
||||
|
||||
public function setInscriptionDate($date)
|
||||
{
|
||||
global $DB;
|
||||
$this->date_inscription = $date;
|
||||
$DB->prepare("UPDATE `tournaments` SET `date_inscription` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
|
||||
}
|
||||
|
||||
public function getSolutionsDate()
|
||||
{
|
||||
return $this->date_solutions;
|
||||
}
|
||||
|
||||
public function setSolutionsDate($date)
|
||||
{
|
||||
global $DB;
|
||||
$this->date_solutions = $date;
|
||||
$DB->prepare("UPDATE `tournaments` SET `date_solutions` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
|
||||
}
|
||||
|
||||
public function getSynthesesDate()
|
||||
{
|
||||
return $this->date_syntheses;
|
||||
}
|
||||
|
||||
public function setSynthesesDate($date)
|
||||
{
|
||||
global $DB;
|
||||
$this->date_syntheses = $date;
|
||||
$DB->prepare("UPDATE `tournaments` SET `date_syntheses` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
|
||||
}
|
||||
|
||||
public function isFinal()
|
||||
{
|
||||
return $this->final;
|
||||
}
|
||||
|
||||
public function setFinal($final)
|
||||
{
|
||||
global $DB;
|
||||
$this->final = $final;
|
||||
$DB->prepare("UPDATE `tournaments` SET `final` = ? WHERE `id` = ?;")->execute([$final, $this->id]);
|
||||
}
|
||||
|
||||
public function getAllTeams()
|
||||
{
|
||||
global $DB, $YEAR;
|
||||
if ($this->final)
|
||||
$req = $DB->query("SELECT `id` FROM `teams` WHERE `final_selection` AND `year` = $YEAR;");
|
||||
else
|
||||
$req = $DB->query("SELECT `id` FROM `teams` WHERE `tournament` = $this->id AND `year` = $YEAR;");
|
||||
|
||||
$teams = [];
|
||||
|
||||
while (($data = $req->fetch()) !== false)
|
||||
$teams[] = Team::fromId($data["id"]);
|
||||
|
||||
return $teams;
|
||||
}
|
||||
|
||||
public function getOrganizers()
|
||||
{
|
||||
return $this->organizers;
|
||||
}
|
||||
|
||||
public function organize($user_id)
|
||||
{
|
||||
foreach ($this->organizers as $organizer) {
|
||||
if ($organizer->getId() == $user_id)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function addOrganizer(User $user)
|
||||
{
|
||||
global $DB;
|
||||
|
||||
$this->organizers[] = $user;
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `organizers`(`organizer`, `tournament`) VALUES(?, ?);");
|
||||
$req->execute([$user->getId(), $this->id]);
|
||||
}
|
||||
|
||||
public function clearOrganizers()
|
||||
{
|
||||
global $DB;
|
||||
|
||||
$this->organizers = [];
|
||||
|
||||
$req = $DB->prepare("DELETE FROM `organizers` WHERE `tournament` = ?;");
|
||||
$req->execute([$this->id]);
|
||||
}
|
||||
|
||||
public function getYear()
|
||||
{
|
||||
return $this->year;
|
||||
}
|
||||
|
||||
public function getAllDocuments($team_id = -1)
|
||||
{
|
||||
global $DB;
|
||||
|
||||
$req = $DB->query("SELECT * FROM `documents` AS `t1` "
|
||||
. "INNER JOIN (SELECT `user`, `type`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `tournament`, `team`, `type`, `user`) `t2` "
|
||||
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`type` = `t2`.`type` AND `t1`.`tournament` = `t2`.`tournament` "
|
||||
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $this->id " . ($team_id == -1 ? "" : "AND `t1`.`team` = $team_id") . " ORDER BY `t1`.`team`, `t1`.`type`;");
|
||||
|
||||
$docs = [];
|
||||
|
||||
while (($data = $req->fetch()) !== false)
|
||||
$docs[] = Document::fromData($data);
|
||||
|
||||
return $docs;
|
||||
}
|
||||
|
||||
public function getAllSolutions($team_id = -1)
|
||||
{
|
||||
global $DB;
|
||||
|
||||
$req = $DB->query("SELECT * FROM `solutions` AS `t1` "
|
||||
. "INNER JOIN (SELECT `team`, `problem`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `solutions` GROUP BY `tournament`, `team`, `problem`) `t2` "
|
||||
. "ON `t1`.`team` = `t2`.`team` AND `t1`.`problem` = `t2`.`problem` AND `t1`.`tournament` = `t2`.`tournament` "
|
||||
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $this->id " . ($team_id == -1 ? "" : "AND `t1`.`team` = $team_id") . " ORDER BY `t1`.`team`, `t1`.`problem`;");
|
||||
|
||||
$sols = [];
|
||||
|
||||
while (($data = $req->fetch()) !== false)
|
||||
$sols[] = Solution::fromData($data);
|
||||
|
||||
return $sols;
|
||||
}
|
||||
|
||||
public function getAllSyntheses($team_id = -1)
|
||||
{
|
||||
global $DB;
|
||||
|
||||
$req = $DB->query("SELECT * FROM `syntheses` AS `t1` "
|
||||
. "INNER JOIN (SELECT `team`, `dest`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `syntheses` GROUP BY `tournament`, `team`, `dest`) `t2` "
|
||||
. "ON `t1`.`team` = `t2`.`team` AND `t1`.`dest` = `t2`.`dest` AND `t1`.`tournament` = `t2`.`tournament` "
|
||||
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $this->id " . ($team_id == -1 ? "" : "AND `t1`.`team` = $team_id") . " ORDER BY `t1`.`team`, `t1`.`dest`;");
|
||||
|
||||
$syntheses = [];
|
||||
|
||||
while (($data = $req->fetch()) !== false)
|
||||
$syntheses[] = Synthesis::fromData($data);
|
||||
|
||||
return $syntheses;
|
||||
}
|
||||
}
|
@ -220,13 +220,13 @@ class User
|
||||
return $this->inscription_date;
|
||||
}
|
||||
|
||||
public function getAllDocuments($tournament_id)
|
||||
public function getAllDocuments($problem)
|
||||
{
|
||||
global $DB;
|
||||
$req = $DB->query("SELECT * FROM `documents` AS `t1` "
|
||||
. "INNER JOIN (SELECT `user`, `type`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `tournament`, `type`, `user`) `t2` "
|
||||
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`type` = `t2`.`type` AND `t1`.`tournament` = `t2`.`tournament` "
|
||||
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $tournament_id AND `t1`.`user` = $this->id ORDER BY `t1`.`type`;");
|
||||
. "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`;");
|
||||
|
||||
$docs = [];
|
||||
|
||||
@ -235,17 +235,4 @@ class User
|
||||
|
||||
return $docs;
|
||||
}
|
||||
|
||||
public function getOrganizedTournaments()
|
||||
{
|
||||
global $DB;
|
||||
$req = $DB->query("SELECT `tournament` FROM `organizers` JOIN `tournaments` ON `tournaments`.`id` = `tournament` WHERE `organizer` = $this->id ORDER BY `date_start`, `name`;");
|
||||
|
||||
$tournaments = [];
|
||||
|
||||
while (($data = $req->fetch()) !== false)
|
||||
$tournaments[] = Tournament::fromId($data["tournament"]);
|
||||
|
||||
return $tournaments;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user