From 9e077c8939761ccaec4e3a0bce521c5e3d8bb92d Mon Sep 17 00:00:00 2001 From: Alexis Date: Tue, 28 Feb 2023 12:24:19 +0100 Subject: [PATCH] Print responses and categories into Admin Page without CSS --- Source/API/script/Gateway/GatewayForm.php | 2 +- Source/API/script/Gateway/GatewayKeyword.php | 2 +- Source/API/script/Gateway/GatewayResponse.php | 2 +- Source/Controller/ControllerAdmin.php | 2 ++ Source/Model/ModelAdmin.php | 22 +++++++++++++-- Source/Views/HTML/admin.php | 28 +++++++++++++++++++ 6 files changed, 53 insertions(+), 5 deletions(-) diff --git a/Source/API/script/Gateway/GatewayForm.php b/Source/API/script/Gateway/GatewayForm.php index 73c18f3..788f825 100644 --- a/Source/API/script/Gateway/GatewayForm.php +++ b/Source/API/script/Gateway/GatewayForm.php @@ -55,7 +55,7 @@ class GatewayForm $query = "SELECT * FROM Form"; $this->connection->executeQuery($query); - return $this->connection->getResults(); + var_dump($this->connection->getResults()); } /** diff --git a/Source/API/script/Gateway/GatewayKeyword.php b/Source/API/script/Gateway/GatewayKeyword.php index 4234cfe..b68381c 100644 --- a/Source/API/script/Gateway/GatewayKeyword.php +++ b/Source/API/script/Gateway/GatewayKeyword.php @@ -94,7 +94,7 @@ class GatewayKeyword */ public function getKeywordsContentByCategorieze(int $id): array { - $query = "SELECT k.* FROM Keyword k, Categorieze c + $query = "SELECT k.* FROM Keyword k, Categorize c WHERE k.word = c.keyword AND c.response = :id"; return $this->getKeywordByAssotiation($id , $query); diff --git a/Source/API/script/Gateway/GatewayResponse.php b/Source/API/script/Gateway/GatewayResponse.php index b22e400..114f4b0 100644 --- a/Source/API/script/Gateway/GatewayResponse.php +++ b/Source/API/script/Gateway/GatewayResponse.php @@ -50,7 +50,7 @@ class GatewayResponse */ public function getResponsesByIdListCandidate(int $listResponsesOfCandidateId): array { - $query = "SELECT r.* FROM Response r, Submit s WHERE s.responseCandidate = :id AND r.id = s.response"; + $query = "SELECT r.* FROM Response r, Submit s WHERE s.responsesCandidate = :id AND r.id = s.response"; return $this->getResponsesByQueryAndIdListCandidate($query, $listResponsesOfCandidateId); } diff --git a/Source/Controller/ControllerAdmin.php b/Source/Controller/ControllerAdmin.php index dcf4d89..2e349a5 100644 --- a/Source/Controller/ControllerAdmin.php +++ b/Source/Controller/ControllerAdmin.php @@ -93,6 +93,8 @@ class ControllerAdmin { $categories = (new ModelAdmin())->getCategories(); $questions = (new ModelAdmin())->getQuestions(); + $responsesCandidate = (new ModelAdmin())->getResponsesCandidate(); + global $rep, $views; require_once($rep.$views['admin']); } diff --git a/Source/Model/ModelAdmin.php b/Source/Model/ModelAdmin.php index 22653ca..034a99b 100644 --- a/Source/Model/ModelAdmin.php +++ b/Source/Model/ModelAdmin.php @@ -4,6 +4,7 @@ namespace Model; use API\script\Gateway\GatewayForm; use API\script\Gateway\GatewayKeyword; +use API\script\Gateway\GatewayListResponseOfCandidate; use API\script\Gateway\GatewayQuestion; use BusinessClass\Form; @@ -14,8 +15,8 @@ use BusinessClass\Form; class ModelAdmin { /** - * Permet de créer et d'ajouter une question et de retourner son ID afin de la reconnaitre facilement dans - * la suite du code. + * Permet de créer et d'ajouter une question et de retourner son ID afin de la + * reconnaitre facilement dans la suite du code. * * @return int */ @@ -105,4 +106,21 @@ class ModelAdmin $questionsArray = (new GatewayQuestion())->getAllQuestions($idForm); return Factory::getBuiltObjects($questionsArray, "Question"); } + + + /** + * Permet de récupérer toutes les réponses existantes. + * + * @return array + */ + public function getResponsesCandidate(): array + { + $responsesCandidate = (new GatewayListResponseOfCandidate())->getAllListResponsesOfCandidate(); + $results = []; + foreach ($responsesCandidate as $response) { + $results[] = (new GatewayListResponseOfCandidate())->getDetailsListResponsesOfCandidate($response["id"]); + } + + return $results; + } } diff --git a/Source/Views/HTML/admin.php b/Source/Views/HTML/admin.php index 9530637..92f982c 100644 --- a/Source/Views/HTML/admin.php +++ b/Source/Views/HTML/admin.php @@ -82,6 +82,34 @@ +
+ +
+ + +

Catégories associées : + +

+ +

Question :

+

Réponse :

+ + +

+ +
+
+