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

3 encadrants max par équipe

This commit is contained in:
Yohann D'ANELLO
2020-02-18 15:33:55 +01:00
parent 2c3e3ffcba
commit 0dab65d82b
6 changed files with 227 additions and 135 deletions

View File

@ -67,7 +67,7 @@ class Team
$this->name = $data["name"];
$this->trigram = $data["trigram"];
$this->tournament = $data["tournament"];
$this->encadrants = [$data["encadrant_1"], $data["encadrant_2"]];
$this->encadrants = [$data["encadrant_1"], $data["encadrant_2"], $data["encadrant_3"]];
$this->participants = [$data["participant_1"], $data["participant_2"], $data["participant_3"], $data["participant_4"], $data["participant_5"], $data["participant_6"]];
$this->inscription_date = $data["inscription_date"];
$this->validation_status = ValidationStatus::fromName($data["validation_status"]);

View File

@ -103,7 +103,7 @@ class AttributeTeam
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 ? 2 : 6; ++$i) {
for ($i = 1; $i <= $role == Role::ENCADRANT ? 3 : 6; ++$i) {
if (($role == Role::PARTICIPANT ? $this->team->getParticipants()[$i - 1] : $this->team->getEncadrants()[$i]) == NULL)
break;
}

View File

@ -35,14 +35,14 @@ class JoinTeam
ensure($this->team != null, "Ce code d'accès est invalide.");
ensure($this->team->getValidationStatus() == ValidationStatus::NOT_READY, "Cette équipe est déjà validée ou en cours de validation, vous ne pouvez pas la rejoindre.");
for ($i = 1; $i <= $_SESSION["role"] == Role::PARTICIPANT ? 6 : 2; ++$i) {
for ($i = 1; $i <= $_SESSION["role"] == Role::PARTICIPANT ? 6 : 3; ++$i) {
if (($_SESSION["role"] == Role::PARTICIPANT ? $this->team->getParticipants()[$i - 1] : $this->team->getEncadrants()[$i - 1]) == NULL)
break;
}
$this->min_null_index = $i;
ensure($_SESSION["role"] == Role::PARTICIPANT && $this->min_null_index <= 6 || $_SESSION["role"] == Role::ENCADRANT && $this->min_null_index <= 2, "Il n'y a plus de place pour vous dans l'équipe.");
ensure($_SESSION["role"] == Role::PARTICIPANT && $this->min_null_index <= 6 || $_SESSION["role"] == Role::ENCADRANT && $this->min_null_index <= 3, "Il n'y a plus de place pour vous dans l'équipe.");
}
public function joinTeam()

View File

@ -47,11 +47,12 @@ function quitTeam($user_id = -1)
if ($role == Role::ADMIN || $role == Role::ORGANIZER)
return;
for ($i = 1; $i <= ($role == Role::ENCADRANT ? 2 : 6); ++$i)
for ($i = 1; $i <= ($role == Role::ENCADRANT ? 3 : 6); ++$i)
/** @noinspection SqlResolve */
$DB->exec("UPDATE `teams` SET `" . strtolower(Role::getName($role)) . "_$i` = NULL WHERE `" . strtolower(Role::getName($role)) . "_$i` = $user_id;");
$user->setTeamId(null);
$DB->exec("UPDATE `teams` SET `encadrant_1` = `encadrant_2`, `encadrant_2` = NULL WHERE `encadrant_1` IS NULL;");
$DB->exec("UPDATE `teams` SET `encadrant_2` = `encadrant_3`, `encadrant_3` = NULL WHERE `encadrant_2` IS NULL;");
for ($i = 1; $i <= 5; ++$i) {
/** @noinspection SqlResolve */
$DB->exec("UPDATE `teams` SET `participant_$i` = `participant_" . strval($i + 1) . "`, `participant_" . strval($i + 1) . "` = NULL WHERE `participant_$i` IS NULL;");

View File

@ -38,7 +38,7 @@
</div>
<div class="alert alert-info">
<?php
for ($i = 1; $i <= 2; ++$i) {
for ($i = 1; $i <= 3; ++$i) {
if ($team->getEncadrants()[$i - 1] == NULL)
continue;
$encadrant = User::fromId($team->getEncadrants()[$i - 1]);