Design phases 1 & 2

This commit is contained in:
galaxyoyo 2019-09-27 19:18:54 +02:00
parent 5c5c670958
commit 8df4c71119
6 changed files with 213 additions and 167 deletions

View File

@ -79,9 +79,9 @@ class Question
null, null,
null, null,
null]; null];
for ($_ = 0; $_ < 6; ++$_) { for ($i = 0; $i < 6; ++$i) {
$req = $DB->prepare("INSERT INTO `questions`(`from`, `to`, `problem`, `question`) VALUES (?, ?, ?, ?);"); $req = $DB->prepare("INSERT INTO `questions`(`from`, `to`, `problem`, `number`, `question`) VALUES (?, ?, ?, ?, ?);");
$req->execute([$from->getId(), $to->getId(), $from->getProblem(), $default_questions[$_]]); $req->execute([$from->getId(), $to->getId(), $from->getProblem(), $i, $default_questions[$i]]);
} }
return self::getQuestions($from, $to); return self::getQuestions($from, $to);
} }

View File

@ -96,7 +96,7 @@ class Team
$this->encadrant = $data["encadrant"]; $this->encadrant = $data["encadrant"];
$this->participants = [$data["participant_1"], $data["participant_2"], $data["participant_3"], $data["participant_4"], $data["participant_5"]]; $this->participants = [$data["participant_1"], $data["participant_2"], $data["participant_3"], $data["participant_4"], $data["participant_5"]];
$this->inscription_date = $data["inscription_date"]; $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->validation_status = ValidationStatus::fromName($data["validation_status"]);
$this->video_team_ids = [$data["video_team1"], $data["video_team2"]]; $this->video_team_ids = [$data["video_team1"], $data["video_team2"]];
$this->access_code = $data["access_code"]; $this->access_code = $data["access_code"];

View File

