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');
17 require(AT_INCLUDE_PATH.'../mods/_standard/tests/lib/test_question_queries.inc.php');
19 authenticate(AT_PRIV_TESTS);
20 require(AT_INCLUDE_PATH.'../mods/_standard/tests/lib/test_result_functions.inc.php');
22 if (isset($_POST['cancel'])) {
23 $msg->addFeedback('CANCELLED');
24 header('Location: question_db.php');
26 } else if ($_POST['submit']) {
27 $_POST['feedback'] = trim($_POST['feedback']);
28 $_POST['instructions'] = trim($_POST['instructions']);
29 $_POST['category_id'] = intval($_POST['category_id']);
31 for ($i = 0 ; $i < 10; $i++) {
32 $_POST['question'][$i] = $addslashes(trim($_POST['question'][$i]));
33 $_POST['question_answer'][$i] = (int) $_POST['question_answer'][$i];
34 $_POST['answer'][$i] = $addslashes(trim($_POST['answer'][$i]));
37 if ($_POST['question'][0] == ''
38 || $_POST['question'][1] == ''
39 || $_POST['answer'][0] == ''
40 || $_POST['answer'][1] == '') {
42 $msg->addError('QUESTION_EMPTY');
46 if (!$msg->containsErrors()) {
47 $_POST['feedback'] = $addslashes($_POST['feedback']);
48 $_POST['instructions'] = $addslashes($_POST['instructions']);
50 $sql_params = array( $_POST['category_id'],
51 $_SESSION['course_id'],
53 $_POST['instructions'],
54 $_POST['question'][0],
55 $_POST['question'][1],
56 $_POST['question'][2],
57 $_POST['question'][3],
58 $_POST['question'][4],
59 $_POST['question'][5],
60 $_POST['question'][6],
61 $_POST['question'][7],
62 $_POST['question'][8],
63 $_POST['question'][9],
64 $_POST['question_answer'][0],
65 $_POST['question_answer'][1],
66 $_POST['question_answer'][2],
67 $_POST['question_answer'][3],
68 $_POST['question_answer'][4],
69 $_POST['question_answer'][5],
70 $_POST['question_answer'][6],
71 $_POST['question_answer'][7],
72 $_POST['question_answer'][8],
73 $_POST['question_answer'][9],
85 $sql = vsprintf(AT_SQL_QUESTION_MATCHINGDD, $sql_params);
87 $result = mysql_query($sql, $db);
89 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
90 header('Location: question_db.php');
95 $onload = 'document.form.category_id.focus();';
97 require(AT_INCLUDE_PATH.'header.inc.php');
99 // for matching test questions
100 $_letters = array(_AT('A'), _AT('B'), _AT('C'), _AT('D'), _AT('E'), _AT('F'), _AT('G'), _AT('H'), _AT('I'), _AT('J'));
103 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
104 <input type="hidden" name="required" value="1" />
105 <div class="input-form">
106 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('test_matchingdd'); ?></legend>
108 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="cats"><?php echo _AT('category'); ?></label><br />
109 <select name="category_id" id="cats">
110 <?php print_question_cats($_POST['category_id']); ?>
115 <label for="optional_feedback"><?php echo _AT('optional_feedback'); ?></label>
116 <?php print_VE('optional_feedback'); ?>
118 <textarea id="optional_feedback" cols="50" rows="3" name="feedback"><?php echo htmlspecialchars(stripslashes($_POST['feedback'])); ?></textarea>
122 <label for="instructions"><?php echo _AT('instructions'); ?></label>
123 <?php print_VE('instructions'); ?>
124 <textarea id="instructions" cols="50" rows="3" name="instructions"><?php echo htmlspecialchars(stripslashes($_POST['instructions'])); ?></textarea>
128 <h2><?php echo _AT('questions');?></h2>
130 <?php for ($i=0; $i<10; $i++): ?>
132 <?php if ($i < 2) :?>
133 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span>
135 <?php echo _AT('question'); ?> <?php echo ($i+1); ?>
137 <?php print_VE('question_' . $i); ?>
141 <select name="question_answer[<?php echo $i; ?>]">
142 <option value="-1">-</option>
143 <?php foreach ($_letters as $key => $value): ?>
144 <option value="<?php echo $key; ?>"><?php echo $value; ?></option>
148 <textarea id="question_<?php echo $i; ?>" cols="50" rows="2" name="question[<?php echo $i; ?>]"><?php
149 echo htmlspecialchars(stripslashes($_POST['question'][$i])); ?></textarea>
154 <h2><?php echo _AT('answers');?></h2>
156 <?php for ($i=0; $i<10; $i++): ?>
158 <?php if ($i < 2) :?>
159 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span>
161 <?php echo _AT('answer'); ?> <?php echo $_letters[$i]; ?>
162 <?php print_VE('answer_' . $i); ?>
164 <textarea id="answer_<?php echo $i; ?>" cols="50" rows="2" name="answer[<?php echo $i; ?>]"><?php
165 echo htmlspecialchars(stripslashes($_POST['answer'][$i])); ?></textarea>
169 <div class="row buttons">
170 <input type="submit" value="<?php echo _AT('save'); ?>" name="submit" accesskey="s" />
171 <input type="submit" value="<?php echo _AT('cancel'); ?>" name="cancel" />
177 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>