moved code up one level to eliminate the docs subdirectory
[acontent.git] / tests / create_question_long.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12
13 define('TR_INCLUDE_PATH', '../include/');
14 require_once(TR_INCLUDE_PATH.'vitals.inc.php');
15 require_once(TR_INCLUDE_PATH.'lib/test_question_queries.inc.php');
16 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsQuestionsDAO.class.php');
17 require_once(TR_INCLUDE_PATH.'classes/Utility.class.php');
18
19 Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);
20 $testsQuestionsDAO = new TestsQuestionsDAO();
21
22 if (isset($_POST['cancel'])) {
23         $msg->addFeedback('CANCELLED');
24         header('Location: question_db.php?_course_id='.$_course_id);
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                                                                 $_course_id,
42                                                                 $_POST['feedback'], 
43                                                                 $_POST['question'], 
44                                                                 $_POST['properties']);
45
46                 $sql = vsprintf(TR_SQL_QUESTION_LONG, $sql_params);     
47                 if ($testsQuestionsDAO->execute($sql))
48                 {
49                         $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
50                         header('Location: question_db.php?_course_id='.$_course_id);
51                         exit;
52                 }
53         }
54 }
55
56 $onload = 'document.form.category_id.focus();';
57
58 require_once(TR_INCLUDE_PATH.'header.inc.php');
59
60 if (!isset($_POST['properties'])) {
61         $_POST['properties'] = 1;
62 }
63
64 $savant->assign('course_id', $_course_id);
65 $savant->display('tests/create_edit_question_long.tmpl.php');
66
67 require (TR_INCLUDE_PATH.'footer.inc.php'); 
68 ?>