You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.9 KiB
75 lines
1.9 KiB
<?php
|
|
|
|
namespace Model;
|
|
|
|
use API\script\Gateway\GatewayForm;
|
|
use API\script\Gateway\GatewayListResponseOfCandidate;
|
|
use API\script\Gateway\GatewayQuestion;
|
|
|
|
class ModelCandidate
|
|
{
|
|
public function submitForm(): void
|
|
{
|
|
$answersAndCategories = $_POST['answers'];
|
|
|
|
$id = [];
|
|
$answer = [];
|
|
$category = [];
|
|
|
|
foreach ($answersAndCategories as $answerAndCategory)
|
|
{
|
|
$idAndAnswer = explode("||", $answerAndCategory)[0];
|
|
$id[] = explode("#", $idAndAnswer)[0];
|
|
$answer[] = explode("#", $idAndAnswer)[1];
|
|
|
|
$categs = explode("||", $answerAndCategory)[1];
|
|
$categs = explode("_", $categs);
|
|
array_pop($categs);
|
|
$category[] = $categs;
|
|
}
|
|
|
|
$titleForm = (new GatewayForm())->getForm()[0]["title"];
|
|
(new GatewayListResponseOfCandidate())->insertListResponsesOfCandidate($id, $answer, $category, $titleForm);
|
|
}
|
|
|
|
public function getForm(): string
|
|
{
|
|
$form = (new GatewayForm())->getForm();
|
|
if(empty($form))
|
|
{
|
|
return "PAS DE FORMULAIRE\n";
|
|
}
|
|
|
|
$title = $form[0]['title'];
|
|
$description = $form[0]['description'];
|
|
$questionsTab = (new GatewayQuestion())->getAllQuestions($form[0]['id']);
|
|
|
|
$questions = Factory::getBuiltObjects($questionsTab, "Question");
|
|
|
|
$html = "
|
|
<h1>$title</h1>\n
|
|
<h3>$description</h3>\n
|
|
<div id='container_form'>\n
|
|
<form method='post'>\n";
|
|
|
|
foreach ($questions as $question)
|
|
{
|
|
$html.= $question->printStrategy()."\n";
|
|
}
|
|
|
|
if(count($questions) > 0)
|
|
{
|
|
$html.= "\t\t\t<input type='submit'>\n
|
|
\t\t\t<input type='hidden' name='action' value='submitForm'>
|
|
\t\t</form>\n
|
|
\t</div>\n";
|
|
}
|
|
else
|
|
{
|
|
$html.= "\t\t</form>\n
|
|
\t</div>\n";
|
|
}
|
|
|
|
return $html;
|
|
}
|
|
} |