1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-25 17:42:24 +00: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->name = $data["name"];
$this->trigram = $data["trigram"]; $this->trigram = $data["trigram"];
$this->tournament = $data["tournament"]; $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->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->inscription_date = $data["inscription_date"];
$this->validation_status = ValidationStatus::fromName($data["validation_status"]); $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."); ensure($this->team->getValidationStatus() == ValidationStatus::NOT_READY, "Cette équipe est déjà validée ou en cours de validation.");
$role = $user->getRole(); $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) if (($role == Role::PARTICIPANT ? $this->team->getParticipants()[$i - 1] : $this->team->getEncadrants()[$i]) == NULL)
break; break;
} }

View File

@ -35,14 +35,14 @@ class JoinTeam
ensure($this->team != null, "Ce code d'accès est invalide."); 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."); 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) if (($_SESSION["role"] == Role::PARTICIPANT ? $this->team->getParticipants()[$i - 1] : $this->team->getEncadrants()[$i - 1]) == NULL)
break; break;
} }
$this->min_null_index = $i; $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() public function joinTeam()

View File

@ -47,11 +47,12 @@ function quitTeam($user_id = -1)
if ($role == Role::ADMIN || $role == Role::ORGANIZER) if ($role == Role::ADMIN || $role == Role::ORGANIZER)
return; return;
for ($i = 1; $i <= ($role == Role::ENCADRANT ? 2 : 6); ++$i) for ($i = 1; $i <= ($role == Role::ENCADRANT ? 3 : 6); ++$i)
/** @noinspection SqlResolve */ /** @noinspection SqlResolve */
$DB->exec("UPDATE `teams` SET `" . strtolower(Role::getName($role)) . "_$i` = NULL WHERE `" . strtolower(Role::getName($role)) . "_$i` = $user_id;"); $DB->exec("UPDATE `teams` SET `" . strtolower(Role::getName($role)) . "_$i` = NULL WHERE `" . strtolower(Role::getName($role)) . "_$i` = $user_id;");
$user->setTeamId(null); $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_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) { for ($i = 1; $i <= 5; ++$i) {
/** @noinspection SqlResolve */ /** @noinspection SqlResolve */
$DB->exec("UPDATE `teams` SET `participant_$i` = `participant_" . strval($i + 1) . "`, `participant_" . strval($i + 1) . "` = NULL WHERE `participant_$i` IS NULL;"); $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>
<div class="alert alert-info"> <div class="alert alert-info">
<?php <?php
for ($i = 1; $i <= 2; ++$i) { for ($i = 1; $i <= 3; ++$i) {
if ($team->getEncadrants()[$i - 1] == NULL) if ($team->getEncadrants()[$i - 1] == NULL)
continue; continue;
$encadrant = User::fromId($team->getEncadrants()[$i - 1]); $encadrant = User::fromId($team->getEncadrants()[$i - 1]);

View File

@ -1,13 +1,15 @@
-- phpMyAdmin SQL Dump -- phpMyAdmin SQL Dump
-- version 4.6.6deb4 -- version 4.7.5
-- https://www.phpmyadmin.net/ -- https://www.phpmyadmin.net/
-- --
-- Client : localhost:3306 -- Host: db
-- Généré le : Dim 08 Septembre 2019 à 19:00 -- Erstellungszeit: 18. Feb 2020 um 14:32
-- Version du serveur : 10.3.15-MariaDB-1 -- Server-Version: 5.7.20
-- Version de PHP : 7.3.4-2 -- PHP-Version: 7.1.9
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+02:00"; SET time_zone = "+02:00";
@ -17,116 +19,117 @@ SET time_zone = "+02:00";
/*!40101 SET NAMES utf8mb4 */; /*!40101 SET NAMES utf8mb4 */;
-- --
-- Base de données : `tfjm` -- Datenbank: `inscription_tfjm`
-- --
CREATE DATABASE IF NOT EXISTS `inscription-tfjm` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE IF NOT EXISTS `inscription_tfjm` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `inscription-tfjm`; USE `inscription_tfjm`;
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
-- Structure de la table `documents` -- Tabellenstruktur für Tabelle `documents`
-- --
CREATE TABLE IF NOT EXISTS `documents` CREATE TABLE `documents` (
(
`file_id` varchar(64) NOT NULL, `file_id` varchar(64) NOT NULL,
`user` int(11) NOT NULL, `user` int(11) NOT NULL,
`team` int(11) NOT NULL, `team` int(11) NOT NULL,
`tournament` int(11) NOT NULL, `tournament` int(11) NOT NULL,
`type` varchar(64) NOT NULL, `type` varchar(64) NOT NULL,
`uploaded_at` datetime NOT NULL DEFAULT current_timestamp(), `uploaded_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
PRIMARY KEY (`file_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
-- Structure de la table `organizers` -- Tabellenstruktur für Tabelle `organizers`
-- --
CREATE TABLE IF NOT EXISTS `organizers` CREATE TABLE `organizers` (
( `id` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
`organizer` int(11) NOT NULL, `organizer` int(11) NOT NULL,
`tournament` int(11) NOT NULL, `tournament` int(11) NOT NULL
PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
-- Structure de la table `solutions` -- Tabellenstruktur für Tabelle `payments`
-- --
CREATE TABLE IF NOT EXISTS `solutions` CREATE TABLE `payments` (
( `id` int(11) NOT NULL,
`user` int(11) NOT NULL,
`tournament` int(11) NOT NULL,
`amount` tinyint(4) NOT NULL,
`method` enum('CREDIT_CARD','BANK_CHECK','BANK_TRANSFER','CASH','SCHOLARSHIP','NOT_PAID') COLLATE utf8_unicode_ci NOT NULL,
`transaction_infos` text COLLATE utf8_unicode_ci NOT NULL,
`validation_status` enum('NOT_READY','WAITING','VALIDATED','') COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `solutions`
--
CREATE TABLE `solutions` (
`file_id` varchar(64) NOT NULL, `file_id` varchar(64) NOT NULL,
`team` int(11) NOT NULL, `team` int(11) NOT NULL,
`tournament` int(11) NOT NULL, `tournament` int(11) NOT NULL,
`problem` int(11) NOT NULL, `problem` int(11) NOT NULL,
`uploaded_at` datetime NOT NULL DEFAULT current_timestamp(), `uploaded_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
PRIMARY KEY (`file_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
-- Structure de la table `syntheses` -- Tabellenstruktur für Tabelle `syntheses`
-- --
CREATE TABLE IF NOT EXISTS `syntheses` CREATE TABLE `syntheses` (
(
`file_id` varchar(64) NOT NULL, `file_id` varchar(64) NOT NULL,
`team` int(11) NOT NULL, `team` int(11) NOT NULL,
`tournament` int(11) NOT NULL, `tournament` int(11) NOT NULL,
`dest` varchar(64) NOT NULL, `dest` varchar(64) NOT NULL,
`uploaded_at` datetime NOT NULL DEFAULT current_timestamp(), `uploaded_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
PRIMARY KEY (`file_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
-- Structure de la table `teams` -- Tabellenstruktur für Tabelle `teams`
-- --
CREATE TABLE IF NOT EXISTS `teams` CREATE TABLE `teams` (
( `id` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(64) NOT NULL, `name` varchar(64) NOT NULL,
`trigram` varchar(3) NOT NULL, `trigram` varchar(3) NOT NULL,
`tournament` int(8) NOT NULL, `tournament` int(8) NOT NULL,
`encadrant_1` int(8) DEFAULT NULL, `encadrant_1` int(8) DEFAULT NULL,
`encadrant_2` int(8) DEFAULT NULL, `encadrant_2` int(8) DEFAULT NULL,
`encadrant_3` int(11) DEFAULT NULL,
`participant_1` int(8) DEFAULT NULL, `participant_1` int(8) DEFAULT NULL,
`participant_2` int(8) DEFAULT NULL, `participant_2` int(8) DEFAULT NULL,
`participant_3` int(8) DEFAULT NULL, `participant_3` int(8) DEFAULT NULL,
`participant_4` int(8) DEFAULT NULL, `participant_4` int(8) DEFAULT NULL,
`participant_5` int(8) DEFAULT NULL, `participant_5` int(8) DEFAULT NULL,
`participant_6` int(8) DEFAULT NULL, `participant_6` int(8) DEFAULT NULL,
`inscription_date` timestamp NOT NULL DEFAULT current_timestamp(), `inscription_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`validation_status` varchar(64) NOT NULL, `validation_status` enum('NOT_READY','WAITING','VALIDATED','') NOT NULL,
`final_selection` tinyint(1) NOT NULL DEFAULT 0, `final_selection` tinyint(1) NOT NULL DEFAULT '0',
`access_code` varchar(6) NOT NULL, `access_code` varchar(6) NOT NULL,
`year` int(4) NOT NULL, `year` int(4) NOT NULL
PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
-- Structure de la table `tournaments` -- Tabellenstruktur für Tabelle `tournaments`
-- --
CREATE TABLE IF NOT EXISTS `tournaments` CREATE TABLE `tournaments` (
( `id` int(8) NOT NULL,
`id` int(8) NOT NULL AUTO_INCREMENT,
`name` varchar(64) NOT NULL, `name` varchar(64) NOT NULL,
`size` int(1) NOT NULL, `size` int(1) NOT NULL,
`place` varchar(255) NOT NULL, `place` varchar(255) NOT NULL,
@ -137,21 +140,18 @@ CREATE TABLE IF NOT EXISTS `tournaments`
`date_inscription` datetime NOT NULL, `date_inscription` datetime NOT NULL,
`date_solutions` datetime NOT NULL, `date_solutions` datetime NOT NULL,
`date_syntheses` datetime NOT NULL, `date_syntheses` datetime NOT NULL,
`final` tinyint(1) NOT NULL DEFAULT 0, `final` tinyint(1) NOT NULL DEFAULT '0',
`year` int(4) NOT NULL, `year` int(4) NOT NULL
PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
-- Structure de la table `users` -- Tabellenstruktur für Tabelle `users`
-- --
CREATE TABLE IF NOT EXISTS `users` CREATE TABLE `users` (
( `id` int(8) NOT NULL,
`id` int(8) NOT NULL AUTO_INCREMENT,
`email` varchar(255) NOT NULL, `email` varchar(255) NOT NULL,
`pwd_hash` varchar(64) NOT NULL, `pwd_hash` varchar(64) NOT NULL,
`surname` varchar(255) NOT NULL, `surname` varchar(255) NOT NULL,
@ -164,20 +164,111 @@ CREATE TABLE IF NOT EXISTS `users`
`country` varchar(255) DEFAULT 'France', `country` varchar(255) DEFAULT 'France',
`phone_number` varchar(20) DEFAULT NULL, `phone_number` varchar(20) DEFAULT NULL,
`school` varchar(255) DEFAULT NULL, `school` varchar(255) DEFAULT NULL,
`class` varchar(255) DEFAULT NULL, `class` enum('SECONDE','PREMIERE','TERMINALE','ADULT') DEFAULT NULL,
`responsible_name` varchar(255) DEFAULT NULL, `responsible_name` varchar(255) DEFAULT NULL,
`responsible_phone` varchar(20) DEFAULT NULL, `responsible_phone` varchar(20) DEFAULT NULL,
`responsible_email` varchar(255) DEFAULT NULL, `responsible_email` varchar(255) DEFAULT NULL,
`description` varchar(255) DEFAULT NULL, `description` varchar(255) DEFAULT NULL,
`role` varchar(64) NOT NULL, `role` enum('PARTICIPANT','ENCADRANT','ORGANIZER','ADMIN') NOT NULL,
`team_id` int(8) DEFAULT NULL, `team_id` int(8) DEFAULT NULL,
`year` int(4) NOT NULL DEFAULT 2020, `year` int(4) NOT NULL DEFAULT '2020',
`confirm_email` varchar(64) DEFAULT NULL COMMENT 'Jeton de confirmation d''e-mail', `confirm_email` varchar(64) DEFAULT NULL COMMENT 'Jeton de confirmation d''e-mail',
`forgotten_password` varchar(64) DEFAULT NULL COMMENT 'Jeton de récupération de mot de passe', `forgotten_password` varchar(64) DEFAULT NULL COMMENT 'Jeton de récupération de mot de passe',
`inscription_date` datetime NOT NULL DEFAULT current_timestamp(), `inscription_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE = InnoDB
DEFAULT CHARSET = utf8; --
-- Indizes der exportierten Tabellen
--
--
-- Indizes für die Tabelle `documents`
--
ALTER TABLE `documents`
ADD PRIMARY KEY (`file_id`);
--
-- Indizes für die Tabelle `organizers`
--
ALTER TABLE `organizers`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `organizer` (`organizer`,`tournament`);
--
-- Indizes für die Tabelle `payments`
--
ALTER TABLE `payments`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `user` (`user`);
--
-- Indizes für die Tabelle `solutions`
--
ALTER TABLE `solutions`
ADD PRIMARY KEY (`file_id`);
--
-- Indizes für die Tabelle `syntheses`
--
ALTER TABLE `syntheses`
ADD PRIMARY KEY (`file_id`);
--
-- Indizes für die Tabelle `teams`
--
ALTER TABLE `teams`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `name/year` (`name`,`year`),
ADD UNIQUE KEY `trigram/year` (`trigram`,`year`);
--
-- Indizes für die Tabelle `tournaments`
--
ALTER TABLE `tournaments`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `Name/year` (`name`,`year`) USING BTREE;
--
-- Indizes für die Tabelle `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `email/year` (`email`,`year`) USING BTREE;
--
-- AUTO_INCREMENT für exportierte Tabellen
--
--
-- AUTO_INCREMENT für Tabelle `organizers`
--
ALTER TABLE `organizers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=40;
--
-- AUTO_INCREMENT für Tabelle `payments`
--
ALTER TABLE `payments`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=111;
--
-- AUTO_INCREMENT für Tabelle `teams`
--
ALTER TABLE `teams`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=61;
--
-- AUTO_INCREMENT für Tabelle `tournaments`
--
ALTER TABLE `tournaments`
MODIFY `id` int(8) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT für Tabelle `users`
--
ALTER TABLE `users`
MODIFY `id` int(8) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=370;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;