1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-07-03 10:02:47 +02:00

Nombreuses petites corrections, ajout de texte.

Les Correspondances peuvent démarrer :)
This commit is contained in:
Yohann
2019-10-22 14:55:33 +02:00
parent 8adad9d5f7
commit 5c88ccb91a
32 changed files with 371 additions and 236 deletions

View File

@ -44,9 +44,10 @@ class NewAdmin {
$this->password = genRandomPhrase(16, true);
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `surname`, `first_name`, `role`, `year`)
VALUES (?, ?, ?, ?, ?, ?);");
$req->execute([$this->email, password_hash($this->password, PASSWORD_BCRYPT), $this->surname, $this->first_name, "ADMIN", $YEAR]);
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `surname`, `first_name`, `class`, `role`, `year`)
VALUES (?, ?, ?, ?, ?, ?, ?);");
$req->execute([$this->email, password_hash($this->password, PASSWORD_BCRYPT), $this->surname,
$this->first_name, "ADULT", "ADMIN", $YEAR]);
Mailer::sendAddAdminMail($this);
}

View File

@ -30,7 +30,8 @@ class GiveQuestions
* @var Team $to_team
*/
private $to_team;
private $question_1;
private $question_0;
private $question_1;
private $question_2;
private $question_3;
private $question_4;
@ -50,7 +51,7 @@ class GiveQuestions
$this->files = [];
$this->has_files = false;
for ($i = 1; $i <= 6; ++$i) {
for ($i = 0; $i <= 6; ++$i) {
if (strlen($files["file_$i"]["name"]) > 0) {
$this->files[] = $files["file_$i"];
$this->has_files = true;
@ -59,7 +60,7 @@ class GiveQuestions
$this->files[] = null;
}
$this->questions = [$this->question_1, $this->question_2, $this->question_3, $this->question_4, $this->question_5, $this->question_6];
$this->questions = [$this->question_0, $this->question_1, $this->question_2, $this->question_3, $this->question_4, $this->question_5, $this->question_6];
}
public function makeVerifications()
@ -73,12 +74,12 @@ class GiveQuestions
"Vous devez poser au moins 3 questions.");
ensure(!$this->has_files || $this->no_drawing, "Vous devez confirmer ne pas avoir inclus de texte dans vos pièces jointes.");
for ($i = 3; $i < 6; ++$i) {
for ($i = 4; $i <= 6; ++$i) {
if ($this->questions[$i] == "")
$this->questions[$i] = null;
}
for ($i = 0; $i < 6; ++$i) {
for ($i = 0; $i <= 6; ++$i) {
ensure($this->files[$i]["size"] <= 2e6, "Le fichier doit peser moins que 2 Mo.");
ensure(!$this->files[$i]["error"], "Une erreur est survenue. Veuillez vérifier vos pièces jointes. Elles ne doivent pas peser plus de 2 Mo chacune.");
}
@ -92,7 +93,7 @@ class GiveQuestions
/** @var Question[] $questions */
$questions = Question::getQuestions($team, $this->to_team);
for ($i = 0; $i < 6; ++$i) {
for ($i = 0; $i <= 6; ++$i) {
$question = $questions[$i];
if ($question->getQuestion() != $this->questions[$i] && $question->getAttachedFile() != null) {
unlink("$LOCAL_PATH/files/" . $question->getAttachedFile());

View File

@ -5,7 +5,7 @@ $problem = htmlspecialchars($_GET["probleme"]);
if (!preg_match("#[0-4]#", $problem))
require_once "server_files/404.php";
if (isset($_GET["modifier"]) && $_SESSION["role"] != Role::ADMIN)
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ADMIN)
require_once "server_files/403.php";
$has_error = false;

View File

@ -26,6 +26,7 @@ class AnswerQuestions
* @var Team $to_team
*/
private $from_team;
private $answer_0;
private $answer_1;
private $answer_2;
private $answer_3;
@ -46,7 +47,7 @@ class AnswerQuestions
$this->files = [];
$this->has_files = false;
for ($i = 1; $i <= 6; ++$i) {
for ($i = 0; $i <= 6; ++$i) {
if (strlen($files["file_$i"]["name"]) > 0) {
$this->files[] = $files["file_$i"];
$this->has_files = true;
@ -55,7 +56,7 @@ class AnswerQuestions
$this->files[] = null;
}
$this->answers = [$this->answer_1, $this->answer_2, $this->answer_3, $this->answer_4, $this->answer_5, $this->answer_6];
$this->answers = [$this->answer_0, $this->answer_1, $this->answer_2, $this->answer_3, $this->answer_4, $this->answer_5, $this->answer_6];
}
public function makeVerifications()
@ -67,12 +68,12 @@ class AnswerQuestions
ensure($team->getProblem() == $this->from_team->getProblem(), "Les équipes ne travaillent pas sur le même problème.");
ensure(!$this->has_files || $this->no_drawing, "Vous devez confirmer ne pas avoir inclus de texte dans vos pièces jointes.");
for ($i = 0; $i < 6; ++$i) {
for ($i = 1; $i <= 6; ++$i) {
if ($this->answers[$i] == "")
$this->answers[$i] = null;
}
for ($i = 0; $i < 6; ++$i) {
for ($i = 0; $i <= 6; ++$i) {
ensure($this->files[$i]["size"] <= 2e6, "Le fichier doit peser moins que 2 Mo.");
ensure(!$this->files[$i]["error"], "Une erreur est survenue. Veuillez vérifier vos pièces jointes. Elles ne doivent pas peser plus de 2 Mo chacune.");
}
@ -86,7 +87,7 @@ class AnswerQuestions
/** @var Question[] $questions */
$questions = Question::getQuestions($this->from_team, $team);
for ($i = 0; $i < 6; ++$i) {
for ($i = 0; $i <= 6; ++$i) {
$question = $questions[$i];
if ($question->getAnswer() != $this->answers[$i] && $question->getAttachedFileAnswer() != null) {
unlink("$LOCAL_PATH/files/" . $question->getAttachedFileAnswer());

View File

@ -64,12 +64,12 @@ switch (Phase::getCurrentPhase()) {
case Phase::PHASE2:
$req = $DB->query("SELECT DISTINCT `teams`.`id` FROM `teams`"
. " WHERE `id` NOT IN (SELECT `q1`.`from` FROM `questions` AS `q1`"
. " JOIN `questions` AS `q2` ON `q2`.`from` = `q1`.`from` AND `q2`.`number` = 1"
. " JOIN `questions` AS `q3` ON `q3`.`from` = `q1`.`from` AND `q3`.`number` = 2"
. " JOIN `questions` AS `q4` ON `q4`.`from` = `q1`.`from` AND `q4`.`number` = 3"
. " JOIN `questions` AS `q5` ON `q5`.`from` = `q1`.`from` AND `q5`.`number` = 4"
. " JOIN `questions` AS `q6` ON `q6`.`from` = `q1`.`from` AND `q6`.`number` = 5"
. " WHERE `q1`.`number` = 0"
. " 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 `q4` ON `q4`.`from` = `q1`.`from` AND `q4`.`number` = 4"
. " JOIN `questions` AS `q5` ON `q5`.`from` = `q1`.`from` AND `q5`.`number` = 5"
. " JOIN `questions` AS `q6` ON `q6`.`from` = `q1`.`from` AND `q6`.`number` = 6"
. " WHERE `q1`.`number` = 1"
. " AND (`q1`.`question` != '" . Question::DEFAULT_QUESTIONS[0] . "'"
. " OR `q2`.`question` != '" . Question::DEFAULT_QUESTIONS[1] . "'"
. " OR `q3`.`question` != '" . Question::DEFAULT_QUESTIONS[2] . "'"
@ -82,12 +82,12 @@ switch (Phase::getCurrentPhase()) {
case Phase::PHASE3:
$req = $DB->query("SELECT DISTINCT `teams`.`id` FROM `teams`"
. " WHERE `id` NOT IN (SELECT `q1`.`to` FROM `questions` AS `q1`"
. " JOIN `questions` AS `q2` ON `q2`.`to` = `q1`.`to` AND `q2`.`number` = 1"
. " JOIN `questions` AS `q3` ON `q3`.`to` = `q1`.`to` AND `q3`.`number` = 2"
. " JOIN `questions` AS `q4` ON `q4`.`to` = `q1`.`to` AND `q4`.`number` = 3"
. " JOIN `questions` AS `q5` ON `q5`.`to` = `q1`.`to` AND `q5`.`number` = 4"
. " JOIN `questions` AS `q6` ON `q6`.`to` = `q1`.`to` AND `q6`.`number` = 5"
. " WHERE `q1`.`question` = 0"
. " 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 `q4` ON `q4`.`to` = `q1`.`to` AND `q4`.`number` = 4"
. " JOIN `questions` AS `q5` ON `q5`.`to` = `q1`.`to` AND `q5`.`number` = 5"
. " JOIN `questions` AS `q6` ON `q6`.`to` = `q1`.`to` AND `q6`.`number` = 6"
. " WHERE `q1`.`question` = 1"
. " AND (`q1`.`answer` IS NOT NULL"
. " OR `q2`.`answer` IS NOT NULL"
. " OR `q3`.`answer` IS NOT NULL"