From ad69255b812162332b330b94bb8637530f28e1d6 Mon Sep 17 00:00:00 2001 From: Alexis Date: Tue, 7 Feb 2023 14:17:49 +0100 Subject: [PATCH] SonarQube code smells resolve #24 --- .../API/script/Gateway/GatewayListResponseOfCandidate.php | 8 ++++---- Source/API/script/Gateway/GatewayPossibleResponse.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/API/script/Gateway/GatewayListResponseOfCandidate.php b/Source/API/script/Gateway/GatewayListResponseOfCandidate.php index 4742b01..7862ea0 100644 --- a/Source/API/script/Gateway/GatewayListResponseOfCandidate.php +++ b/Source/API/script/Gateway/GatewayListResponseOfCandidate.php @@ -48,7 +48,7 @@ class GatewayListResponseOfCandidate { $gatewayResponse = new GatewayResponse(); - foreach ( $gatewayResponse->getResponsesIdByIdListCandidate($id) as $response){ + foreach ($gatewayResponse->getResponsesIdByIdListCandidate($id) as $response) { $gatewayResponse->deleteResponseById($response); } @@ -71,9 +71,9 @@ class GatewayListResponseOfCandidate $idListQuestion = $this->connection->lastInsertId(); - for($i = 0; $i < count($answer); $i++) - { - $idResponse = $gatewayResponse->insertResponse($gatewayQuestion->getQuestionContentById($id[$i]), $answer[$i], $category[$i]); + 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( diff --git a/Source/API/script/Gateway/GatewayPossibleResponse.php b/Source/API/script/Gateway/GatewayPossibleResponse.php index 6aa3c73..58956d8 100644 --- a/Source/API/script/Gateway/GatewayPossibleResponse.php +++ b/Source/API/script/Gateway/GatewayPossibleResponse.php @@ -16,7 +16,7 @@ class GatewayPossibleResponse public function getPossibleResponseByQuestion(string $idQuestion): array { - $query = "SELECT pr.* FROM Propose p, PossibleResponse pr + $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) @@ -34,4 +34,4 @@ class GatewayPossibleResponse return $this->connection->lastInsertId(); } -} \ No newline at end of file +}