2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
16 define('AT_INCLUDE_PATH', '../../../include/');
17 require(AT_INCLUDE_PATH.'vitals.inc.php');
18 authenticate(AT_PRIV_TESTS);
19 require(AT_INCLUDE_PATH.'../mods/_standard/tests/lib/test_result_functions.inc.php');
21 $qid = intval($_GET['qid']);
23 $qid = intval($_POST['qid']);
26 if (isset($_POST['cancel'])) {
27 $msg->addFeedback('CANCELLED');
29 header('Location: questions.php?tid='.$_POST['tid']);
31 header('Location: question_db.php');
34 } else if (isset($_POST['submit'])) {
36 $_POST['question'] = trim($_POST['question']);
38 if ($_POST['question'] == ''){
39 $msg->addError(array('EMPTY_FIELDS', _AT('statement')));
42 if (!$msg->containsErrors()) {
43 $_POST['feedback'] = $addslashes(trim($_POST['feedback']));
44 $_POST['question'] = $addslashes($_POST['question']);
45 $_POST['qid'] = intval($_POST['qid']);
46 $_POST['category_id'] = intval($_POST['category_id']);
47 $_POST['answer'] = intval($_POST['answer']);
49 $sql = "UPDATE ".TABLE_PREFIX."tests_questions SET category_id=$_POST[category_id],
50 feedback='$_POST[feedback]',
51 question='$_POST[question]',
52 answer_0={$_POST[answer]}
53 WHERE question_id=$_POST[qid] AND course_id=$_SESSION[course_id]";
55 $result = mysql_query($sql, $db);
57 $msg->addFeedback('QUESTION_UPDATED');
59 header('Location: questions.php?tid='.$_POST['tid']);
61 header('Location: question_db.php');
66 require(AT_INCLUDE_PATH.'header.inc.php');
68 if (!$_POST['submit']) {
69 $sql = "SELECT * FROM ".TABLE_PREFIX."tests_questions WHERE question_id=$qid AND course_id=$_SESSION[course_id] AND type=2";
70 $result = mysql_query($sql, $db);
72 if (!($row = mysql_fetch_array($result))){
73 $msg->printErrors('ITEM_NOT_FOUND');
74 require (AT_INCLUDE_PATH.'footer.inc.php');
81 if ($_POST['required'] == 1) {
82 $req_yes = ' checked="checked"';
84 $req_no = ' checked="checked"';
87 if ($_POST['answer'] == '') {
88 if ($_POST['answer_0'] == 1) {
89 $ans_yes = ' checked="checked"';
90 } else if ($_POST['answer_0'] == 2){
91 $ans_no = ' checked="checked"';
92 } else if ($_POST['answer_0'] == 3) {
93 $ans_yes1 = ' checked="checked"';
95 $ans_no1 = ' checked="checked"';
98 if ($_POST['answer'] == 1) {
99 $ans_yes = ' checked="checked"';
100 } else if($_POST['answer'] == 2){
101 $ans_no = ' checked="checked"';
102 } else if ($_POST['answer'] == 3) {
103 $ans_yes1 = ' checked="checked"';
105 $ans_no1 = ' checked="checked"';
110 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
111 <input type="hidden" name="qid" value="<?php echo $qid; ?>" />
112 <input type="hidden" name="tid" value="<?php echo $_REQUEST['tid']; ?>" />
113 <input type="hidden" name="required" value="1" />
115 <div class="input-form">
116 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('test_tf'); ?></legend>
118 <label for="cats"><?php echo _AT('category'); ?></label>
119 <select name="category_id" id="cats">
120 <?php print_question_cats($_POST['category_id']); ?>
125 <label for="optional_feedback"><?php echo _AT('optional_feedback'); ?></label>
126 <?php print_VE('optional_feedback'); ?>
127 <textarea id="optional_feedback" cols="50" rows="3" name="feedback"><?php echo htmlspecialchars(stripslashes($_POST['feedback'])); ?></textarea>
131 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="question"><?php echo _AT('statement'); ?></label>
132 <?php print_VE('question'); ?>
133 <textarea id="question" cols="50" rows="6" name="question"><?php
134 echo htmlspecialchars(stripslashes($_POST['question'])); ?></textarea>
138 <?php echo _AT('answer'); ?><br />
139 <input type="radio" name="answer" value="1" id="answer1"<?php echo $ans_yes; ?> /><label for="answer1"><?php echo _AT('true'); ?></label>, <input type="radio" name="answer" value="2" id="answer2"<?php echo $ans_no; ?> /><label for="answer2"><?php echo _AT('false'); ?></label>
142 <div class="row buttons">
143 <input type="submit" value="<?php echo _AT('save'); ?>" name="submit" accesskey="s"/>
144 <input type="submit" value="<?php echo _AT('cancel'); ?>" name="cancel" />
150 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>