public function delete($id) { $id = (int) $id; $question = $this->getById($id); $managerProp = new PropositionManager(); foreach ($question->getPropositions() as $prop) { $managerProp->delete($prop->getId()); } $this->_access->delete(StudyPressDB::getTableNameQuestions(), array(StudyPressDB::COL_ID_QUESTION => $id)); }
$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") { if (isset($_POST['order']) && !empty($_POST['order'])) { $managerQuestion = new QuestionManager();