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_MATCHING, $sql_params);
86 $result = mysql_query($sql, $db);
88 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
89 header('Location: question_db.php');
94 $onload = 'document.form.category_id.focus();';
96 require(AT_INCLUDE_PATH.'header.inc.php');
98 // for matching test questions
99 $_letters = array(_AT('A'), _AT('B'), _AT('C'), _AT('D'), _AT('E'), _AT('F'), _AT('G'), _AT('H'), _AT('I'), _AT('J'));
102 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
103 <input type="hidden" name="required" value="1" />
104 <div class="input-form">
105 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('test_matching'); ?></legend>
107 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="cats"><?php echo _AT('category'); ?></label><br />
108 <select name="category_id" id="cats">
109 <?php print_question_cats($_POST['category_id']); ?>
114 <label for="optional_feedback"><?php echo _AT('optional_feedback'); ?></label>
115 <?php print_VE('optional_feedback'); ?>
117 <textarea id="optional_feedback" cols="50" rows="3" name="feedback"><?php echo htmlspecialchars(stripslashes($_POST['feedback'])); ?></textarea>
121 <label for="instructions"><?php echo _AT('instructions'); ?></label>
122 <?php print_VE('instructions'); ?>
123 <textarea id="instructions" cols="50" rows="3" name="instructions"><?php
124 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 echo htmlspecialchars(stripslashes($_POST['question'][$i])); ?></textarea>
153 <h2><?php echo _AT('answers');?></h2>
155 <?php for ($i=0; $i<10; $i++): ?>
157 <?php if ($i < 2) :?>
158 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span>
160 <?php echo _AT('answer'); ?> <?php echo $_letters[$i]; ?>
161 <?php print_VE('answer_' . $i); ?>
163 <textarea id="answer_<?php echo $i; ?>" cols="50" rows="2" name="answer[<?php echo $i; ?>]"><?php echo htmlspecialchars(stripslashes($_POST['answer'][$i])); ?></textarea>
167 <div class="row buttons">
168 <input type="submit" value="<?php echo _AT('save'); ?>" name="submit" accesskey="s" />
169 <input type="submit" value="<?php echo _AT('cancel'); ?>" name="cancel" />
175 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>