示例#1
0
 public static function GetQuestion($category)
 {
     $dbh = MySqlConnection::getInstance();
     /** @var \PDOStatement $statement */
     $statement = $dbh->prepare('SELECT * FROM mdl_question WHERE category = :cat AND qtype != "random" ORDER BY RAND() LIMIT 1');
     $statement->bindParam(':quizid', $category);
     $statement->setFetchMode(PDO::FETCH_ASSOC);
     $statement->execute();
     $question = $statement->fetch();
     return Examen::instanceQuestion($question);
 }
 private static function getQuestion($id)
 {
     /** @var MySqlConnection $dbh */
     $dbh = MySqlConnection::getInstance();
     /** @var \PDOStatement $statement */
     $statement = $dbh->prepare('SELECT * FROM mdl_question WHERE id = :id');
     $statement->bindParam(':id', $id);
     $statement->execute();
     $_question = $statement->fetch();
     if (is_array($_question)) {
         return Examen::instanceQuestion($_question);
     }
     return null;
 }