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.
49 lines
1014 B
49 lines
1014 B
<?php
|
|
|
|
namespace Model;
|
|
|
|
use Entity\quizEntity;
|
|
use Gateway\QuizGateway;
|
|
use Gateway\Gateway;
|
|
|
|
class QuizModel extends Model{
|
|
|
|
public function createQuiz(int $id_quiz, int $nb_questions) : bool
|
|
{
|
|
return $this -> gateway -> create($id_quiz, $nb_questions);
|
|
}
|
|
|
|
public function getQuiz(int $id_quiz): ?quizEntity
|
|
{
|
|
$q = $this -> gateway -> findQuizById($id_quiz);
|
|
if ($q) {
|
|
return new quizEntity(
|
|
$q[0]['id_quiz'],
|
|
$q[0]['nb_quest']
|
|
);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public function deleteQuiz(int $id_quiz) : bool
|
|
{
|
|
return $this -> gateway -> delete($id_quiz);
|
|
}
|
|
|
|
public function getAllQuiz() : array
|
|
{
|
|
$q = $this -> gateway -> findAll();
|
|
|
|
$quizzes = [];
|
|
|
|
foreach ($q as $quiz) {
|
|
$quizzes[] = new quizEntity(
|
|
$quiz['id_quiz'],
|
|
$quiz['nb_questions']
|
|
);
|
|
}
|
|
return $quizzes;
|
|
|
|
}
|
|
|
|
} |