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.
64 lines
1.6 KiB
64 lines
1.6 KiB
<?php
|
|
|
|
namespace Model;
|
|
|
|
use API\script\Gateway\GatewayForm;
|
|
use API\script\Gateway\GatewayKeyword;
|
|
use API\script\Gateway\GatewayQuestion;
|
|
use BusinessClass\Form;
|
|
use BusinessClass\ListBoxQuestion;
|
|
|
|
class ModelAdmin
|
|
{
|
|
public function addQuestion(): void
|
|
{
|
|
$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))
|
|
{
|
|
(new GatewayQuestion())->insertQuestion($question, $form[0]['id']);
|
|
}
|
|
}
|
|
|
|
public function createForm(): void
|
|
{
|
|
if(empty((new GatewayForm())->getForm()))
|
|
{
|
|
$form = new Form(0, "Votre avis nous intéresse !!!", "Description de notrer formulaire", array());
|
|
(new GatewayForm())->insertForm($form);
|
|
}
|
|
}
|
|
|
|
public function addKeyword(): void
|
|
{
|
|
$keyword = $_POST['keyword'];
|
|
(new GatewayKeyword())->insertKeyword($keyword);
|
|
}
|
|
}
|