From f580b7d45e102a562b3082788386634bf2a94703 Mon Sep 17 00:00:00 2001 From: Alexis Date: Wed, 1 Feb 2023 17:58:36 +0100 Subject: [PATCH] finish getAllQuestion test --- Source/API/script/Gateway/GatewayQuestion.php | 23 +++++++++++-------- Source/Model/ModelCandidate.php | 1 - 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Source/API/script/Gateway/GatewayQuestion.php b/Source/API/script/Gateway/GatewayQuestion.php index bfc9aac..121f39d 100644 --- a/Source/API/script/Gateway/GatewayQuestion.php +++ b/Source/API/script/Gateway/GatewayQuestion.php @@ -107,23 +107,23 @@ class GatewayQuestion $possibleResponsesContent = []; $keywordsResponses = []; - if(!empty($resultQuestion)) { + if(!empty($listQuestions)) { - for ($i = 0; $i < count($resultQuestion); $i++) { + for ($i = 0; $i < count($listQuestions); $i++) { - if ($resultQuestion[$i]["type"] != "BusinessClass/TextQuestion") { + if ($listQuestions[$i]["type"] != "BusinessClass/TextQuestion") { $query = "SELECT pr.* FROM Propose p, PossibleResponse pr WHERE p.question = :questionId AND p.possibleResponse = pr.id"; $this->connection->executeQuery($query, array( - ':questionId' => array($resultQuestion[$i]["id"], PDO::PARAM_INT) + ':questionId' => array($listQuestions[$i]["id"], PDO::PARAM_INT) )); $possibleResponses[] = $this->connection->getResults(); $tmpTabKeyword = []; - $tmptabPossibleResponse = []; + $tmpTabPossibleResponse = []; foreach ($possibleResponses[$i] as $row){ $query = "SELECT k.* FROM Keyword k, Reference r WHERE k.word = r.keyword AND r.possibleResponse = :id"; @@ -131,11 +131,16 @@ class GatewayQuestion ':id' => array($row["id"], PDO::PARAM_INT) )); - $tmpTabKeyword[] = $this->connection->getResults()["word"]; + $tabTmp = []; + foreach ($this->connection->getResults() as $keywords) + { + $tabTmp[] = $keywords["word"]; + } + $tmpTabKeyword[] = $tabTmp; - $tmptabPossibleResponse[] = $row["content"]; + $tmpTabPossibleResponse[] = $row["content"]; } - $possibleResponsesContent[] = $tmptabPossibleResponse; + $possibleResponsesContent[] = $tmpTabPossibleResponse; $keywordsResponses[] = $tmpTabKeyword; } else{ @@ -143,7 +148,7 @@ class GatewayQuestion $keywordsResponses[] = null; } } - return array($resultQuestion, $possibleResponsesContent, $keywordsResponses); + return array($listQuestions, $possibleResponsesContent, $keywordsResponses); } return array(); diff --git a/Source/Model/ModelCandidate.php b/Source/Model/ModelCandidate.php index a068795..635fdf9 100644 --- a/Source/Model/ModelCandidate.php +++ b/Source/Model/ModelCandidate.php @@ -39,7 +39,6 @@ class ModelCandidate $description = $form[0]['description']; $questionsTab = (new GatewayQuestion())->getAllQuestions($form[0]['id']); - var_dump($questionsTab); $questions = [];