From 8df4c71119a773176dd534c1ac70ed9c9d37c7ac Mon Sep 17 00:00:00 2001 From: galaxyoyo Date: Fri, 27 Sep 2019 19:18:54 +0200 Subject: [PATCH] Design phases 1 & 2 --- server_files/classes/Question.php | 6 +- server_files/classes/Team.php | 2 +- server_files/controllers/ajouter_equipe.php | 2 +- server_files/views/equipe.php | 85 ++++++----- server_files/views/poser_questions.php | 124 ++++++++------- server_files/views/videos_solutions.php | 161 +++++++++++--------- 6 files changed, 213 insertions(+), 167 deletions(-) diff --git a/server_files/classes/Question.php b/server_files/classes/Question.php index 40279ad..a45fb6e 100644 --- a/server_files/classes/Question.php +++ b/server_files/classes/Question.php @@ -79,9 +79,9 @@ class Question null, null, null]; - for ($_ = 0; $_ < 6; ++$_) { - $req = $DB->prepare("INSERT INTO `questions`(`from`, `to`, `problem`, `question`) VALUES (?, ?, ?, ?);"); - $req->execute([$from->getId(), $to->getId(), $from->getProblem(), $default_questions[$_]]); + for ($i = 0; $i < 6; ++$i) { + $req = $DB->prepare("INSERT INTO `questions`(`from`, `to`, `problem`, `number`, `question`) VALUES (?, ?, ?, ?, ?);"); + $req->execute([$from->getId(), $to->getId(), $from->getProblem(), $i, $default_questions[$i]]); } return self::getQuestions($from, $to); } diff --git a/server_files/classes/Team.php b/server_files/classes/Team.php index d8ccf03..351cb71 100644 --- a/server_files/classes/Team.php +++ b/server_files/classes/Team.php @@ -96,7 +96,7 @@ class Team $this->encadrant = $data["encadrant"]; $this->participants = [$data["participant_1"], $data["participant_2"], $data["participant_3"], $data["participant_4"], $data["participant_5"]]; $this->inscription_date = $data["inscription_date"]; - $this->allow_publish = $data["allow_publish"]; + $this->allow_publish = $data["allow_publish"] ? 1 : 0; $this->validation_status = ValidationStatus::fromName($data["validation_status"]); $this->video_team_ids = [$data["video_team1"], $data["video_team2"]]; $this->access_code = $data["access_code"]; diff --git a/server_files/controllers/ajouter_equipe.php b/server_files/controllers/ajouter_equipe.php index 3977ad7..788ef4d 100644 --- a/server_files/controllers/ajouter_equipe.php +++ b/server_files/controllers/ajouter_equipe.php @@ -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() { diff --git a/server_files/views/equipe.php b/server_files/views/equipe.php index 11bd8e4..87c071c 100644 --- a/server_files/views/equipe.php +++ b/server_files/views/equipe.php @@ -18,20 +18,20 @@ : getValidationStatus()) ?>
- getEncadrantId() !== null) { - $encadrant = User::fromId($team->getEncadrantId()); - $id = $encadrant->getId(); - echo "Encadrant : getFirstName() . " " . $encadrant->getSurname() . "\">" . $encadrant->getFirstName() . " " . $encadrant->getSurname() . "
"; - } - for ($i = 1; $i <= 5; ++$i) { - if ($team->getParticipants()[$i - 1] == NULL) - continue; - $participant = User::fromId($team->getParticipants()[$i - 1]); - $id = $participant->getId(); - echo "Participant $i : getFirstName() . " " . $participant->getSurname() . "\">" . $participant->getFirstName() . " " . $participant->getSurname() . "
"; - } - ?> + getEncadrantId() !== null) { + $encadrant = User::fromId($team->getEncadrantId()); + $id = $encadrant->getId(); + echo "Encadrant : getFirstName() . " " . $encadrant->getSurname() . "\">" . $encadrant->getFirstName() . " " . $encadrant->getSurname() . "
"; + } + for ($i = 1; $i <= 5; ++$i) { + if ($team->getParticipants()[$i - 1] == NULL) + continue; + $participant = User::fromId($team->getParticipants()[$i - 1]); + $id = $participant->getId(); + echo "Participant $i : getFirstName() . " " . $participant->getSurname() . "\">" . $participant->getFirstName() . " " . $participant->getSurname() . "
"; + } + ?>
Autorise Animath à diffuser les vidéos : allowPublish() ? "oui" : "non" ?> @@ -40,32 +40,36 @@
-
-
-
- - = Phase::PHASE2 ? "disable" : "" ?>> + getId() == $team->getId()) + continue; - $team_name = $other_team->getName() . " (" . $other_team->getTrigram() . ")"; - $team_id = $other_team->getId(); - echo "\n"; - } - ?> - + $team_name = $other_team->getName() . " (" . $other_team->getTrigram() . ")"; + $team_id = $other_team->getId(); + echo "\n"; + } + ?> + +
-
-
- -
- +
+ + + +
+ +
@@ -84,12 +88,13 @@ if ($_SESSION["role"] == Role::ADMIN) { ?>
- +
- \ No newline at end of file diff --git a/server_files/views/poser_questions.php b/server_files/views/poser_questions.php index 9adcd00..ae856cd 100644 --- a/server_files/views/poser_questions.php +++ b/server_files/views/poser_questions.php @@ -2,66 +2,86 @@ require_once "header.php"; ?> -

Veuillez toujours enregistrer votre travail ailleurs que sur la plateforme !

-
+
+

Poser des questions

+
+ + +
+ Vos questions ont bien été mises à jour ! +
+ + +
+

Veuillez toujours enregistrer votre travail ailleurs que sur la plateforme !

+
-

Questions pour l'équipe getName() ?> (getTrigram() ?>) :

- Lien de la vidéo : getLink() ?>
- getLink()) ?> -
-
- - - +
+

