Ejemplo n.º 1
0
 public function getQuestionsOfQuiz($quizId)
 {
     $questions = array();
     $quizId = (int) $quizId;
     $managerProp = new PropositionManager();
     $result = $this->_access->getResults($this->_access->prepare("SELECT * FROM " . StudyPressDB::getTableNameQuestions() . " WHERE " . StudyPressDB::COL_ID_QUIZ_QUESTION . " = '%d' ORDER BY " . StudyPressDB::COL_ORDER_QUESTION . " ASC", $quizId));
     foreach ($result as $row) {
         $question = self::returnedQuestion($row);
         if ($question) {
             $question->setPropositions($managerProp->getPropositionsOfQuestion($question->getId()));
             array_push($questions, $question);
         }
     }
     return $questions;
 }
Ejemplo n.º 2
0
                    $result['propositions'][$key]['true'] = $prop->getType();
                }
                $result['result'] = "true";
                echo json_encode($result);
            } else {
                $result['result'] = "false";
                echo json_encode($result);
            }
        }
    }
}
if (isset($_POST['type']) && $_POST['type'] === "update-question") {
    if (isset($_POST['id_quiz']) && isset($_POST['value']) && isset($_POST['checked']) && isset($_POST['question']) && isset($_POST['id_question'])) {
        $managerQuiz = new QuizManager();
        $managerQuestion = new QuestionManager();
        $managerProp = new PropositionManager();
        $vq = new validation();
        $vv = new validation();
        $vq->addSource($_POST);
        $vv->addSource($_POST['value']);
        $vq->AddRules(array('question' => array('type' => 'string', 'required' => 'true', 'min' => '1', 'max' => '9999', 'trim' => 'true'), 'id_quiz' => array('type' => 'numeric', 'required' => 'true', 'min' => '1', 'max' => '999999', 'trim' => 'true'), 'id_question' => array('type' => 'numeric', 'required' => 'true', 'min' => '1', 'max' => '999999', 'trim' => 'true')));
        foreach ($_POST['value'] as $key => $value) {
            if (preg_match('/^[0-9]{1,}$/', $key)) {
                $vv->addRule($key . "", 'string', true, 1, 99999, true);
            }
        }
        $checked = array();
        //rules checked
        foreach ($_POST['checked'] as $key => $value) {
            if (preg_match('/^[0-9]{1,}$/', $key)) {
                if ($value === "false") {