diff --git a/Source/Config/config.php b/Source/Config/config.php index a36c020..161d220 100644 --- a/Source/Config/config.php +++ b/Source/Config/config.php @@ -5,3 +5,4 @@ $rep = __DIR__ . '/../'; // Vues $views['form'] = 'Views/HTML/form.php'; +$views['admin'] = 'Views/HTML/admin.php'; diff --git a/Source/Controller/ControllerAdmin.php b/Source/Controller/ControllerAdmin.php index 0ac775d..f46df58 100644 --- a/Source/Controller/ControllerAdmin.php +++ b/Source/Controller/ControllerAdmin.php @@ -15,4 +15,10 @@ class ControllerAdmin { (new ModelAdmin())->createForm(); } + + public function goToAdminPage(): void + { + global $rep, $views; + require($rep.$views['admin']); + } } diff --git a/Source/Controller/FrontController.php b/Source/Controller/FrontController.php index 7e5155e..e1617d4 100644 --- a/Source/Controller/FrontController.php +++ b/Source/Controller/FrontController.php @@ -36,4 +36,4 @@ class FrontController exit(0); } -} \ No newline at end of file +} diff --git a/Source/Model/ModelAdmin.php b/Source/Model/ModelAdmin.php index 87f81b8..ac9f831 100644 --- a/Source/Model/ModelAdmin.php +++ b/Source/Model/ModelAdmin.php @@ -11,9 +11,32 @@ class ModelAdmin { public function addQuestion(): void { - $question = new ListBoxQuestion(array("Réponse1", "Réponse2", "Réponse3"), - "Quelle est votre réponse préférée ?", - array(array("Catégorie1.1", "Catégorie 1.2", "Catégorie1.3"), array("Catégorie2.1", "Catégorie 2.2"), array("Catégorie3")), 0); + $questionContent = $_POST['question']; + $type = $_POST['type']; + $responses = $_POST['responses']; + $categories = $_POST['categories']; + + $responses = explode(";", $responses); + array_pop($responses); + $categories = explode(";", $categories); + + $tmp = []; + foreach($categories as $category) + { + $tmp[] = explode(",", $category); + } + $categories = $tmp; + array_pop($categories); + + if(strcmp($type,"BusinessClass\TextQuestion") == 0) + { + $question = new $type($questionContent, 0); + } + else + { + $question = new $type($responses, $questionContent, $categories, 0); + } + $form = (new GatewayForm())->getForm(); if(!empty($form)) diff --git a/Source/Model/ModelCandidate.php b/Source/Model/ModelCandidate.php index 635fdf9..164a6c7 100644 --- a/Source/Model/ModelCandidate.php +++ b/Source/Model/ModelCandidate.php @@ -44,7 +44,7 @@ class ModelCandidate for($i = 0; $i < count($questionsTab[0]); $i++) { - if(strcmp($questionsTab[0][$i]['type'], "TextQuestion") == 0) + if(strcmp($questionsTab[0][$i]['type'], "BusinessClass\TextQuestion") == 0) { $questions[] = new TextQuestion($questionsTab[0][$i]['content'], $questionsTab[0][$i]['id']); } diff --git a/Source/Views/HTML/admin.php b/Source/Views/HTML/admin.php new file mode 100644 index 0000000..995d87d --- /dev/null +++ b/Source/Views/HTML/admin.php @@ -0,0 +1,60 @@ + + +
+ + + + + +