2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2010 */
\r
6 /* Inclusive Design Institute */
\r
8 /* This program is free software. You can redistribute it and/or */
\r
9 /* modify it under the terms of the GNU General Public License */
\r
10 /* as published by the Free Software Foundation. */
\r
11 /************************************************************************/
\r
14 define('TR_INCLUDE_PATH', '../include/');
\r
15 require_once(TR_INCLUDE_PATH.'vitals.inc.php');
\r
16 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsQuestionsCategoriesDAO.class.php');
\r
17 require_once(TR_INCLUDE_PATH.'classes/Utility.class.php');
\r
21 Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);
\r
23 $testsQuestionsCategoriesDAO = new TestsQuestionsCategoriesDAO();
\r
25 if (isset($_POST['cancel'])) {
\r
26 $msg->addFeedback('CANCELLED');
\r
27 header('Location: question_cats.php');
\r
29 } else if (isset($_POST['submit'])) {
\r
31 $_POST['title'] = trim($_POST['title']);
\r
33 if (!empty($_POST['title']) && !isset($_POST['catid'])) {
\r
34 if ($testsQuestionsCategoriesDAO->Create($_course_id, $_POST['title']))
\r
36 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
\r
37 header('Location: question_cats.php?_course_id='.$_course_id);
\r
40 } else if (!empty($_POST['title']) && isset($_POST['catid'])) {
\r
41 if ($testsQuestionsCategoriesDAO->Update($_POST['catid'], $_POST['title']))
\r
43 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
\r
44 header('Location: question_cats.php?_course_id='.$_course_id);
\r
48 $msg->addError(array('EMPTY_FIELDS', _AT('title')));
\r
52 if (isset($_GET['catid'])) {
\r
53 $row = $testsQuestionsCategoriesDAO->get($_GET['catid']);
\r
54 $_POST['title'] = $row['title'];
\r
57 $onload = "document.form.title.focus();";
\r
58 require_once(TR_INCLUDE_PATH.'header.inc.php');
\r
60 $msg->printErrors();
\r
62 if (isset($_GET['catid']))
\r
64 $savant->assign('catid', $_GET['catid']);
\r
65 $savant->assign('title', _AT('manage_category'));
\r
69 $savant->assign('title', _AT('create_category'));
\r
71 $savant->assign('course_id', $_course_id);
\r
72 $savant->display('tests/question_cats_manage.tmpl.php');
\r
74 require_once(TR_INCLUDE_PATH.'footer.inc.php');
\r