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.'classes/DAO/TestsQuestionsDAO.class.php');
16 require_once(TR_INCLUDE_PATH.'classes/Utility.class.php');
19 Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);
20 $testsQuestionsDAO = new TestsQuestionsDAO();
22 $qid = intval($_GET['qid']);
24 $qid = intval($_POST['qid']);
27 if (isset($_POST['cancel'])) {
28 $msg->addFeedback('CANCELLED');
30 header('Location: questions.php?tid='.$_POST['tid'].'&_course_id='.$_course_id);
32 header('Location: question_db.php?_course_id='.$_course_id);
35 } else if (isset($_POST['submit'])) {
36 $_POST['feedback'] = trim($_POST['feedback']);
37 $_POST['question'] = trim($_POST['question']);
38 $_POST['category_id'] = intval($_POST['category_id']);
39 $_POST['properties'] = intval($_POST['properties']);
41 if ($_POST['question'] == ''){
42 $msg->addError(array('EMPTY_FIELDS', _AT('question')));
45 if (!$msg->containsErrors()) {
46 $_POST['question'] = $addslashes($_POST['question']);
47 $_POST['feedback'] = $addslashes($_POST['feedback']);
49 $sql = "UPDATE ".TABLE_PREFIX."tests_questions SET category_id=$_POST[category_id],
50 feedback='$_POST[feedback]',
51 question='$_POST[question]',
52 properties=$_POST[properties]
53 WHERE question_id=$_POST[qid]";
55 $testsQuestionsDAO->execute($sql);
57 $msg->addFeedback('QUESTION_UPDATED');
59 header('Location: questions.php?tid='.$_POST['tid'].'&_course_id='.$_course_id);
61 header('Location: question_db.php?_course_id='.$_course_id);
67 if (!isset($_POST['submit'])) {
68 if (!($row = $testsQuestionsDAO->get($qid))){
69 $msg->printErrors('ITEM_NOT_FOUND');
70 require (TR_INCLUDE_PATH.'footer.inc.php');
77 require_once(TR_INCLUDE_PATH.'header.inc.php');
81 $savant->assign('qid', $qid);
82 $savant->assign('tid', $_REQUEST['tid']);
83 $savant->assign('course_id', $_course_id);
84 $savant->display('tests/create_edit_question_long.tmpl.php');
86 require (TR_INCLUDE_PATH.'footer.inc.php');