Merge branch 'delete'

# Conflicts:
#	Source/Model/ModelAdmin.php
interestingProfiles
dorian.hodin 2 years ago
commit 25fe072a12

1
.gitignore vendored

@ -0,0 +1 @@
/Source/Config/vendor/

@ -1,17 +1,28 @@
RewriteEngine on
# Vérifier si le serveur est MAMP ou WAMP
RewriteCond %{DOCUMENT_ROOT} /Applications/MAMP/htdocs/
RewriteRule .* - [E=APP_ROOT:/SAE4.01_FORMULAIRE/]
RewriteRule ^/$ index.php?page=goToForm [L]
RewriteRule ^goToForm$ index.php?page=goToForm [L]
RewriteRule ^submitForm$ index.php?page=submitForm [L]
RewriteRule ^addQuestion$ index.php?page=addQuestion [L]
RewriteRule ^addResponse$ index.php?page=addResponse [L]
RewriteRule ^continueResponse$ index.php?page=continueResponse [L]
RewriteRule ^createForm$ index.php?page=createForm [L]
RewriteRule ^addKeyword$ index.php?page=addKeyword [L]
RewriteRule "goToAdmin" index.php?page=goToAdmin [L]
RewriteRule ^goToAdminLogin$ index.php?page=goToAdminLogin [L]
RewriteRule ^login$ index.php?page=login [L]
RewriteRule ^goToCategories$ index.php?page=goToCategories [L]
RewriteRule ^goToQuestions$ index.php?page=goToQuestions [L]
RewriteRule ^goToResponses$ index.php?page=goToResponses [L]
RewriteCond %{DOCUMENT_ROOT} /
RewriteRule .* - [E=APP_ROOT:]
# Redirection des URLs
RewriteRule ^/$ %{ENV:APP_ROOT}index.php?page=goToForm [L]
RewriteRule ^goToForm$ %{ENV:APP_ROOT}index.php?page=goToForm [L]
RewriteRule ^submitForm$ %{ENV:APP_ROOT}index.php?page=submitForm [L]
RewriteRule ^addQuestion$ %{ENV:APP_ROOT}index.php?page=addQuestion [L]
RewriteRule ^addResponse$ %{ENV:APP_ROOT}index.php?page=addResponse [L]
RewriteRule ^continueResponse$ %{ENV:APP_ROOT}index.php?page=continueResponse [L]
RewriteRule ^createForm$ %{ENV:APP_ROOT}index.php?page=createForm [L]
RewriteRule ^addKeyword$ %{ENV:APP_ROOT}index.php?page=addKeyword [L]
RewriteRule "goToAdmin" %{ENV:APP_ROOT}index.php?page=goToAdmin [L]
RewriteRule ^goToAdminLogin$ %{ENV:APP_ROOT}index.php?page=goToAdminLogin [L]
RewriteRule ^login$ %{ENV:APP_ROOT}index.php?page=login [L]
RewriteRule ^goToCategories$ %{ENV:APP_ROOT}index.php?page=goToCategories [L]
RewriteRule ^goToQuestions$ %{ENV:APP_ROOT}index.php?page=goToQuestions [L]
RewriteRule ^goToResponses$ %{ENV:APP_ROOT}index.php?page=goToResponses [L]
RewriteRule ^deleteQuestion$ %{ENV:APP_ROOT}index.php?page=deleteQuestion [L]
RewriteRule ^deleteResponse$ %{ENV:APP_ROOT}index.php?page=deleteResponse [L]
RewriteRule ^deleteKeyword$ %{ENV:APP_ROOT}index.php?page=deleteKeyword [L]
RewriteRule ^deleteResponsesCandidate$ %{ENV:APP_ROOT}index.php?page=deleteResponsesCandidate [L]

