|
|
@ -28,6 +28,7 @@ class UserControler {
|
|
|
|
private UserModel $uMod;
|
|
|
|
private UserModel $uMod;
|
|
|
|
private QuoteModel $qMod;
|
|
|
|
private QuoteModel $qMod;
|
|
|
|
private QuestionModel $mdl;
|
|
|
|
private QuestionModel $mdl;
|
|
|
|
|
|
|
|
private CharacterModel $caMod;
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
public function __construct() {
|
|
|
|
global $co;
|
|
|
|
global $co;
|
|
|
@ -35,6 +36,8 @@ class UserControler {
|
|
|
|
$this->uMod = new UserModel(new UserGateway($co));
|
|
|
|
$this->uMod = new UserModel(new UserGateway($co));
|
|
|
|
$this->qMod = new QuoteModel(new QuoteGateway($co));
|
|
|
|
$this->qMod = new QuoteModel(new QuoteGateway($co));
|
|
|
|
$this -> mdl = new QuestionModel(new QuestionGateway($co));
|
|
|
|
$this -> mdl = new QuestionModel(new QuestionGateway($co));
|
|
|
|
|
|
|
|
$this -> caMod = new CharacterModel(new CharacterGateway($co));
|
|
|
|
|
|
|
|
$this->srcMod = new SourceModel(new SourceGateway($co));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function profil() {
|
|
|
|
public function profil() {
|
|
|
@ -113,6 +116,7 @@ class UserControler {
|
|
|
|
if ($_SESSION['no_question'] >= $total_questions) {
|
|
|
|
if ($_SESSION['no_question'] >= $total_questions) {
|
|
|
|
$_SESSION['no_question'] = 0;
|
|
|
|
$_SESSION['no_question'] = 0;
|
|
|
|
$this->endQuiz($id_quiz, $score);
|
|
|
|
$this->endQuiz($id_quiz, $score);
|
|
|
|
|
|
|
|
$_SESSION['score'] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else header("Location: ".$racine."/quiz/$id_quiz"); ///~kekentin/WF/WF-Website
|
|
|
|
else header("Location: ".$racine."/quiz/$id_quiz"); ///~kekentin/WF/WF-Website
|
|
|
|
|
|
|
|
|
|
|
@ -159,7 +163,6 @@ class UserControler {
|
|
|
|
$answer = explode('-', $answerd)[0];
|
|
|
|
$answer = explode('-', $answerd)[0];
|
|
|
|
$id = (int) explode('-', $answerd)[1];
|
|
|
|
$id = (int) explode('-', $answerd)[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$res = $this->mdl->getQuestion($id);
|
|
|
|
$res = $this->mdl->getQuestion($id);
|
|
|
|
return $answer == $res->getCanswer();
|
|
|
|
return $answer == $res->getCanswer();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -261,6 +264,8 @@ class UserControler {
|
|
|
|
public function submit() : void
|
|
|
|
public function submit() : void
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $vues;
|
|
|
|
global $vues;
|
|
|
|
|
|
|
|
$p = $this->caMod->getAllPerso();
|
|
|
|
|
|
|
|
$s = $this->srcMod->getAllSources();
|
|
|
|
require_once $vues['submitQuote'];
|
|
|
|
require_once $vues['submitQuote'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -276,7 +281,7 @@ class UserControler {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$content = $_POST['content'] ?? null;
|
|
|
|
$content = $_POST['content'] ?? null;
|
|
|
|
$character = $_POST['character'] ?? null;
|
|
|
|
$character = $_POST['character'] ?? null;
|
|
|
|
$source = $_POST['source'] ?? null;
|
|
|
|
$source = $_POST['src'] ?? null;
|
|
|
|
//$img = $_POST['img'] ?? null;
|
|
|
|
//$img = $_POST['img'] ?? null;
|
|
|
|
|
|
|
|
|
|
|
|
$errors = [null, null];
|
|
|
|
$errors = [null, null];
|
|
|
@ -284,12 +289,12 @@ class UserControler {
|
|
|
|
$gw = new CharacterGateway($co);
|
|
|
|
$gw = new CharacterGateway($co);
|
|
|
|
$mdl = new CharacterModel($gw);
|
|
|
|
$mdl = new CharacterModel($gw);
|
|
|
|
|
|
|
|
|
|
|
|
$character = $mdl -> getCharacterByName($character);
|
|
|
|
$character = $mdl -> getCharacterById($character);
|
|
|
|
|
|
|
|
|
|
|
|
$gw = new SourceGateway($co);
|
|
|
|
$gw = new SourceGateway($co);
|
|
|
|
$mdl = new SourceModel($gw);
|
|
|
|
$mdl = new SourceModel($gw);
|
|
|
|
|
|
|
|
|
|
|
|
$source = $mdl -> getSourceByTitle($source);
|
|
|
|
$source = $mdl -> getSourceById($source);
|
|
|
|
|
|
|
|
|
|
|
|
if (!$character)
|
|
|
|
if (!$character)
|
|
|
|
$errors[0] = "Personnage inexistant";
|
|
|
|
$errors[0] = "Personnage inexistant";
|
|
|
@ -298,16 +303,16 @@ class UserControler {
|
|
|
|
if ($errors[0] || $errors[1])
|
|
|
|
if ($errors[0] || $errors[1])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $twig;
|
|
|
|
global $twig;
|
|
|
|
echo $twig->render("submitQuote.html.twig", ['errors' => $errors]);
|
|
|
|
$this->submit();
|
|
|
|
exit();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$gw = new QuoteGateway($co);
|
|
|
|
$gw = new QuoteGateway($co);
|
|
|
|
$mdl = new QuoteModel($gw);
|
|
|
|
$mdl = new QuoteModel($gw);
|
|
|
|
|
|
|
|
|
|
|
|
$mdl -> insert4User($content, '/imgPath', 'fr', $this -> getIdOfUser(), $source->getIdSource(), $character->getIdCharacter());
|
|
|
|
//$mdl -> insert4User($content, '/imgPath', 'fr', $this -> getIdOfUser(), $source->getIdSource(), $character->getIdCharacter());
|
|
|
|
|
|
|
|
|
|
|
|
return [$content, $_POST['character'], $_POST['source']];
|
|
|
|
return [$content, $_POST['character'], $_POST['src']];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -319,6 +324,28 @@ class UserControler {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function validsubmit() : void
|
|
|
|
public function validsubmit() : void
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if($_POST['src'] == 'other' && $_POST['character'] == 'other'){
|
|
|
|
|
|
|
|
global $vues;
|
|
|
|
|
|
|
|
$src = true;
|
|
|
|
|
|
|
|
$char = true;
|
|
|
|
|
|
|
|
require_once $vues['create'];
|
|
|
|
|
|
|
|
exit();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
elseif($_POST['src'] == 'other'){
|
|
|
|
|
|
|
|
global $vues;
|
|
|
|
|
|
|
|
$src = true;
|
|
|
|
|
|
|
|
$char = false;
|
|
|
|
|
|
|
|
require_once $vues['create'];
|
|
|
|
|
|
|
|
exit();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
elseif($_POST['character'] == 'other'){
|
|
|
|
|
|
|
|
global $vues;
|
|
|
|
|
|
|
|
$src = false;
|
|
|
|
|
|
|
|
$char = true;
|
|
|
|
|
|
|
|
require_once $vues['create'];
|
|
|
|
|
|
|
|
exit();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if($_POST)
|
|
|
|
$recap = $this -> toSubmit();
|
|
|
|
$recap = $this -> toSubmit();
|
|
|
|
if ($recap)
|
|
|
|
if ($recap)
|
|
|
|
{
|
|
|
|
{
|
|
|
|