@ -32,7 +32,7 @@ class NewTeam {
$this->trigram = strtoupper($this->trigram); $this->trigram = strtoupper($this->trigram);
$this->allow_publish = $this->allow_publish == "on"; $this->allow_publish = $this->allow_publish == "on" ? 1 : 0;
} }
public function makeVerifications() { public function makeVerifications() {

View File

@ -18,20 +18,20 @@
:</strong> <?= ValidationStatus::getTranslatedName($team->getValidationStatus()) ?> :</strong> <?= ValidationStatus::getTranslatedName($team->getValidationStatus()) ?>
</div> </div>
<div class="alert alert-info"> <div class="alert alert-info">
<?php <?php
if ($team->getEncadrantId() !== null) { if ($team->getEncadrantId() !== null) {
$encadrant = User::fromId($team->getEncadrantId()); $encadrant = User::fromId($team->getEncadrantId());
$id = $encadrant->getId(); $id = $encadrant->getId();
echo "<strong>Encadrant :</strong> <a href=\"$URL_BASE/informations/$id/" . $encadrant->getFirstName() . " " . $encadrant->getSurname() . "\">" . $encadrant->getFirstName() . " " . $encadrant->getSurname() . "</a><br />"; echo "<strong>Encadrant :</strong> <a href=\"$URL_BASE/informations/$id/" . $encadrant->getFirstName() . " " . $encadrant->getSurname() . "\">" . $encadrant->getFirstName() . " " . $encadrant->getSurname() . "</a><br />";
} }
for ($i = 1; $i <= 5; ++$i) { for ($i = 1; $i <= 5; ++$i) {
if ($team->getParticipants()[$i - 1] == NULL) if ($team->getParticipants()[$i - 1] == NULL)
continue; continue;
$participant = User::fromId($team->getParticipants()[$i - 1]); $participant = User::fromId($team->getParticipants()[$i - 1]);
$id = $participant->getId(); $id = $participant->getId();
echo "<strong>Participant $i :</strong> <a href=\"$URL_BASE/informations/$id/" . $participant->getFirstName() . " " . $participant->getSurname() . "\">" . $participant->getFirstName() . " " . $participant->getSurname() . "</a><br />"; echo "<strong>Participant $i :</strong> <a href=\"$URL_BASE/informations/$id/" . $participant->getFirstName() . " " . $participant->getSurname() . "\">" . $participant->getFirstName() . " " . $participant->getSurname() . "</a><br />";
} }
?> ?>
</div> </div>
<div class="alert alert-info"> <div class="alert alert-info">
<strong>Autorise Animath à diffuser les vidéos :</strong> <?= $team->allowPublish() ? "oui" : "non" ?> <strong>Autorise Animath à diffuser les vidéos :</strong> <?= $team->allowPublish() ? "oui" : "non" ?>
@ -40,32 +40,36 @@
<?php <?php
if ($_SESSION["role"] == Role::ADMIN) { ?> if ($_SESSION["role"] == Role::ADMIN) { ?>
<hr/> <hr/>
<form method="POST"> <? if ($team->getValidationStatus() == ValidationStatus::VALIDATED) { ?>
<div class="form-group row"> <form method="POST">
<div class="form-group col-md-12"> <div class="form-group row">
<label for="other_teams">L'équipe va recevoir les questions des équipes suivantes (merci d'en <div class="form-group col-md-12">
sélectionner <label for="other_teams">L'équipe va recevoir les questions des équipes suivantes (merci d'en
exactement 2) :</label> sélectionner
<select class="custom-select" id="other_teams" name="other_teams[]" multiple> exactement 2) :</label>
<?php <select class="custom-select" id="other_teams" name="other_teams[]" multiple <?= Phase::getCurrentPhase() >= Phase::PHASE2 ? "disable" : "" ?>>
/** @var Team $other_team */ <?php
foreach ($other_teams as $other_team) { /** @var Team $other_team */
if ($other_team->getId() == $team->getId()) foreach ($other_teams as $other_team) {
continue; if ($other_team->getId() == $team->getId())
continue;
$team_name = $other_team->getName() . " (" . $other_team->getTrigram() . ")"; $team_name = $other_team->getName() . " (" . $other_team->getTrigram() . ")";
$team_id = $other_team->getId(); $team_id = $other_team->getId();
echo "<option value=\"$team_id\" " . (in_array($other_team->getId(), $team->getVideoTeamIds()) ? "selected" : "") . ">$team_name</option>\n"; echo "<option value=\"$team_id\" " . (in_array($other_team->getId(), $team->getVideoTeamIds()) ? "selected" : "") . ">$team_name</option>\n";
} }
?> ?>
</select> </select>
</div>
</div> </div>
</div> <div class="form-group row">
<div class="form-group row"> <?php if (Phase::getCurrentPhase() < Phase::PHASE2) { ?>
<input type="submit" class="btn btn-secondary btn-lg btn-block" name="update_video_teams" <input type="submit" class="btn btn-secondary btn-lg btn-block" name="update_video_teams"
value="Mettre à jour"/> value="Mettre à jour"/>
</div> <?php } ?>
</form> </div>
</form>
<?php } ?>
<?php } ?> <?php } ?>
<hr/> <hr/>
@ -84,12 +88,13 @@ if ($_SESSION["role"] == Role::ADMIN) { ?>
<form method="POST"> <form method="POST">
<div class="form-group"> <div class="form-group">
<div class="form-group row col-mod-6"> <div class="form-group row col-mod-6">
<input type="submit" class="btn btn-secondary btn-lg btn-block" name="unvalidate" value="Refuser l'équipe"/> <input type="submit" class="btn btn-secondary btn-lg btn-block" name="unvalidate"
value="Refuser l'équipe"/>
<input type="submit" class="btn btn-primary btn-lg btn-block" name="validate" value="Valider l'équipe"/> <input type="submit" class="btn btn-primary btn-lg btn-block" name="validate" value="Valider l'équipe"/>
</div> </div>
</div> </div>
</form> </form>
<?php <?php
} }
require_once "footer.php" ?> require_once "footer.php" ?>

View File

@ -2,66 +2,86 @@
require_once "header.php"; require_once "header.php";
?> ?>
<h1>Veuillez toujours enregistrer votre travail ailleurs que sur la plateforme !</h1> <div class="mt-4 mb-4">
<hr /> <h1 class="display-4">Poser des questions</h1>
</div>
<?php
if (isset($give_questions) && !$has_error) { ?>
<div class="alert alert-success">
Vos questions ont bien été mises à jour !
</div>
<?php } ?>
<div class="alert alert-warning">
<h1>Veuillez toujours enregistrer votre travail ailleurs que sur la plateforme !</h1>
</div>
<?php <?php
for ($i = 0; $i < 2; ++$i) { for ($i = 0; $i < 2; ++$i) {
$receiver = $receivers[$i]; $receiver = $receivers[$i];
$video = $videos[$i]; ?> $video = $videos[$i]; ?>
<h2>Questions pour l'équipe <?= $receiver->getName() ?> (<?= $receiver->getTrigram() ?>) :</h2> <div class="jumbotron">
Lien de la vidéo : <a href="<?= $video->getLink() ?>"><?= $video->getLink() ?></a><br/> <h2>Questions pour l'équipe <?= $receiver->getName() ?> (<?= $receiver->getTrigram() ?>) :</h2>
<?php displayVideo($video->getLink()) ?> <div class="alert alert-info">
<br/> Lien de la vidéo : <a href="<?= $video->getLink() ?>"><?= $video->getLink() ?></a>
<form method="POST" enctype="multipart/form-data"> </div>
<input type="hidden" name="to" value="<?= $receiver->getTrigram() ?>"/> <?php displayVideo($video->getLink()) ?>
<table > <br/>
<tbody> <form method="POST" enctype="multipart/form-data">
<input type="hidden" name="to" value="<?= $receiver->getTrigram() ?>"/>
<?php <?php
for ($j = 0; $j < 6; ++$j) { for ($j = 0; $j < 6; ++$j) {
$question = $questions[$i][$j]; ?> $question = $questions[$i][$j];
<tr>
<td style="width: 30%;"> if ($question->getQuestion() == null && $j) { ?>
<label for="question_<?= $j + 1 ?>">Question <?= $j + 1 ?> <?= $j >= 3 ? "(<em>facultatif</em>)" : "" ?> :</label> <a id="button_<?= $i ?>_<?= $j ?>" class="btn btn-secondary btn-lg btn-block"
</td> style="display: <?= $j == 0 || $questions[$i][$j - 1]->getQuestion() != null ? "block" : "none" ?>"
<td style="width: 70%;"> onclick="addQuestion(<?= $i ?>, <?= $j ?>)">Ajouter une question</a>
<textarea id="question_<?= $j + 1 ?>" name="question_<?= $j + 1 ?>"><?= $question->getQuestion() ?></textarea> <br/>
</td> <?php
</tr> }
<?php
if ($question->getAttachedFile() != null) { ?> ?>
<tr> <div id="block_<?= $i ?>_<?= $j ?>" style="display: <?= $question->getQuestion() == null ? "none" : "block" ?>;">
<td> <div class="form-group-row">
Pièce jointe : <label for="question_<?= $j + 1 ?>_<?= $i ?>">Question <?= $j + 1 ?> :</label>
</td> <textarea class="form-control" id="question_<?= $j + 1 ?>_<?= $i ?>"
<td> name="question_<?= $j + 1 ?>"><?= $question->getQuestion() ?></textarea>
<a href=/file/<?= $question->getAttachedFile() ?>">Télécharger</a> </div>
</td>
</tr> <?php
<?php } ?> if ($question->getAttachedFile() != null) { ?>
<tr> <br/>
<td> <div class="alert alert-info">
<label for="file_<?= $j + 1 ?>">Ajouter une pièce jointe (<em>facultatif</em>) :</label> Pièce jointe : <a href="/file/<?= $question->getAttachedFile() ?>">Télécharger</a>
</td> </div>
<td> <?php } ?>
<input type="file" name="file_<?= $j + 1 ?>" id="file_<?= $j + 1 ?>" />
</td> <div class="form-group-row">
</tr> <label for="file_<?= $j + 1 ?>_<?= $i ?>">Ajouter une pièce jointe (<em>facultatif</em>)
:</label>
<input type="file" name="file_<?= $j + 1 ?>" id="file_<?= $j + 1 ?>"/>
</div>
</div>
<?php } ?> <?php } ?>
<tr>
<td style="text-align: center" colspan="2"> <input type="checkbox" name="no_drawing" id="no_drawing_<?= $i ?>"/> <label for="no_drawing_<?= $i ?>">Je
<input type="checkbox" name="no_drawing" id="no_drawing" /> <label for="no_drawing">Je confirme que mes pièces jointes ne contiennent pas de texte.</label> confirme que mes pièces jointes ne contiennent pas de texte.</label>
</td> <input class="btn btn-primary btn-lg btn-block" type="submit" name="give_questions"
</tr> value="Poser les questions"/>
<tr> </form>
<td colspan="2"> </div>
<input type="submit" name="give_questions" value="Poser les questions" />
</td> <script>
</tr> function addQuestion(i, j) {
</tbody> document.getElementById("button_" + i + "_" + j).style.display = "none";
</table> document.getElementById("block_" + i + "_" + j).style.display = "block";
</form> document.getElementById("button_" + i + "_" + (j + 1)).style.display = "block";
<hr/> }
</script>
<?php } <?php }
require_once "footer.php"; require_once "footer.php";

