debut ajout quiz aléatoire

pull/25/head
kevin.modejar 3 months ago
parent ab176cb06e
commit ccc48431e8

@ -27,16 +27,16 @@ class UserControler {
private CommentaryModel $cMod; private CommentaryModel $cMod;
private UserModel $uMod; private UserModel $uMod;
private QuoteModel $qMod; private QuoteModel $qMod;
private QuestionModel $mdl;
private CharacterModel $caMod; private CharacterModel $caMod;
private SourceModel $srcMod; private SourceModel $srcMod;
private QuestionModel $questMod;
public function __construct() { public function __construct() {
global $co; global $co;
$this->cMod = new CommentaryModel(new CommentaryGateway($co)); $this->cMod = new CommentaryModel(new CommentaryGateway($co));
$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 -> questMod = new QuestionModel(new QuestionGateway($co));
$this -> caMod = new CharacterModel(new CharacterGateway($co)); $this -> caMod = new CharacterModel(new CharacterGateway($co));
$this->srcMod = new SourceModel(new SourceGateway($co)); $this->srcMod = new SourceModel(new SourceGateway($co));
} }
@ -174,7 +174,7 @@ 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->questMod->getQuestion($id);
return $answer == $res->getCanswer(); return $answer == $res->getCanswer();
} }
@ -509,4 +509,26 @@ class UserControler {
var_dump($error); var_dump($error);
} }
} }
// Quiz aléatoire
// argument = Langue / type question / type reponse
public function quizAleatoire(){
global $vues;
if(!isset($_POST["nbVie"])){
$vie = 3;
}
$question = $questMod->getRandomQuestion([$_POST["questionType"],$_POST["awnserType"]],$_POST["langue"]);
addTab($question);
if($question == null){
$require_once($vues["erreur"]);
}
else{
$require_once($vues['quiz']);
}
}
public function questionSuivantAleatoire(){
}
} }

@ -98,4 +98,8 @@ class QuestionGateway extends Gateway
return $this -> co -> getResults(); return $this -> co -> getResults();
} }
public function getQuestionQuoteSrc(string $l) : array{
}
} }

@ -79,4 +79,39 @@ class QuestionModel extends Model
); );
return null; return null;
} }
public function getRandomQuestion(string $quesType, string $repType, string $langue) : ?QuestionEntity{
switch([$questType,$repType]){
case ["Quote","Src"]:
$q = $this -> gateway -> getQuestionQuoteSrc($langue);
return new QuestionEntity(
$q[], //idQuote
$q[], //Quote
$q[], //SrcJuste
$q[], //rndSrc 1
$q[], //rndSrc 2
$q[], //rndSrc 3
$q[], //SrcJuste
);
case ["Quote","Charac"]:
$q = $this -> gateway -> getQuestionQuoteCharac($langue);
case ["Charac","Src"]:
$q = $this -> gateway -> getQuestionCharacSrc($langue);
case ["Charac","Quote"]:
$q = $this -> gateway -> getQuestionCharacQuote($langue);
case ["Src","Quote"]:
$q = $this -> gateway -> getQuestionSrcQuote($langue);
case ["Src","Charac"]:
$q = $this -> gateway -> getQuestionSrcCharac($langue);
case ["Test","Test"]:
return new QuestionEntity(-1,"1","1","2","3","4","1");
default :
return null;
}
}
} }
Loading…
Cancel
Save