1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-06-25 06:20:29 +02:00

Flexibilité sur la validation des vidéos accrue

This commit is contained in:
galaxyoyo
2019-09-19 00:31:53 +02:00
parent 1e67b8569d
commit 5372350f46
13 changed files with 289 additions and 17 deletions

View File

@ -3,11 +3,16 @@
class Video
{
const NOT_CONTROLLED = 0;
const REJECTED = -1;
const ACCEPTED = 1;
private $id;
private $team;
private $problem;
private $link;
private $reason;
private $validation;
private $uploaded_at;
private $year;
private $version;
@ -29,14 +34,16 @@ class Video
return $video;
}
public static function getVideos($reason, $problem, $team_id = -1)
public static function getVideos($reason, $problem, $validation_min = -1, $team_id = -1)
{
global $DB;
global $DB, $YEAR;
$req = $DB->query("SELECT * FROM `videos` AS `t1` "
. "INNER JOIN (SELECT `team`, `problem`, `reason`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `videos` GROUP BY `problem`, `reason`, `team`) `t2` "
. "INNER JOIN (SELECT `team`, `problem`, `reason`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `videos` "
. "WHERE `validation` >= $validation_min AND `year` = $YEAR GROUP BY `problem`, `reason`, `team`) `t2` "
. "ON `t1`.`team` = `t2`.`team` AND `t1`.`reason` = `t2`.`reason` AND `t1`.`problem` = `t2`.`problem` "
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`problem` = $problem AND `t1`.`reason` = '" . Reason::getName($reason) . "'"
. ($team_id >= 0 ? " AND `t1`.`team` = $team_id" : "") . " ORDER BY `t1`.`problem`, `t1`.`reason`;");
. ($team_id >= 0 ? " AND `t1`.`team` = $team_id" : "")
. " AND `validation` >= $validation_min AND `year` = $YEAR ORDER BY `t1`.`problem`, `t1`.`reason`;");
$videos = [];
@ -52,10 +59,11 @@ class Video
/**
* @param int $reason
* @param Team $team
* @param int $validation_min
* @return Video|null
*/
public static function getVideo($reason, Team $team) {
$videos = self::getVideos($reason, $team->getProblem(), $team->getId());
public static function getVideo($reason, Team $team, $validation_min = -1) {
$videos = self::getVideos($reason, $team->getProblem(), $validation_min, $team->getId());
if (sizeof($videos) == 0)
return null;
else
@ -95,6 +103,18 @@ class Video
return $this->reason;
}
public function getValidation()
{
return $this->validation;
}
public function setValidation($validation)
{
global $DB;
$this->validation = $validation;
$DB->exec("UPDATE `videos` SET `validation` = $validation WHERE `id` = $this->id;");
}
public function getUploadedAt()
{
return $this->uploaded_at;