break; case "edit-question": $q = getQuestionByID($r['edit-question']); createQuestionForm(true, $r['edit-question'], $q['question'], $q['display'], $q['answers'], $q['search']); break; case "update-question": if (!updateQuestion($v, $r['text'], $r['display'], $r['answers'], $r['search'])) { echo 'fehler beim bearbeiten der frage'; } else { echo "änderungen wurden gespeichert"; } echoQuestionList(getQuestionList()); break; case "delete-question": if ($r['accept'] && $r['submit'] == "ja") { deleteQuestion($v); echo "frage wurde gelöscht"; echoQuestionList(getQuestionList()); } else { if ($v && $r['submit'] == "nein") { echoQuestionList(getQuestionList()); } else { $question = getQuestionByID($v); $id = "<ins style='background-color:#FA8D18'>" . $v . "</ins>"; $frage = "<ins style='background-color:#FA8D18'>" . $question['question'] . "</ins>"; areyousure("?delete-question=" . $v . "&accept=true", "Frage (" . $frage . ") mit der Id " . $id . " löschen?", "Achtung! Diese Frage wird gelöscht. Ist diese Frage Teil eines Fragebogens kann dies zu Systemfehlern führen!"); } } break; break; case "choose-form":
$question_data = $db_con->selectEntries(false, 'dynmc_questions', array("where" => "question_ID = " . $question_ID))[0]; $incorrect_answers = $db_con->selectEntries(true, 'dynmc_incorrect', array("where" => "incorrect_question_ID = " . $question_ID)); foreach ($incorrect_answers as $incorrect) { $question_data['incorrect_answers'][] = $incorrect['incorrect_text']; } //foreach $question_data["db_error"] = $db_con->getErrorMessage(); print json_encode($question_data); } else { if (isset($_POST['delete_test'])) { $test_id = $_POST['selected_test_id']; $db_con = new Db_Connection(); //delete questions: $lookups = $db_con->selectEntries(false, 'dynmc_lookup', array("where" => "lookup_test_ID = " . $test_id)); for ($i = 0; $i < sizeof($lookups); $i++) { deleteQuestion($lookups[$i]['lookup_question_ID'], $test_id); } //for $db_con->deleteEntries(true, 'tests', array("where" => "test_ID = " . $test_id)); if ($db_con->getErrorMessage() !== '') { $error = true; $error_msg = 'The following error has occurred while deleting the test: ' . $db_con->getErrorMessage(); } else { $deleted_successfully = true; } //else include INCLUDE_PATH . 'index.php'; } else { if (isset($_GET['new_option'])) { resumeAndCheckSession(); $timestamp = $_GET['timestamp'];
/** * function actionEdit: * processes subaction and calls getQuizEditForm function which renders edit interface */ public function actionEdit() { // dataSource: the $dataSource argument to get*Form() functions specifies where to persist data for the form from. // if a submit was in progress, and the submit was successful, we set dataSource to db. // else, we set dataSource to POST, because we need to present the user's entered values, rather than existing values // so that he/she may make changes and submit again, with least hassle. if (isset($_GET['subaction'])) { switch ($_GET['subaction']) { case 'addsections': if (!$this->isValidId($_POST['txtSectionCount'])) { displayerror('Error. No count specified.'); } else { $count = escape($_POST['txtSectionCount']); if (addSections($this->moduleComponentId, $count) !== false) { displayinfo('Section(s) added successfully.'); } } break; case 'editsection': $dataSource = 'db'; if (!$this->isValidId($_GET['sectionid'])) { displayerror('Error. Invalid section id specified.'); } elseif (isset($_POST['btnSubmit'])) { $dataSource = 'POST'; if (submitSectionEditForm($this->moduleComponentId, intval($_GET['sectionid']))) { displayinfo('Section properties saved successfully.'); $dataSource = 'db'; } } return getSectionEditForm($this->moduleComponentId, intval($_GET['sectionid']), $dataSource); break; case 'deletesection': if (!$this->isValidId($_POST['hdnSectionId'])) { displayerror('Error. Invalid section id specified.'); } elseif (deleteSection($this->moduleComponentId, intval($_POST['hdnSectionId']))) { displayinfo('The specified section was successfully deleted.'); } break; case 'movesection': if (!$this->isValidId($_GET['sectionid'])) { displayerror('Error. Invalid section id specified.'); } elseif (!isset($_GET['direction']) || $_GET['direction'] != 'up' && $_GET['direction'] != 'down') { displayerror('Error. No or invalid direction specified. Could not move section.'); } elseif (moveSection($this->moduleComponentId, intval($_GET['sectionid']))) { displayinfo('The specified section was successfully moved.'); } break; case 'addquestions': if (!$this->isValidId($_GET['sectionid'])) { displayerror('Error. No or invalid section id specified. Could not add question.'); } elseif (!$this->isValidId($_POST['txtQuestionCount'])) { displayerror('Error. No or invalid count specified. Could not add question.'); } else { $count = intval($_POST['txtQuestionCount']); $insertIds = addQuestions($this->moduleComponentId, intval($_GET['sectionid']), $count); if ($insertIds !== false) { displayinfo('New question(s) added successfully.'); } } break; case 'editquestion': $dataSource = 'db'; if (!$this->isValidId($_GET['sectionid']) || !$this->isValidId($_GET['questionid'])) { displayerror('Error. Invalid section or question specified.'); } elseif (isset($_POST['btnSubmit'])) { $dataSource = 'POST'; if (submitQuestionEditForm($this->moduleComponentId, intval($_GET['sectionid']), intval($_GET['questionid']))) { displayinfo('Question properties saved successfully.'); $dataSource = 'db'; } } return getQuestionEditForm($this->moduleComponentId, intval($_GET['sectionid']), intval($_GET['questionid']), $dataSource); break; case 'deletequestion': if (!$this->isValidId($_POST['hdnSectionId']) || !$this->isValidId($_POST['hdnQuestionId'])) { displayerror('Error. Invalid section or question specified.'); } elseif (deleteQuestion($this->moduleComponentId, intval($_POST['hdnSectionId']), intval($_POST['hdnQuestionId']))) { displayinfo('Question successfully deleted.'); } break; case 'movequestion': if (!$this->isValidId($_GET['sectionid'])) { displayerror('Error. Invalid section id specified.'); } elseif (!$this->isValidId($_GET['questionid'])) { displayerror('Error. Invalid question id specified.'); } elseif (!isset($_GET['direction']) || $_GET['direction'] != 'up' && $_GET['direction'] != 'down') { displayerror('Error. No or invalid direction specified. Could not move section.'); } elseif (moveQuestion($this->moduleComponentId, intval($_GET['sectionid']), intval($_GET['questionid']), $_GET['direction'])) { displayinfo('The specified question was successfully moved.'); } break; } } if (isset($_POST['btnSetWeightMarks'])) { if (setWeightMark(intval($_POST['quizId']), intval($_POST['weight']), intval($_POST['pos']), intval($_POST['neg']))) { displayinfo('Weight - Marks saved.'); } else { displayerror('Error in changing weight mark'); } } $dataSource = 'db'; if (isset($_POST['btnSubmit'])) { $dataSource = 'POST'; if (submitQuizEditForm($this->moduleComponentId)) { $dataSource = 'db'; } } return getQuizEditForm($this->moduleComponentId, $dataSource); }
<?php require_once '../includes/mysql.php'; if (isset($_POST['id'])) { deleteQuestion($_POST['id']); }
<?php if (isset($_POST["box_questions"])) { foreach ($_POST["box_questions"] as $f_questionid) { deleteQuestion((int) $f_questionid); } } else { $f_questionid = (int) readGetVar('questionid'); deleteQuestion($f_questionid); } if (isset($_GET["testid"])) { gotoLocation('test-manager.php' . getURLAddon('?action=editt', array('action', 'confirmed', 'questionid'))); } else { gotoLocation('question-bank.php' . getURLAddon('', array('action', 'confirmed', 'questionid'))); } function deleteQuestion($i_questionid) { global $g_db, $srv_settings; $i_rSet1 = $g_db->Execute("SELECT test_questionid, testid FROM " . $srv_settings['table_prefix'] . "tests_questions WHERE questionid={$i_questionid} ORDER BY test_questionid DESC"); if (!$i_rSet1) { showDBError(__FILE__, 1); } else { while (!$i_rSet1->EOF) { deleteQuestionLink($i_rSet1->fields["testid"], $i_rSet1->fields["test_questionid"]); $i_rSet1->MoveNext(); } $i_rSet1->Close(); } if ($g_db->Execute("DELETE FROM " . $srv_settings['table_prefix'] . "answers WHERE questionid={$i_questionid}") === false) { showDBError(__FILE__, 2); }
} $breadcrumbs->addElement($lang->get('poll_create'), makeURL($mod, array('mode' => 'create'))); $polltitle = @trim($_POST['poll']['title']); $polldescription = @$_POST['poll']['description']; if (isset($_POST['send']) && $polltitle != '') { // Poll exists if ($poll) { updatePoll($pollid, $polltitle, $polldescription); // Create new poll } else { $pollid = savePoll($polltitle, $polldescription, $login->currentUserId()); redirect(makeUrl('detailedpoll', array('mode' => 'create', 'pollid' => $pollid))); } foreach ($_POST['data'] as $key => $dataset) { if (isset($dataset['delete'])) { deleteQuestion($key); } $rank = $dataset['rank']; $parentid = $dataset['parentid']; $title = trim($dataset['title']); $description = $dataset['description']; $percent = $dataset['percent']; if (!parentExists($pollid, $parentid)) { $notify->add($lang->get('detailedpoll'), sprintf($lang->get('notify_parent_missing'), $parentid, $title)); } else { if ($title != '') { if ($key == 'new') { saveQuestion($pollid, $title, $description, $rank, $parentid, $percent); } else { updateQuestion($key, $title, $description, $rank, $parentid, $percent); }