@ -12,42 +12,47 @@ class ModelCandidate
{
{
$answersAndCategories = $_POST['answers'];
$answersAndCategories = $_POST['answers'];
$answers = array();
$id = [];
$answer = [];
$category = [];
foreach ($answersAndCategories as $answerAndCategory)
foreach ($answersAndCategories as $answerAndCategory)
{
{
$answer = explode("_", $answerAndCategory);
$idAndAnswer = explode("||", $answerAndCategory)[0];
$answer = reset($answer);
$id[] = explode("#", $idAndAnswer)[0];
$answers[] = $answer;
$answer[] = explode("#", $idAndAnswer)[1];
$categs = explode("||", $answerAndCategory)[1];
$categs = explode("_", $categs);
array_pop($categs);
$category[] = $categs;
}
var_dump($id);
echo "< br > ";
var_dump($answer);
echo "< br > ";
var_dump($category);
echo "< br > < br > ";
for($i = 0; $i < count ( $ answer ) ; $ i + + )
{
// (new GatewayResponse())->insertResponse($id[$i], $answer[$i], $category[$i]);
}
}
}
}
public function getForm(): string
public function getForm(): string
{
{
/*
$title = "Candidature à un témoignage";
$description = "Ce formulaire vous permet de candidater à un potentiel témoignage vidéo.";
$questions = array(
new TextQuestion("Décrivez-nous votre parcours en quelques lignes :"),
new ListBoxQuestion(array("Oui", "Non"), "Êtes-vous originaire de Clermont et ses alentours ? (- de 2 heures de trajet)", array(array("Clermont"), array("OrigineLointaine"))),
new ListBoxQuestion(array("BAC Général", "BAC Pro", "Étude supérieure"), "Quel étude avez-vous réalisé avant l'IUT?", array(array("Général"), array("Pro"), array("EtudSupp"))),
new CheckBoxQuestion(array("Mathématiques", "Web", "Mobile", "Gestion"), "Quels matières appréciez-vous ?", array(array("Maths", "Maths2", "Maths3"), array("Web"), array(""), array("Gestion", "Gestion2"))),
);
$form = new Form($title, $description, $questions);
*/
$form = (new GatewayForm())->getForm();
$form = (new GatewayForm())->getForm();
if(empty($form))
if(empty($form))
{
{
return "PAS DE FORMULAIRE\n";
return "PAS DE FORMULAIRE\n";
}
}
$title = $form[0]['title'];
$title = $form[0]['title'];
$description = $form[0]['description'];
$description = $form[0]['description'];
$questionsTab = (new GatewayQuestion())->getAllQuestions($form[0]['id']);
$questionsTab = (new GatewayQuestion())->getAllQuestions($form[0]['id']);
$questions = [];
$questions = [];
for($i = 0; $i < count ( $ questionsTab [ 0 ] ) ; $ i + + )
for($i = 0; $i < count ( $ questionsTab [ 0 ] ) ; $ i + + )
@ -75,16 +80,23 @@ class ModelCandidate
< div id = 'container_form' > \n
< div id = 'container_form' > \n
< form method = 'post' > \n";
< form method = 'post' > \n";
foreach ($questions as $question)
foreach ($questions as $question)
{
{
$html.= $question->printStrategy()."\n";
$html.= $question->printStrategy()."\n";
}
}
if(count($questions) > 0)
{
$html.= "\t\t\t< input type = 'submit' > \n
$html.= "\t\t\t< input type = 'submit' > \n
\t\t\t< input type = 'hidden' name = 'action' value = 'submitForm' >
\t\t\t< input type = 'hidden' name = 'action' value = 'submitForm' >
\t\t< / form > \n
\t\t< / form > \n
\t< / div > \n";
\t< / div > \n";
}
else
{
$html.= "\t\t< / form > \n
\t< / div > \n";
}
return $html;
return $html;
}
}