SVN tag for release should only contain scripts in "docs" folder without "mods",...
[atutor.git] / docs / mods / _standard / assignments / 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_ASSIGNMENTS);\r
18 \r
19 if (isset($_GET['edit'])) {\r
20         $_GET['assignment'] = intval($_GET['assignment']);\r
21         header('Location: edit_assignment.php?id='. $_GET['assignment']);\r
22         exit;\r
23 } else if (isset($_GET['delete'])) {\r
24         $_GET['assignment'] = intval($_GET['assignment']);\r
25         header('Location: delete_assignment.php?id='. $_GET['assignment']);\r
26         exit;\r
27 } else if (isset($_GET['submissions'])){\r
28         $_GET['assignment'] = intval($_GET['assignment']);\r
29         header('Location: '.url_rewrite('mods/_standard/file_storage/index.php?ot='.WORKSPACE_ASSIGNMENT.SEP.'oid='.$_GET['assignment'], AT_PRETTY_URL_IS_HEADER));\r
30         exit;\r
31 }\r
32 $msg->addInfo('ASSIGNMENT_FS_SUBMISSIONS'); \r
33 require(AT_INCLUDE_PATH.'header.inc.php'); \r
34 \r
35 // sort order of table\r
36 $orders = array('ASC' => 'DESC', 'DESC' => 'ASC');\r
37 $cols   = array('title' => 1, 'date_due' => 1);\r
38 $sort = 'title';\r
39 $order = 'ASC';\r
40 if (isset($_GET['sort'])){\r
41         $sort = isset($cols[$_GET['sort']]) ? $_GET['sort'] : 'title';\r
42 }\r
43 if (isset($_GET['order'])){\r
44         $order = $addslashes($_GET['order']);\r
45         if (($order != 'ASC') && ($order != 'DESC')){\r
46                 $order = 'ASC';\r
47         }\r
48 }\r
49 $sql = "SELECT * FROM ".TABLE_PREFIX."assignments WHERE course_id=$_SESSION[course_id] ORDER BY $sort $order";\r
50 $result = mysql_query($sql, $db);\r
51 ?>\r
52 \r
53 \r
54 \r
55 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">\r
56 <table class="data" style="width: 90%;" rules="cols">\r
57 <colgroup>\r
58         <?php if ($sort == 'title'): ?>\r
59                 <col />\r
60                 <col class="sort" />\r
61                 <col span="5" />\r
62         <?php elseif($sort == 'assign_to'): ?>\r
63                 <col span="2" />\r
64                 <col class="sort" />\r
65                 <col span="4" />\r
66         <?php elseif($sort == 'date_due'): ?>\r
67                 <col span="3" />\r
68                 <col class="sort" />\r
69                 <col span="3" />\r
70         <?php endif; ?>\r
71 </colgroup>\r
72 <thead>\r
73 <tr>\r
74         <th>&nbsp;</th>\r
75         <th scope="col"><a href="mods/_standard/assignments/index_instructor.php?sort=title<?php echo SEP; ?>order=<?php echo $orders[$order]; ?>"><?php echo _AT('title'); ?></a></th>\r
76         <th scope="col"><?php echo _AT('assigned_to'); ?></th>\r
77         <th scope="col"><a href="mods/_standard/assignments/index_instructor.php?sort=date_due<?php echo SEP; ?>order=<?php echo $orders[$order]; ?>"><?php echo _AT('due_date'); ?></a></th>\r
78 </tr>\r
79 </thead>\r
80 <?php if (($result != 0) && ($row = mysql_fetch_assoc($result))) : ?>\r
81 <tfoot>\r
82 <tr>\r
83         <td colspan="4">\r
84                 <input type="submit" name="submissions" value="<?php echo _AT('submissions'); ?>" class="button"/> \r
85                 <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>"  class="button"/> \r
86                 <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" class="button" />\r
87                                         \r
88         </td>\r
89 </tr>\r
90 </tfoot>\r
91 <tbody>\r
92         <?php do { ?>\r
93                 <tr onmousedown="document.form['a<?php echo $row['assignment_id']; ?>'].checked = true; rowselect(this);" id="a_<?php echo $row['assignment_id']; ?>_0">\r
94                 \r
95                 <td><input type="radio" id="a<?php echo $row['assignment_id']; ?>" name="assignment" value="<?php echo $row['assignment_id']; ?>" \r
96 \r
97                 <?php // set first item as checked if nothing selected\r
98                 if (isset($_GET['assignment_id'])){\r
99                         if ($_GET['assignment_id'] == $row['assignment_id']){ \r
100                                 echo ' checked="checked"'; \r
101                         } \r
102                 }\r
103                 else {\r
104                         echo ' checked="checked"';\r
105                         $_GET['assignment_id'] = $row['assignment_id'];\r
106                 }\r
107                 ?>/></td>\r
108 \r
109                 <td><label for="a<?php echo $row['assignment_id']; ?>"><?php echo htmlentities_utf8($row['title']); ?></label></td>\r
110 \r
111                 <td><?php if($row['assign_to'] == '0'){echo _AT('all_students'); } else {\r
112                                         $sql = "SELECT title FROM ".TABLE_PREFIX."groups_types WHERE type_id=$row[assign_to] AND course_id=$_SESSION[course_id]";\r
113                                         $type_result = mysql_query($sql, $db);\r
114                                         $type_row = mysql_fetch_assoc($type_result);\r
115                                         echo $type_row['title']; } ?></td>\r
116 \r
117                 <td><?php  if ($row['date_due'] == '0000-00-00 00:00:00'){\r
118                         echo _AT('none');\r
119                 }else {\r
120                         echo AT_Date(_AT('forum_date_format'), $row['date_due'], AT_DATE_MYSQL_DATETIME);\r
121                 }?></td>\r
122                 </tr>\r
123         <?php } while($row = mysql_fetch_assoc($result)); ?>\r
124 </tbody>\r
125 <?php else: ?>\r
126         <tr>\r
127                 <td colspan="4"><strong><?php echo _AT('none_found'); ?></strong></td>\r
128         </tr>\r
129 <?php endif; ?>\r
130 </table>\r
131 </form>\r
132 \r
133 \r
134 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>