diff --git a/src/questionModel.php b/src/questionModel.php new file mode 100644 index 0000000..d0dc225 --- /dev/null +++ b/src/questionModel.php @@ -0,0 +1,65 @@ + gateway = $gateway; + } + + public function createQuestion(int $id_question, string $question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer) : bool + { + $q = new QuestionEntity($id_question, $question, $answerA, $answerB, $answerC, $answerD, $cAnswer); + return $this -> gateway -> create($q); + } + + public function getQuestion(int $id_question) : ?QuestionEntity + { + return $this -> gateway -> findById($id_question); + } + + public function updateTextQuestion(int $id_question, string $question) : bool + { + $q = $this -> gateway -> findById($id_question); + + if ($q) + { + $q -> setQuestion($question); + return $this -> gateway -> updateText($q); + } + + return false; + } + + public function updateAnswersQuestion(int $id_question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer) : bool + { + $q = $this -> gateway -> findById($id_question); + + if ($q) + { + $q -> setAnswerA($answerA); + $q -> setAnswerB($answerB); + $q -> setAnswerC($answerC); + $q -> setAnswerD($answerD); + $q -> setAnswerC($cAnswer); + return $this -> gateway -> updateAnswers($q); + } + + return false; + } + + public function deleteQuestion(int $id_question) : bool + { + return $this -> gateway -> delete($id_question); + } + + public function getAllQuestions() : array + { + return $this -> gateway -> findAll(); + } +} \ No newline at end of file