@ -14,6 +14,7 @@ $views['categories'] = 'Views/HTML/categories.php';
$views['questions'] = 'Views/HTML/questions.php';
$views['responses'] = 'Views/HTML/responses.php';
$views['thanks'] = 'Views/HTML/thanks.php';
$views['error'] = 'Views/HTML/error.php';
$_SERVER['BASE_URI'] = '';
@ -26,9 +27,9 @@ $poppins = "https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=sw
$icon = "https://cdn.uca.fr/images/favicon/favicon.ico";
$logoUCA = "https://cdn.uca.fr/images/logos/logo_uca_mini_light.png";
function connect()
function connect() //temoignage formulaire
{
$dsn = "mysql:host=localhost;dbname=formulaire;charset=utf8";
$dsn = "mysql:host=localhost;dbname=temoignage;charset=utf8";
$login = "root";
try {

@ -31,6 +31,16 @@ class ControllerAdmin
}
}
/**
* Supprime une question par son id récupéré par le tableau $_POST ainsi que les possibles réponses associées
*
* @return void
*/
public function deleteQuestion(): void
{
(new ModelAdmin())->deleteQuestion();
$this->goToQuestions();
}
/**
* Ajoute une possibilité de réponse à une question, on assige également cette réponse
@ -49,6 +59,17 @@ class ControllerAdmin
require_once($rep.$views['continue']);
}
/**
* Permet de supprimer une possible réponse par son id récupéré par le tableau $_POST
*
* @return void
*/
public function deleteResponse(): void
{
(new ModelAdmin())->deleteResponse();
$this->goToQuestions();
}
/**
* Permet de proposer à l'utiliser de continuer ou non à ajouter des possibilités de réponses à l'aide
@ -94,6 +115,16 @@ class ControllerAdmin
$this->goToCategories();
}
/**
* Permet de supprimer un mot clef qui sera récupéré par le tableau $_POST
*
* @return void
*/
public function deleteKeyword(): void
{
(new ModelAdmin())->deleteKeyword();
$this->goToCategories();
}
/**
* Permet de naviguer jusqu'à la page de gestion des catégories
@ -120,7 +151,6 @@ class ControllerAdmin
require_once($rep.$views['questions']);
}
/**
* Permet de naviguer jusqu'à la page de gestion des réponses
*
@ -138,4 +168,10 @@ class ControllerAdmin
global $rep, $views;
require_once($rep.$views['admin']);
}
public function deleteResponsesCandidate(): void
{
(new ModelAdmin())->deleteResponsesCandidate();
$this->goToResponses();
}
}

@ -37,7 +37,9 @@ class FrontController {
$_SESSION['role'] = 'Candidate';
}
$role = Clean::simpleString($_SESSION['role']);
foreach($this->rights[$role] as $controllerName) {
if(strcmp($controllerName,$target[0])===0) {
$controllerClass = '\Controller\\' . $target[0];
$controller = new $controllerClass();
@ -46,12 +48,12 @@ class FrontController {
}
}
if(!$exists) {
$error = $error['403'];
$error = '403';
require_once($rep . $views['error']);
}
} else {
// no route was matched
$error = $error['404'];
$error = '404';
require_once($rep . $views['error']);
}
}
@ -72,5 +74,9 @@ class FrontController {
$this->router->map('GET','/goToCategories',array($controller['Admin'],'goToCategories'),'goToCategories');
$this->router->map('GET','/goToQuestions',array($controller['Admin'],'goToQuestions'),'goToQuestions');
$this->router->map('GET','/goToResponses',array($controller['Admin'],'goToResponses'),'goToResponses');
$this->router->map('POST','/deleteQuestion',array($controller['Admin'],'deleteQuestion'),'deleteQuestion');
$this->router->map('POST','/deleteResponse',array($controller['Admin'],'deleteResponse'),'deleteResponse');
$this->router->map('POST','/deleteKeyword',array($controller['Admin'],'deleteKeyword'),'deleteKeyword');
$this->router->map('POST','/deleteResponsesCandidate',array($controller['Admin'],'deleteResponsesCandidate'),'deleteResponsesCandidate');
}
}

@ -62,6 +62,28 @@ class ModelAdmin
return -1;
}
/**
* Permet de supprimer une question du formulaire
*
* @return void
* @throws Exception
*/
public function deleteQuestion():void
{
$idQuestion = $_POST["idQuestion"];
$type = $_POST["type"];
try {
$res = $this->client->request('DELETE', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/deleteQuestion?
classQuestion='.$type.'&
id='.$idQuestion
);
if ($res->getStatusCode()!=200){
throw new Exception('DeleteQuestion failed');
}
}catch (GuzzleException $g){
throw new Exception($g->getMessage(),$g->getCode(),$g);
}
}
/**
* Permet d'ajouter une possibilité de réponse à une question en l'assignant à des catégories.
@ -88,6 +110,25 @@ class ModelAdmin
}
}
/**
* Permet de supprimer une possible réponse à une question
*
* @return void
* @throws Exception
*/
public function deleteResponse(): void
{
try {
$res = $this->client->request('DELETE', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/deletePossibleResponse?
id='.$_POST["possibleResponse"]
);
if ($res->getStatusCode()!=200){
throw new Exception('DeletePossibleResponse failed');
}
}catch (GuzzleException $g){
throw new Exception($g->getMessage(),$g->getCode(),$g);
}
}
/**
* Permet de créer un nouveau formulaire en précisant son titre et sa description.
@ -131,6 +172,25 @@ class ModelAdmin
}
}
/**
* Permet de supprimer une catégorie (mot-clef)
*
* @return void
* @throws Exception
*/
public function deleteKeyword(): void
{
try {
$res = $this->client->request('DELETE', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/deleteKeyword?
keyword='.$_POST["idCateg"]
);
if ($res->getStatusCode()!=200){
throw new Exception('DeleteKeyword failed');
}
}catch (GuzzleException $g){
throw new Exception($g->getMessage(),$g->getCode(),$g);
}
}
/**
* Permet de récupérer toutes les catégories existantes.
@ -205,4 +265,24 @@ class ModelAdmin
throw new Exception($g->getMessage(),$g->getCode(),$g);
}
}
/**
* Permet de supprimer les réponses d'une personne d'un formulaire
*
* @return void
* @throws Exception
*/
public function deleteResponsesCandidate(): void
{
try {
$res = $this->client->request('DELETE', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/deleteListResponseOfCandidate?
id='.$_POST["idResponseCandidate"]
);
if ($res->getStatusCode()!=200){
throw new Exception('DeleteListResponseOfCandidate failed');
}
}catch (GuzzleException $g){
throw new Exception($g->getMessage(),$g->getCode(),$g);
}
}
}

