diff --git a/.drone.yml b/.drone.yml index 9c4e86c..0058be5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,64 +14,4 @@ steps: SONAR_TOKEN: from_secret: SONARQ_TOKEN commands: - - apt-get update && apt-get install -y unzip nodejs npm - - export SONAR_SCANNER_VERSION=4.7.0.2747 - - export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux - - curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip - - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ - - export PATH=$SONAR_SCANNER_HOME/bin:$PATH - - export SONAR_SCANNER_OPTS="-server" - - sonar-scanner -Dsonar.projectKey=SAE4.01_FORMULAIRE -Dsonar.sources=. -Dsonar.php.coverage.reportPaths=coverage.xml -Dsonar.php.tests.reportPath=junit-logfile.xml -Dsonar.host.url=https://codefirst.iut.uca.fr/sonar - - - - # docker image build - - name: set_api_form - image: plugins/docker - settings: - dockerfile: ./Source/API/Dockerfile - context: Source/API - registry: hub.codefirst.iut.uca.fr - repo: hub.codefirst.iut.uca.fr/dorian.hodin/sae4.01_formulaire - username: - from_secret: SECRET_USERNAME - password: - from_secret: SECRET_PASSWD - - # conteneur deployment - - name: deploy_api_form - image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest - environment: - IMAGENAME: hub.codefirst.iut.uca.fr/dorian.hodin/sae4.01_formulaire:latest - CONTAINERNAME: deploy_api_form - COMMAND: create - OVERWRITE: true - CODEFIRST_CLIENTDRONE_ENV_HOST: - from_secret: db_host - CODEFIRST_CLIENTDRONE_ENV_DATABASE: - from_secret: db_database - CODEFIRST_CLIENTDRONE_ENV_USER: - from_secret: db_user - CODEFIRST_CLIENTDRONE_ENV_PASSWORD: - from_secret: db_password - CODEFIRST_CLIENTDRONE_ENV_ROOT_PASSWORD: - from_secret: db_root_password - depends_on: [ set_api_form ] - - # database container deployment - - name: db_form - image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest - environment: - IMAGENAME: mariadb:10.5 - CONTAINERNAME: db_form - COMMAND: create - CODEFIRST_CLIENTDRONE_ENV_MARIADB_ROOT_PASSWORD: - from_secret: db_root_password - CODEFIRST_CLIENTDRONE_ENV_MARIADB_DATABASE: - from_secret: db_database - CODEFIRST_CLIENTDRONE_ENV_MARIADB_USER: - from_secret: db_user - CODEFIRST_CLIENTDRONE_ENV_MARIADB_PASSWORD: - from_secret: db_password - depends_on: [ deploy_api_form ] - + - sonar-scanner -Dsonar.projectKey=SAE4.01_FORMULAIRE -Dsonar.sources=. -Dsonar.login=$${SONAR_TOKEN} -Dsonar.language=php -Dsonar.host.url=https://codefirst.iut.uca.fr/sonar -Dsonar.php.coverage.reportPaths=coverage.xml diff --git a/Source/API/Dockerfile b/Source/API/Dockerfile deleted file mode 100644 index 8a4ee87..0000000 --- a/Source/API/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM php:8.0-apache -RUN apt-get update && apt-get upgrade -y -RUN docker-php-ext-install pdo pdo_mysql -COPY ./script /var/www/html \ No newline at end of file diff --git a/Source/API/script/APIController.php b/Source/API/script/APIController.php deleted file mode 100644 index 5119b57..0000000 --- a/Source/API/script/APIController.php +++ /dev/null @@ -1,28 +0,0 @@ -$action(); - } - } - } catch (PDOException) { - return http_response_code(404); - } - exit(0); - } -} diff --git a/Source/API/script/Config/Connection.php b/Source/API/script/Config/Connection.php deleted file mode 100644 index 1ccd434..0000000 --- a/Source/API/script/Config/Connection.php +++ /dev/null @@ -1,54 +0,0 @@ -setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } - - - /** - * Éxécute une réquête SQL. - * - * @param string $query - * @param array $parameters - * @return bool Returns `true` on success, `false` otherwise - */ - public function executeQuery(string $query, array $parameters = []): bool - { - $this->stmt = parent::prepare($query); - foreach ($parameters as $name => $value) { - $this->stmt->bindValue($name, $value[0], $value[1]); - } - - return $this->stmt->execute(); - } - - - /** - * Permet de récupère le résultat de la dernière réquête éxecuté avec - * la fonction executeQuery(). - * - * @return array - */ - public function getResults(): array - { - return $this->stmt->fetchAll(); - - } -} diff --git a/Source/API/script/Config/config.php b/Source/API/script/Config/config.php deleted file mode 100644 index c412be2..0000000 --- a/Source/API/script/Config/config.php +++ /dev/null @@ -1,18 +0,0 @@ -con = connect(); - } - - public function executeScript(): void - { - $queryScript = 'CREATE TABLE `Categorize` ( - `response` int(11) NOT NULL, - `keyword` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -CREATE TABLE `Form` ( - `id` int(11) NOT NULL, - `title` varchar(50) NOT NULL, - `description` text NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -CREATE TABLE `Keyword` ( - `id` int(11) NOT NULL, - `word` varchar(50) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -CREATE TABLE `ListResponsesOfCandidate` ( - `id` int(11) NOT NULL, - `date` datetime NOT NULL, - `titleForm` varchar(50) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -CREATE TABLE `PossibleResponse` ( - `id` int(11) NOT NULL, - `content` text NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -CREATE TABLE `Propose` ( - `question` int(11) NOT NULL, - `possibleResponse` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -CREATE TABLE `Question` ( - `id` int(11) NOT NULL, - `content` text NOT NULL, - `type` varchar(50) NOT NULL, - `form` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -CREATE TABLE `Reference` ( - `possibleResponse` int(11) NOT NULL, - `keyword` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -CREATE TABLE `Response` ( - `id` int(11) NOT NULL, - `content` varchar(200) NOT NULL, - `questionContent` text NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -CREATE TABLE `Submit` ( - `responsesCandidate` int(11) NOT NULL, - `response` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -ALTER TABLE `Categorize` - ADD PRIMARY KEY (`response`,`keyword`), - ADD KEY `keyword` (`keyword`); -ALTER TABLE `Form` - ADD PRIMARY KEY (`id`); -ALTER TABLE `Keyword` - ADD PRIMARY KEY (`id`); -ALTER TABLE `ListResponsesOfCandidate` - ADD PRIMARY KEY (`id`); -ALTER TABLE `PossibleResponse` - ADD PRIMARY KEY (`id`); -ALTER TABLE `Propose` - ADD PRIMARY KEY (`question`,`possibleResponse`), - ADD KEY `possibleResponse` (`possibleResponse`); -ALTER TABLE `Question` - ADD PRIMARY KEY (`id`), - ADD KEY `form` (`form`); -ALTER TABLE `Reference` - ADD PRIMARY KEY (`possibleResponse`,`keyword`), - ADD KEY `keyword` (`keyword`); -ALTER TABLE `Response` - ADD PRIMARY KEY (`id`); -ALTER TABLE `Submit` - ADD PRIMARY KEY (`responsesCandidate`,`response`), - ADD KEY `response` (`response`); -ALTER TABLE `Form` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -ALTER TABLE `Keyword` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -ALTER TABLE `ListResponsesOfCandidate` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -ALTER TABLE `PossibleResponse` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -ALTER TABLE `Question` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -ALTER TABLE `Response` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -ALTER TABLE `Categorize` - ADD CONSTRAINT `Categorize_ibfk_1` FOREIGN KEY (`keyword`) REFERENCES `Keyword` (`id`), - ADD CONSTRAINT `Categorize_ibfk_2` FOREIGN KEY (`response`) REFERENCES `Response` (`id`); -ALTER TABLE `Propose` - ADD CONSTRAINT `Propose_ibfk_1` FOREIGN KEY (`possibleResponse`) REFERENCES `PossibleResponse` (`id`), - ADD CONSTRAINT `Propose_ibfk_2` FOREIGN KEY (`question`) REFERENCES `Question` (`id`); -ALTER TABLE `Question` - ADD CONSTRAINT `Question_ibfk_1` FOREIGN KEY (`form`) REFERENCES `Form` (`id`); -ALTER TABLE `Reference` - ADD CONSTRAINT `Reference_ibfk_1` FOREIGN KEY (`keyword`) REFERENCES `Keyword` (`id`), - ADD CONSTRAINT `Reference_ibfk_2` FOREIGN KEY (`possibleResponse`) REFERENCES `PossibleResponse` (`id`); -ALTER TABLE `Submit` - ADD CONSTRAINT `Submit_ibfk_1` FOREIGN KEY (`response`) REFERENCES `Response` (`id`), - ADD CONSTRAINT `Submit_ibfk_2` FOREIGN KEY (`responsesCandidate`) REFERENCES `ListResponsesOfCandidate` (`id`); -COMMIT;'; - - $this->con->executeQuery($queryScript); - - try { - $test = "SELECT * FROM Categorize;"; - $this->con->executeQuery($test); - } catch (Exception $e) { - echo $e->getMessage(); - } - - - } - -} diff --git a/Source/API/script/Gateway/GatewayForm.php b/Source/API/script/Gateway/GatewayForm.php deleted file mode 100644 index 400f98d..0000000 --- a/Source/API/script/Gateway/GatewayForm.php +++ /dev/null @@ -1,111 +0,0 @@ -connection = connect(); - } - - public function insertForm(Form $form): void - { - if (empty($this->getForm())) { - $query = "INSERT INTO Form(title, description) VALUES(:title, :desc)"; - $this->connection->executeQuery($query, array( - ':title' => array($form->getTitle(), PDO::PARAM_STR), - ':desc' => array($form->getDescription(), PDO::PARAM_STR) - )); - } - } - - public function getForm(): array - { - $query = "SELECT * FROM Form"; - $this->connection->executeQuery($query); - - return $this->connection->getResults(); - } - - public function deleteForm(Form $form): void - { - $query = "DELETE FROM Form WHERE id = :id"; - $this->connection->executeQuery($query, array( - ':id' => array($form->getId(), PDO::PARAM_INT) - )); - } - - public function assignKeywordToQuestion(string $keyword, string $response, int $idQuestion): void - { - $query = "SELECT pr.id - FROM Propose p, PossibleResponse pr - WHERE p.question = :id AND p.possibleResponse = pr.id - AND pr.content = :response"; - $this->connection->executeQuery($query, array( - ':id' => array($idQuestion, PDO::PARAM_INT), - ':response' => array($response, PDO::PARAM_STR) - )); - - $idPossibleResponse = $this->connection->getResults()[0][0]; - - $query = "INSERT INTO Reference(possibleResponse, keyword) VALUES(:possibleResponse, :keyword)"; - $this->connection->executeQuery($query, array( - ':possibleResponse' => array($idPossibleResponse, PDO::PARAM_INT), - ':keyword' => array($keyword, PDO::PARAM_STR) - )); - } - - public function deleteKeywordFromQuestion(string $keyword, string $response, Question $question): void - { - $query = "SELECT pr.id FROM Propose p, PossibleResponse r - WHERE p.question = :id AND p.possibleResponse = pr.id - AND pr.content = :response"; - $this->connection->executeQuery($query, array( - ':id' => array($question->getId(), PDO::PARAM_INT), - ':response' => array($response, PDO::PARAM_STR) - )); - - $idPossibleResponse = $this->connection->getResults()[0][0]; - - $query = "DELETE FROM Reference WHERE response = :idResponse AND keyword = :idKeword"; - $this->connection->executeQuery($query, array( - ':idResponse' => array($idPossibleResponse, PDO::PARAM_INT), - ':idKeword' => array($keyword, PDO::PARAM_INT) - )); - } - - public function updateTitleToForm(string $title, Form $form): void - { - $query = "UPDATE Form SET title = :title WHERE id = :id"; - $this->connection->executeQuery($query, array( - ':title' => array($title, PDO::PARAM_STR), - ':id' => array($form->getId(), PDO::PARAM_INT) - )); - } - - public function updateDescriptionToForm(string $description, Form $form): void - { - $query = "UPDATE Form SET title = :title WHERE description = :description"; - $this->connection->executeQuery($query, array( - ':description' => array($description, PDO::PARAM_STR), - ':id' => array($form->getId(), PDO::PARAM_INT) - )); - } - - public function deleteDescriptionToForm(Form $form): void - { - $query = "UPDATE Form SET title = :title WHERE description = :descript"; - $this->connection->executeQuery($query, array( - ':descript' => array('', PDO::PARAM_STR), - ':id' => array($form->getId(), PDO::PARAM_INT) - )); - } -} diff --git a/Source/API/script/Gateway/GatewayKeyword.php b/Source/API/script/Gateway/GatewayKeyword.php deleted file mode 100644 index 37b8b4b..0000000 --- a/Source/API/script/Gateway/GatewayKeyword.php +++ /dev/null @@ -1,57 +0,0 @@ -connection = connect(); - } - - public function insertKeyword(string $keyword) - { - $query = "INSERT INTO Keyword(word) VALUES(:word)"; - $this->connection->executeQuery($query, array( - ':word' => array($keyword, PDO::PARAM_STR) - )); - } - - public function deleteKeyword(string $keyword) - { - $query = "DELETE FROM Keyword WHERE word = :word"; - $this->connection->executeQuery($query, array( - ':word' => array($keyword, PDO::PARAM_STR) - )); - } - - public function getAllKeyword(): array - { - $query = "SELECT * FROM Keyword"; - $this->connection->executeQuery($query); - - return $this->connection->getResults(); - } - - public function getKeywordsContentByReference(int $id): array - { - $query = "SELECT k.* FROM Keyword k, Reference r - WHERE k.word = r.keyword AND r.possibleResponse = :id"; - $this->connection->executeQuery($query, array( - ':id' => array($id, PDO::PARAM_STR) - )); - - - $tab = []; - foreach ($this->connection->getResults() as $result) { - $tab[] = $result["word"]; - } - - return $tab; - } -} diff --git a/Source/API/script/Gateway/GatewayListResponseOfCandidate.php b/Source/API/script/Gateway/GatewayListResponseOfCandidate.php deleted file mode 100644 index 74c19a7..0000000 --- a/Source/API/script/Gateway/GatewayListResponseOfCandidate.php +++ /dev/null @@ -1,85 +0,0 @@ -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): void - { - $gatewayResponse = new GatewayResponse(); - $gatewayQuestion = new GatewayQuestion(); - - $query = "INSERT INTO ListResponsesOfCandidate(date, titleForm) VALUES(:date, :titleForm)"; - $this->connection->executeQuery($query, array( - ':date' => array(date('Y-m-d H:i:s'), PDO::PARAM_STR), - ':titleForm' => array($titleForm, PDO::PARAM_STR) - )); - - $idListQuestion = $this->connection->lastInsertId(); - - for ($i = 0; $i < count($answer); $i++) { - $question = $gatewayQuestion->getQuestionContentById($id[$i]); - $idResponse = $gatewayResponse->insertResponse($question, $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) - )); - } - } -} diff --git a/Source/API/script/Gateway/GatewayPossibleResponse.php b/Source/API/script/Gateway/GatewayPossibleResponse.php deleted file mode 100644 index 58956d8..0000000 --- a/Source/API/script/Gateway/GatewayPossibleResponse.php +++ /dev/null @@ -1,37 +0,0 @@ -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(); - } -} diff --git a/Source/API/script/Gateway/GatewayQuestion.php b/Source/API/script/Gateway/GatewayQuestion.php deleted file mode 100644 index 643c7b8..0000000 --- a/Source/API/script/Gateway/GatewayQuestion.php +++ /dev/null @@ -1,140 +0,0 @@ -connection = connect(); - } - - public function addQuestion(Question $question, int $idForm): int - { - $query = "INSERT INTO Question(content, type, form) VALUES(:content, :type, :form)"; - $this->connection->executeQuery($query, array( - ':content' => array($question->getContent(), PDO::PARAM_STR), - ':type' => array(get_class($question), PDO::PARAM_STR), - ':form' => array($idForm, PDO::PARAM_INT) - )); - - return $this->connection->lastInsertId(); - } - - public function insertResponseInQuestion(string $response, array $categories, int $idQuestion): int - { - $gatewayPossibleResponse = new GatewayPossibleResponse(); - $idPossibleResponse = $gatewayPossibleResponse->insertPossibleResponse($response); - - $query = "INSERT INTO Propose(question, possibleResponse) VALUES(:question, :possibleResponse)"; - $this->connection->executeQuery($query, array( - ':question' => array($idQuestion, PDO::PARAM_INT), - ':possibleResponse' => array($idPossibleResponse, PDO::PARAM_INT) - )); - - - foreach ($categories as $keyword) { - $gatewayForm = new GatewayForm(); - $gatewayForm->assignKeywordToQuestion($keyword, $response, $idQuestion); - } - - return $idQuestion; - } - - public function deleteQuestion(Question $question): void - { - if (get_class($question) == BoxQuestion::class) { - $query = "DELETE FROM Propose WHERE question = :id"; - $this->connection->executeQuery($query, array( - ':id' => array($question->getId(), PDO::PARAM_INT) - )); - - $listPossibleResponse = $question->getPossibleResponses(); - for ($i = 0; $i < count($listPossibleResponse); $i++) { - $query = "DELETE FROM Reference WHERE response = :id"; - $this->connection->executeQuery($query, array( - ':id' => array($listPossibleResponse[$i]->getId(), PDO::PARAM_INT) - )); - - $query = "DELETE FROM PossibleResponse WHERE id = :id"; - $this->connection->executeQuery($query, array( - ':id' => array($listPossibleResponse[$i]->getId(), PDO::PARAM_INT) - )); - } - } - - $query = "DELETE FROM Question WHERE id = :id"; - $this->connection->executeQuery($query, array( - ':id' => array($question->getId(), PDO::PARAM_INT) - )); - } - - public function updateQuestion(Question $question): void - { - $query = "UPDATE Question SET content = :content, type = :type, form = :frm WHERE id = :id"; - $this->connection->executeQuery($query, array( - ':content' => array($question->getContent(), PDO::PARAM_STR), - ':type' => array(get_class($question), PDO::PARAM_STR), - ':frm' => array($question->getForm(), PDO::PARAM_STR), - ':id' => array($question->getId(), PDO::PARAM_STR) - )); - } - - public function getAllQuestions(string $idForm): array - { - $query = "SELECT * FROM Question WHERE form = :fom"; - $this->connection->executeQuery($query, array( - ':fom' => array($idForm, PDO::PARAM_INT) - )); - - $listQuestions = $this->connection->getResults(); - $possibleResponsesContent = []; - $keywordsResponses = []; - $gatewayKeyword = new GatewayKeyword(); - $gatewayPossibleResponse = new GatewayPossibleResponse(); - - if (!empty($listQuestions)) { - - for ($i = 0; $i < count($listQuestions); $i++) { - - if ($listQuestions[$i]["type"] != "BusinessClass/TextQuestion") { - $idQuestion = $listQuestions[$i]["id"]; - $possibleResponses = $gatewayPossibleResponse->getPossibleResponseByQuestion($idQuestion); - $tmpTabKeyword = []; - $tmpTabPossibleResponse = []; - - foreach ($possibleResponses as $row) { - $tmpTabKeyword[] = $gatewayKeyword->getKeywordsContentByReference($row["id"]); - $tmpTabPossibleResponse[] = $row["content"]; - } - - $possibleResponsesContent[] = $tmpTabPossibleResponse; - $keywordsResponses[] = $tmpTabKeyword; - } else { - $possibleResponsesContent[] = null; - $keywordsResponses[] = null; - } - } - return array($listQuestions, $possibleResponsesContent, $keywordsResponses); - } - return array(); - } - - public function getQuestionContentById(string $id): string - { - $query = "SELECT content FROM Question WHERE id = :id"; - $this->connection->executeQuery($query, array( - ':id' => array($id, PDO::PARAM_INT) - )); - - return $this->connection->getResults()[0][0]; - } -} diff --git a/Source/API/script/Gateway/GatewayResponse.php b/Source/API/script/Gateway/GatewayResponse.php deleted file mode 100644 index 6803de0..0000000 --- a/Source/API/script/Gateway/GatewayResponse.php +++ /dev/null @@ -1,77 +0,0 @@ -connection = connect(); - } - - public function getResponsesByIdListCandidate(int $listResponsesOfCandidateId): array - { - - $result = $this->getResponsesIdByIdListCandidate($listResponsesOfCandidateId); - $tab = []; - foreach ($result as $row) { - $tab[] = (new GatewayKeyword())->getKeywordsContentByCategorieze($row['id']); - } - - return array($result, $tab); - } - - public function getResponsesIdByIdListCandidate(int $listResponsesOfCandidateId): array - { - $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 $questionContent, array $category): int - { - $query = "INSERT INTO Response(content, questionContent) VALUES (:content, :questionContent)"; - $this->connection->executeQuery($query, array( - ':content' => array($content, PDO::PARAM_STR), - ':questionContent' => array($questionContent, 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) - )); - } - - return $idResponse; - } -}