View File

@ -2,87 +2,108 @@
require_once "header.php"; require_once "header.php";
for ($problem = 1; $problem <= 4; ++$problem) { for ($problem = 1; $problem <= 4; ++$problem) { ?>
echo "<h2>Vidéos pour le problème $problem</h2>\n"; <div class="mt-4 mb-4">
<h1 class="display-4">Vidéos pour le problème <?= $problem ?></h1>
</div>
<?php
/** @var Video $video */ /** @var Video $video */
foreach ($videos[$problem - 1] as $video) { foreach ($videos[$problem - 1] as $video) {
$link = $video->getLink(); $link = $video->getLink();
$team = Team::fromId($video->getTeam()); $team = Team::fromId($video->getTeam());
$version = $video->getVersion(); $version = $video->getVersion();
echo "<h4>Vidéo de présentation de l'équipe « " . $team->getName() . " » (" . $team->getTrigram() . ") :</h4>\n"; ?>
echo "Lien de la vidéo (version $version) : <a href=\"$link\">$link</a>"; <div class="jumbotron">
displayVideo($link); <h2>
Équipe « <?= $team->getName() ?> » (<?= $team->getTrigram() ?>)
</h2>
<div class="alert alert-info">
Lien de la vidéo (version <?= $version ?>) : <a href="<?= $link ?>"><?= $link ?></a>
</div>
<?php
displayVideo($link);
if ($video->getValidation() == 0) { ?> if ($video->getValidation() == 0) { ?>
<form method="POST"> <form method="POST">
<input type="hidden" name="validate_video" value="" /> <input type="hidden" name="validate_video" value=""/>
<input type="hidden" name="video_id" value="<?= $video->getId() ?>" /> <input type="hidden" name="video_id" value="<?= $video->getId() ?>"/>
<input style="width: 49%;" type="submit" name="accept" value="Accepter la vidéo" /> <input class="btn btn-primary btn-lg" style="width: 49%;" type="submit" name="accept"
<input style="width: 49%;" type="submit" name="reject" value="Refuser la vidéo" /> value="Accepter la vidéo"/>
</form> <input class="btn btn-light btn-lg" style="width: 49%;" type="submit" name="reject"
<?php } value="Refuser la vidéo"/>
else </form>
echo "<h5>La vidéo a été " . ($video->getValidation() == 1 ? "acceptée" : "refusée") . ".</h5><br />\n"; <br/>a
<?php } else { ?>
<div class="alert alert-<?= $video->getValidation() == 1 ? "success" : "danger" ?>">
La vidéo a été <?= $video->getValidation() == 1 ? "acceptée" : "refusée" ?>.
</div>
<?php }
if ($video->getValidation() != Video::ACCEPTED) { if ($video->getValidation() != Video::ACCEPTED) {
$last_validated_video = Video::getVideo(Reason::SOLUTION, $team, Video::ACCEPTED); $last_validated_video = Video::getVideo(Reason::SOLUTION, $team, Video::ACCEPTED);
if ($last_validated_video !== null) { if ($last_validated_video !== null) {
$link = $last_validated_video->getLink(); $link = $last_validated_video->getLink(); ?>
echo "\n<br />\nLien de la dernière vidéo validée de cette équipe : <a href=\"$link\">$link</a><br />\n"; <div class="alert alert-info">
displayVideo($link); Lien de la vidéo validée de cette équipe (version <?= $version ?>) : <a
} href="<?= $link ?>"><?= $link ?></a>
} </div>
<?php
if (Phase::getCurrentPhase() > Phase::PHASE1) {
/** @var Question[] $from_questions */
foreach (Question::getQuestionsTo($team) as $from_questions) {
$from = Team::fromId($from_questions[0]->getFrom());
echo "<h5>Questions posées par l'équipe " . $from->getName() . " (" . $from->getTrigram() . ") :</h5>\n";
for ($i = 0; $i < sizeof($from_questions); ++$i) {
$question = $from_questions[$i];
if ($question->getQuestion() == null)
continue;
echo "Question " . ($i + 1) . " : " . $question->getQuestion() . "<br />\n";
if ($question->getAttachedFile() != null)
echo "<em>Pièce jointe attachée :</em> <a href=\"/file/" . $question->getAttachedFile() . "\">Télécharger</a><br />\n";
if ($question->getAnswer() != null)
echo "Réponse apportée : " . $question->getAnswer() . "<br />\n";
if ($question->getAttachedFileAnswer() != null)
echo "<em>Pièce jointe attachée pour la réponse :</em> <a href=\"/file/" . $question->getAttachedFileAnswer() . "\">Télécharger</a><br />\n";
}
echo "<br />\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 "<h5>Vidéo de réponse :</h5>\n";
echo "Lien de la vidéo (version $version) : <a href=\"$link\">$link</a>";
displayVideo($link); displayVideo($link);
}
}
if ($answer->getValidation() == 0) { ?> if (Phase::getCurrentPhase() > Phase::PHASE1) {
<form method="POST"> /** @var Question[] $from_questions */
<input type="hidden" name="validate_video" value="" /> foreach (Question::getQuestionsTo($team) as $from_questions) {
<input type="hidden" name="video_id" value="<?= $answer->getId() ?>" /> $from = Team::fromId($from_questions[0]->getFrom());
<input style="width: 49%;" type="submit" name="accept" value="Accepter la vidéo" /> echo "<h5>Questions posées par l'équipe " . $from->getName() . " (" . $from->getTrigram() . ") :</h5>\n";
<input style="width: 49%;" type="submit" name="reject" value="Refuser la vidéo" /> for ($i = 0; $i < sizeof($from_questions); ++$i) {
</form> $question = $from_questions[$i];
<?php } if ($question->getQuestion() == null)
else continue;
echo "<h5>La vidéo a été " . ($answer->getValidation() == 1 ? "acceptée" : "refusée") . ".</h5><br />\n";
if ($answer->getValidation() != Video::ACCEPTED) { echo "<div class=\"alert alert-info\">\n";
$last_validated_answer = Video::getVideo($from->getVideoTeamIds()[0] == $team->getId() ? Reason::ANSWER1 : Reason::ANSWER2, $team, Video::ACCEPTED); echo "<strong>Question " . ($i + 1) . " :</strong> " . $question->getQuestion() . "<br />\n";
if ($last_validated_answer !== null) { if ($question->getAttachedFile() != null)
$link = $last_validated_answer->getLink(); echo "<em>Pièce jointe attachée :</em> <a href=\"/file/" . $question->getAttachedFile() . "\"><strong>Télécharger</strong></a><br />\n";
echo "\n<br />\nLien de la dernière vidéo validée de cette équipe : <a href=\"$link\">$link</a><br />\n"; if ($question->getAnswer() != null)
displayVideo($link); echo "<strong>Réponse apportée :</strong> " . $question->getAnswer() . "<br />\n";
} if ($question->getAttachedFileAnswer() != null)
echo "<em>Pièce jointe attachée pour la réponse :</em> <a href=\"/file/" . $question->getAttachedFileAnswer() . "\"><strong>Télécharger</strong></a><br />\n";
echo "</div>\n";
} }
} echo "<br />\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 "<h5>Vidéo de réponse :</h5>\n";
echo "Lien de la vidéo (version $version) : <a href=\"$link\">$link</a>";
displayVideo($link);
if ($answer->getValidation() == 0) { ?>
<form method="POST">
<input type="hidden" name="validate_video" value=""/>
<input type="hidden" name="video_id" value="<?= $answer->getId() ?>"/>
<input style="width: 49%;" type="submit" name="accept" value="Accepter la vidéo"/>
<input style="width: 49%;" type="submit" name="reject" value="Refuser la vidéo"/>
</form>
<?php } else
echo "<h5>La vidéo a été " . ($answer->getValidation() == 1 ? "acceptée" : "refusée") . ".</h5><br />\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<br />\nLien de la dernière vidéo validée de cette équipe : <a href=\"$link\">$link</a><br />\n";
displayVideo($link);
}
}
}
}
} ?>
</div>
<?php }
echo "<hr />\n"; echo "<hr />\n";
} }