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

Améliorations du code

This commit is contained in:
Yohann
2019-09-08 01:35:05 +02:00
committed by galaxyoyo
parent 3cc66ef783
commit a25ec69ae9
23 changed files with 558 additions and 457 deletions

View File

@ -8,6 +8,7 @@ class Document
private $tournament_id;
private $type;
private $uploaded_at;
private $version;
private function __construct() {}
@ -21,9 +22,14 @@ class Document
if ($data === false)
return null;
$user = new Document();
$user->fill($data);
return $user;
return self::fromData($data);
}
public static function fromData($data)
{
$doc = new Document();
$doc->fill($data);
return $doc;
}
private function fill($data)
@ -34,6 +40,7 @@ class Document
$this->tournament_id = $data["tournament"];
$this->type = DocumentType::fromName($data["type"]);
$this->uploaded_at = $data["uploaded_at"];
$this->version = isset($data["version"]) ? $data["version"] : 1;
}
public function getFileId()
@ -65,6 +72,11 @@ class Document
{
return $this->uploaded_at;
}
public function getVersion()
{
return $this->version;
}
}
class Solution
@ -74,6 +86,7 @@ class Solution
private $tournament_id;
private $problem;
private $uploaded_at;
private $version;
private function __construct() {}
@ -87,9 +100,14 @@ class Solution
if ($data === false)
return null;
$user = new Solution();
$user->fill($data);
return $user;
return self::fromData($data);
}
public static function fromData($data)
{
$sol = new Solution();
$sol->fill($data);
return $sol;
}
private function fill($data)
@ -99,6 +117,7 @@ class Solution
$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()
@ -125,15 +144,21 @@ class Solution
{
return $this->uploaded_at;
}
public function getVersion()
{
return $this->version;
}
}
class Synthese
class Synthesis
{
private $file_id;
private $team_id;
private $tournament_id;
private $dest;
private $uploaded_at;
private $version;
private function __construct() {}
@ -147,9 +172,14 @@ class Synthese
if ($data === false)
return null;
$user = new Synthese();
$user->fill($data);
return $user;
return self::fromData($data);
}
public static function fromData($data)
{
$synthese = new Synthesis();
$synthese->fill($data);
return $synthese;
}
private function fill($data)
@ -159,6 +189,7 @@ class Synthese
$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()
@ -185,6 +216,11 @@ class Synthese
{
return $this->uploaded_at;
}
public function getVersion()
{
return $this->version;
}
}
class DestType
@ -233,7 +269,7 @@ class DocumentType
const PHOTO_CONSENT = 1;
const SANITARY_PLUG = 2;
const SOLUTION = 3;
const SYNTHESE = 4;
const SYNTHESIS = 4;
public static function getTranslatedName($type) {
switch ($type) {
@ -261,7 +297,7 @@ class DocumentType
case self::SOLUTION:
return "SOLUTION";
default:
return "SYNTHESE";
return "SYNTHESIS";
}
}
@ -276,7 +312,7 @@ class DocumentType
case "SOLUTION":
return self::SOLUTION;
default:
return self::SYNTHESE;
return self::SYNTHESIS;
}
}
}