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']) || isset($_POST['submit_no'])) {
25 $msg->addFeedback('CANCELLED');
26 header('Location: question_db.php?_course_id='.$_course_id);
28 } else if (isset($_POST['submit'])) {
29 $_POST['required'] = 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('question')));
39 if (!$msg->containsErrors()) {
40 for ($i=0; $i<10; $i++) {
41 $_POST['choice'][$i] = $addslashes(trim($_POST['choice'][$i]));
44 $answers = array_fill(0, 10, 0);
45 $answers[$_POST['answer']] = 1;
47 $_POST['feedback'] = $addslashes($_POST['feedback']);
48 $_POST['question'] = $addslashes($_POST['question']);
50 $sql_params = array( $_POST['category_id'],
74 $sql = vsprintf(TR_SQL_QUESTION_MULTI, $sql_params);
76 if ($testsQuestionsDAO->execute($sql)) {
77 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
78 header('Location: question_db.php?_course_id='.$_course_id);
86 $onload = 'document.form.category_id.focus();';
88 require_once(TR_INCLUDE_PATH.'header.inc.php');
92 $savant->assign('course_id', $_course_id);
93 $savant->display('tests/create_edit_question_multichoice.tmpl.php');
95 require (TR_INCLUDE_PATH.'footer.inc.php'); ?>