1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-06-25 05:00:28 +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

@ -16,6 +16,7 @@ class User
private $confirm_email;
private $forgotten_password;
private $inscription_date;
private $receive_animath_mails;
private function __construct() {}
@ -48,6 +49,21 @@ class User
$user->fill($data);
return $user;
}
public static function getAdmins()
{
global $DB, $YEAR;
$admins = [];
$req = $DB->query("SELECT * FROM `users` WHERE `year` = $YEAR;");
while (($data = $req->fetch()) !== false) {
$admin = new User();
$admin->fill($data);
$admins[] = $admin;
}
return $admins;
}
private function fill($data)
{
@ -65,6 +81,7 @@ class User
$this->confirm_email = $data["confirm_email"];
$this->forgotten_password = $data["forgotten_password"];
$this->inscription_date = $data["inscription_date"];
$this->receive_animath_mails = $data["receive_animath_mails"];
}
public function getEmail()
@ -170,7 +187,6 @@ class User
{
global $DB;
$this->role = $role;
/** @noinspection PhpUndefinedMethodInspection */
$DB->prepare("UPDATE `users` SET `role` = ? WHERE `id` = ?;")->execute([Role::getName($role), $this->getId()]);
}
@ -215,6 +231,18 @@ class User
return $this->inscription_date;
}
public function doReceiveAnimathMails()
{
return $this->receive_animath_mails;
}
public function setReceiveAnimathMails($receive_animath_mails)
{
global $DB;
$this->receive_animath_mails = $receive_animath_mails;
$DB->prepare("UPDATE `users` SET `receive_animath_mails` = ? WHERE `id` = ?;")->execute([$receive_animath_mails, $this->getId()]);
}
public function getAllDocuments($problem)
{
global $DB;

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;