diff --git a/Source/API/script/Gateway/GatewayQuestion.php b/Source/API/script/Gateway/GatewayQuestion.php index 14bc153..6be7cc8 100644 --- a/Source/API/script/Gateway/GatewayQuestion.php +++ b/Source/API/script/Gateway/GatewayQuestion.php @@ -99,32 +99,64 @@ class GatewayQuestion { $query = "SELECT * FROM Question WHERE form = :form"; $this->connection->executeQuery($query, array( - ':form' => array($idForm, PDO::PARAM_STR) + ':form' => array($idForm, PDO::PARAM_INT) )); + $listQuestions = $this->connection->getResults(); + $possibleResponses = []; + $possibleResponsesContent = []; + $keywordsResponses = []; + if(!empty($resultQuestion)) { - $resultQuestion = $this->connection->getResults(); - $possibleResponse = []; - $keywordResponse = []; + for ($i = 0; $i < count($resultQuestion); $i++) { + + if ($resultQuestion[$i]["type"] != "BusinessClass/TextQuestion") { - if(!empty($resultQuestion)) - { - for ($i=0; $i < count($resultQuestion); $i++) - { - if($resultQuestion[$i]["type"]!="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) )); - $possibleResponse[] = $this->connection->getResults(); + $possibleResponses[] = $this->connection->getResults(); + + $tmpTab = []; + foreach ($possibleResponses[$i] as $row){ + $query = "SELECT k.* FROM Keyword k, Reference r + WHERE k.word = r.keyword AND r.possibleResponse = :id"; + $this->connection->executeQuery($query, array( + ':id' => array($row["id"], PDO::PARAM_INT) + )); + + $tmpTab[] = $this->connection->getResults(); + + var_dump($tmpTab); + + $possibleResponsesContent[] = $row["content"]; + } + $keywordsResponses[] = $tmpTab["word"]; + } + else{ + $possibleResponses[] = null; + $keywordsResponses[] = null; + } + } + return array($resultQuestion, $possibleResponsesContent, $keywordsResponses); + } + return array(); + + + /* + if(!empty($resultQuestion)) + { + for ($i=0; $i < count($resultQuestion); $i++) + { + if($resultQuestion[$i]["type"]!="BusinessClass/TextQuestion") + { $tmpTab = []; foreach ($possibleResponse[$i] as $row){ - var_dump($row); $query = "SELECT k.* FROM Keyword k, Reference r WHERE k.word = r.keyword AND r.possibleResponse = :id"; $this->connection->executeQuery($query, array( @@ -132,16 +164,22 @@ class GatewayQuestion )); $tmpTab[] = $this->connection->getResults(); + + var_dump($tmpTab); + + $possibleResponsesContent[] = $row["content"]; } - $keywordResponse[] = $tmpTab; + $keywordResponse[] = $tmpTab["word"]; } else{ $possibleResponse[] = null; $keywordResponse[] = null; } } - return array($resultQuestion, $possibleResponse, $keywordResponse); + return array($resultQuestion, $possibleResponsesContent, $keywordResponse); } return array(); + + */ } } \ No newline at end of file diff --git a/Source/Model/ModelAdmin.php b/Source/Model/ModelAdmin.php index bb718e2..87f81b8 100644 --- a/Source/Model/ModelAdmin.php +++ b/Source/Model/ModelAdmin.php @@ -30,6 +30,4 @@ class ModelAdmin (new GatewayForm())->insertForm($form); } } - - } diff --git a/Source/Model/ModelCandidate.php b/Source/Model/ModelCandidate.php index 591b068..a068795 100644 --- a/Source/Model/ModelCandidate.php +++ b/Source/Model/ModelCandidate.php @@ -39,6 +39,8 @@ class ModelCandidate $description = $form[0]['description']; $questionsTab = (new GatewayQuestion())->getAllQuestions($form[0]['id']); + var_dump($questionsTab); + $questions = []; for($i = 0; $i < count($questionsTab[0]); $i++) @@ -51,6 +53,7 @@ class ModelCandidate { $possiblesResponses = $questionsTab[1][$i]; $content = $questionsTab[0][$i]['content']; + $categories = $questionsTab[2][$i]; $id = $questionsTab[0][$i]['id'];