@ -109,7 +109,7 @@ class ModelCandidate
$html = "<div class='container mt-5'>
<div class='row d-flex justify-content-center align-items-center'>
<div class='col-md-8'>
<form id='regForm' method='post'>
<form id='regForm' method='post' action='submitForm'>
<h1 id='register'>$title</h1>
<div class='all-steps' id='all-steps'>";

@ -51,7 +51,7 @@
<div class="container mt-5">
<div class="row d-flex justify-content-center align-items-center">
<div class="col-md-8">
<form id="regForm" method="post">
<form id="regForm" method="post" action="addQuestion">
<h1 id="register">Ajout d'une question</h1>
<div class="all-steps" id="all-steps">
<span class="step"><i class="fa"></i></span>

@ -29,18 +29,26 @@
<div class="form-center">
<h3>Les catégories :</h3>
<form method="post">
<form method="post" action="addKeyword">
<label for="keyword"></label><input id="keyword" name="keyword" type="text" size="25" placeholder="...">
<input type="submit" value="Ajouter">
<input type="hidden" name="action" value="addKeyword">
</form>
<br>
<ul class="form-center">
<?php
foreach ($categories as $category) {
?> <li><?php echo $category; ?></li> <?php
}
?>
<form method="post" action="deleteKeyword">
<?php
foreach ($categories as $category) {
?> <li><?php
echo '<form method="post" action="deleteKeyword">';
echo $category;
echo ' <input type="submit" value="Delete">';
echo ' <input type="hidden" name="idCateg" value="'.$category.'">';
echo ' <input type="hidden" name="page" value="deleteQuestion">';
echo '</form>';
}
?>
</li>
</ul>
</div>

