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']) || isset($_POST['submit_no'])) {
23 $msg->addFeedback('CANCELLED');
24 header('Location: question_db.php');
26 } else if (isset($_POST['submit'])) {
27 $_POST['required'] = intval($_POST['required']);
28 $_POST['feedback'] = trim($_POST['feedback']);
29 $_POST['question'] = trim($_POST['question']);
30 $_POST['category_id'] = intval($_POST['category_id']);
31 $_POST['answer'] = intval($_POST['answer']);
33 if ($_POST['question'] == ''){
34 $msg->addError(array('EMPTY_FIELDS', _AT('question')));
37 if (!$msg->containsErrors()) {
38 for ($i=0; $i<10; $i++) {
39 $_POST['choice'][$i] = $addslashes(trim($_POST['choice'][$i]));
42 $answers = array_fill(0, 10, 0);
43 $answers[$_POST['answer']] = 1;
45 $_POST['feedback'] = $addslashes($_POST['feedback']);
46 $_POST['question'] = $addslashes($_POST['question']);
48 $sql_params = array( $_POST['category_id'],
49 $_SESSION['course_id'],
72 $sql = vsprintf(AT_SQL_QUESTION_MULTI, $sql_params);
74 $result = mysql_query($sql, $db);
76 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
77 header('Location: question_db.php');
84 $onload = 'document.form.category_id.focus();';
86 require(AT_INCLUDE_PATH.'header.inc.php');
90 <form action="mods/_standard/tests/create_question_multi.php" method="post" name="form">
91 <input type="hidden" name="required" value="1" />
92 <div class="input-form">
93 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('test_mc'); ?></legend>
95 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="cats"><?php echo _AT('category'); ?></label><br />
96 <select name="category_id" id="cats">
97 <?php print_question_cats($_POST['category_id']); ?>
102 <label for="optional_feedback"><?php echo _AT('optional_feedback'); ?></label>
103 <?php print_VE('optional_feedback'); ?>
104 <textarea id="optional_feedback" cols="50" rows="3" name="feedback"><?php echo htmlspecialchars(stripslashes($_POST['feedback'])); ?></textarea>
108 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="question"><?php echo _AT('question'); ?></label>
109 <?php print_VE('question'); ?>
110 <textarea id="question" cols="50" rows="4" name="question" style="width:90%;"><?php
111 echo htmlspecialchars(stripslashes($_POST['question'])); ?></textarea>
115 for ($i=0; $i<10; $i++) {
118 <?php echo _AT('choice'); ?> <?php echo ($i+1); ?>
120 <?php print_VE('choice_' . $i); ?>
124 <small><input type="radio" name="answer" id="answer_<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if($_POST['answer'] == $i) { echo 'checked="checked"';} ?>><label for="answer_<?php echo $i; ?>"><?php echo _AT('correct_answer'); ?></label></small>
126 <textarea id="choice_<?php echo $i; ?>" cols="50" rows="2" name="choice[<?php echo $i; ?>]"><?php
127 echo htmlspecialchars(stripslashes($_POST['choice'][$i])); ?></textarea>
131 <div class="row buttons">
132 <input type="submit" value="<?php echo _AT('save'); ?>" name="submit" accesskey="s" />
133 <input type="submit" value="<?php echo _AT('cancel'); ?>" name="cancel" />
139 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>