mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-06-24 04:28:46 +02:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@ -32,7 +32,7 @@ class NewTeam {
|
||||
|
||||
$this->trigram = strtoupper($this->trigram);
|
||||
|
||||
$this->allow_publish = $this->allow_publish == "on";
|
||||
$this->allow_publish = $this->allow_publish == "on" ? 1 : 0;
|
||||
}
|
||||
|
||||
public function makeVerifications() {
|
||||
|
@ -7,10 +7,10 @@ if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::PARTICIPANT && $_
|
||||
require_once "server_files/403.php";
|
||||
|
||||
if (isset($_POST["upload_answer"])) {
|
||||
$new_video = new NewAnswer($_POST);
|
||||
$new_answer = new NewAnswer($_POST);
|
||||
try {
|
||||
$new_video->makeVerifications();
|
||||
$new_video->uploadVideo();
|
||||
$new_answer->makeVerifications();
|
||||
$new_answer->uploadVideo();
|
||||
} catch (AssertionError $e) {
|
||||
$has_error = true;
|
||||
$error_message = $e->getMessage();
|
||||
|
@ -54,6 +54,7 @@ class UpdateVideoTeams
|
||||
|
||||
public function makeVerifications()
|
||||
{
|
||||
ensure(Phase::getCurrentPhase() < Phase::PHASE2, "Il est trop tard pour réaffecter les vidéos aux équipes.");
|
||||
ensure(sizeof($this->other_teams) == 2, "L'équipe doit recevoir exactement deux vidéos.");
|
||||
ensure(Team::fromId($this->other_teams[0]) != null, "La première équipe n'existe pas.");
|
||||
ensure(Team::fromId($this->other_teams[1]) != null, "La seconde équipe n'existe pas.");
|
||||
|
@ -16,6 +16,77 @@ if ($user === null)
|
||||
|
||||
$team = Team::fromId($user->getTeamId());
|
||||
|
||||
$has_error = false;
|
||||
$error_message = null;
|
||||
|
||||
if (isset($_POST["kick"])) {
|
||||
if ($team == null) {
|
||||
$has_error = true;
|
||||
$error_message = "La personne à expulser n'est dans aucune équipe.";
|
||||
}
|
||||
else {
|
||||
quitTeam($id);
|
||||
$team = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST["attribute_team"])) {
|
||||
$attribute_team = new AttributeTeam($_POST);
|
||||
try {
|
||||
$attribute_team->makeVerifications();
|
||||
$attribute_team->attribute();
|
||||
} catch (AssertionError $e) {
|
||||
$has_error = true;
|
||||
$error_message = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
class AttributeTeam
|
||||
{
|
||||
private $team;
|
||||
private $min_null_index;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->team = Team::fromId($data["team"]);
|
||||
}
|
||||
|
||||
public function makeVerifications()
|
||||
{
|
||||
global $user;
|
||||
|
||||
ensure($this->team != null, "Cette équipe n'existe pas.");
|
||||
ensure($this->team->getValidationStatus() == ValidationStatus::NOT_READY, "Cette équipe est déjà validée ou en cours de validation.");
|
||||
|
||||
$role = $user->getRole();
|
||||
for ($i = 1; $i <= $role == Role::ENCADRANT ? 1 : 5; ++$i) {
|
||||
if (($role == Role::PARTICIPANT ? $this->team->getParticipants()[$i - 1] : $this->team->getEncadrantId()) == NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
$this->min_null_index = $i;
|
||||
|
||||
ensure($role == Role::PARTICIPANT && $this->min_null_index <= 5 || $role == Role::ENCADRANT && $this->min_null_index <= 2,
|
||||
"Il n'y a plus de place pour vous dans l'équipe.");
|
||||
}
|
||||
|
||||
public function attribute()
|
||||
{
|
||||
global $user, $team;
|
||||
|
||||
$user->setTeamId($this->team->getId());
|
||||
|
||||
if ($user->getRole() == Role::ENCADRANT)
|
||||
$this->team->setEncadrant($user->getId());
|
||||
else
|
||||
$this->team->setParticipant($this->min_null_index, $user->getId());
|
||||
|
||||
Mailer::sendJoinTeamMail($user, $this->team);
|
||||
|
||||
$team = $this->team;
|
||||
}
|
||||
}
|
||||
|
||||
if ($team != null)
|
||||
$documents = $user->getAllDocuments($team->getProblem());
|
||||
|
||||
|
@ -58,8 +58,6 @@ if (isset($_SESSION["user_id"]) && isset($_SESSION["team"]) && $_SESSION["team"]
|
||||
$team = $_SESSION["team"];
|
||||
|
||||
$documents = $user->getAllDocuments($team->getProblem());
|
||||
$video = Video::getVideo(Reason::SOLUTION, $team);
|
||||
$questions_received = Question::getQuestionsTo($team);
|
||||
}
|
||||
else
|
||||
require_once "server_files/403.php";
|
||||
|
17
server_files/controllers/mon_tournoi.php
Normal file
17
server_files/controllers/mon_tournoi.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
if (isset($_SESSION["user_id"]) && isset($_SESSION["team"]) && $_SESSION["team"] !== null) {
|
||||
/**
|
||||
* @var User $user
|
||||
* @var Team $team
|
||||
*/
|
||||
$user = $_SESSION["user"];
|
||||
$team = $_SESSION["team"];
|
||||
|
||||
$video = Video::getVideo(Reason::SOLUTION, $team);
|
||||
$questions_received = Question::getQuestionsTo($team);
|
||||
}
|
||||
else
|
||||
require_once "server_files/403.php";
|
||||
|
||||
require_once "server_files/views/mon_tournoi.php";
|
8
server_files/controllers/profils_orphelins.php
Normal file
8
server_files/controllers/profils_orphelins.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ADMIN)
|
||||
require_once "server_files/403.php";
|
||||
|
||||
$orphan_users = User::getOrphanUsers();
|
||||
|
||||
require_once "server_files/views/profils_orphelins.php";
|
Reference in New Issue
Block a user