@ -51,7 +51,7 @@
<div class="text-center">
<h2>Continuer d'ajouter des possibilités de réponses ?</h2>
<form method="post">
<form method="post" action="continueResponse">
<input name="idQuestion" type="hidden" value="<?php echo $idQuestion; ?>">
<input name="question" type="hidden" value="<?php echo $questionContent; ?>">
<input name="type" type="hidden" value="<?php echo $type; ?>">

@ -28,7 +28,7 @@
</div>
</header>
<?php //echo $html; ?>
<?php echo $html; ?>
<br><br>
<footer class="py-5 bg-white">

@ -51,7 +51,7 @@
<div class="container mt-5">
<div class="row d-flex justify-content-center align-items-center">
<div class="col-md-8">
<form id="regForm" method="post">
<form id="regForm" method="post" action="addResponse">
<input name="idQuestion" type="hidden" value="<?php echo $idQuestion; ?>">
<input name="question" type="hidden" value="<?php echo $questionContent; ?>">
<input name="type" type="hidden" value="<?php echo $type; ?>">

@ -30,7 +30,7 @@
<div class="form-center">
<h3>Les questions :</h3>
<br>
<form method="post">
<form method="post" action="addQuestion">
<div>
<label for="question">Écrivez la question : </label>
<br>
@ -63,8 +63,14 @@
<?php
foreach ($questions as $question) {
?>
<?php echo $question->printStrategy() ?>
<?php
<form method="post" action="deleteQuestion">
<li><?php echo $question->printStrategy();
echo '<input type="submit" value="Delete">';
echo '<input type="hidden" name="idQuestion" value="'.$question->getId().'">';
echo '<input type="hidden" name="type" value="<'.get_class($question).'">';
echo '<input type="hidden" name="page" value="deleteQuestion">';
echo ' </li>';
echo '</form>';
}
?>
</ul>

@ -31,28 +31,33 @@
<h3>Les réponses :</h3>
<br>
<div id="listResponses">
<?php
foreach ($responsesCandidate as $response) { ?>
<i><?php echo $response[0]["date"]; ?></i>
<p>Catégories associées :
<?php
echo " | ";
foreach ($response[2] as $category)
if(!empty($category)) {
echo $category[0] . " | ";
}
?>
</p>
<?php foreach ($response[1] as $questionResponses) { ?>
<p><i>Question : </i><?php echo $questionResponses["content"]; ?></p>
<p><i>Réponse : </i><?php echo $questionResponses["questionContent"]; ?></p>
<?php
} ?>
<hr><br>
<form method="post" action="deleteResponsesCandidate">
<?php
}
?>
foreach ($responsesCandidate as $response) { ?>
<i><?php echo $response[0]["date"];;?></i>
<p>Catégories associées :
<?php
echo " | ";
foreach ($response[2] as $category)
if(!empty($category)) {
echo $category[0] . " | ";
}
?>
</p>
<?php foreach ($response[1] as $questionResponses) { ?>
<p><i>Question : </i><?php echo $questionResponses["content"]; ?></p>
<p><i>Réponse : </i><?php echo $questionResponses["questionContent"]; ?></p>
<?php
} ?>
<input type="submit" value="Delete">
<input type="hidden" name="idResponseCandidate" value="<?php echo $response[0]["id"] ?>">
<input type="hidden" name="action" value="deleteResponsesCandidate">
<hr><br>
<?php
}
?>
</form>
</div>
</div>

Loading…
Cancel
Save