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.
WF-Website/src/Model/QuizQuestionModel.php

56 lines
1.3 KiB

<?php
namespace Model;
use Entity\QuizQuestionEntity;
use Gateway\QuizQuestionGateway;
class QuizQuestionModel
{
private QuizQuestionGateway $gw;
public function __construct(QuizQuestionGateway $gw)
{
$this -> gw = $gw;
}
public function createQuizQuestionModel(int $idQuiz, int $idQuestion) : bool
{
return $this -> gw -> createQuizQuestionGateway($idQuiz, $idQuestion);
}
public function getQuizQuestionById(int $idQuiz, int $idQuestion) : ?QuizQuestionEntity
{
$res = $this -> gw -> findQuizQuestionById($idQuiz, $idQuestion);
if ($res)
{
return new QuizQuestionEntity (
$res[0]['quiz_qq'],
$res[0]['question_qq']
);
}
return null;
}
public function getQuestionsFromQuiz(int $idQuiz) : array
{
$res = $this -> gw -> findQuestionsFromQuiz($idQuiz);
$questions = [];
foreach ($res as $question)
{
$questions[] = new QuizQuestionEntity (
$question['quiz_qq'],
$question['question_qq']
);
}
return $questions;
}
public function deleteQuizQuestionModel(int $idQuiz, int $idQuestion) : bool
{
return $this -> gw -> deleteQuizQuestionGateway($idQuiz, $idQuestion);
}
}