$answer_new = array_pad($answer_new, 10, 0); $sql = "UPDATE " . TABLE_PREFIX . "tests_questions SET\n\t\t\tcategory_id={$_POST['category_id']},\n\t\t\tfeedback='{$_POST['feedback']}',\n\t\t\tquestion='{$_POST['question']}',\n\t\t\tchoice_0='{$_POST[choice][0]}',\n\t\t\tchoice_1='{$_POST[choice][1]}',\n\t\t\tchoice_2='{$_POST[choice][2]}',\n\t\t\tchoice_3='{$_POST[choice][3]}',\n\t\t\tchoice_4='{$_POST[choice][4]}',\n\t\t\tchoice_5='{$_POST[choice][5]}',\n\t\t\tchoice_6='{$_POST[choice][6]}',\n\t\t\tchoice_7='{$_POST[choice][7]}',\n\t\t\tchoice_8='{$_POST[choice][8]}',\n\t\t\tchoice_9='{$_POST[choice][9]}',\n\t\t\tanswer_0={$answer_new['0']},\n\t\t\tanswer_0={$answer_new['1']},\n\t\t\tanswer_0={$answer_new['2']},\n\t\t\tanswer_0={$answer_new['3']},\n\t\t\tanswer_0={$answer_new['4']},\n\t\t\tanswer_0={$answer_new['5']},\n\t\t\tanswer_0={$answer_new['6']},\n\t\t\tanswer_0={$answer_new['7']},\n\t\t\tanswer_0={$answer_new['8']},\n\t\t\tanswer_0={$answer_new['9']}\n\n\t\t\tWHERE question_id={$_POST['qid']}"; if ($testsQuestionsDAO->execute($sql)) { $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY'); if ($_POST['tid']) { header('Location: questions.php?tid=' . $_POST['tid'] . '&_course_id=' . $_course_id); } else { header('Location: question_db.php?_course_id=' . $_course_id); } exit; } else { $msg->addError('DB_NOT_UPDATED'); } } } else { if (!($row = $testsQuestionsDAO->get($qid))) { require_once TR_INCLUDE_PATH . 'header.inc.php'; $msg->printErrors('ITEM_NOT_FOUND'); require TR_INCLUDE_PATH . 'footer.inc.php'; exit; } $_POST['required'] = $row['required']; $_POST['question'] = $row['question']; $_POST['category_id'] = $row['category_id']; $_POST['feedback'] = $row['feedback']; for ($i = 0; $i < 10; $i++) { $_POST['choice'][$i] = $row['choice_' . $i]; } } } $onload = 'document.form.category_id.focus();';
if ($_POST['tid']) { header('Location: questions.php?tid=' . $_POST['tid'] . '&_course_id=' . $_course_id); } else { header('Location: question_db.php?_course_id=' . $_course_id); } exit; } } else { if (isset($_POST['preset'])) { // load preset $_POST['preset_num'] = intval($_POST['preset_num']); if (isset($_likert_preset[$_POST['preset_num']])) { $_POST['choice'] = $_likert_preset[$_POST['preset_num']]; } else { if ($_POST['preset_num']) { if ($row = $testsQuestionsDAO->get($_POST['preset_num'])) { for ($i = 0; $i < 10; $i++) { $_POST['choice'][$i] = $row['choice_' . $i]; } } } } } else { if (!($row = $testsQuestionsDAO->get($qid))) { require_once TR_INCLUDE_PATH . 'header.inc.php'; $msg->printErrors('ITEM_NOT_FOUND'); require TR_INCLUDE_PATH . 'footer.inc.php'; exit; } $_POST['question'] = $row['question']; $_POST['category_id'] = $row['category_id'];
$msg->addFeedback('CANCELLED'); header('Location: question_db.php?_course_id=' . $_course_id); exit; } else { if (isset($_POST['submit_yes'])) { $_POST['qid'] = explode(',', $_POST['qid']); foreach ($_POST['qid'] as $id) { $id = intval($id); if ($testsQuestionsDAO->Delete($id)) { $testsQuestionsAssocDAO->DeleteByQuestionID($id); } } $msg->addFeedback('QUESTION_DELETED'); header('Location: question_db.php?_course_id=' . $_course_id); exit; } } /* else: */ require_once TR_INCLUDE_PATH . 'header.inc.php'; $these_questions = explode(",", $_REQUEST['qid']); foreach ($these_questions as $this_question) { $this_question = intval($this_question); $row = $testsQuestionsDAO->get($this_question); $confirm .= "<li>" . $row['question'] . "</li>"; } $confirm = array('DELETE', $confirm); $hidden_vars['qid'] = $_REQUEST['qid']; $hidden_vars['_course_id'] = $_course_id; $msg->addConfirm($confirm, $hidden_vars); $msg->printConfirm(); require_once TR_INCLUDE_PATH . 'footer.inc.php';
$content_base_href = 'content/' . $_course_id . '/'; } // Verify that we may access this question if (!isset($_SESSION['dd_question_ids']) || !is_array($_SESSION['dd_question_ids']) || !isset($_SESSION['dd_question_ids'][$_GET['qid']])) { // Just exit as we're in an IFRAME exit; } // Clean up tidily unset($_SESSION['dd_question_ids'][$_GET['qid']]); if (count($_SESSION['dd_question_ids']) == 0) { unset($_SESSION['dd_question_ids']); } session_write_close(); $_GET['qid'] = intval($_GET['qid']); $testQuestionsDAO = new TestsQuestionsDAO(); $row = $testQuestionsDAO->get($_GET['qid']); $_letters = array(_AT('A'), _AT('B'), _AT('C'), _AT('D'), _AT('E'), _AT('F'), _AT('G'), _AT('H'), _AT('I'), _AT('J')); $_colours = array('#FF9900', '#00FF00', '#0000FF', '#F23AA3', '#9999CC', '#990026', '#0099CC', '#22C921', '#007D48', '#00248F'); $num_options = 0; for ($i = 0; $i < 10; $i++) { if ($row['option_' . $i] != '') { $num_options++; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="<?php echo $_SESSION['lang']; ?> "> <head>
$msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY'); header('Location: question_db.php?_course_id=' . $_course_id); exit; } else { $msg->addError('DB_NOT_UPDATED'); } } } else { if (isset($_POST['preset'])) { // load preset $_POST['preset_num'] = intval($_POST['preset_num']); if (isset($_likert_preset[$_POST['preset_num']])) { $_POST['choice'] = $_likert_preset[$_POST['preset_num']]; } else { if ($_POST['preset_num']) { $row = $testsQuestionsDAO->get($_POST[preset_num]); if (isset($row)) { for ($i = 0; $i < 10; $i++) { $_POST['choice'][$i] = $row['choice_' . $i]; } } } } } } } global $onload; $onload = 'document.form.category_id.focus();'; require_once TR_INCLUDE_PATH . 'header.inc.php'; $savant->assign('likert_preset', $_likert_preset); $savant->assign('testsQuestionsDAO', $testsQuestionsDAO);