parent
2b21d0e039
commit
6ee05447aa
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace API\script\Gateway;
|
||||
|
||||
use API\script\Config\Connection;
|
||||
use PDO;
|
||||
|
||||
class GatewayListResponseOfCandidate
|
||||
{
|
||||
private Connection $connection;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = connect();
|
||||
}
|
||||
|
||||
public function getDetailsListResponsesOfCandidate(int $idListResponse)
|
||||
{
|
||||
$gatewayResponse = new GatewayResponse();
|
||||
$gatewayKeyword = new GatewayKeyword();
|
||||
$tabKeywords = [];
|
||||
|
||||
$query = "SELECT * FROM ListResponsesOfCandidate WHERE id = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($idListResponse, PDO::PARAM_INT)
|
||||
));
|
||||
|
||||
$questionList = $this->connection->getResults()[0];
|
||||
|
||||
$responses = $gatewayResponse->getResponsesByIdListCandidate($questionList['id']);
|
||||
|
||||
foreach ($responses as $row) {
|
||||
$tabKeywords[] = $gatewayKeyword->getKeywordsContentByCategorieze($row['id']);
|
||||
}
|
||||
|
||||
return array($questionList, $responses, $tabKeywords);
|
||||
}
|
||||
|
||||
public function getAllListResponsesOfCandidate(): array
|
||||
{
|
||||
$query = "SELECT * FROM ListResponsesOfCandidate";
|
||||
$this->connection->executeQuery($query);
|
||||
|
||||
return $this->connection->getResults();
|
||||
}
|
||||
|
||||
public function deleteListResponseOfCandidate(): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace API\script\Gateway;
|
||||
|
||||
use API\script\Config\Connection;
|
||||
use PDO;
|
||||
|
||||
class GatewayPossibleResponse
|
||||
{
|
||||
private Connection $connection;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = connect();
|
||||
}
|
||||
|
||||
public function getPossibleResponseByQuestion(string $idQuestion): array
|
||||
{
|
||||
$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)
|
||||
));
|
||||
|
||||
return $this->connection->getResults();
|
||||
}
|
||||
|
||||
public function insertPossibleResponse(string $contentPossibleResponse): int
|
||||
{
|
||||
$query = "INSERT INTO PossibleResponse(content) VALUES(:content)";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':content' => array($contentPossibleResponse, PDO::PARAM_STR)
|
||||
));
|
||||
|
||||
return $this->connection->lastInsertId();
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace API\script\Gateway;
|
||||
|
||||
use API\script\Config\Connection;
|
||||
use PDO;
|
||||
|
||||
class GatewayResponse
|
||||
{
|
||||
private Connection $connection;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = connect();
|
||||
}
|
||||
|
||||
public function getResponsesByIdListCandidate(int $listResponsesOfCandidateId)
|
||||
{
|
||||
$query = "SELECT r.* FROM Response r, Submit s WHERE s.responseCandidate = :id AND r.id = s.response";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($listResponsesOfCandidateId, PDO::PARAM_INT)
|
||||
));
|
||||
|
||||
$result = $this->connection->getResults();
|
||||
$tab = [];
|
||||
foreach ($result as $row){
|
||||
$tab[] = (new GatewayKeyword())->getKeywordsContentByCategorieze($row['id']);
|
||||
}
|
||||
|
||||
return array($result, $tab);
|
||||
}
|
||||
|
||||
public function deleteResponseById(int $responseId): void
|
||||
{
|
||||
$query = "DELETE FROM Categorize WHERE response = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($responseId, PDO::PARAM_INT)
|
||||
));
|
||||
|
||||
$query = "DELETE FROM Submit WHERE response = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($responseId, PDO::PARAM_INT)
|
||||
));
|
||||
|
||||
$query = "DELETE FROM Response WHERE id = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':id' => array($responseId, PDO::PARAM_INT)
|
||||
));
|
||||
}
|
||||
|
||||
public function insertResponse(string $content, string $question): int
|
||||
{
|
||||
$query = "INSERT INTO Response(content, question) VALUES (:content, :question)";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':content' => array($content, PDO::PARAM_STR),
|
||||
':question' => array($question, PDO::PARAM_STR)
|
||||
));
|
||||
|
||||
return $this->connection->lastInsertId();
|
||||
}
|
||||
}
|
Loading…
Reference in new issue