1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-02-11 15:41:18 +00:00

Mails groupés

This commit is contained in:
Yohann 2019-12-13 19:50:32 +01:00
parent 79400ca298
commit 7e02a2dd2a
6 changed files with 49 additions and 10 deletions

View File

@ -237,4 +237,18 @@ class Team
return $docs; return $docs;
} }
public function getAllEmails()
{
$emails = [];
if ($this->getEncadrantId() != null)
$emails[] = User::fromId($this->getEncadrantId())->getEmail();
foreach ($this->getParticipants() as $participantId) {
if ($participantId != 0)
$emails[] = User::fromId($participantId)->getEmail();
}
return $emails;
}
} }

View File

@ -13,4 +13,14 @@ $error_message = null;
$teams = Team::getAllTeams($problem); $teams = Team::getAllTeams($problem);
$validated_emails = [];
$not_validated_emails = [];
foreach ($teams as $team) {
if ($team->getValidationStatus() == ValidationStatus::VALIDATED)
$validated_emails = array_merge($validated_emails, $team->getAllEmails());
else
$not_validated_emails = array_merge($not_validated_emails, $team->getAllEmails());
}
require_once "server_files/views/probleme.php"; require_once "server_files/views/probleme.php";

View File

@ -54,15 +54,16 @@ for ($problem = 1; $problem <= 4; ++$problem)
$videos[] = Video::getVideos(Reason::SOLUTION, $problem); $videos[] = Video::getVideos(Reason::SOLUTION, $problem);
$waiting_teams = []; $waiting_teams = [];
$waiting_emails = [];
switch (Phase::getCurrentPhase()) { switch (Phase::getCurrentPhase()) {
case Phase::PHASE1: case Phase::PHASE1:
$req = $DB->query("SELECT DISTINCT `teams`.`id` FROM `teams` WHERE `validation_status` = '" . ValidationStatus::getName(ValidationStatus::VALIDATED) . "'" $req = $DB->query("SELECT DISTINCT `teams`.`id`, `teams`.`problem`, `teams`.`trigram` FROM `teams` WHERE `validation_status` = '" . ValidationStatus::getName(ValidationStatus::VALIDATED) . "'"
. " AND `id` NOT IN (SELECT DISTINCT `team` FROM `videos` WHERE `reason` = 'SOLUTION' AND `validation` = " . Video::ACCEPTED . ")" . " AND `id` NOT IN (SELECT DISTINCT `team` FROM `videos` WHERE `reason` = 'SOLUTION' AND `validation` = " . Video::ACCEPTED . ")"
. " AND `year` = $YEAR;"); . " AND `year` = $YEAR ORDER BY `problem`, `trigram`;");
break; break;
case Phase::PHASE2: case Phase::PHASE2:
$req = $DB->query("SELECT DISTINCT `teams`.`id` FROM `teams`" $req = $DB->query("SELECT DISTINCT `teams`.`id`, `teams`.`problem`, `teams`.`trigram` FROM `teams`"
. " WHERE `id` NOT IN (SELECT `q1`.`from` FROM `questions` AS `q1`" . " WHERE `id` NOT IN (SELECT `q1`.`from` FROM `questions` AS `q1`"
. " JOIN `questions` AS `q2` ON `q2`.`from` = `q1`.`from` AND `q2`.`number` = 2" . " JOIN `questions` AS `q2` ON `q2`.`from` = `q1`.`from` AND `q2`.`number` = 2"
. " JOIN `questions` AS `q3` ON `q3`.`from` = `q1`.`from` AND `q3`.`number` = 3" . " JOIN `questions` AS `q3` ON `q3`.`from` = `q1`.`from` AND `q3`.`number` = 3"
@ -77,10 +78,10 @@ switch (Phase::getCurrentPhase()) {
. " OR `q5`.`question` IS NOT NULL" . " OR `q5`.`question` IS NOT NULL"
. " OR `q6`.`question` IS NOT NULL))" . " OR `q6`.`question` IS NOT NULL))"
. " AND `validation_status` = '" . ValidationStatus::getName(ValidationStatus::VALIDATED) . "'" . " AND `validation_status` = '" . ValidationStatus::getName(ValidationStatus::VALIDATED) . "'"
. " AND `year` = $YEAR;"); . " AND `year` = $YEAR ORDER BY `problem`, `trigram`;");
break; break;
case Phase::PHASE3: case Phase::PHASE3:
$req = $DB->query("SELECT DISTINCT `teams`.`id` FROM `teams`" $req = $DB->query("SELECT DISTINCT `teams`.`id`, `teams`.`problem`, `teams`.`trigram` FROM `teams`"
. " WHERE `id` NOT IN (SELECT `q1`.`to` FROM `questions` AS `q1`" . " WHERE `id` NOT IN (SELECT `q1`.`to` FROM `questions` AS `q1`"
. " JOIN `questions` AS `q2` ON `q2`.`to` = `q1`.`to` AND `q2`.`number` = 2" . " JOIN `questions` AS `q2` ON `q2`.`to` = `q1`.`to` AND `q2`.`number` = 2"
. " JOIN `questions` AS `q3` ON `q3`.`to` = `q1`.`to` AND `q3`.`number` = 3" . " JOIN `questions` AS `q3` ON `q3`.`to` = `q1`.`to` AND `q3`.`number` = 3"
@ -95,19 +96,23 @@ switch (Phase::getCurrentPhase()) {
. " OR `q5`.`answer` IS NOT NULL" . " OR `q5`.`answer` IS NOT NULL"
. " OR `q6`.`answer` IS NOT NULL))" . " OR `q6`.`answer` IS NOT NULL))"
. " AND `validation_status` = '" . ValidationStatus::getName(ValidationStatus::VALIDATED) . "'" . " AND `validation_status` = '" . ValidationStatus::getName(ValidationStatus::VALIDATED) . "'"
. " AND `year` = $YEAR;"); . " AND `year` = $YEAR ORDER BY `problem`, `trigram`;");
break; break;
case Phase::PHASE4: case Phase::PHASE4:
$req = $DB->query("SELECT DISTINCT `teams`.`id` FROM `teams` WHERE `validation_status` = '" . ValidationStatus::getName(ValidationStatus::VALIDATED) . "'" $req = $DB->query("SELECT DISTINCT `teams`.`id`, `teams`.`problem`, `teams`.`trigram` FROM `teams` WHERE `validation_status` = '" . ValidationStatus::getName(ValidationStatus::VALIDATED) . "'"
. " AND (`id` NOT IN (SELECT DISTINCT `team` FROM `videos` WHERE `reason` = 'ANSWER1' AND `validation` = " . Video::ACCEPTED . ")" . " AND (`id` NOT IN (SELECT DISTINCT `team` FROM `videos` WHERE `reason` = 'ANSWER1' AND `validation` = " . Video::ACCEPTED . ")"
. " OR `id` NOT IN (SELECT DISTINCT `team` FROM `videos` WHERE `reason` = 'ANSWER2' AND `validation` = " . Video::ACCEPTED . "))" . " OR `id` NOT IN (SELECT DISTINCT `team` FROM `videos` WHERE `reason` = 'ANSWER2' AND `validation` = " . Video::ACCEPTED . "))"
. " AND `year` = $YEAR;"); . " AND `year` = $YEAR ORDER BY `problem`, `trigram`;");
break; break;
} }
if (isset($req)) { if (isset($req)) {
while (($data = $req->fetch()) !== false) $waiting_emails = [];
$waiting_teams[] = Team::fromId($data["id"]); while (($data = $req->fetch()) !== false) {
$team = Team::fromId($data["id"]);
$waiting_teams[] = $team;
$waiting_emails = array_merge($waiting_emails, $team->getAllEmails());
}
} }
require_once "server_files/views/suivi_correspondances.php"; require_once "server_files/views/suivi_correspondances.php";

View File

@ -53,6 +53,10 @@
<strong>Autorise Animath à diffuser les vidéos :</strong> <?= $team->allowPublish() ? "oui" : "non" ?> <strong>Autorise Animath à diffuser les vidéos :</strong> <?= $team->allowPublish() ? "oui" : "non" ?>
</div> </div>
<div class="alert alert-info">
<a href="mailto:contact@correspondances-maths.fr?<? foreach ($team->getAllEmails() as $email) echo "bcc=" . $email . "&" ?>subject=Correspondances de Jeunes Mathématicien·ne·s" target="_blank">Envoyer un mail à toute l'équipe</a>
</div>
<? if ($team->getValidationStatus() == ValidationStatus::VALIDATED) { ?> <? if ($team->getValidationStatus() == ValidationStatus::VALIDATED) { ?>
<hr/> <hr/>
<!--suppress HtmlUnknownTarget --> <!--suppress HtmlUnknownTarget -->

View File

@ -10,6 +10,11 @@
<h2>Équipes inscrites <?= $problem > 0 ? "pour ce problème" : "sans problème choisi" ?> :</h2> <h2>Équipes inscrites <?= $problem > 0 ? "pour ce problème" : "sans problème choisi" ?> :</h2>
<div class="alert alert-info">
<a href="mailto:contact@correspondances-maths.fr?<? foreach ($validated_emails as $email) echo "bcc=" . $email . "&" ?>subject=Correspondances de Jeunes Mathématicien·ne·s" target="_blank">Envoyer un mail à toutes les équipes validées</a><br />
<a href="mailto:contact@correspondances-maths.fr?<? foreach ($not_validated_emails as $email) echo "bcc=" . $email . "&" ?>subject=Correspondances de Jeunes Mathématicien·ne·s" target="_blank">Envoyer un mail à toutes les équipes non validées</a>
</div>
<table class="table table-striped table-bordered table-hover"> <table class="table table-striped table-bordered table-hover">
<thead> <thead>
<tr> <tr>

View File

@ -20,6 +20,7 @@ if (sizeof($waiting_teams) > 0) { ?>
</li> </li>
<?php } ?> <?php } ?>
</ul> </ul>
<a href="mailto:contact@correspondances-maths.fr?<? foreach ($waiting_emails as $email) echo "bcc=" . $email . "&" ?>subject=Correspondances de Jeunes Mathématicien·ne·s" target="_blank">Leur envoyer un mail</a>
</div> </div>
<?php } ?> <?php } ?>