|
|
|
@ -29,8 +29,7 @@ class ControllerAdminQuestions
|
|
|
|
|
'questions' => $questions,
|
|
|
|
|
'chapters' => $chapters,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
header("Location:/login");
|
|
|
|
|
}
|
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
@ -40,12 +39,14 @@ class ControllerAdminQuestions
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function delete($param) {
|
|
|
|
|
function delete($param)
|
|
|
|
|
{
|
|
|
|
|
$this->mdQuestion->deleteQuestionByID($param["id"]);
|
|
|
|
|
header("Location:/admin/questions");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function add($param) {
|
|
|
|
|
function add($param)
|
|
|
|
|
{
|
|
|
|
|
$content = $_POST['content'];
|
|
|
|
|
$idChapter = intval($_POST['idChapter']);
|
|
|
|
|
$AnswersPost = array();
|
|
|
|
@ -58,6 +59,7 @@ class ControllerAdminQuestions
|
|
|
|
|
$Question = [
|
|
|
|
|
'content' => $content,
|
|
|
|
|
'idchapter' => $idChapter,
|
|
|
|
|
'idanswergood' => $correctAnswer,
|
|
|
|
|
'difficulty' => 1,
|
|
|
|
|
'nbfails' => 0,
|
|
|
|
|
];
|
|
|
|
@ -90,28 +92,38 @@ class ControllerAdminQuestions
|
|
|
|
|
header("Location:/admin/questions");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updatemodal($param) {
|
|
|
|
|
|
|
|
|
|
function updatemodal($param)
|
|
|
|
|
{
|
|
|
|
|
$question = $this->mdQuestion->getQuestionByID($param["id"]);
|
|
|
|
|
|
|
|
|
|
$answers = array();
|
|
|
|
|
$answers = $this->mdAnswer->getAnswersByIDQuestions($param["id"]);
|
|
|
|
|
$answersIDArray = $this->mdAnswer->getAnswersByIDQuestions($param["id"]);
|
|
|
|
|
|
|
|
|
|
$chapters = $this->mdChapter->getChapters();
|
|
|
|
|
|
|
|
|
|
$answers = array();
|
|
|
|
|
$i = 0;
|
|
|
|
|
foreach ($answersIDArray as $answerIDArray) {
|
|
|
|
|
$answers["{$i}"] = $answerIDArray;
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo $this->twig->render($this->vues["adminQuestionsModal"], [
|
|
|
|
|
'question' => $question,
|
|
|
|
|
'chapters' => $chapters,
|
|
|
|
|
'answers' => $answers,
|
|
|
|
|
'answerZero' => $answers[0],
|
|
|
|
|
'answerOne' => $answers[1],
|
|
|
|
|
'answerTwo' => $answers[2],
|
|
|
|
|
'answerThree' => $answers[3],
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function update($param) {
|
|
|
|
|
function update($param)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$id = $_POST['id'];
|
|
|
|
|
$content = $_POST['content'];
|
|
|
|
|
$idChapter = intval($_POST['idChapter']);
|
|
|
|
|
|
|
|
|
|
var_dump($idChapter);
|
|
|
|
|
$correctAnswer = intval($_POST['correctAnswer']);
|
|
|
|
|
|
|
|
|
|
$answersId = array();
|
|
|
|
@ -126,23 +138,25 @@ class ControllerAdminQuestions
|
|
|
|
|
$answers[2] = $_POST['answer3'];
|
|
|
|
|
$answers[3] = $_POST['answer4'];
|
|
|
|
|
|
|
|
|
|
$Question = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$questionDataArray = [
|
|
|
|
|
'content' => $content,
|
|
|
|
|
'idchapter' => $idChapter,
|
|
|
|
|
'idanswergood' => $answersId[$correctAnswer],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$this->mdQuestion->updateQuestion($id, $Question);
|
|
|
|
|
$this->mdQuestion->updateQuestion($id, $questionDataArray);
|
|
|
|
|
|
|
|
|
|
for ($i = 0; $i <= 3; $i++) {
|
|
|
|
|
$Answers[] = [
|
|
|
|
|
$answersDataArray[] = [
|
|
|
|
|
'content' => $answers[$i],
|
|
|
|
|
'id' => $id,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var_dump($answersId, $answersDataArray);
|
|
|
|
|
for ($i = 0; $i <= 3; $i++) {
|
|
|
|
|
$this->mdAnswer->updateAnswer($answersId[$i],$Answers[$i]);
|
|
|
|
|
$this->mdAnswer->updateAnswer($answersId[$i], $answersDataArray[$i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
header("Location:/admin/questions");
|
|
|
|
|