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 /****************************************************************/
15 define('AT_INCLUDE_PATH', '../../../include/');
16 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'])) {
35 $_POST['feedback'] = trim($_POST['feedback']);
36 $_POST['question'] = trim($_POST['question']);
37 $_POST['category_id'] = intval($_POST['category_id']);
38 $_POST['properties'] = intval($_POST['properties']);
40 if ($_POST['question'] == ''){
41 $msg->addError(array('EMPTY_FIELDS', _AT('question')));
44 if (!$msg->containsErrors()) {
45 $_POST['question'] = $addslashes($_POST['question']);
46 $_POST['feedback'] = $addslashes($_POST['feedback']);
48 $sql = "UPDATE ".TABLE_PREFIX."tests_questions SET category_id=$_POST[category_id],
49 feedback='$_POST[feedback]',
50 question='$_POST[question]',
51 properties=$_POST[properties]
52 WHERE question_id=$_POST[qid] AND course_id=$_SESSION[course_id]";
54 $result = mysql_query($sql, $db);
56 $msg->addFeedback('QUESTION_UPDATED');
58 header('Location: questions.php?tid='.$_POST['tid']);
60 header('Location: question_db.php');
66 require(AT_INCLUDE_PATH.'header.inc.php');
68 if (!isset($_POST['submit'])) {
69 $sql = "SELECT * FROM ".TABLE_PREFIX."tests_questions WHERE question_id=$qid AND course_id=$_SESSION[course_id] AND type=3";
70 $result = mysql_query($sql, $db);
71 if (!($row = mysql_fetch_assoc($result))){
72 $msg->printErrors('ITEM_NOT_FOUND');
73 require (AT_INCLUDE_PATH.'footer.inc.php');
82 <form action="mods/_standard/tests/edit_question_long.php" method="post" name="form">
83 <input type="hidden" name="required" value="1" />
84 <input type="hidden" name="tid" value="<?php echo $_REQUEST['tid']; ?>" />
85 <input type="hidden" name="qid" value="<?php echo $qid; ?>" />
87 <div class="input-form">
88 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('test_open'); ?></legend>
90 <label for="cats"><?php echo _AT('category'); ?></label>
91 <select name="category_id" id="cats">
92 <?php print_question_cats($_POST['category_id']); ?>
97 <label for="optional_feedback"><?php echo _AT('optional_feedback'); ?></label>
98 <?php print_VE('optional_feedback'); ?>
100 <textarea id="optional_feedback" cols="50" rows="3" name="feedback"><?php echo htmlspecialchars(stripslashes($_POST['feedback'])); ?></textarea>
104 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="question"><?php echo _AT('question'); ?></label>
105 <?php print_VE('question'); ?>
107 <textarea id="question" cols="50" rows="6" name="question"><?php
108 echo htmlspecialchars(stripslashes($_POST['question'])); ?></textarea>
112 <?php echo _AT('answer_size'); ?><br />
113 <input type="radio" name="properties" value="1" id="az1" <?php if ($_POST['properties'] == 1) { echo 'checked="checked"'; } ?> /><label for="az1"><?php echo _AT('one_word'); ?></label><br />
114 <input type="radio" name="properties" value="2" id="az2" <?php if ($_POST['properties'] == 2) { echo 'checked="checked"'; } ?> /><label for="az2"><?php echo _AT('one_sentence'); ?></label><br />
115 <input type="radio" name="properties" value="3" id="az3" <?php if ($_POST['properties'] == 3) { echo 'checked="checked"'; } ?> /><label for="az3"><?php echo _AT('short_paragraph'); ?></label><br />
116 <input type="radio" name="properties" value="4" id="az4" <?php if ($_POST['properties'] == 4) { echo 'checked="checked"'; } ?> /><label for="az4"><?php echo _AT('one_page'); ?></label>
119 <div class="row buttons">
120 <input type="submit" value="<?php echo _AT('save'); ?>" name="submit" accesskey="s" />
121 <input type="submit" value="<?php echo _AT('cancel'); ?>" name="cancel" />
127 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>