1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-06-24 09:08:47 +02:00

Phase 3 : réponse aux questions

This commit is contained in:
galaxyoyo
2019-09-21 20:39:40 +02:00
parent ac48412f7e
commit 5355ba87b1
9 changed files with 261 additions and 22 deletions

View File

@ -10,6 +10,8 @@ class Question
private $number;
private $question;
private $attached_file;
private $answer;
private $attached_file_answer;
private function __construct()
{
@ -35,8 +37,8 @@ class Question
{
global $DB;
$req = $DB->prepare("SELECT * FROM `questions` WHERE `attached_file` = ?;");
$req->execute([htmlspecialchars($attached_file)]);
$req = $DB->prepare("SELECT * FROM `questions` WHERE `attached_file` = ? OR `attached_file_answer` = ?;");
$req->execute([htmlspecialchars($attached_file), htmlspecialchars($attached_file)]);
$data = $req->fetch();
if ($data === false)
@ -151,4 +153,30 @@ class Question
$req = $DB->prepare("UPDATE `questions` SET `attached_file` = ? WHERE `id` = ?;");
$req->execute([$attached_file, $this->id]);
}
public function getAnswer()
{
return $this->answer;
}
public function setAnswer($answer)
{
global $DB;
$this->answer = $answer;
$req = $DB->prepare("UPDATE `questions` SET `answer` = ? WHERE `id` = ?;");
$req->execute([$answer, $this->id]);
}
public function getAttachedFileAnswer()
{
return $this->attached_file_answer;
}
public function setAttachedFileAnswer($attached_file)
{
global $DB;
$this->attached_file_answer = $attached_file;
$req = $DB->prepare("UPDATE `questions` SET `attached_file_answer` = ? WHERE `id` = ?;");
$req->execute([$attached_file, $this->id]);
}
}