Questions pour l'équipe getName() ?> (getTrigram() ?>) :

+
+ Lien de la vidéo : getLink() ?> +
+ getLink()) ?> +
+ + + -
- - - - getAttachedFile() != null) { ?> - - - - - - - - - + $question = $questions[$i][$j]; + + if ($question->getQuestion() == null && $j) { ?> + " + onclick="addQuestion(, )">Ajouter une question +
+ +
;"> +
+ + +
+ + getAttachedFile() != null) { ?> +
+
+ Pièce jointe : Télécharger +
+ + +
+ + +
+
+ - - - - - - - -
- - - -
- Pièce jointe : - - getAttachedFile() ?>">Télécharger -
- - - -
- -
- -
-
-
+ + + + + + + Vidéos pour le problème $problem\n"; +for ($problem = 1; $problem <= 4; ++$problem) { ?> +
+

Vidéos pour le problème

+
+ getLink(); $team = Team::fromId($video->getTeam()); $version = $video->getVersion(); - echo "

Vidéo de présentation de l'équipe « " . $team->getName() . " » (" . $team->getTrigram() . ") :

\n"; - echo "Lien de la vidéo (version $version) : $link"; - displayVideo($link); + ?> +
+

+ Équipe « getName() ?> » (getTrigram() ?>) +

+
+ Lien de la vidéo (version ) : +
+ getValidation() == 0) { ?> -
- - - - -
- La vidéo a été " . ($video->getValidation() == 1 ? "acceptée" : "refusée") . ".
\n"; + if ($video->getValidation() == 0) { ?> +
+ + + + +
+
a + +
"> + La vidéo a été getValidation() == 1 ? "acceptée" : "refusée" ?>. +
+ getValidation() != Video::ACCEPTED) { - $last_validated_video = Video::getVideo(Reason::SOLUTION, $team, Video::ACCEPTED); - if ($last_validated_video !== null) { - $link = $last_validated_video->getLink(); - echo "\n
\nLien de la dernière vidéo validée de cette équipe : $link
\n"; - displayVideo($link); - } - } - - if (Phase::getCurrentPhase() > Phase::PHASE1) { - /** @var Question[] $from_questions */ - foreach (Question::getQuestionsTo($team) as $from_questions) { - $from = Team::fromId($from_questions[0]->getFrom()); - echo "
Questions posées par l'équipe " . $from->getName() . " (" . $from->getTrigram() . ") :
\n"; - for ($i = 0; $i < sizeof($from_questions); ++$i) { - $question = $from_questions[$i]; - if ($question->getQuestion() == null) - continue; - - echo "Question " . ($i + 1) . " : " . $question->getQuestion() . "
\n"; - if ($question->getAttachedFile() != null) - echo "Pièce jointe attachée : getAttachedFile() . "\">Télécharger
\n"; - if ($question->getAnswer() != null) - echo "Réponse apportée : " . $question->getAnswer() . "
\n"; - if ($question->getAttachedFileAnswer() != null) - echo "Pièce jointe attachée pour la réponse : getAttachedFileAnswer() . "\">Télécharger
\n"; - } - echo "
\n"; - if (Phase::getCurrentPhase() >= Phase::PHASE4) { - $answer = Video::getVideo($from->getVideoTeamIds()[0] == $team->getId() ? Reason::ANSWER1 : Reason::ANSWER2, $from); - $link = $answer->getLink(); - $version = $answer->getVersion(); - echo "
Vidéo de réponse :
\n"; - echo "Lien de la vidéo (version $version) : $link"; + if ($video->getValidation() != Video::ACCEPTED) { + $last_validated_video = Video::getVideo(Reason::SOLUTION, $team, Video::ACCEPTED); + if ($last_validated_video !== null) { + $link = $last_validated_video->getLink(); ?> +
+ Lien de la vidéo validée de cette équipe (version ) : +
+ getValidation() == 0) { ?> -
- - - - -
- La vidéo a été " . ($answer->getValidation() == 1 ? "acceptée" : "refusée") . ".
\n"; + if (Phase::getCurrentPhase() > Phase::PHASE1) { + /** @var Question[] $from_questions */ + foreach (Question::getQuestionsTo($team) as $from_questions) { + $from = Team::fromId($from_questions[0]->getFrom()); + echo "
Questions posées par l'équipe " . $from->getName() . " (" . $from->getTrigram() . ") :
\n"; + for ($i = 0; $i < sizeof($from_questions); ++$i) { + $question = $from_questions[$i]; + if ($question->getQuestion() == null) + continue; - if ($answer->getValidation() != Video::ACCEPTED) { - $last_validated_answer = Video::getVideo($from->getVideoTeamIds()[0] == $team->getId() ? Reason::ANSWER1 : Reason::ANSWER2, $team, Video::ACCEPTED); - if ($last_validated_answer !== null) { - $link = $last_validated_answer->getLink(); - echo "\n
\nLien de la dernière vidéo validée de cette équipe : $link
\n"; - displayVideo($link); - } + echo "
\n"; + echo "Question " . ($i + 1) . " : " . $question->getQuestion() . "
\n"; + if ($question->getAttachedFile() != null) + echo "Pièce jointe attachée : getAttachedFile() . "\">Télécharger
\n"; + if ($question->getAnswer() != null) + echo "Réponse apportée : " . $question->getAnswer() . "
\n"; + if ($question->getAttachedFileAnswer() != null) + echo "Pièce jointe attachée pour la réponse : getAttachedFileAnswer() . "\">Télécharger
\n"; + echo "
\n"; } - } - } - } - } + echo "
\n"; + if (Phase::getCurrentPhase() >= Phase::PHASE4) { + $answer = Video::getVideo($from->getVideoTeamIds()[0] == $team->getId() ? Reason::ANSWER1 : Reason::ANSWER2, $from); + $link = $answer->getLink(); + $version = $answer->getVersion(); + echo "
Vidéo de réponse :
\n"; + echo "Lien de la vidéo (version $version) : $link"; + displayVideo($link); + + if ($answer->getValidation() == 0) { ?> +
+ + + + +
+ La vidéo a été " . ($answer->getValidation() == 1 ? "acceptée" : "refusée") . ".
\n"; + + if ($answer->getValidation() != Video::ACCEPTED) { + $last_validated_answer = Video::getVideo($from->getVideoTeamIds()[0] == $team->getId() ? Reason::ANSWER1 : Reason::ANSWER2, $team, Video::ACCEPTED); + if ($last_validated_answer !== null) { + $link = $last_validated_answer->getLink(); + echo "\n
\nLien de la dernière vidéo validée de cette équipe : $link
\n"; + displayVideo($link); + } + } + } + } + } ?> +
+ \n"; }