Gateway Question Select(idForm: string): array

AdminInterface
Ness Gaster 2 years ago
parent e275d1f9a2
commit e5c8d75d6f

@ -104,4 +104,48 @@ class GatewayQuestion
$this->connection->executeQuery();
}
public function getAllQuestions(string $idForm): array //revoie un array contenant trois qui pour chaque indice commun de ces 3 array une question, sa liste de reponse possible et sa liste de keyword associer au réponse. les deux autres sont null si c'est une textBox
{
$query = "SELECT * FROM Question WHERE from = :form";
$this->connection->executeQuery($query, array(
':form' => array($idForm, PDO::PARAM_STR)
));
$this->connection->executeQuery();
$resultQuestion = $this->connection->getResults();
$possibleResponse = [];
$keywordResponse = [];
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(
':id' => array($resultQuestion[$i]["id"], PDO::PARAM_STR)
));
$this->connection->executeQuery();
$possibleResponse[] = $this->connection->getResults();
$tmpTab = [];
foreach ($possibleResponse[$i] as $row){
$query = "SELECT k.* FROM Keyword k, Reference r
WHERE k.id = r.keyword AND r.response = :id";
$this->connection->executeQuery($query, array(
':id' => array($row["id"], PDO::PARAM_STR)
));
$this->connection->executeQuery();
$tmpTab[] = $this->connection->getResults();
}
$keywordResponse[] = $tmpTab;
}
else{
$possibleResponse[] = null;
$keywordResponse[] = null;
}
}
return array($resultQuestion, $possibleResponse, $keywordResponse);
}
}
Loading…
Cancel
Save