}
        $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;
        }
        $questionId = "";
        if ($managerQuiz->getById($vq->sanitized['id_quiz'])) {
            $questionId = $managerQuestion->add(new Question(array('content' => $vq->sanitized['question'], 'quizId' => $vq->sanitized['id_quiz'], 'type' => $_POST['typeQcm'] === "unique" ? "unique" : "multiple")));
            foreach ($vv->sanitized as $key => $value) {
                $managerProp->add(new Proposition(array('content' => $vv->sanitized[$key], 'questionId' => $questionId, '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'] === "remove-question") {
    if (isset($_POST['id_question']) && isset($_POST['id_quiz'])) {
        $managerQuiz = new QuizManager();
        $managerQuestion = new QuestionManager();
示例#2
0
 $adminLvlThisControler = 4;
 require_once 'lib/checkRights.php';
 if (isset($_POST['file']) && !empty($_POST['theme'])) {
     if ($file = fopen('web/csv/' . $_POST['file'], 'r')) {
         $questionManager = new QuestionManager($bdd);
         $question = new Question(array());
         while ($ligne = fgetcsv($file, 0, '|', '"')) {
             $question->setQuestion(stripslashes($ligne[0]));
             $question->setRep1($ligne[1]);
             $question->setRep2($ligne[2]);
             $question->setRep3($ligne[3]);
             $question->setRep4($ligne[4]);
             $question->setRep($ligne[5]);
             $question->setThemeid($_POST['theme']);
             $question->setUserid($ligne[6]);
             $questionManager->add($question);
         }
         header('Location: ?controler=question&action=list');
     }
 } else {
     $directory = 'web/csv/';
     $files = array_diff(scandir($directory), array('..', '.'));
     $themeManager = new ThemeManager($bdd);
     $themes = $themeManager->getList();
     ob_start();
     require_once 'view/question/csvimport.php';
     $content = ob_get_contents();
     ob_end_clean();
     require_once 'view/layout/layout.php';
 }
 break;