finish "add question" with responses and categories
continuous-integration/drone/push Build is passing Details

LoginModification
alexi 2 years ago
parent e9cf2b055c
commit cbb9677250

@ -14,7 +14,7 @@ class CheckBoxQuestion extends BoxQuestion
parent::__construct($args[0], $args[1], $args[2], $args[3]);
break;
case 2:
parent::__construct($args[3], $args[1]);
parent::__construct($args[0], $args[1]);
break;
default:
break;

@ -8,7 +8,7 @@ class TextQuestion extends Question
* @param string $content
* @param int $id
*/
public function __construct(string $content, int $id)
public function __construct(int $id, string $content)
{
parent::__construct($id, $content);
}

@ -7,6 +7,7 @@ use Model\ModelAdmin;
class ControllerAdmin
{
public function addQuestion(): void
{
global $rep, $views;
@ -15,15 +16,26 @@ class ControllerAdmin
$questionContent = $_POST['question'];
$type = $_POST['type'];
require_once($rep.$views['possibleResponsesForm']);
}
if(strcmp($type, "BusinessClass\TextQuestion") == 0)
{
$this->goToAdminPage();
}
else
{
require_once($rep.$views['possibleResponsesForm']);
}
}
public function addResponse(): void
{
(new ModelAdmin())->addResponse();
global $rep, $views;
$idQuestion = $_POST['idQuestion'];
$categories = (new ModelAdmin())->getCategories();
$questionContent = $_POST['question'];
$type = $_POST['type'];
require_once($rep.$views['continue']);
}
@ -31,13 +43,16 @@ class ControllerAdmin
{
global $rep, $views;
$idQuestion = $_POST['idQuestion'];
$choose = $_POST['choose'];
if($choose == "Oui") {
$idQuestion = $_POST['idQuestion'];
$categories = (new ModelAdmin())->getCategories();
$questionContent = $_POST['question'];
$type = $_POST['type'];
require_once($rep.$views['possibleResponsesForm']);
}
else {
require_once($rep.$views['']);
$this->goToAdminPage();
}
}

@ -13,7 +13,7 @@ class FactoryQuestion extends Factory
if ($results[0] != null) {
for ($i = 0; $i < count($results[0]); $i++) {
if (strcmp($results[0][$i]['type'], "BusinessClass\TextQuestion") == 0) {
$questions[] = new TextQuestion($results[0][$i]['content'], $results[0][$i]['id']);
$questions[] = new TextQuestion($results[0][$i]['id'], $results[0][$i]['content']);
} else {
$possiblesResponses = $results[1][$i];
$content = $results[0][$i]['content'];

@ -73,6 +73,8 @@
<h2>Continuer d'ajouter des possibilités de réponses ?</h2>
<form method="post">
<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; ?>">
<input type="submit" name="choose" value="Oui">
<input type="submit" name="choose" value="Non">

@ -72,6 +72,8 @@
<div style="text-align: center">
<form method="post">
<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; ?>">
<p>Votre question : <?php echo $questionContent; ?></p>
<br><br>

Loading…
Cancel
Save