|
|
|
@ -10,7 +10,7 @@ class GatewayQuestion
|
|
|
|
|
$this->con = new Connection($dns, $user, $pass);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function addQuestion($question)
|
|
|
|
|
public function addQuestion($question)
|
|
|
|
|
{
|
|
|
|
|
$query = "insert into questions(content,idchapter,difficulty,nbfails) values (:content,:idchapter,:difficulty,:nbfails);";
|
|
|
|
|
$this->con->executeQuery(
|
|
|
|
@ -40,11 +40,11 @@ class GatewayQuestion
|
|
|
|
|
$query = "SELECT * FROM questions";
|
|
|
|
|
$this->con->executeQuery($query);
|
|
|
|
|
$results = $this->con->getResults();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $results;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function updateQuestion($id,$question)
|
|
|
|
|
public function updateQuestion($id, $question)
|
|
|
|
|
{
|
|
|
|
|
$query = "UPDATE questions SET content = :content, idchapter = :idchapter, idanswergood = :idanswergood WHERE id = :id;";
|
|
|
|
|
$this->con->executeQuery(
|
|
|
|
@ -63,19 +63,19 @@ class GatewayQuestion
|
|
|
|
|
$query = "DELETE FROM questions WHERE id = :id;";
|
|
|
|
|
$this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getQuestionsByChapterAndDifficulty($idChapter,$difficulty)
|
|
|
|
|
|
|
|
|
|
public function getQuestionsByChapterAndDifficulty($idChapter, $difficulty)
|
|
|
|
|
{
|
|
|
|
|
var_dump($idChapter,$difficulty);
|
|
|
|
|
$query = "SELECT * FROM questions WHERE idchapter = :idChapter AND difficulty = :difficulty;";
|
|
|
|
|
$this->con->executeQuery($query,
|
|
|
|
|
$this->con->executeQuery(
|
|
|
|
|
$query,
|
|
|
|
|
array(
|
|
|
|
|
':idChapter' => array($idChapter, PDO::PARAM_INT),
|
|
|
|
|
':difficulty' => array($difficulty, PDO::PARAM_INT),
|
|
|
|
|
':idChapter' => array($idChapter, PDO::PARAM_INT),
|
|
|
|
|
':difficulty' => array($difficulty, PDO::PARAM_INT),
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$results = $this->con->getResults();
|
|
|
|
|
|
|
|
|
|
return $results[0];
|
|
|
|
|
return $results;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|