AC_4897, AC_4898, AC_4899: Multifile uploader fixes.
[acontent.git] / docs / tests / classes / TestsUtility.class.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 /**\r
14 * Tests Utility functions \r
15 * @access       public\r
16 * @author       Cindy Qi Li\r
17 */\r
18 \r
19 if (!defined('TR_INCLUDE_PATH')) exit;\r
20 \r
21 class TestsUtility {\r
22 \r
23         /**\r
24         * This function prints the drop down list box for question categories\r
25         * @access  public\r
26         * @param   categoryID\r
27         * @author  Cindy Qi Li\r
28         */\r
29         public static function printQuestionCatsInDropDown($categoryID = 0) {   \r
30                 global $_course_id;\r
31                 \r
32                 require_once(TR_INCLUDE_PATH."classes/DAO/TestsQuestionsCategoriesDAO.class.php");\r
33         \r
34                 echo '<option value="0"';\r
35                 if ($categoryID == 0) {\r
36                         echo ' selected="selected"';\r
37                 }\r
38                 echo '>'._AT('cats_uncategorized').'</option>' . "\n";\r
39         \r
40                 $testsQuestionsCategoriesDAO = new TestsQuestionsCategoriesDAO();\r
41                 $rows = $testsQuestionsCategoriesDAO->getByCourseID($_course_id);\r
42 \r
43                 if (is_array($rows)) {\r
44                         foreach ($rows as $row) {\r
45                                 echo '<option value="'.$row['category_id'].'"';\r
46                                 if ($row['category_id'] == $categoryID) {\r
47                                         echo ' selected="selected"';\r
48                                 }\r
49                                 echo '>'.$row['title'].'</option>'."\n";\r
50                         }\r
51                 }\r
52         }\r
53         \r
54         /**\r
55         * This function prints the link to open up the visual editor popup page\r
56         * @access  public\r
57         * @param   area: One of the values: question\r
58         * @author  Cindy Qi Li\r
59         */\r
60         public static function printVisualEditorLink ($area) {\r
61                 global $_course_id;\r
62 ?>\r
63         <script type="text/javascript" language="javascript">\r
64                 document.writeln('<a href="#" onclick="javascript:window.open(\'<?php echo TR_BASE_HREF; ?>tests/form_editor.php?area=<?php echo $area; ?>&_course_id=<?php echo $_course_id; ?>\',\'formEditorWin\',\'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=640,height=480\'); return false;" style="cursor: pointer; text-decoration: none" ><?php echo _AT('use_visual_editor'); ?></a>');\r
65         </script>\r
66 \r
67 <?php\r
68         }\r
69         \r
70 }\r
71 ?>