2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or */
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /************************************************************************/
\r
16 define('AT_INCLUDE_PATH', '../../../include/');
\r
17 require(AT_INCLUDE_PATH.'vitals.inc.php');
\r
19 authenticate(AT_PRIV_TESTS);
\r
21 if (isset($_POST['cancel'])) {
\r
22 $msg->addFeedback('CANCELLED');
\r
23 header('Location: question_cats.php');
\r
25 } else if (isset($_POST['submit'])) {
\r
27 $_POST['title'] = trim($_POST['title']);
\r
29 if (!empty($_POST['title']) && !isset($_POST['catid'])) {
\r
30 $_POST['title'] = $addslashes($_POST['title']);
\r
31 $sql = "INSERT INTO ".TABLE_PREFIX."tests_questions_categories VALUES (NULL, $_SESSION[course_id], '$_POST[title]')";
\r
32 $result = mysql_query($sql, $db);
\r
33 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
\r
34 header('Location: question_cats.php');
\r
36 } else if (!empty($_POST['title']) && isset($_POST['catid'])) {
\r
37 $_POST['title'] = $addslashes($_POST['title']);
\r
38 $sql = "REPLACE INTO ".TABLE_PREFIX."tests_questions_categories VALUES ($_POST[catid], $_SESSION[course_id], '$_POST[title]')";
\r
39 $result = mysql_query($sql, $db);
\r
40 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
\r
41 header('Location: question_cats.php');
\r
44 $msg->addError(array('EMPTY_FIELDS', _AT('title')));
\r
48 if (isset($_GET['catid'])) {
\r
49 $sql = "SELECT title FROM ".TABLE_PREFIX."tests_questions_categories WHERE category_id=$_GET[catid]";
\r
50 $result = mysql_query($sql, $db);
\r
51 $row = mysql_fetch_assoc($result);
\r
53 $_POST['title'] = $row['title'];
\r
56 require(AT_INCLUDE_PATH.'header.inc.php');
\r
58 $msg->printErrors();
\r
61 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
\r
63 if (isset($_REQUEST['catid'])) {
\r
64 echo '<input type="hidden" value="'.$_REQUEST['catid'].'" name="catid" />';
\r
67 <div class="input-form">
\r
68 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('create_category'); ?></legend>
\r
70 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="cat"><?php echo _AT('title'); ?></label><br />
\r
71 <input type="text" name="title" id="cat" value="<?php echo htmlspecialchars($_POST['title']); ?>" />
\r
74 <div class="row buttons">
\r
75 <input type="submit" value="<?php echo _AT('save'); ?>" name="submit" accesskey="s" />
\r
76 <input type="submit" value="<?php echo _AT('cancel'); ?>" name="cancel" />
\r
82 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>