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.
31 lines
1.1 KiB
31 lines
1.1 KiB
<?php
|
|
|
|
namespace Gateway;
|
|
use PDO;
|
|
|
|
class QuizQuestionGateway extends Gateway
|
|
{
|
|
|
|
/**
|
|
* Retrieves the questions associated with a specific quiz.
|
|
*
|
|
* This method fetches all records from the `Quiz_Question` table that are linked to a specific quiz by its ID.
|
|
*
|
|
* @param int $idQuiz The ID of the quiz for which the questions are to be retrieved.
|
|
*
|
|
* @return array Returns an array of questions linked to the provided quiz ID. Each question is represented as an associative array with its columns as keys.
|
|
*/
|
|
public function findQuestionsFromQuiz(int $idQuiz) : array
|
|
{
|
|
// SQL query to select all records from the Quiz_Question table where the quiz ID matches the given ID
|
|
$query = "SELECT * FROM Quiz_Question
|
|
WHERE quiz = :id_quiz";
|
|
|
|
// Execute the query with the provided quiz ID
|
|
$this -> co -> executeQuery($query, ['id_quiz' => array($idQuiz, PDO::PARAM_INT)]);
|
|
|
|
// Return the results retrieved from the database
|
|
return $this -> co -> getResults();
|
|
}
|
|
|
|
} |