}
        $vq->run();
        $vv->run();
        if (sizeof($vv->errors) > 0 || sizeof($vq->errors) > 0) {
            header("HTTP/1.0 400 Bad Request");
            $tr->_e("Please fill in all fields");
            exit;
        }
        if (count($vv->sanitized) !== count($checked) || count($vv->sanitized) < 2 || !in_array("true", $checked, true)) {
            header("HTTP/1.0 400 Bad Request");
            $tr->_e("Please select at least one correct answer");
            exit;
        }
        if ($managerQuiz->getById($vq->sanitized['id_quiz']) && ($question = $managerQuestion->getById($vq->sanitized['id_question']))) {
            $question->setContent($vq->sanitized['question']);
            $managerQuestion->update($vq->sanitized['id_question'], $question);
            foreach ($question->getPropositions() as $prop) {
                $managerProp->delete($prop->getId());
            }
            foreach ($vv->sanitized as $key => $value) {
                $managerProp->add(new Proposition(array('content' => $vv->sanitized[$key], 'questionId' => $question->getId(), 'type' => $checked[$key])));
            }
            echo "true";
        }
    } else {
        header("HTTP/1.0 400 Bad Request");
        $tr->_e("Please fill in all fields");
    }
    exit;
}
if (isset($_POST['type']) && $_POST['type'] === "order-question") {
示例#2
0
     if (isset($_GET['id']) && !isset($_POST['question']) && !isset($_POST['rep'])) {
         $questionManager = new QuestionManager($bdd);
         $question = $questionManager->get((int) $_GET['id']);
         $themeManager = new ThemeManager($bdd);
         $themes = $themeManager->getList();
         ob_start();
         require_once 'view/question/updateQuestion.php';
         $content = ob_get_contents();
         ob_end_clean();
         require_once 'view/layout/layout.php';
     } elseif (isset($_POST['question']) && isset($_POST['rep'])) {
         $questionManager = new QuestionManager($bdd);
         $question = new Question($_POST);
         $questionOld = $questionManager->get($question->id());
         $question->setUserid($questionOld->userid());
         $questionManager->update($question);
         header('Location: ?controler=question&action=list');
     } else {
         header('Location: ?controler=question&action=list');
     }
     break;
 case 'delete':
     $adminLvlThisControler = 3;
     require_once 'lib/checkRights.php';
     if (isset($_GET['id'])) {
         $questionManager = new QuestionManager($bdd);
         $questionManager->delete($_GET['id']);
         header('Location: ?controler=question&action=list');
     } else {
         header('Location: ?controler=question&action=list');
     }