diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 1e95804..0000000
--- a/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-./Source/Config/vendor/
\ No newline at end of file
diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
deleted file mode 100644
index 1802a0d..0000000
--- a/.idea/dataSources.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
- mariadb
- true
- org.mariadb.jdbc.Driver
- jdbc:mariadb://localhost:3306
- $ProjectFileDir$
-
-
-
\ No newline at end of file
diff --git a/Source/.gitignore b/Source/.gitignore
new file mode 100644
index 0000000..1567b4f
--- /dev/null
+++ b/Source/.gitignore
@@ -0,0 +1 @@
+/Config/vendor/
diff --git a/Source/Model/ModelCandidate.php b/Source/Model/ModelCandidate.php
index df67a58..a768c55 100644
--- a/Source/Model/ModelCandidate.php
+++ b/Source/Model/ModelCandidate.php
@@ -2,15 +2,13 @@
namespace Model;
-use API\script\Gateway\GatewayForm;
-use API\script\Gateway\GatewayListResponseOfCandidate;
-use API\script\Gateway\GatewayQuestion;
-use API\script\Gateway\GatewayAdmin;
use Config\Clean;
use Config\Validate;
-use Exceptions\InvalidUsernameOrPasswordException;
+use Exception;
use Exceptions\InvalidLoginOrPasswordException;
use Exceptions\InexistantLoginException;
+use GuzzleHttp\Client;
+use GuzzleHttp\Exception\GuzzleException;
/**
* Permet de développer les fonctions appelées par le controllerCandidate pour gérer
@@ -18,10 +16,18 @@ use Exceptions\InexistantLoginException;
*/
class ModelCandidate
{
+
+ private Client $client;
+
+ public function __construct(){
+ $this->client = new Client();
+ }
+
/**
* Permet de soumettre et d'envoyer la réponse à un formulaire.
*
* @return void
+ * @throws Exception
*/
public function submitForm(): void
{
@@ -52,29 +58,48 @@ class ModelCandidate
$category[] = [];
}
}
-
- $title = (new GatewayForm())->getForm()[0]["title"];
- (new GatewayListResponseOfCandidate())->insertListResponsesOfCandidate($questionsId, $answer, $category, $title);
+ try {
+ $res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getForm');
+ $form = json_decode($res->getBody());
+ $title = $form[0]["title"];
+ $this->client->request('POST', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/insertListResponsesOfCandidate?
+ id='.implode(",",$questionsId).'&
+ answer='.implode(",",$answer).'&
+ category='.implode(",",$category).'&
+ titleForm='.$title
+ );
+ }catch (GuzzleException $g){
+ throw new Exception($g->getMessage(),$g->getCode(),$g);
+ }
}
/**
* Permet de récupérer le code html à afficher dans la page du formulaire,
* on récupère donc le formulaire et toutes les questions qu'il contient.
- * On les traduits en code HTML puis on le retourne. On utilise une Factory
- * pour récupèrer les questions.
+ * On les traduit en code HTML puis on le retourne. On utilise une Factory
+ * pour récupérer les questions.
*
* @return string
+ * @throws Exception
*/
public function getForm(): string
{
- $form = (new GatewayForm())->getForm();
- if (empty($form)) {
- return "PAS DE FORMULAIRE\n";
- }
+ try {
+ $res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getForm');
+ $form = json_decode($res->getBody());
+ if (empty($form)) {
+ return "PAS DE FORMULAIRE\n";
+ }
- $title = $form[0]['title'];
- $description = $form[0]['description'];
- $questionsTab = (new GatewayQuestion())->getAllQuestions($form[0]['id']);
+ $title = $form[0]['title'];
+ $description = $form[0]['description'];
+ $res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getAllQuestions?
+ idForm='.$form[0]['id']
+ );
+ $questionsTab = json_decode($res->getBody());
+ }catch (GuzzleException $g){
+ throw new Exception($g->getMessage(),$g->getCode(),$g);
+ }
$questions = Factory::getBuiltObjects($questionsTab, "Question");
@@ -88,9 +113,7 @@ class ModelCandidate
$title
";
- for ($i = 0; $i < sizeof($questions); $i++) {
- $html.= "";
- }
+ $html .= str_repeat("", sizeof($questions));
$html.= "
";
foreach ($questions as $question) {
@@ -98,7 +121,7 @@ class ModelCandidate
}
if (count($questions) > 0) {
- $html.= " 
+ $html.= "