From d44e655d8e75a877fe718e4fe8673ca8597bdf3c Mon Sep 17 00:00:00 2001 From: Alexis Date: Tue, 7 Feb 2023 10:22:24 +0100 Subject: [PATCH] Test the merge --- .../Gateway/GatewayListResponseOfCandidate.php | 5 ++--- Source/API/script/Gateway/GatewayResponse.php | 9 +++++---- Source/Model/ModelCandidate.php | 13 +++---------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/Source/API/script/Gateway/GatewayListResponseOfCandidate.php b/Source/API/script/Gateway/GatewayListResponseOfCandidate.php index 7416537..4742b01 100644 --- a/Source/API/script/Gateway/GatewayListResponseOfCandidate.php +++ b/Source/API/script/Gateway/GatewayListResponseOfCandidate.php @@ -65,8 +65,8 @@ class GatewayListResponseOfCandidate $query = "INSERT INTO ListResponsesOfCandidate(date, titleForm) VALUES(:date, :titleForm)"; $this->connection->executeQuery($query, array( - ':date' => array(date('d-m-y h:i:s'), PDO::PARAM_STR), - 'titleForm' => array($titleForm, PDO::PARAM_STR) + ':date' => array(date('Y-m-d H:i:s'), PDO::PARAM_STR), + ':titleForm' => array($titleForm, PDO::PARAM_STR) )); $idListQuestion = $this->connection->lastInsertId(); @@ -75,7 +75,6 @@ class GatewayListResponseOfCandidate { $idResponse = $gatewayResponse->insertResponse($gatewayQuestion->getQuestionContentById($id[$i]), $answer[$i], $category[$i]); - $query = "INSERT INTO Submit (responsesCandidate, response) VALUES(:responsesCandidate, :response)"; $this->connection->executeQuery($query, array( ':responsesCandidate' => array($idListQuestion, PDO::PARAM_STR), diff --git a/Source/API/script/Gateway/GatewayResponse.php b/Source/API/script/Gateway/GatewayResponse.php index 4c4b921..c98c713 100644 --- a/Source/API/script/Gateway/GatewayResponse.php +++ b/Source/API/script/Gateway/GatewayResponse.php @@ -53,21 +53,22 @@ class GatewayResponse )); } - public function insertResponse(string $content, string $question, array $category): int + public function insertResponse(string $content, string $questionContent, array $category): int { - $query = "INSERT INTO Response(content, question) VALUES (:content, :question)"; + $query = "INSERT INTO Response(content, questionContent) VALUES (:content, :questionContent)"; $this->connection->executeQuery($query, array( ':content' => array($content, PDO::PARAM_STR), - ':question' => array($question, 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) + ':keyword' => array($keyword, PDO::PARAM_STR) )); } diff --git a/Source/Model/ModelCandidate.php b/Source/Model/ModelCandidate.php index 4dbe3c9..d4de148 100644 --- a/Source/Model/ModelCandidate.php +++ b/Source/Model/ModelCandidate.php @@ -3,9 +3,8 @@ namespace Model; use API\script\Gateway\GatewayForm; +use API\script\Gateway\GatewayListResponseOfCandidate; use API\script\Gateway\GatewayQuestion; -use API\script\Gateway\GatewayResponse; -use BusinessClass\TextQuestion; class ModelCandidate { @@ -29,14 +28,8 @@ class ModelCandidate $category[] = $categs; } - var_dump($id); - echo "
"; - var_dump($answer); - echo "
"; - var_dump($category); - echo "

"; - - (new GatewayResponse())->insertResponse($id, $answer, $category); + $titleForm = (new GatewayForm())->getForm()[0]["title"]; + (new GatewayListResponseOfCandidate())->insertListResponsesOfCandidate($id, $answer, $category, $titleForm); } public function getForm(): string