remove old readme
[atutor.git] / mods / _standard / reading_list / index_instructor.php
1 <?php\r
2 /****************************************************************/\r
3 /* ATutor                                                                                                               */\r
4 /****************************************************************/\r
5 /* Copyright (c) 2002-2008                                      */\r
6 /* Written by Greg Gay & Joel Kronenberg & Chris Ridpath        */\r
7 /* Inclusive Design Institute                                   */\r
8 /* http://atutor.ca                                                                                             */\r
9 /*                                                              */\r
10 /* This program is free software. You can redistribute it and/or*/\r
11 /* modify it under the terms of the GNU General Public License  */\r
12 /* as published by the Free Software Foundation.                                */\r
13 /****************************************************************/\r
14 // $Id$\r
15 define('AT_INCLUDE_PATH', '../../../include/');\r
16 require (AT_INCLUDE_PATH.'vitals.inc.php');\r
17 authenticate(AT_PRIV_READING_LIST);\r
18 \r
19 if (isset($_GET['edit'])) {\r
20         if (!isset($_GET['reading'])) {\r
21                 $msg->addError('NO_ITEM_SELECTED');\r
22                 header('Location: index_instructor.php');\r
23                 exit;\r
24         }\r
25 \r
26         // reading ID of item that will be edited\r
27         $_GET['reading'] = intval($_GET['reading']);\r
28 \r
29         // get resource ID of reading\r
30         $sql = "SELECT resource_id FROM ".TABLE_PREFIX."reading_list WHERE course_id=$_SESSION[course_id] AND reading_id=$_GET[reading]";\r
31         $result = mysql_query($sql, $db);\r
32         if ($row = mysql_fetch_assoc($result)){\r
33                 // what kind of resource is it? (book, URL, file etc.)\r
34                 $sql = "SELECT type FROM ".TABLE_PREFIX."external_resources WHERE course_id=$_SESSION[course_id] AND resource_id=$row[resource_id]";\r
35                 $result = mysql_query($sql, $db);\r
36                 if ($row = mysql_fetch_assoc($result)){\r
37                         // display the correct page for editing the resource\r
38                         header('Location: edit_reading_'.substr($_rl_types[$row['type']], 3).'.php?id='. $_GET['reading']);\r
39                         exit;\r
40                 }\r
41         }\r
42         $msg->addError('ITEM_NOT_FOUND');\r
43 } else if (isset($_GET['delete'])) {\r
44         if (!isset($_GET['reading'])) {\r
45                 $msg->addError('NO_ITEM_SELECTED');\r
46                 header('Location: index_instructor.php');\r
47                 exit;\r
48         }\r
49         $_GET['reading'] = intval($_GET['reading']);\r
50         header('Location: delete_reading.php?id='. $_GET['reading']);\r
51         exit;\r
52 } else if (isset($_GET['create'])){\r
53         $_GET['new_reading'] = intval($_GET['new_reading']);\r
54 \r
55         if (isset($_rl_types[$_GET['new_reading']])){\r
56                 // Note: the '3' substring is used here to strip out the 'rl_' from the name\r
57                 header('Location: new_reading_'.substr($_rl_types[$_GET['new_reading']], 3).'.php');\r
58                 exit;\r
59         }\r
60 }\r
61 \r
62 require(AT_INCLUDE_PATH.'header.inc.php'); \r
63 ?>\r
64 \r
65 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">\r
66 <div class="input-form" style="width: 90%">\r
67         <fieldset class="group_form"><legend class="group_form"><?php echo _AT('create'); ?></legend>\r
68         <div class="row">\r
69                 <label for="question"><?php echo _AT('rl_type_of_reading'); ?></label><br />\r
70                 <select name="new_reading" class="dropdown" id="type">\r
71 \r
72                 <?php foreach ($_rl_types as $key => $value): ?>\r
73                         <option value="<?php echo $key; ?>"><?php echo _AT($value); ?></option>\r
74                 <?php endforeach; ?>\r
75 \r
76                 </select>\r
77         </div>\r
78         <div class="row buttons">\r
79                 <input type="submit" name="create" value="<?php echo _AT('create'); ?>" />\r
80         </div>\r
81         </fieldset>\r
82 </div>\r
83 </form>\r
84 \r
85 <?php\r
86 $sql = "SELECT * FROM ".TABLE_PREFIX."reading_list WHERE course_id=$_SESSION[course_id] ORDER BY date_start";\r
87 $result = mysql_query($sql, $db);\r
88 ?>\r
89 \r
90 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">\r
91 <table class="data" style="width: 90%;">\r
92 <thead>\r
93 <tr>\r
94         <th>&nbsp;</th>\r
95         <th><?php echo _AT('rl_start'); ?></th>\r
96         <th><?php echo _AT('rl_end'); ?></th>\r
97         <th><?php echo _AT('title'); ?></th>\r
98         <th><?php echo _AT('required'); ?></th>\r
99         <th><?php echo _AT('comment'); ?></th>\r
100 </tr>\r
101 </thead>\r
102 <tfoot>\r
103 <tr>\r
104         <td colspan="6">\r
105                 <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" /> \r
106                 <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" />\r
107         </td>\r
108 </tr>\r
109 </tfoot>\r
110 <?php if ($row = mysql_fetch_assoc($result)): ?>\r
111 <tbody>\r
112                 <?php do { ?>\r
113 \r
114                         <?php // get the external resource using the resource ID from the reading\r
115                         $id = $row['resource_id'];\r
116                         $sql = "SELECT title FROM ".TABLE_PREFIX."external_resources WHERE course_id=$_SESSION[course_id] AND resource_id=$id";\r
117                         $resource_result = mysql_query($sql, $db);\r
118                         if ($resource_row = mysql_fetch_assoc($resource_result)){ \r
119                         ?>\r
120                                 <tr onmousedown="document.form['t<?php echo $row['reading_id']; ?>'].checked = true; rowselect(this);" id="r_<?php echo $row['reading_id']; ?>_0">\r
121                                 \r
122                                 <td><input type="radio" id="t<?php echo $row['reading_id']; ?>" name="reading" value="<?php echo $row['reading_id']; ?>" \r
123 \r
124                                 <?php // set first item as checked if nothing selected\r
125                                 if (isset($_GET['reading'])){\r
126                                         if ($_GET['reading'] == $row['reading_id']){ \r
127                                                 echo ' checked="checked"'; \r
128                                         } \r
129                                 } else {\r
130                                         echo ' checked="checked"';\r
131                                         $_GET['reading'] = $row['reading_id'];\r
132                                 }\r
133                                 ?> /></td>\r
134                                 <td><?php  if ($row['date_start'] == '0000-00-00'){\r
135                                         echo _AT ('none');\r
136                                 }else {\r
137                                         echo AT_Date(_AT('rl_date_format'), $row['date_start'], AT_DATE_MYSQL_DATETIME);\r
138                                 }?></td>\r
139 \r
140                                 <td><?php  if ($row['date_end'] == '0000-00-00'){\r
141                                         echo _AT ('none');\r
142                                 }else {\r
143                                         echo AT_Date(_AT('rl_date_format'), $row['date_end'], AT_DATE_MYSQL_DATETIME);\r
144                                 }?></td>\r
145                                 <td><label for="t<?php echo $row['reading_id'];?>"><strong><?php echo AT_print($resource_row['title'], 'reading_list.title'); ?></strong></label></td>\r
146                                 <td><?php echo _AT ($row['required']); ?></td>\r
147                                 <td><?php echo AT_print($row['comment'], 'reading_list.comment'); ?></td>\r
148                                 </tr>\r
149 \r
150                         <?php } ?>\r
151 \r
152                 <?php } while($row = mysql_fetch_assoc($result)); ?>\r
153 </tbody>\r
154 <?php else: ?>\r
155         <tr>\r
156                 <td colspan="6"><strong><?php echo _AT('none_found'); ?></strong></td>\r
157         </tr>\r
158 <?php endif; ?>\r
159 </table>\r
160 </form>\r
161 \r
162 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>