# Conflicts: # Source/API/script/Gateway/GatewayAdmin.php # Source/API/script/Gateway/GatewayForm.php # Source/API/script/Gateway/GatewayKeyword.php # Source/API/script/Gateway/GatewayListResponseOfCandidate.php # Source/API/script/Gateway/GatewayPossibleResponse.php # Source/API/script/Gateway/GatewayQuestion.php # Source/API/script/Gateway/GatewayResponse.php # Source/Model/ModelAdmin.phpinterestingProfiles
commit
5872130e9c
@ -0,0 +1,17 @@
|
||||
RewriteEngine on
|
||||
|
||||
|
||||
RewriteRule ^/$ index.php?page=goToForm [L]
|
||||
RewriteRule ^goToForm$ index.php?page=goToForm [L]
|
||||
RewriteRule ^submitForm$ index.php?page=submitForm [L]
|
||||
RewriteRule ^addQuestion$ index.php?page=addQuestion [L]
|
||||
RewriteRule ^addResponse$ index.php?page=addResponse [L]
|
||||
RewriteRule ^continueResponse$ index.php?page=continueResponse [L]
|
||||
RewriteRule ^createForm$ index.php?page=createForm [L]
|
||||
RewriteRule ^addKeyword$ index.php?page=addKeyword [L]
|
||||
RewriteRule "goToAdmin" index.php?page=goToAdmin [L]
|
||||
RewriteRule ^goToAdminLogin$ index.php?page=goToAdminLogin [L]
|
||||
RewriteRule ^login$ index.php?page=login [L]
|
||||
RewriteRule ^goToCategories$ index.php?page=goToCategories [L]
|
||||
RewriteRule ^goToQuestions$ index.php?page=goToQuestions [L]
|
||||
RewriteRule ^goToResponses$ index.php?page=goToResponses [L]
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace API\script\Gateway;
|
||||
|
||||
use Config\Connection;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Permet d'accéder, d'écrire ou de modifier les données contenues dans la table Admin afin de gérer l'espace administrateur.
|
||||
*/
|
||||
class GatewayAdmin
|
||||
{
|
||||
/**
|
||||
* @var Connection
|
||||
*/
|
||||
private Connection $connection;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de récupérer le mot de passe de l'administrateur en fonction de son login.
|
||||
* @param String $login Le login de l'administrateur.
|
||||
* @return String|null Le mot de passe de l'administrateur ou null si l'administrateur n'existe pas.
|
||||
*/
|
||||
|
||||
public function getPasswordWithLogin(String $login)
|
||||
{
|
||||
$query = "SELECT password FROM ADMIN WHERE login = :login";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':login' => array($login, PDO::PARAM_STR)
|
||||
));
|
||||
$result = $this->connection->getResults();
|
||||
if(empty($result))
|
||||
return null;
|
||||
return $result[0]['password'];
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace API\script\Gateway;
|
||||
|
||||
use Config\Connection;
|
||||
use BusinessClass\Form;
|
||||
use BusinessClass\Question;
|
||||
use PDO;
|
||||
|
||||
class GatewayForm
|
||||
{
|
||||
private Connection $connection;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = connect();
|
||||
}
|
||||
|
||||
public function insertForm(Form $form): void
|
||||
{
|
||||
if (empty($this->getForm())) {
|
||||
$query = "INSERT INTO Form(title, description) VALUES(:title, :desc)";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':title' => array($form->getTitle(), PDO::PARAM_STR),
|
||||
':desc' => array($form->getDescription(), PDO::PARAM_STR)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public function getForm(): array
|
||||
{
|
||||
$query = "SELECT * FROM Form";
|
||||
$this->connection->executeQuery($query);
|
||||
|
||||
return $this->connection->getResults();
|
||||
}
|
||||
|
||||
public function deleteForm(Form $form): void
|
||||
{
|
||||
$query = "DELETE FROM Form WHERE id = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($form->getId(), PDO::PARAM_INT)
|
||||
));
|
||||
}
|
||||
|
||||
public function assignKeywordToQuestion(string $keyword, string $response, int $idQuestion): void
|
||||
{
|
||||
$query = "SELECT pr.id
|
||||
FROM Propose p, PossibleResponse pr
|
||||
WHERE p.question = :id AND p.possibleResponse = pr.id
|
||||
AND pr.content = :response";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($idQuestion, PDO::PARAM_INT),
|
||||
':response' => array($response, PDO::PARAM_STR)
|
||||
));
|
||||
|
||||
$idPossibleResponse = $this->connection->getResults()[0][0];
|
||||
|
||||
$query = "INSERT INTO Reference(possibleResponse, keyword) VALUES(:possibleResponse, :keyword)";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':possibleResponse' => array($idPossibleResponse, PDO::PARAM_INT),
|
||||
':keyword' => array($keyword, PDO::PARAM_STR)
|
||||
));
|
||||
}
|
||||
|
||||
public function deleteKeywordFromQuestion(string $keyword, string $response, Question $question): void
|
||||
{
|
||||
$query = "SELECT pr.id FROM Propose p, PossibleResponse r
|
||||
WHERE p.question = :id AND p.possibleResponse = pr.id
|
||||
AND pr.content = :response";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($question->getId(), PDO::PARAM_INT),
|
||||
':response' => array($response, PDO::PARAM_STR)
|
||||
));
|
||||
|
||||
$idPossibleResponse = $this->connection->getResults()[0][0];
|
||||
|
||||
$query = "DELETE FROM Reference WHERE response = :idResponse AND keyword = :idKeword";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':idResponse' => array($idPossibleResponse, PDO::PARAM_INT),
|
||||
':idKeword' => array($keyword, PDO::PARAM_INT)
|
||||
));
|
||||
}
|
||||
|
||||
public function updateTitleToForm(string $title, Form $form): void
|
||||
{
|
||||
$query = "UPDATE Form SET title = :title WHERE id = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':title' => array($title, PDO::PARAM_STR),
|
||||
':id' => array($form->getId(), PDO::PARAM_INT)
|
||||
));
|
||||
}
|
||||
|
||||
public function updateDescriptionToForm(string $description, Form $form): void
|
||||
{
|
||||
$query = "UPDATE Form SET title = :title WHERE description = :description";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':description' => array($description, PDO::PARAM_STR),
|
||||
':id' => array($form->getId(), PDO::PARAM_INT)
|
||||
));
|
||||
}
|
||||
|
||||
public function deleteDescriptionToForm(Form $form): void
|
||||
{
|
||||
$query = "UPDATE Form SET title = :title WHERE description = :descript";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':descript' => array('', PDO::PARAM_STR),
|
||||
':id' => array($form->getId(), PDO::PARAM_INT)
|
||||
));
|
||||
}
|
||||
|
||||
public function existsForm(): bool
|
||||
{
|
||||
$query = "SELECT * FROM Form";
|
||||
$this->connection->executeQuery($query);
|
||||
return !empty($this->connection->getResults());
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace API\script\Gateway;
|
||||
|
||||
use Config\Connection;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Permet d'accéder, d'écrire ou de modifier les données contenues dans la table Keyword
|
||||
* afin de gérer les catégories disponibles et associer aux différentes réponses des questions.
|
||||
*/
|
||||
class GatewayKeyword
|
||||
{
|
||||
/**
|
||||
* @var Connection
|
||||
*/
|
||||
private Connection $connection;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet d'ajouter un Keyword dans la base de donnée.
|
||||
*
|
||||
* @param string $keyword Keyword à ajouter
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function insertKeyword(string $keyword)
|
||||
{
|
||||
$query = "INSERT INTO Keyword(word) VALUES(:word)";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':word' => array($keyword, PDO::PARAM_STR)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de supprimer un keyword de la base de donnée.
|
||||
*
|
||||
* @param string $keyword Keyword à supprimer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteKeyword(string $keyword)
|
||||
{
|
||||
$query = "DELETE FROM Keyword WHERE word = :word";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':word' => array($keyword, PDO::PARAM_STR)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de récupérer l'ensemble des Keyword disponible.
|
||||
*
|
||||
* @return array Retourne la liste de l'ensemble des keyword sauvé dans la base de donnée
|
||||
*/
|
||||
public function getAllKeyword(): array
|
||||
{
|
||||
$query = "SELECT * FROM Keyword";
|
||||
$this->connection->executeQuery($query);
|
||||
|
||||
return $this->connection->getResults();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de récupérer tous les Keyword qui font référence à l'id de la réponse possible à une question passée en paramètre.
|
||||
*
|
||||
* @param int $id Id de la possible réponse que l'on veut connaitre ses catégories
|
||||
*
|
||||
* @return array Retourne l'ensemble de tous les Keyword associer à la réponse
|
||||
*/
|
||||
public function getKeywordsContentByReference(int $id): array
|
||||
{
|
||||
$query = "SELECT k.* FROM Keyword k, Reference r
|
||||
WHERE k.word = r.keyword AND r.possibleResponse = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($id, PDO::PARAM_STR)
|
||||
));
|
||||
|
||||
return $this->getKeywordByAssotiation($id , $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de récupérer tous les Keyword qui font référence à l'id de la réponse d'un candidat passée en paramètre.
|
||||
*
|
||||
* @param int $id Id de la réponse que l'on veut connaitre ses catégories
|
||||
*
|
||||
* @return array Retourne l'ensemble de tous les Keyword associer à la réponse
|
||||
*/
|
||||
public function getKeywordsContentByCategorieze(int $id): array
|
||||
{
|
||||
$query = "SELECT k.* FROM Keyword k, Categorize c
|
||||
WHERE k.word = c.keyword AND c.response = :id";
|
||||
|
||||
return $this->getKeywordByAssotiation($id , $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de récupérer une liste de Keyword selon une requête donnée et un id associé.
|
||||
*
|
||||
* @param int $id Id de l'objet dont on veut ses Keyword associé
|
||||
* @param string $query Requête que l'on veut exécuter
|
||||
*
|
||||
* @return array Retourne la liste des différents Keyword associé à l'objet voulu
|
||||
*/
|
||||
private function getKeywordByAssotiation(int $id, string $query): array
|
||||
{
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($id, PDO::PARAM_STR)
|
||||
));
|
||||
|
||||
$tab = [];
|
||||
foreach ($this->connection->getResults() as $result) {
|
||||
$tab[] = $result["word"];
|
||||
}
|
||||
|
||||
return $tab;
|
||||
}
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace API\script\Gateway;
|
||||
|
||||
use Config\Connection;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Permet d'accéder, d'écrire ou de modifier les données contenues dans la table PossibleResponse
|
||||
* afin de gérer la liste des réponses et les catégories associer d'un candidat.
|
||||
*/
|
||||
class GatewayListResponseOfCandidate
|
||||
{
|
||||
/**
|
||||
* @var Connection
|
||||
*/
|
||||
private Connection $connection;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de récupérer la liste détaillée des réponses avec leurs catégories associer
|
||||
* aux différentes questions qu'un candidat cible a répondu
|
||||
*
|
||||
* @param int $idListResponse Id du candidat pour lequel on veut récupérer ses réponses
|
||||
*
|
||||
* @return array Retourne une liste qui pour
|
||||
* l'indice 0 a la liste des infos du candidat
|
||||
* l'indice 1 la liste des réponses
|
||||
* l'indice 2 une liste de liste de catégories, qui pour chaque même indice correspont à la liste des catégories de la réponse
|
||||
*/
|
||||
public function getDetailsListResponsesOfCandidate(int $idListResponse)
|
||||
{
|
||||
$gatewayResponse = new GatewayResponse();
|
||||
$gatewayKeyword = new GatewayKeyword();
|
||||
$tabKeywords = [];
|
||||
|
||||
$query = "SELECT * FROM ListResponsesOfCandidate WHERE id = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($idListResponse, PDO::PARAM_INT)
|
||||
));
|
||||
|
||||
$questionList = $this->connection->getResults()[0];
|
||||
|
||||
$responses = $gatewayResponse->getResponsesByIdListCandidate($questionList['id']);
|
||||
|
||||
foreach ($responses as $row) {
|
||||
$tabKeywords[] = $gatewayKeyword->getKeywordsContentByCategorieze($row['id']);
|
||||
}
|
||||
|
||||
return array($questionList, $responses, $tabKeywords);
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de récupérer la liste des personnes ayant répondu aux formulaire
|
||||
*
|
||||
* @return array Retourne la liste brute des informations de tous les candidats ayant répondu au formulaire
|
||||
*/
|
||||
public function getAllListResponsesOfCandidate(): array
|
||||
{
|
||||
$query = "SELECT * FROM ListResponsesOfCandidate";
|
||||
$this->connection->executeQuery($query);
|
||||
|
||||
return $this->connection->getResults();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de supprimer la liste des réponses d'un candidat de la base de donnée
|
||||
*
|
||||
* @param int $id Id du candidat à supprimer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteListResponseOfCandidate(int $id): void
|
||||
{
|
||||
$gatewayResponse = new GatewayResponse();
|
||||
|
||||
foreach ($gatewayResponse->getResponsesIdByIdListCandidate($id) as $response) {
|
||||
$gatewayResponse->deleteResponseById($response);
|
||||
}
|
||||
|
||||
$query = "DELETE FROM ListResponsesOfCandidate WHERE id = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
'id' => array($id, PDO::PARAM_INT)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet d'insérer dans la base de données les réponses aux questions d'un candidat
|
||||
* ainsi que les catégories associées à chaque réponse
|
||||
*
|
||||
* @param array $id Liste des id des questions répondue
|
||||
* @param array $answer Liste des réponses à chaque question
|
||||
* @param array $category Liste des catégories attribuées à chaque réponse
|
||||
* @param string $titleForm Titre du formulaire
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function insertListResponsesOfCandidate(array $id, array $answer, array $category, string $titleForm): void
|
||||
{
|
||||
$gatewayResponse = new GatewayResponse();
|
||||
$gatewayQuestion = new GatewayQuestion();
|
||||
|
||||
$query = "INSERT INTO ListResponsesOfCandidate(date, titleForm) VALUES(:date, :titleForm)";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':date' => array(date('Y-m-d H:i:s'), PDO::PARAM_STR),
|
||||
':titleForm' => array($titleForm, PDO::PARAM_STR)
|
||||
));
|
||||
|
||||
$idListQuestion = $this->connection->lastInsertId();
|
||||
|
||||
for ($i = 0; $i < count($answer); $i++) {
|
||||
$question = $gatewayQuestion->getQuestionContentById($id[$i]);
|
||||
$idResponse = $gatewayResponse->insertResponse($question, $answer[$i], $category[$i]);
|
||||
|
||||
$query = "INSERT INTO Submit (responsesCandidate, response) VALUES(:responsesCandidate, :response)";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':responsesCandidate' => array($idListQuestion, PDO::PARAM_STR),
|
||||
':response' => array($idResponse, PDO::PARAM_STR)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace API\script\Gateway;
|
||||
|
||||
use Config\Connection;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Permet d'accéder, d'écrire ou de modifier les données contenues dans la table PossibleResponse.
|
||||
*/
|
||||
class GatewayPossibleResponse
|
||||
{
|
||||
/**
|
||||
* @var Connection
|
||||
*/
|
||||
private Connection $connection;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de récupérer les différentes réponses possibles à une question donnée.
|
||||
*
|
||||
* @param string $idQuestion Id de la question pour laquelle on veut récupérer les réponses possibles
|
||||
*
|
||||
* @return array Retourne la liste de possibles réponses
|
||||
*/
|
||||
public function getPossibleResponseByQuestion(string $idQuestion): array
|
||||
{
|
||||
$query = "SELECT pr.* FROM Propose p, PossibleResponse pr
|
||||
WHERE p.question = :questionId AND p.possibleResponse = pr.id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':questionId' => array($idQuestion, PDO::PARAM_INT)
|
||||
));
|
||||
|
||||
return $this->connection->getResults();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet d'insérer une possible réponse dans la base de donnée.
|
||||
*
|
||||
* @param string $contentPossibleResponse Contenu de la possible réponse
|
||||
* @return int
|
||||
*/
|
||||
public function insertPossibleResponse(string $contentPossibleResponse): int
|
||||
{
|
||||
$query = "INSERT INTO PossibleResponse(content) VALUES(:content)";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':content' => array($contentPossibleResponse, PDO::PARAM_STR)
|
||||
));
|
||||
|
||||
return $this->connection->lastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de supprimer une possible réponse de la base de donnée par son id.
|
||||
*
|
||||
* @param int $id Id de la possible réponse à supprimer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deletePossibleResponse(int $id): void
|
||||
{
|
||||
$query = "DELETE FROM Reference WHERE response = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($id, PDO::PARAM_INT)
|
||||
));
|
||||
|
||||
$query = "DELETE FROM PossibleResponse WHERE id = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($id, PDO::PARAM_INT)
|
||||
));
|
||||
}
|
||||
}
|
@ -0,0 +1,193 @@
|
||||
<?php
|
||||
|
||||
namespace API\script\Gateway;
|
||||
|
||||
use Config\Connection;
|
||||
use BusinessClass\BoxQuestion;
|
||||
use BusinessClass\Question;
|
||||
use BusinessClass\TextQuestion;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Permet d'accéder, d'écrire ou de modifier les données contenues dans la table Question
|
||||
* afin de rendre le formulaire modulable.
|
||||
*/
|
||||
class GatewayQuestion
|
||||
{
|
||||
/**
|
||||
* @var Connection
|
||||
*/
|
||||
private Connection $connection;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet d'ajouter une question dans la base de donnée.
|
||||
*
|
||||
* @param Question $question Information sur la question ajouter
|
||||
* @param int $idForm Id du formulaire associer
|
||||
*
|
||||
* @return int Id de la question ajouté en base
|
||||
*/
|
||||
public function addQuestion(Question $question, int $idForm): int
|
||||
{
|
||||
$query = "INSERT INTO Question(content, type, form) VALUES(:content, :type, :form)";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':content' => array($question->getContent(), PDO::PARAM_STR),
|
||||
':type' => array(get_class($question), PDO::PARAM_STR),
|
||||
':form' => array($idForm, PDO::PARAM_INT)
|
||||
));
|
||||
|
||||
return $this->connection->lastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajoute une possible réponse à une question cible et associe à la possible réponse des catégories.
|
||||
*
|
||||
* @param string $response Contenu de la réponse possible
|
||||
* @param array $categories Liste des catégories attribuées à la possible réponse
|
||||
* @param int $idQuestion Id de la question associée à cette possible réponse
|
||||
*
|
||||
* @return int Retourne l'id de la possible réponse insérée en base
|
||||
*/
|
||||
public function insertResponseInQuestion(string $response, array $categories, int $idQuestion): int
|
||||
{
|
||||
$gatewayPossibleResponse = new GatewayPossibleResponse();
|
||||
$idPossibleResponse = $gatewayPossibleResponse->insertPossibleResponse($response);
|
||||
|
||||
$query = "INSERT INTO Propose(question, possibleResponse) VALUES(:question, :possibleResponse)";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':question' => array($idQuestion, PDO::PARAM_INT),
|
||||
':possibleResponse' => array($idPossibleResponse, PDO::PARAM_INT)
|
||||
));
|
||||
|
||||
|
||||
foreach ($categories as $keyword) {
|
||||
$gatewayForm = new GatewayForm();
|
||||
$gatewayForm->assignKeywordToQuestion($keyword, $response, $idQuestion);
|
||||
}
|
||||
|
||||
return $idQuestion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de supprimer une question dans la base ainsi que ses dépendances
|
||||
*
|
||||
* @param Question $question Information de la question à supprimer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteQuestion(Question $question): void
|
||||
{
|
||||
if (get_class($question) == BoxQuestion::class) {
|
||||
$query = "DELETE FROM Propose WHERE question = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($question->getId(), PDO::PARAM_INT)
|
||||
));
|
||||
|
||||
$listPossibleResponse = $question->getPossibleResponses();
|
||||
for ($i = 0; $i < count($listPossibleResponse); $i++) {
|
||||
$gatewayPossibleResponse = new GatewayPossibleResponse();
|
||||
$gatewayPossibleResponse->deletePossibleResponse($listPossibleResponse[$i]->getId());
|
||||
}
|
||||
}
|
||||
|
||||
$query = "DELETE FROM Question WHERE id = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($question->getId(), PDO::PARAM_INT)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de modifier dans la base de données les informations de la question.
|
||||
*
|
||||
* @param Question $question Question modifier à changer en base
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateQuestion(Question $question): void
|
||||
{
|
||||
$query = "UPDATE Question SET content = :content, type = :type, form = :frm WHERE id = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':content' => array($question->getContent(), PDO::PARAM_STR),
|
||||
':type' => array(get_class($question), PDO::PARAM_STR),
|
||||
':frm' => array($question->getForm(), PDO::PARAM_STR),
|
||||
':id' => array($question->getId(), PDO::PARAM_STR)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de récupérer toutes les questions, possibles réponses et catégories associées d'un formualire cible.
|
||||
*
|
||||
* @param string $idForm Id du formulaire
|
||||
*
|
||||
* @return array Retourne une liste qui pour
|
||||
* l'indice 0 la liste des questions
|
||||
* l'indice 1 une liste de liste de réponses, qui pour chaque même indice correspond à la liste des réponses possibles de la question
|
||||
* l'indice 2 une liste de liste de liste de catégories qui pour chaque indice de questions,
|
||||
* on a une liste de liste de catégories qui pour chaque indice de réponses est associer une liste de catégories
|
||||
* Ou vide s'il n'y a pas de question dans la base
|
||||
*/
|
||||
public function getAllQuestions(string $idForm): array
|
||||
{
|
||||
$query = "SELECT * FROM Question WHERE form = :fom";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':fom' => array($idForm, PDO::PARAM_INT)
|
||||
));
|
||||
|
||||
$listQuestions = $this->connection->getResults();
|
||||
$possibleResponsesContent = [];
|
||||
$keywordsResponses = [];
|
||||
$gatewayKeyword = new GatewayKeyword();
|
||||
$gatewayPossibleResponse = new GatewayPossibleResponse();
|
||||
|
||||
if (!empty($listQuestions)) {
|
||||
|
||||
for ($i = 0; $i < count($listQuestions); $i++) {
|
||||
|
||||
if ($listQuestions[$i]["type"] != "BusinessClass/TextQuestion") {
|
||||
$idQuestion = $listQuestions[$i]["id"];
|
||||
$possibleResponses = $gatewayPossibleResponse->getPossibleResponseByQuestion($idQuestion);
|
||||
$tmpTabKeyword = [];
|
||||
$tmpTabPossibleResponse = [];
|
||||
|
||||
foreach ($possibleResponses as $row) {
|
||||
$tmpTabKeyword[] = $gatewayKeyword->getKeywordsContentByReference($row["id"]);
|
||||
$tmpTabPossibleResponse[] = $row["content"];
|
||||
}
|
||||
|
||||
$possibleResponsesContent[] = $tmpTabPossibleResponse;
|
||||
$keywordsResponses[] = $tmpTabKeyword;
|
||||
} else {
|
||||
$possibleResponsesContent[] = null;
|
||||
$keywordsResponses[] = null;
|
||||
}
|
||||
}
|
||||
return array($listQuestions, $possibleResponsesContent, $keywordsResponses);
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de récupérer le contenu d'une réponse à une question par son id.
|
||||
*
|
||||
* @param string $id Id de la question cible
|
||||
*
|
||||
* @return string Retourne le contenu de la question ciblé
|
||||
*/
|
||||
public function getQuestionContentById(string $id): string
|
||||
{
|
||||
$query = "SELECT content FROM Question WHERE id = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($id, PDO::PARAM_INT)
|
||||
));
|
||||
|
||||
return $this->connection->getResults()[0][0];
|
||||
}
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace API\script\Gateway;
|
||||
|
||||
use Config\Connection;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Permet d'accéder, d'écrire ou de modifier les données contenues dans la table Response
|
||||
* afin de récupérer les réponses d'un utilisateur.
|
||||
*/
|
||||
class GatewayResponse
|
||||
{
|
||||
/**
|
||||
* @var Connection
|
||||
*/
|
||||
private Connection $connection;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de récupérer la liste des réponses d'un candidat ainsi que les Keyword couvert pour chaque réponse.
|
||||
*
|
||||
* @param int $listResponsesOfCandidateId Id du candidat
|
||||
*
|
||||
* @return array Retourne une liste contenant à l'indice 0 la liste de réponse
|
||||
* et à l'indice 1 une liste de liste de Keword,
|
||||
* où chaque indice d'une liste de question est associé au même indice une réponse
|
||||
*/
|
||||
public function getCatgoriezeOfResponsesIdByIdListCandidate(int $listResponsesOfCandidateId): array
|
||||
{
|
||||
$result = $this->getResponsesByIdListCandidate($listResponsesOfCandidateId);
|
||||
$tab = [];
|
||||
foreach ($result as $row) {
|
||||
$tab[] = (new GatewayKeyword())->getKeywordsContentByCategorieze($row['id']);
|
||||
}
|
||||
|
||||
return array($result, $tab);
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de récupérer la liste des réponses d'un candidat par son id.
|
||||
*
|
||||
* @param int $listResponsesOfCandidateId Id du candidat
|
||||
*
|
||||
* @return array Retourne la list des réponses du candidat
|
||||
*/
|
||||
public function getResponsesByIdListCandidate(int $listResponsesOfCandidateId): array
|
||||
{
|
||||
$query = "SELECT r.* FROM Response r, Submit s WHERE s.responsesCandidate = :id AND r.id = s.response";
|
||||
return $this->getResponsesByQueryAndIdListCandidate($query, $listResponsesOfCandidateId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de récupérer la liste des id des réponses d'un candidat par son id.
|
||||
*
|
||||
* @param int $listResponsesOfCandidateId Id du candidat
|
||||
*
|
||||
* @return array Retourne la list des id des réponses du candidat
|
||||
*/
|
||||
public function getResponsesIdByIdListCandidate(int $listResponsesOfCandidateId): array
|
||||
{
|
||||
$query = "SELECT r.id FROM Response r, Submit s WHERE s.responseCandidate = :id AND r.id = s.response";
|
||||
return $this->getResponsesByQueryAndIdListCandidate($query, $listResponsesOfCandidateId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de récupérer une liste de format de réponse définit par la commande sql passé en paramètre,
|
||||
* dont l'id du candidat, ayant formulé ces réponses, est passé en paramètre.
|
||||
*
|
||||
* @param string $query Requête du format de liste de réponse voulu
|
||||
* @param int $id Id du candidat cible
|
||||
*
|
||||
* @return array Retourne la liste des réponses d'un candidat selon le format voulu
|
||||
*/
|
||||
private function getResponsesByQueryAndIdListCandidate(string $query, int $id): array
|
||||
{
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($id, PDO::PARAM_INT)
|
||||
));
|
||||
return $this->connection->getResults();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de supprimer la réponse et ses liens avec les différents Keyword
|
||||
* selon l'id de la réponse passée en paramêtre
|
||||
*
|
||||
* @param int $responseId Id de la réponse à supprimer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteResponseById(int $responseId): void
|
||||
{
|
||||
$query = "DELETE FROM Categorize WHERE response = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($responseId, PDO::PARAM_INT)
|
||||
));
|
||||
|
||||
$query = "DELETE FROM Submit WHERE response = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($responseId, PDO::PARAM_INT)
|
||||
));
|
||||
|
||||
$query = "DELETE FROM Response WHERE id = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($responseId, PDO::PARAM_INT)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet d'insérer une réponse ainsi que de la lier avec les Keywords passés en paramètre.
|
||||
*
|
||||
* @param string $content Contenu de la réponse
|
||||
* @param string $questionContent Contenu de la question, dans le cas où la question viendra à changer dans le futur
|
||||
* @param array $category Liste des Keyword associé à la réponse
|
||||
*
|
||||
* @return int Retourne l'Id de la réponse insérée
|
||||
*/
|
||||
public function insertResponse(string $content, string $questionContent, array $category): int
|
||||
{
|
||||
$query = "INSERT INTO Response(content, questionContent) VALUES (:content, :questionContent)";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':content' => array($content, PDO::PARAM_STR),
|
||||
':questionContent' => array($questionContent, PDO::PARAM_STR)
|
||||
));
|
||||
|
||||
$idResponse = $this->connection->lastInsertId();
|
||||
|
||||
foreach ($category as $keyword) {
|
||||
$query = "INSERT INTO Categorize (response, keyword) VALUES(:response, :keyword)";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':response' => array($idResponse, PDO::PARAM_STR),
|
||||
':keyword' => array($keyword, PDO::PARAM_STR)
|
||||
));
|
||||
}
|
||||
|
||||
return $idResponse;
|
||||
}
|
||||
}
|
@ -0,0 +1,306 @@
|
||||
<?php
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2012 Danny van Kooten <hi@dannyvankooten.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Config;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class AltoRouter
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array Array of all routes (incl. named routes).
|
||||
*/
|
||||
protected $routes = [];
|
||||
|
||||
/**
|
||||
* @var array Array of all named routes.
|
||||
*/
|
||||
protected $namedRoutes = [];
|
||||
|
||||
/**
|
||||
* @var string Can be used to ignore leading part of the Request URL (if main file lives in subdirectory of host)
|
||||
*/
|
||||
protected $basePath = '';
|
||||
|
||||
/**
|
||||
* @var array Array of default match types (regex helpers)
|
||||
*/
|
||||
protected $matchTypes = [
|
||||
'i' => '[0-9]++',
|
||||
'a' => '[0-9A-Za-z]++',
|
||||
'h' => '[0-9A-Fa-f]++',
|
||||
'*' => '.+?',
|
||||
'**' => '.++',
|
||||
'' => '[^/\.]++'
|
||||
];
|
||||
|
||||
/**
|
||||
* Create router in one call from config.
|
||||
*
|
||||
* @param array $routes
|
||||
* @param string $basePath
|
||||
* @param array $matchTypes
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(array $routes = [], $basePath = '', array $matchTypes = [])
|
||||
{
|
||||
$this->addRoutes($routes);
|
||||
$this->setBasePath($basePath);
|
||||
$this->addMatchTypes($matchTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all routes.
|
||||
* Useful if you want to process or display routes.
|
||||
* @return array All routes.
|
||||
*/
|
||||
public function getRoutes()
|
||||
{
|
||||
return $this->routes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add multiple routes at once from array in the following format:
|
||||
*
|
||||
* $routes = [
|
||||
* [$method, $route, $target, $name]
|
||||
* ];
|
||||
*
|
||||
* @param array $routes
|
||||
* @return void
|
||||
* @author Koen Punt
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addRoutes($routes)
|
||||
{
|
||||
if (!is_array($routes) && !$routes instanceof Traversable) {
|
||||
throw new RuntimeException('Routes should be an array or an instance of Traversable');
|
||||
}
|
||||
foreach ($routes as $route) {
|
||||
call_user_func_array([$this, 'map'], $route);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the base path.
|
||||
* Useful if you are running your application from a subdirectory.
|
||||
* @param string $basePath
|
||||
*/
|
||||
public function setBasePath($basePath)
|
||||
{
|
||||
$this->basePath = $basePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add named match types. It uses array_merge so keys can be overwritten.
|
||||
*
|
||||
* @param array $matchTypes The key is the name and the value is the regex.
|
||||
*/
|
||||
public function addMatchTypes(array $matchTypes)
|
||||
{
|
||||
$this->matchTypes = array_merge($this->matchTypes, $matchTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a route to a target
|
||||
*
|
||||
* @param string $method One of 5 HTTP Methods, or a pipe-separated list of multiple HTTP Methods (GET|POST|PATCH|PUT|DELETE)
|
||||
* @param string $route The route regex, custom regex must start with an @. You can use multiple pre-set regex filters, like [i:id]
|
||||
* @param mixed $target The target where this route should point to. Can be anything.
|
||||
* @param string $name Optional name of this route. Supply if you want to reverse route this url in your application.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function map($method, $route, $target, $name = null)
|
||||
{
|
||||
|
||||
$this->routes[] = [$method, $route, $target, $name];
|
||||
|
||||
if ($name) {
|
||||
if (isset($this->namedRoutes[$name])) {
|
||||
throw new RuntimeException("Can not redeclare route '{$name}'");
|
||||
}
|
||||
$this->namedRoutes[$name] = $route;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reversed routing
|
||||
*
|
||||
* Generate the URL for a named route. Replace regexes with supplied parameters
|
||||
*
|
||||
* @param string $routeName The name of the route.
|
||||
* @param array @params Associative array of parameters to replace placeholders with.
|
||||
* @return string The URL of the route with named parameters in place.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function generate($routeName, array $params = [])
|
||||
{
|
||||
|
||||
// Check if named route exists
|
||||
if (!isset($this->namedRoutes[$routeName])) {
|
||||
throw new RuntimeException("Route '{$routeName}' does not exist.");
|
||||
}
|
||||
|
||||
// Replace named parameters
|
||||
$route = $this->namedRoutes[$routeName];
|
||||
|
||||
// prepend base path to route url again
|
||||
$url = $this->basePath . $route;
|
||||
|
||||
if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
|
||||
foreach ($matches as $index => $match) {
|
||||
list($block, $pre, $type, $param, $optional) = $match;
|
||||
|
||||
if ($pre) {
|
||||
$block = substr($block, 1);
|
||||
}
|
||||
|
||||
if (isset($params[$param])) {
|
||||
// Part is found, replace for param value
|
||||
$url = str_replace($block, $params[$param], $url);
|
||||
} elseif ($optional && $index !== 0) {
|
||||
// Only strip preceding slash if it's not at the base
|
||||
$url = str_replace($pre . $block, '', $url);
|
||||
} else {
|
||||
// Strip match block
|
||||
$url = str_replace($block, '', $url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Match a given Request Url against stored routes
|
||||
* @param string $requestUrl
|
||||
* @param string $requestMethod
|
||||
* @return array|boolean Array with route information on success, false on failure (no match).
|
||||
*/
|
||||
public function match($requestUrl = null, $requestMethod = null)
|
||||
{
|
||||
|
||||
$params = [];
|
||||
|
||||
// set Request Url if it isn't passed as parameter
|
||||
if ($requestUrl === null) {
|
||||
$requestUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
|
||||
}
|
||||
|
||||
// strip base path from request url
|
||||
$requestUrl = substr($requestUrl, strlen($this->basePath));
|
||||
|
||||
// Strip query string (?a=b) from Request Url
|
||||
if (($strpos = strpos($requestUrl, '?')) !== false) {
|
||||
$requestUrl = substr($requestUrl, 0, $strpos);
|
||||
}
|
||||
|
||||
$lastRequestUrlChar = $requestUrl ? $requestUrl[strlen($requestUrl)-1] : '';
|
||||
|
||||
// set Request Method if it isn't passed as a parameter
|
||||
if ($requestMethod === null) {
|
||||
$requestMethod = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
|
||||
}
|
||||
|
||||
foreach ($this->routes as $handler) {
|
||||
list($methods, $route, $target, $name) = $handler;
|
||||
|
||||
$method_match = (stripos($methods, $requestMethod) !== false);
|
||||
|
||||
// Method did not match, continue to next route.
|
||||
if (!$method_match) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($route === '*') {
|
||||
// * wildcard (matches all)
|
||||
$match = true;
|
||||
} elseif (isset($route[0]) && $route[0] === '@') {
|
||||
// @ regex delimiter
|
||||
$pattern = '`' . substr($route, 1) . '`u';
|
||||
$match = preg_match($pattern, $requestUrl, $params) === 1;
|
||||
} elseif (($position = strpos($route, '[')) === false) {
|
||||
// No params in url, do string comparison
|
||||
$match = strcmp($requestUrl, $route) === 0;
|
||||
} else {
|
||||
// Compare longest non-param string with url before moving on to regex
|
||||
// Check if last character before param is a slash, because it could be optional if param is optional too (see https://github.com/dannyvankooten/AltoRouter/issues/241)
|
||||
if (strncmp($requestUrl, $route, $position) !== 0 && ($lastRequestUrlChar === '/' || $route[$position-1] !== '/')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$regex = $this->compileRoute($route);
|
||||
$match = preg_match($regex, $requestUrl, $params) === 1;
|
||||
}
|
||||
|
||||
if ($match) {
|
||||
if ($params) {
|
||||
foreach ($params as $key => $value) {
|
||||
if (is_numeric($key)) {
|
||||
unset($params[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'target' => $target,
|
||||
'params' => $params,
|
||||
'name' => $name
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile the regex for a given route (EXPENSIVE)
|
||||
* @param $route
|
||||
* @return string
|
||||
*/
|
||||
protected function compileRoute($route)
|
||||
{
|
||||
if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
|
||||
$matchTypes = $this->matchTypes;
|
||||
foreach ($matches as $match) {
|
||||
list($block, $pre, $type, $param, $optional) = $match;
|
||||
|
||||
if (isset($matchTypes[$type])) {
|
||||
$type = $matchTypes[$type];
|
||||
}
|
||||
if ($pre === '.') {
|
||||
$pre = '\.';
|
||||
}
|
||||
|
||||
$optional = $optional !== '' ? '?' : null;
|
||||
|
||||
//Older versions of PCRE require the 'P' in (?P<named>)
|
||||
$pattern = '(?:'
|
||||
. ($pre !== '' ? $pre : null)
|
||||
. '('
|
||||
. ($param !== '' ? "?P<$param>" : null)
|
||||
. $type
|
||||
. ')'
|
||||
. $optional
|
||||
. ')'
|
||||
. $optional;
|
||||
|
||||
$route = str_replace($block, $pattern, $route);
|
||||
}
|
||||
}
|
||||
return "`^$route$`u";
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use PDO;
|
||||
use PDOStatement;
|
||||
|
||||
/**
|
||||
* Définit une connection à la base de données.
|
||||
*/
|
||||
class Connection extends PDO
|
||||
{
|
||||
/**
|
||||
* @var PDOStatement
|
||||
*/
|
||||
private PDOStatement $stmt;
|
||||
|
||||
public function __construct(string $dsn, string $username, string $password)
|
||||
{
|
||||
parent::__construct($dsn, $username, $password);
|
||||
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Éxécute une réquête SQL.
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $parameters
|
||||
* @return bool Returns `true` on success, `false` otherwise
|
||||
*/
|
||||
public function executeQuery(string $query, array $parameters = []): bool
|
||||
{
|
||||
$this->stmt = parent::prepare($query);
|
||||
foreach ($parameters as $name => $value) {
|
||||
$this->stmt->bindValue($name, $value[0], $value[1]);
|
||||
}
|
||||
|
||||
return $this->stmt->execute();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Permet de récupère le résultat de la dernière réquête éxecuté avec
|
||||
* la fonction executeQuery().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getResults(): array
|
||||
{
|
||||
return $this->stmt->fetchAll();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class InexistantLoginException extends Exception
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct("Identifiant inexistant");
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Exceptions;
|
||||
|
||||
use Exception;
|
||||
class InvalidLoginOrPasswordException extends Exception
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct("Identifiant ou mot de passe invalide");
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class InvalidUsernameOrPasswordException extends Exception
|
||||
{
|
||||
public function __construct($message = "nom d'utilisateur ou mot de passe invalide", $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
.acolorba {
|
||||
background-color: #006D82;
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: auto;
|
||||
height: 100px;
|
||||
padding: 24px 0;
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 450px;
|
||||
margin: 0 auto;
|
||||
background: white;
|
||||
border-radius: 24px;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
#main-content {
|
||||
margin-right: 10px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.content {
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
input {
|
||||
max-width: 350px;
|
||||
padding: 12px 16px;
|
||||
height: 48px;
|
||||
background: #ffffff;
|
||||
border: 1px solid #CACAC9;
|
||||
border-radius: 12px;
|
||||
color: #4A4A49;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 24px;
|
||||
line-height: 150%;
|
||||
color: #6D6D6C;
|
||||
text-align: center;
|
||||
margin: 0 0 24px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
body, p, span, div, a, h1, h2, h3, h4, h5, h6{
|
||||
font-family: 'Barlow', sans-serif;
|
||||
}
|
||||
|
||||
.margin-space {
|
||||
margin: 12px;
|
||||
}
|
||||
|
||||
button{
|
||||
padding: 12px 32px;
|
||||
background: #006D82 !important;
|
||||
border-radius: 12px;
|
||||
height: 48px;
|
||||
border: none;
|
||||
color: white;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
background-color: transparent;
|
||||
color: #018786 !important;
|
||||
margin: 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #006D82 !important;
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
body {
|
||||
background: #eee
|
||||
}
|
||||
|
||||
#regForm {
|
||||
background-color: #ffffff;
|
||||
margin: 0px auto;
|
||||
font-family: Poppins;
|
||||
padding: 40px;
|
||||
border-radius: 30px;
|
||||
background-color: rgba(23,143,150,0.7);
|
||||
}
|
||||
|
||||
#register{
|
||||
color: white;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
font-family: Poppins;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
input {
|
||||
padding: 10px;
|
||||
width: 100%;
|
||||
font-size: 17px;
|
||||
font-family: Raleway;
|
||||
border: 1px solid #aaaaaa;
|
||||
border-radius: 10px;
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.tab input:focus{
|
||||
|
||||
border:1px solid #6a1b9a !important;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
input.invalid {
|
||||
|
||||
border:1px solid #e03a0666;
|
||||
}
|
||||
|
||||
.tab {
|
||||
display: none
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: #6A1B9A;
|
||||
color: #ffffff;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
padding: 10px 20px;
|
||||
font-size: 17px;
|
||||
font-family: Raleway;
|
||||
cursor: pointer
|
||||
}
|
||||
|
||||
button:hover {
|
||||
opacity: 0.8
|
||||
}
|
||||
|
||||
button:focus{
|
||||
|
||||
outline: none !important;
|
||||
}
|
||||
|
||||
#prevBtn {
|
||||
background-color: #bbbbbb
|
||||
}
|
||||
|
||||
|
||||
.all-steps{
|
||||
text-align: center;
|
||||
margin-top: 30px;
|
||||
margin-bottom: 30px;
|
||||
width: 100%;
|
||||
display: inline-flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.step {
|
||||
height: 10px;
|
||||
width: 10px;
|
||||
margin: 0 2px;
|
||||
background-color: #bbbbbb;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 15px;
|
||||
color: #6a1b9a;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.step.active {
|
||||
opacity: 1
|
||||
}
|
||||
|
||||
|
||||
.step.finish {
|
||||
color: #fff;
|
||||
background: green;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.all-steps {
|
||||
text-align: center;
|
||||
margin-top: 30px;
|
||||
margin-bottom: 30px
|
||||
}
|
||||
|
||||
.thanks-message {
|
||||
display: none
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<?php
|
||||
global $googleApis, $googleStatic, $poppins, $icon, $logoUCA;
|
||||
?>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.grid-min.css">
|
||||
<link rel="stylesheet" href="Views\CSS\adminLogin.css">
|
||||
<link rel="preconnect" href="<?php echo $googleApis; ?>">
|
||||
<link rel="preconnect" href="<?php echo $googleStatic; ?>" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Barlow&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
<body class="acolorba d-flex flex-column align-items-center">
|
||||
<img src="Views\IMAGES\logoUca.png" class="logo">
|
||||
<article class="card">
|
||||
<main id="main-content">
|
||||
<section id="content">
|
||||
<form method="post" action="login" class="d-flex flex-column align-items-center">
|
||||
<h3>Service d'authentification</h3>
|
||||
<div id="adminRegistrationErrorPanel" class="margin-space">
|
||||
<?php
|
||||
if (isset($error)) {
|
||||
echo $error;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<label class="margin-space" for="login">
|
||||
<input type="text" name="login" id="login" placeholder="Identifiant" required>
|
||||
</label>
|
||||
<label class="margin-space" for="password">
|
||||
<input type="password" name="password" id="password" placeholder="Mot de passe" required>
|
||||
</label>
|
||||
<button class="margin-space" name="submitBtn" type="submit">Se connecter</button>
|
||||
</form>
|
||||
</section>
|
||||
</main>
|
||||
</article>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="Views/CSS/common.css">
|
||||
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
|
||||
<body class="d-flex flex-column align-items-center">
|
||||
<h1><?php echo $error ?></h1>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<?php
|
||||
global $googleApis, $googleStatic, $poppins, $icon, $logoUCA;
|
||||
?>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="Views/CSS/styles.css" />
|
||||
<link rel="stylesheet" href="Views/CSS/stylesForm.css" />
|
||||
<link rel="preconnect" href="<?php echo $googleApis; ?>">
|
||||
<link rel="preconnect" href="<?php echo $googleStatic; ?>" crossorigin>
|
||||
<link href="<?php echo $poppins; ?>" rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css" rel="stylesheet" />
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
|
||||
<title>Formulaire de témoignage</title>
|
||||
<link rel="shortcut icon" href="<?php echo $icon; ?>" type="image/x-icon">
|
||||
<link rel="icon" href="<?php echo $icon; ?>" type="image/x-icon">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header class="py-1">
|
||||
<div class="container px-4 px-lg-5 my-5">
|
||||
<div class="text-center text-white">
|
||||
<h1 class="display-4 fw-bolder">Les Témoignages</h1>
|
||||
<p class="lead fw-normal text-white-50 mb-0">IUT Informatique de Clermont-Ferrand</p>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class='container mt-5'>
|
||||
<div class='row d-flex justify-content-center align-items-center'>
|
||||
<div class='col-md-8'>
|
||||
<div class="text-center">
|
||||
<h2>Merci d'avoir participé à ce questionnaire !</h2>
|
||||
<p>Nous vous recontacterons si votre profil nous intéresse.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="Views/JS/scripts.js"></script>
|
||||
<script src="Views/JS/getData-Ids.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
After Width: | Height: | Size: 6.4 KiB |
@ -0,0 +1,68 @@
|
||||
var currentTab = 0;
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
|
||||
|
||||
showTab(currentTab);
|
||||
|
||||
});
|
||||
|
||||
function showTab(n) {
|
||||
var x = document.getElementsByClassName("tab");
|
||||
x[n].style.display = "block";
|
||||
if (n == 0) {
|
||||
document.getElementById("prevBtn").style.display = "none";
|
||||
} else {
|
||||
document.getElementById("prevBtn").style.display = "inline";
|
||||
}
|
||||
if (n == (x.length - 1)) {
|
||||
document.getElementById("nextBtn").innerHTML = '<i class="fa fa-angle-double-right"></i>';
|
||||
} else {
|
||||
document.getElementById("nextBtn").innerHTML = '<i class="fa fa-angle-double-right"></i>';
|
||||
}
|
||||
fixStepIndicator(n)
|
||||
}
|
||||
|
||||
function nextPrev(n) {
|
||||
var x = document.getElementsByClassName("tab");
|
||||
if (n == 1 && !validateForm()) return false;
|
||||
x[currentTab].style.display = "none";
|
||||
currentTab = currentTab + n;
|
||||
if (currentTab >= x.length) {
|
||||
|
||||
document.getElementById("nextprevious").style.display = "none";
|
||||
document.getElementById("all-steps").style.display = "none";
|
||||
document.getElementById("register").style.display = "none";
|
||||
document.getElementById("text-message").style.display = "block";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
showTab(currentTab);
|
||||
}
|
||||
|
||||
function validateForm() {
|
||||
var x, y, i, valid = true;
|
||||
x = document.getElementsByClassName("tab");
|
||||
y = x[currentTab].getElementsByTagName("input");
|
||||
for (i = 0; i < y.length; i++) {
|
||||
if (y[i].value == "") {
|
||||
y[i].className += " invalid";
|
||||
valid = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (valid) {
|
||||
document.getElementsByClassName("step")[currentTab].className += " finish";
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
function fixStepIndicator(n) {
|
||||
var i, x = document.getElementsByClassName("step");
|
||||
for (i = 0; i < x.length; i++) {
|
||||
x[i].className = x[i].className.replace(" active", "");
|
||||
}
|
||||
x[n].className += " active";
|
||||
}
|
Loading…
Reference in new issue