remove old readme
[atutor.git] / mods / _standard / student_tools / instructor_index.php
1 <?php\r
2 /************************************************************************/\r
3 /* ATutor                                                                                                                               */\r
4 /************************************************************************/\r
5 /* Copyright (c) 2002-2009                                              */\r
6 /* Inclusive Design Institute                                           */\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 \r
14 define('AT_INCLUDE_PATH', '../../../include/');\r
15 require(AT_INCLUDE_PATH.'vitals.inc.php');\r
16 authenticate(AT_PRIV_ADMIN);\r
17 \r
18 if (isset($_POST['up'])) {\r
19         $up = key($_POST['up']);\r
20         $_new_modules  = array();\r
21         if (isset($_POST['main'])) {\r
22                 foreach ($_POST['main'] as $m) {\r
23                         if ($m == $up) {\r
24                                 $last_m = array_pop($_new_modules);\r
25                                 $_new_modules[] = $m;\r
26                                 $_new_modules[] = $last_m;\r
27                         } else {\r
28                                 $_new_modules[] = $m;\r
29                         }\r
30                 }\r
31 \r
32                 $_POST['main'] = $_new_modules;\r
33         }\r
34 \r
35         $_POST['submit'] = TRUE;\r
36 } else if (isset($_POST['down'])) {\r
37         $_new_modules  = array();\r
38 \r
39         $down = key($_POST['down']);\r
40 \r
41         if (isset($_POST['main'])) {\r
42                 foreach ($_POST['main'] as $m) {\r
43                         if ($m == $down) {\r
44                                 $found = TRUE;\r
45                                 continue;\r
46                         }\r
47                         $_new_modules[] = $m;\r
48                         if ($found) {\r
49                                 $_new_modules[] = $down;\r
50                                 $found = FALSE;\r
51                         }\r
52                 }\r
53 \r
54                 $_POST['main'] = $_new_modules;\r
55         }\r
56 \r
57         $_POST['submit'] = TRUE;\r
58 }\r
59 \r
60 if (isset($_POST['submit'])) {\r
61         if (isset($_POST['main'])) {\r
62                 $_POST['main'] = array_intersect($_POST['main'], $_modules);\r
63                 $_POST['main'] = array_unique($_POST['main']);\r
64                 $main_links = implode('|', $_POST['main']);\r
65         } else {\r
66                 $main_links = '';\r
67         }\r
68         $main_links = $addslashes($main_links);\r
69         $sql    = "REPLACE INTO ".TABLE_PREFIX."fha_student_tools VALUES ($_SESSION[course_id], '$main_links', 1)";\r
70         $result = mysql_query($sql, $db);\r
71 \r
72         $msg->addFeedback('STUDENT_TOOLS_SAVED');\r
73         header('Location: '.$_SERVER['PHP_SELF']);\r
74         exit;\r
75 }\r
76 \r
77 require(AT_INCLUDE_PATH.'header.inc.php');\r
78 \r
79 $fha_student_tools = array();\r
80 \r
81 $sql = "SELECT links FROM ".TABLE_PREFIX."fha_student_tools WHERE course_id=$_SESSION[course_id] AND links <> ''";\r
82 $result = mysql_query($sql, $db);\r
83 if ($row = mysql_fetch_assoc($result)) {\r
84         $fha_student_tools = explode('|', $row['links']);\r
85 }\r
86 \r
87 $_current_modules = array_merge($fha_student_tools, array_diff($_modules, $fha_student_tools));\r
88 \r
89 $num_modules = count($fha_student_tools);\r
90 ?>\r
91 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">\r
92 <table class="data" rules="rows" summary="">\r
93 <thead>\r
94 <tr>\r
95         <th scope="cols"><?php echo _AT('section'); ?></th>\r
96         <th><?php echo _AT('order'); ?></th>\r
97 </tr>\r
98 </thead>\r
99 <tfoot>\r
100 <tr>\r
101         <td colspan="2"><input type="submit" name="submit" value="<?php echo _AT('save'); ?>" accesskey="s" /></td>\r
102 </tr>\r
103 </tfoot>\r
104 <tbody>\r
105 \r
106 <?php foreach ($_current_modules as $module): ?>\r
107 <?php if ($module == 'mods/_standard/student_tools/index.php') { continue; } ?>\r
108 <?php  ?>\r
109 <tr>\r
110         <td>\r
111                 <?php if (in_array($module, $fha_student_tools)): ?>\r
112                         <input type="checkbox" name="main[]" value="<?php echo $module; ?>" id="m<?php echo $count; ?>" checked="checked" />\r
113                 <?php else: ?>\r
114                         <input type="checkbox" name="main[]" value="<?php echo $module; ?>" id="m<?php echo $count; ?>" />\r
115                 <?php endif; ?>\r
116                 <label for="m<?php echo $count; ?>"><?php \r
117                         if (isset($_pages[$module]['title'])) {\r
118                                 echo $_pages[$module]['title'];\r
119                         } else {\r
120                                 echo _AT($_pages[$module]['title_var']);\r
121                 } ?></label>\r
122         </td>\r
123 \r
124         <td align="right">\r
125                 <?php if (!in_array($module, $fha_student_tools)): ?>\r
126                         &nbsp;\r
127                 <?php else: ?>\r
128                         <?php if (($count != $num_main+1) && ($count > 1)): ?>\r
129                                 <input type="submit" name="up[<?php echo $module; ?>]" value="<?php echo _AT('move_up'); ?>" title="<?php echo _AT('move_up'); ?>" style="background-color: white; border: 1px solid; padding: 0px;" />\r
130                         <?php else: ?>\r
131                                 <img src="images/clr.gif" alt="" width="12" />\r
132                         <?php endif; ?>\r
133                         <?php if (($count != $num_main) && ($count < $num_modules)): ?>\r
134                                 <input type="submit" name="down[<?php echo $module; ?>]" value="<?php echo _AT('move_down'); ?>" title="<?php echo _AT('move_down'); ?>" style="background-color: white; border: 1px solid; padding: 0px;"/>\r
135                         <?php else: ?>\r
136                                 <img src="images/clr.gif" alt="" width="12" />\r
137                         <?php endif; ?>\r
138                 <?php endif; ?>\r
139         </td>\r
140 </tr>\r
141 <?php \r
142 $count++;\r
143 endforeach; ?>\r
144 </tbody>\r
145 </table>\r
146 </form>\r
147 \r
148 \r
149 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>