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');
21 Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);
22 $testsQuestionsDAO = new TestsQuestionsDAO();
24 if (isset($_POST['cancel'])) {
25 $msg->addFeedback('CANCELLED');
26 header('Location: question_db.php?_course_id='.$_course_id);
28 } else if ($_POST['submit']) {
29 $_POST['required'] = 1; //intval($_POST['required']);
30 $_POST['feedback'] = trim($_POST['feedback']);
31 $_POST['question'] = trim($_POST['question']);
32 $_POST['category_id'] = intval($_POST['category_id']);
33 $_POST['answer'] = intval($_POST['answer']);
35 if ($_POST['question'] == ''){
36 $msg->addError(array('EMPTY_FIELDS', _AT('statement')));
39 if (!$msg->containsErrors()) {
40 $_POST['feedback'] = $addslashes($_POST['feedback']);
41 $_POST['question'] = $addslashes($_POST['question']);
44 $sql = 'SELECT content_id FROM '.TABLE_PREFIX."tests WHERE test_id=$_POST[tid]";
45 $result = mysql_query($sql, $db);
46 $row = mysql_fetch_assoc($result);
49 $sql_params = array( $_POST['category_id'],
55 $sql = vsprintf(TR_SQL_QUESTION_TRUEFALSE, $sql_params);
56 if ($testsQuestionsDAO->execute($sql)) {
57 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
58 header('Location: question_db.php?_course_id='.$_course_id);
61 $msg->addError('DB_NOT_UPDATED');
65 $onload = 'document.form.category_id.focus();';
66 require_once(TR_INCLUDE_PATH.'header.inc.php');
68 $savant->assign('course_id', $_course_id);
69 $savant->display('tests/create_edit_question_truefalse.tmpl.php');
71 require (TR_INCLUDE_PATH.'footer.inc.php'); ?>