mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2024-12-05 02:06:52 +00:00
Attribution des vidéos aux équipes (manuelle)
This commit is contained in:
parent
3b54b75395
commit
80eeb71262
@ -16,6 +16,10 @@ class Team
|
||||
|
||||
private function __construct() {}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return Team|null
|
||||
*/
|
||||
public static function fromId($id)
|
||||
{
|
||||
global $DB;
|
||||
@ -31,6 +35,10 @@ class Team
|
||||
return $team;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $trigram
|
||||
* @return Team|null
|
||||
*/
|
||||
public static function fromTrigram($trigram)
|
||||
{
|
||||
global $DB, $YEAR;
|
||||
|
@ -26,13 +26,16 @@ if (isset($_POST["give_questions"])) {
|
||||
class GiveQuestions
|
||||
{
|
||||
private $to;
|
||||
/**
|
||||
* @var Team $to_team
|
||||
*/
|
||||
private $to_team;
|
||||
private $question_0;
|
||||
private $question_1;
|
||||
private $question_2;
|
||||
private $question_3;
|
||||
private $question_4;
|
||||
private $question_5;
|
||||
private $question_6;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
@ -43,15 +46,28 @@ class GiveQuestions
|
||||
|
||||
public function makeVerifications()
|
||||
{
|
||||
$this->to_team = Team::fromId($this->to);
|
||||
global $team;
|
||||
|
||||
$this->to_team = Team::fromTrigram($this->to);
|
||||
ensure($this->to_team, "L'équipe indiquée n'existe pas.");
|
||||
ensure($team->getProblem() == $this->to_team->getProblem(), "Les équipes ne travaillent pas sur le même problème.");
|
||||
ensure($this->question_1 == null || $this->question_1 == "" || $this->question_2 == null || $this->question_2 == "" || $this->question_3 == null || $this->question_3 == "",
|
||||
"Vous devez poser au moins 3 questions.");
|
||||
}
|
||||
|
||||
public function giveQuestions()
|
||||
{
|
||||
global $DB, $team;
|
||||
|
||||
$DB->exec("DELETE FROM `questions` WHERE `from` = " . $team->getId() . " AND `to` = $this->to;");
|
||||
$DB->exec("DELETE FROM `questions` WHERE `from` = " . $team->getId() . " AND `to` = " . $this->to_team->getId() . ";");
|
||||
$req = $DB->prepare("INSERT INTO `questions`(`from`, `to`, `problem`, `question`) VALUES "
|
||||
. "(?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?), (?, ?, ?, ?);");
|
||||
$req->execute([$team->getId(), $this->to_team->getId(), $team->getProblem(), $this->question_1,
|
||||
$team->getId(), $this->to_team->getId(), $team->getProblem(), $this->question_2,
|
||||
$team->getId(), $this->to_team->getId(), $team->getProblem(), $this->question_3,
|
||||
$team->getId(), $this->to_team->getId(), $team->getProblem(), $this->question_4,
|
||||
$team->getId(), $this->to_team->getId(), $team->getProblem(), $this->question_5,
|
||||
$team->getId(), $this->to_team->getId(), $team->getProblem(), $this->question_6]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user