function delete() { $this->is_loggedin(); global $runtime; $to_trash = new Question($runtime['ident']); $to_trash->delete(); redirect('questions/all'); }
function delete($id = NULL) { if ($id) { $question = new Question($id); $question->delete(); set_notify('success', lang('delete_data_complete')); } redirect('questions'); }
/** * Edit enquete * @global object $db Database object used to communicate with MySQL database * @param string $name New name of the enquete * @param string $introduction New introduction o * @param date $start_date New start date on which the enquete will start * @param date $end_date New end date on which the enquete wil end * @param array$questions New questions of the enquete * @param array $deleted_questions Ids of the deleted questions * @param array $deleted_attributes Ids of the deleted attributes * @param int $enquete_id The id of the enquete * @param int $user_id The id of the user who edited the enquete */ static function edit($name, $introduction, $start_date, $end_date, $questions, $deleted_questions, $deleted_attributes, $enquete_id, $user_id) { global $db; $data = array("name" => $name, "introduction" => $introduction, "start_date" => $start_date, "end_date" => $end_date, "Users_id" => $user_id); $db->update('Enquetes', $data, "id = {$enquete_id}"); foreach ($questions as $question) { if (isset($question['id'])) { Question::edit($question, $deleted_attributes); } else { Question::make($question, $enquete_id); } } if (!empty($deleted_questions) && count($deleted_questions) > 0) { foreach ($deleted_questions as $deleted_question) { Question::delete($deleted_question); } } }
$dialogBox = new DialogBox(); /* * Execute commands */ // use question in exercise if ($cmd == 'rqUse' && !is_null($quId) && !is_null($exId)) { if ($exercise->addQuestion($quId)) { // TODO show confirmation and back link header('Location: ' . Url::Contextualize('edit_exercise.php?exId=' . $exId)); } } // delete question if ($cmd == 'delQu' && !is_null($quId)) { $question = new Question(); if ($question->load($quId)) { if (!$question->delete()) { // TODO show confirmation and list } } } // export question if ($cmd == 'exExport' && get_conf('enableExerciseExportQTI')) { require_once '../export/qti2/qti2_export.php'; require_once get_path('incRepositorySys') . '/lib/fileManage.lib.php'; require_once get_path('incRepositorySys') . '/lib/file.lib.php'; require_once get_path('incRepositorySys') . '/lib/thirdparty/pclzip/pclzip.lib.php'; $question = new Qti2Question(); $question->load($quId); // contruction of XML flow $xml = $question->export(); // remove trailing slash
define('QUESTIONS_PER_PAGE', 15); if (!isset($_GET['page'])) { $page = 0; } else { $page = $_GET['page']; } if ($is_editor) { // deletes a question from the data base and all exercises if (isset($_GET['delete'])) { $delete = intval($_GET['delete']); // construction of the Question object $objQuestionTmp = new Question(); // if the question exists if ($objQuestionTmp->read($delete)) { // deletes the question from all exercises $objQuestionTmp->delete(); } // destruction of the Question object unset($objQuestionTmp); //Session::set_flashdata($message, $class); redirect_to_home_page("modules/exercise/question_pool.php?course={$course_code}" . (isset($fromExercise) ? "&fromExercise={$fromExercise}" : "") . "&exerciseId={$exerciseId}"); } elseif (isset($_GET['recup']) && isset($fromExercise)) { $recup = intval($_GET['recup']); // construction of the Question object $objQuestionTmp = new Question(); // if the question exists if ($objQuestionTmp->read($recup)) { // adds the exercise ID into the list of exercises for the current question $objQuestionTmp->addToList($fromExercise); } // destruction of the Question object
<?php require_once "/etc/apache2/capstone-mysql/encrypted-config.php"; require_once "question.php"; $pdo = connectToEncryptedMySQL("/etc/apache2/data-design/jfindley2.ini"); $question = new Question(null, 1, 2, "Huh?", null); $question->insert($pdo); $question->setQuestionText("What?"); $question->update($pdo); $question->delete($pdo);
public static function deleteCustom() { RecruiterController::requireLogin(); global $params; $questionId = new MongoId($params['questionId']); $jobId = new MongoId($params['jobId']); $recruiterId = $_SESSION['_id']; $question = Question::getById($questionId); if ($question->getVanilla() == true) { return; } $usesCount = $question->getUsesCount(); // Delete question only if 'uses' is 0, if ($usesCount == 0) { return Question::delete($questionId); } }
redirect_to_home_page("modules/exercise/admin.php?course={$course_code}&exerciseId={$exerciseId}"); } // moves a question down in the list if (isset($_GET['moveDown'])) { $objExercise->moveDown($_GET['moveDown']); $objExercise->save(); redirect_to_home_page("modules/exercise/admin.php?course={$course_code}&exerciseId={$exerciseId}"); } // deletes a question from the exercise (not from the data base) if (isset($_GET['deleteQuestion'])) { $deleteQuestion = $_GET['deleteQuestion']; // construction of the Question object $objQuestionTmp = new Question(); // if the question exists if ($objQuestionTmp->read($deleteQuestion)) { $objQuestionTmp->delete($exerciseId); // if the question has been removed from the exercise if ($objExercise->removeFromList($deleteQuestion)) { $nbrQuestions--; } } redirect_to_home_page("modules/exercise/admin.php?course={$course_code}&exerciseId={$exerciseId}"); } $tool_content .= action_bar(array(array('title' => $langNewQu, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&exerciseId={$exerciseId}&newQuestion=yes", 'icon' => 'fa-plus-circle', 'level' => 'primary-label', 'button-class' => 'btn-success'), array('title' => $langSelection . ' ' . $langWithCriteria, 'class' => 'randomSelection', 'url' => "#", 'icon' => 'fa-random', 'level' => 'primary-label'), array('title' => $langSelection . ' ' . $langFrom2 . ' ' . $langQuestionPool, 'url' => "question_pool.php?course={$course_code}&fromExercise={$exerciseId}", 'icon' => 'fa-bank', 'level' => 'primary-label'))); if ($nbrQuestions) { $questionList = $objExercise->selectQuestionList(); $i = 1; $tool_content .= "\n <div class='table-responsive'>\n\t <table class='table-default'>\n\t <tr>\n\t <th colspan='2' class='text-left'>{$langQuestionList}</th>\n\t <th class='text-center'>" . icon('fa-gears', $langActions) . "</th>\n\t </tr>"; foreach ($questionList as $id) { $objQuestionTmp = new Question(); $objQuestionTmp->read($id);
private static function delete() { if (!isset($_POST['deleteQuestion'])) { return false; } global $params; extract($data = self::dataDelete($params)); return Question::delete($_id) == 1; }
<?php include '../lib/common.inc.php'; $question = new Question(); $question->id = $_REQUEST['question_id']; $question->delete();
function test_delete() { //Arrange $test_field = "What is their name?"; $test_description = "What you want to call your character."; $test_question = new Question($test_field, $test_description); $test_question->save(); $test_field2 = "What is their profession?"; $test_description2 = "What you want your character to do."; $test_question2 = new Question($test_field2, $test_description2); $test_question2->save(); //Act $test_question->delete(); $result = Question::getAll(); //Assert $this->assertEquals($test_question2, $result[0]); }
// Add empty condition; if (@$_POST['create_question']) { $question = new Question(); $question->author_id = $login_uid; if (!empty($_POST['body'])) { $question->body = $_POST['body']; $question->save(); $message = 'Question has been successfully saved'; } else { $message = 'Fields marked with * must not be left empty'; } } if (@$_GET['action'] == 'delete') { $question = new Question(); if (!empty($_GET['content_id'])) { $question->delete($_GET['content_id']); $message = 'Question has been deleted successfully'; } } } /* ---------- FUNCTION DEFINITION ------------------*/ //call back function function setup_module($column, $module, $obj) { global $configure_permission, $paging; if (!$configure_permission) { return 'skip'; } switch ($module) { case 'ManageQuestionsModule': // $obj->edit = $edit; // this seems to be set nowhere
/** * Deletes the question **/ public function getDelete($id) { //First, let's try to find the question: $question = Question::find($id); if ($question) { //We delete the question directly Question::delete(); //We won't have to think about the tags and the answers, , //because they are set as foreign key and we defined them cascading on deletion, //they will be automatically deleted //Let's return to the index page with a success message return Redirect::route('index')->with('success', 'Question deleted successfully!'); } else { return Redirect::route('index')->with('error', 'Nothing to delete!'); } }
function init() { $question = new Question(); $func = array_shift($this->param); if (is_numeric($func)) { $this->id = $func; } else { if ($func != '') { $_SERVER['REQUEST_METHOD'] = 'POST'; $course_id = array_shift($this->param); Security::checkEditor($course_id); switch ($func) { case 'save': $data['course_id'] = $course_id; $data['type_id'] = $_POST['type_id']; $data['data'] = $_POST['data']; $data['count'] = $_POST['count']; $data['answer'] = $_POST['answer']; $id = $_POST['id']; try { $question->update($id, $data); } catch (Exception $e) { } header('Location: /admin_questions/' . $data['course_id']); exit; break; case 'delete': try { $question_id = array_shift($this->param); $question->delete($question_id); echo "ok"; } catch (Exception $e) { echo $e; } header('Location: /admin_questions/' . $course_id); exit; break; case 'find': try { $data = array('course_id' => $course_id, 'type_id' => 0, 'data' => '', 'answer' => ''); $q_id = $question->add($data); $data['id'] = $q_id; echo json_encode($data); } catch (Exception $e) { echo $e; } exit; break; case 'load': try { $question_id = array_shift($this->param); $data = $question->get(array('course_id' => $course_id, 'id' => $question_id)); echo json_encode($data); } catch (Exception $e) { echo $e; } exit; break; default: } } else { header('Location: /404'); exit; } } }