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.
42 lines
1.2 KiB
42 lines
1.2 KiB
<?php
|
|
//require_once ('Question.php');
|
|
class QCMGateway {
|
|
private $db;
|
|
|
|
|
|
function __construct(SqliteDb $db) {
|
|
$this->db=$db;
|
|
}
|
|
|
|
public function afficherQCM() {
|
|
$i = 0;
|
|
$query = 'SELECT * FROM QcmQuestion';
|
|
$query = $this->db->prepare($query);
|
|
$result = $query->execute();
|
|
$tabQuestions = array();
|
|
//$resultats = $this->db->query('SELECT found_rows()');
|
|
while($q = $result->fetchArray()){
|
|
$i= $i+1;
|
|
$reponseQuery = 'SELECT * FROM QcmReponse WHERE numQuestion=?';
|
|
$stmt = $this->db->prepare($reponseQuery);
|
|
$stmt->bindParam(1, $q['numQuestion']);
|
|
$reponseResult = $stmt->execute();
|
|
$i=0;
|
|
$tabReponses =array();
|
|
while ($r = $reponseResult->fetchArray()){
|
|
|
|
$i++;
|
|
$tabReponses[] = new ReponseQCM($r['numReponse'], $r['reponse'], $r['numQuestion']) ;
|
|
|
|
}
|
|
//die(print_r($i, true ));
|
|
$tabQuestions[] = new QCM($q['numQuestion'],$q['question'],$tabReponses);
|
|
}
|
|
//die(print_r($tabQuestions, true ));
|
|
return $tabQuestions;
|
|
}
|
|
|
|
}
|
|
|
|
|