83 lines
2.0 KiB
PHP
83 lines
2.0 KiB
PHP
|
<?php
|
||
|
|
||
|
/**
|
||
|
* @brief Question du burger quizz
|
||
|
*/
|
||
|
class question
|
||
|
{
|
||
|
|
||
|
///Identifiant de la question
|
||
|
private $id;
|
||
|
|
||
|
///Identidiant du groupe associé à la question
|
||
|
private $group_id;
|
||
|
|
||
|
///libelle de la question
|
||
|
private $question_text;
|
||
|
|
||
|
///Index de la bonne réponse à la question (0, 1, 2 pour les 2)
|
||
|
private $bonne_reponse;
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @brief Constructeur de question
|
||
|
* @arg $id identifiant de la question
|
||
|
* @arg $groupe_id identifiant du groupe associé à la question
|
||
|
* @arg $question texte de la question
|
||
|
* @arg $reponse index de la réponse
|
||
|
* @note si group_id est NULL, on charge les données à partir de la base de données
|
||
|
*/
|
||
|
public function __construct($id, $group_id = NULL, $question = NULL, $reponse = NULL)
|
||
|
{
|
||
|
if ($group_id == NULL)
|
||
|
{
|
||
|
//On demande le chargement via l'ID seulement
|
||
|
//On charge les fichiers nécessaires
|
||
|
include_once './dao/question_dao.php';
|
||
|
|
||
|
//On met en place un nouvel objet DAO
|
||
|
$dao = new question_dao();
|
||
|
|
||
|
//On charge les données
|
||
|
$data = $dao->select($id);
|
||
|
|
||
|
//On parse les données récupérées
|
||
|
$this->id = $id;
|
||
|
$this->group_id = $data["group_id"];
|
||
|
$this->question = $data["question"];
|
||
|
$this->bonne_reponse = $data["bonnereponse"];
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//On crée un nouvel objet
|
||
|
$this->id = $id;
|
||
|
$this->group_id = $group_id;
|
||
|
$this->question_text = $question;
|
||
|
$this->bonne_reponse = $reponse;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function getId()
|
||
|
{
|
||
|
return $this->id;
|
||
|
}
|
||
|
|
||
|
public function getGroupId()
|
||
|
{
|
||
|
return $this->group_id;
|
||
|
}
|
||
|
|
||
|
public function getQuestion()
|
||
|
{
|
||
|
return $this->question_text;
|
||
|
}
|
||
|
|
||
|
public function getReponse()
|
||
|
{
|
||
|
return $this->bonne_reponse;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
?>
|