tagging as ATutor 1.5.4-release
[atutor.git] / tools / tests / question_cats.php
1 <?php\r
2 /************************************************************************/\r
3 /* ATutor                                                                                                                               */\r
4 /************************************************************************/\r
5 /* Copyright (c) 2002-2006 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/\r
6 /* Adaptive Technology Resource Centre / University of Toronto                  */\r
7 /* http://atutor.ca                                                                                                             */\r
8 /*                                                                                                                                              */\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
13 // $Id$\r
14 \r
15 $page = 'tests';\r
16 define('AT_INCLUDE_PATH', '../../include/');\r
17 require(AT_INCLUDE_PATH.'vitals.inc.php');\r
18 \r
19 authenticate(AT_PRIV_TESTS);\r
20 \r
21 if (isset($_POST['edit'], $_POST['category'])) {\r
22         header('Location: question_cats_manage.php?catid='.$_POST['category']);\r
23         exit;\r
24 } else if (isset($_POST['delete'], $_POST['category'])) {\r
25         header('Location: question_cats_delete.php?catid='.$_POST['category']);\r
26         exit;\r
27 } else if (!empty($_POST)) {\r
28         $msg->addError('NO_ITEM_SELECTED');\r
29 }\r
30 \r
31 require(AT_INCLUDE_PATH.'header.inc.php');\r
32 \r
33 $sql    = "SELECT * FROM ".TABLE_PREFIX."tests_questions_categories WHERE course_id=$_SESSION[course_id] ORDER BY title";\r
34 $result = mysql_query($sql, $db);\r
35 \r
36 if ($row = mysql_fetch_assoc($result)) {\r
37 ?>\r
38         <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">\r
39         <div class="input-form">\r
40 <?php   do { ?>\r
41                         <div class="row">\r
42                                 <input type="radio" id="cat_<?php echo $row['category_id']; ?>" name="category" value="<?php echo $row['category_id']; ?>" />   <label for="cat_<?php echo $row['category_id']; ?>"><?php echo AT_print($row['title'], 'tests_questions_categories.title'); ?></label>\r
43                         </div>\r
44 <?php \r
45                 } while ($row = mysql_fetch_assoc($result));\r
46 ?>\r
47 \r
48                 <div class="row buttons">\r
49                         <input type="submit" value="<?php echo _AT('edit'); ?>"   name="edit" />\r
50                         <input type="submit" value="<?php echo _AT('delete'); ?>" name="delete" />\r
51                 </div>\r
52         </div>\r
53         </form>\r
54 <?php\r
55 \r
56         } else {\r
57                 echo '<p>'._AT('cats_no_categories').'</p>';\r
58         }\r
59 ?>\r
60 \r
61 \r
62 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>