remove old readme
[atutor.git] / docs / mods / _standard / tests / create_question_long.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2010                                      */
6 /* Inclusive Design Institute                                   */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
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 /****************************************************************/
13 // $Id$
14
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 require(AT_INCLUDE_PATH.'../mods/_standard/tests/lib/test_question_queries.inc.php');
18
19 authenticate(AT_PRIV_TESTS);
20 require(AT_INCLUDE_PATH.'../mods/_standard/tests/lib/test_result_functions.inc.php');
21
22 if (isset($_POST['cancel'])) {
23         $msg->addFeedback('CANCELLED');
24         header('Location: question_db.php');
25         exit;
26 } else if ($_POST['submit']) {
27         $_POST['feedback']    = trim($_POST['feedback']);
28         $_POST['question']    = trim($_POST['question']);
29         $_POST['category_id'] = intval($_POST['category_id']);
30         $_POST['properties']  = intval($_POST['properties']);
31
32         if ($_POST['question'] == ''){
33                 $msg->addError(array('EMPTY_FIELDS', _AT('question')));
34         }
35
36         if (!$msg->containsErrors()) {
37                 $_POST['feedback'] = $addslashes($_POST['feedback']);
38                 $_POST['question'] = $addslashes($_POST['question']);
39
40                 $sql_params = array(    $_POST['category_id'], 
41                                                                 $_SESSION['course_id'],
42                                                                 $_POST['feedback'], 
43                                                                 $_POST['question'], 
44                                                                 $_POST['properties']);
45
46                 $sql = vsprintf(AT_SQL_QUESTION_LONG, $sql_params);     
47                 $result = mysql_query($sql, $db);
48
49                 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
50                 header('Location: question_db.php');
51                 exit;
52         }
53 }
54
55 $onload = 'document.form.category_id.focus();';
56
57 require(AT_INCLUDE_PATH.'header.inc.php');
58
59 if (!isset($_POST['properties'])) {
60         $_POST['properties'] = 1;
61 }
62
63 ?>
64 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
65 <input type="hidden" name="required" value="1" />
66 <div class="input-form">
67         <fieldset class="group_form"><legend class="group_form"><?php echo _AT('test_open'); ?></legend>
68         <div class="row">
69                 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="cats"><?php echo _AT('category'); ?></label><br />
70                 <select name="category_id" id="cats">
71                         <?php print_question_cats($_POST['category_id']); ?>
72                 </select>
73         </div>
74
75         <div class="row">
76                 <label for="optional_feedback"><?php echo _AT('optional_feedback'); ?></label> 
77                 <?php print_VE('optional_feedback'); ?>
78
79                 <textarea id="optional_feedback" cols="50" rows="3" name="feedback"><?php 
80                 echo htmlspecialchars(stripslashes($_POST['feedback'])); ?></textarea>
81         </div>
82
83         <div class="row">
84                 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="question"><?php echo _AT('question'); ?></label> 
85                 <?php print_VE('question'); ?>
86                 <textarea id="question" cols="50" rows="6" name="question" style="width:90%;"><?php 
87                 echo htmlspecialchars(stripslashes($_POST['question'])); ?></textarea>
88         </div>
89         
90         <div class="row">
91                 <?php echo _AT('answer_size'); ?><br />
92                 <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 />
93                 
94                 <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 />
95                 
96                 <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 />
97                 
98                 <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>
99         </div>
100         
101         <div class="row buttons">
102                 <input type="submit" value="<?php echo _AT('save'); ?>"   name="submit" accesskey="s" />
103                 <input type="submit" value="<?php echo _AT('cancel'); ?>" name="cancel" />
104         </div>
105         </fieldset>
106 </div>
107 </form>
108
109 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>