2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2010 */
6 /* Inclusive Design Institute */
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 /************************************************************************/
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');
19 Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);
20 $testsQuestionsDAO = new TestsQuestionsDAO();
22 if (isset($_POST['cancel'])) {
23 $msg->addFeedback('CANCELLED');
24 header('Location: question_db.php?_course_id='.$_course_id);
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']);
32 if ($_POST['question'] == ''){
33 $msg->addError(array('EMPTY_FIELDS', _AT('question')));
36 if (!$msg->containsErrors()) {
37 $_POST['feedback'] = $addslashes($_POST['feedback']);
38 $_POST['question'] = $addslashes($_POST['question']);
40 $sql_params = array( $_POST['category_id'],
44 $_POST['properties']);
46 $sql = vsprintf(TR_SQL_QUESTION_LONG, $sql_params);
47 if ($testsQuestionsDAO->execute($sql))
49 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
50 header('Location: question_db.php?_course_id='.$_course_id);
56 $onload = 'document.form.category_id.focus();';
58 require_once(TR_INCLUDE_PATH.'header.inc.php');
60 if (!isset($_POST['properties'])) {
61 $_POST['properties'] = 1;
64 $savant->assign('course_id', $_course_id);
65 $savant->display('tests/create_edit_question_long.tmpl.php');
67 require (TR_INCLUDE_PATH.'footer.inc.php');