AC_4897, AC_4898, AC_4899: Multifile uploader fixes.
[acontent.git] / tests / question_cats_manage.php
1 <?php\r
2 /************************************************************************/\r
3 /* AContent                                                             */\r
4 /************************************************************************/\r
5 /* Copyright (c) 2010                                                   */\r
6 /* Inclusive Design Institute                                           */\r
7 /*                                                                      */\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
12 \r
13 $page = 'tests';\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
18 \r
19 global $_course_id;\r
20 \r
21 Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);\r
22 \r
23 $testsQuestionsCategoriesDAO = new TestsQuestionsCategoriesDAO();\r
24 \r
25 if (isset($_POST['cancel'])) {\r
26         $msg->addFeedback('CANCELLED');\r
27         header('Location: question_cats.php');\r
28         exit;\r
29 } else if (isset($_POST['submit'])) {\r
30 \r
31         $_POST['title'] = trim($_POST['title']);\r
32 \r
33         if (!empty($_POST['title']) && !isset($_POST['catid'])) {\r
34                 if ($testsQuestionsCategoriesDAO->Create($_course_id, $_POST['title']))\r
35                 {\r
36                         $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');\r
37                         header('Location: question_cats.php?_course_id='.$_course_id);\r
38                         exit;\r
39                 }\r
40         } else if (!empty($_POST['title']) && isset($_POST['catid']))  {\r
41                 if ($testsQuestionsCategoriesDAO->Update($_POST['catid'], $_POST['title']))\r
42                 {\r
43                         $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');\r
44                         header('Location: question_cats.php?_course_id='.$_course_id);\r
45                         exit;\r
46                 }\r
47         } else {\r
48                 $msg->addError(array('EMPTY_FIELDS', _AT('title')));\r
49         }\r
50 }\r
51 \r
52 if (isset($_GET['catid'])) {\r
53         $row = $testsQuestionsCategoriesDAO->get($_GET['catid']);\r
54         $_POST['title'] = $row['title'];\r
55 }\r
56 \r
57 $onload = "document.form.title.focus();";\r
58 require_once(TR_INCLUDE_PATH.'header.inc.php');\r
59 \r
60 $msg->printErrors();\r
61 \r
62 if (isset($_GET['catid'])) \r
63 {\r
64         $savant->assign('catid', $_GET['catid']);\r
65         $savant->assign('title', _AT('manage_category'));\r
66 }\r
67 else \r
68 {\r
69         $savant->assign('title', _AT('create_category'));\r
70 }\r
71 $savant->assign('course_id', $_course_id);\r
72 $savant->display('tests/question_cats_manage.tmpl.php');\r
73 \r
74 require_once(TR_INCLUDE_PATH.'footer.inc.php'); \r
75 \r
76 ?>