# Conflicts: # Source/API/script/Gateway/GatewayKeyword.phpLoginModification
commit
cdf2bcac4f
@ -0,0 +1,86 @@
|
||||
<?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($id): void
|
||||
{
|
||||
$gatewayResponse = new GatewayResponse();
|
||||
|
||||
foreach ( $gatewayResponse->getResponsesIdByIdListCandidate($id) as $response){
|
||||
$gatewayResponse->deleteResponseById($response);
|
||||
}
|
||||
|
||||
$query = "DELETE FROM ListResponsesOfCandidate WHERE id = :id";
|
||||
$this->connection->executeQuery($query, array(
|
||||
'id' => array($id, PDO::PARAM_STR)
|
||||
));
|
||||
}
|
||||
|
||||
public function insertListResponsesOfCandidate($id, $answer, $category, $titleForm)
|
||||
{
|
||||
$gatewayResponse = new GatewayResponse();
|
||||
$gatewayQuestion = new GatewayQuestion();
|
||||
|
||||
$query = "INSERT INTO ListResponsesOfCandidate(date, titleForm) VALUES(:date, :titleForm)";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':date' => array(date('d-m-y h:i:s'), PDO::PARAM_STR),
|
||||
'titleForm' => array($titleForm, PDO::PARAM_STR)
|
||||
));
|
||||
|
||||
$idListQuestion = $this->connection->lastInsertId();
|
||||
|
||||
for($i = 0; $i < count($answer); $i++)
|
||||
{
|
||||
$idResponse = $gatewayResponse->insertResponse($gatewayQuestion->getQuestionContentById($id[$i]), $answer[$i], $category[$i]);
|
||||
|
||||
|
||||
$query = "INSERT INTO Submit (responsesCandidate, response) VALUES(:responsesCandidate, :response)";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':responsesCandidate' => array($idListQuestion, PDO::PARAM_STR),
|
||||
'response' => array($idResponse, PDO::PARAM_STR)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
@ -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,74 @@
|
||||
<?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)
|
||||
{
|
||||
|
||||
$result = $this->getResponsesIdByIdListCandidate($listResponsesOfCandidateId);
|
||||
$tab = [];
|
||||
foreach ($result as $row){
|
||||
$tab[] = (new GatewayKeyword())->getKeywordsContentByCategorieze($row['id']);
|
||||
}
|
||||
|
||||
return array($result, $tab);
|
||||
}
|
||||
|
||||
public function getResponsesIdByIdListCandidate(int $listResponsesOfCandidateId)
|
||||
{
|
||||
$query = "SELECT r.id 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)
|
||||
));
|
||||
return $this->connection->getResults();
|
||||
}
|
||||
|
||||
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, array $category): void
|
||||
{
|
||||
$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)
|
||||
));
|
||||
|
||||
$idResponse = $this->connection->lastInsertId();
|
||||
|
||||
foreach ($category as $keyword){
|
||||
$query = "INSERT INTO Categorize (response, keyword) VALUES(:response, :keyword)";
|
||||
$this->connection->executeQuery($query, array(
|
||||
':response' => array($idResponse, PDO::PARAM_STR),
|
||||
'keyword' => array($keyword, PDO::PARAM_STR)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue