Added classes menu for students with more than one class.
[Assignment-Trapper.git] / assignment.php
blob5731fbfc19df86b271fd99c89539134151c82aa4
1 <?php
3 include_once("auth.php");
4 include_once("header.php");
6 include_once("time.php");
8 if(!isset($_GET["class"])) { die("No Class ID Sent"); }
10 /* get class info */
12 $class = "";
14 $_GET["class"] = mysql_real_escape_string($_GET["class"]);
16 $sql = "select class_name, class_id from class where class_id =". $_GET['class'];
18 $result = mysql_query($sql);
20 if (!$result) { die("SQL ERROR"); }
22 $row = mysql_fetch_array($result);
24 $breadcrumb = '<a href=assignment.php?class='.$row['class_id'].'>'.$row['class_name'].'</a>&nbsp;';
27 /* get list of assignments */
28 $html = "";
30 if($role == 0) {
31 $sql = "select chapter, section_id, title, class_id, schedule.assign_type, ava_date, due_date, sched_id, NOW()-due_date as due, type_name, NOW()-ava_date as ava, due_date, graded from schedule, types where (schedule.assign_type = types.assign_type) and class_id=". $_GET['class']." order by due_date desc, ava_date desc, title, chapter, section_id, schedule.assign_type";
33 } else {
35 $sql = "select chapter, section_id, title, class_id, schedule.assign_type, ava_date, due_date, sched_id, NOW()-due_date as due, type_name, NOW()-ava_date as ava, due_date, graded from schedule, types where (schedule.assign_type = types.assign_type) and class_id=". $_GET['class']." and NOW()-ava_date > 0 order by due_date desc, ava_date desc, title, chapter, section_id, schedule.assign_type";
39 $result = mysql_query($sql);
41 //echo $sql;
43 if (!$result) { die("SQL ERROR"); }
44 while($row = mysql_fetch_row($result))
46 $html .= '<tr><td>'.$row[7].'</td>';
47 //$html .= '<tr><td>'.$row[10].'</td>';
49 // assignment open?
50 if($row[8] > 0 || $row[10] < 0) { $html .= "<td><img src=gfx/bullet_delete.png>"; } else { $html .= "<td><img src=gfx/bullet_add.png>"; }
52 // assignment graded?
53 if($row[12]) { $html .= "<img src=gfx/bullet_disk.png></td>"; } else { $html .= "<img src=gfx/bullet_wrench.png></td>"; }
55 if($role == 0 ) {
56 $html .= '<td><a href="detail_root.php?sched='.$row[7].'">'.$row[2].'</a></td><td>'.$row[9].'</td><td>'.$row[0].'</td>';
57 } else {
58 $html .= '<td><a href="detail_root.php?sched='.$row[7].'">'.$row[2].'</a></td><td>'.$row[9].'</td><td>'.$row[0].'</td>';
61 $html .= '<td>'.$row[1].'</td><td>'.$row[5].'</td><td>'.$row[6].'</td>';
63 $html .= '<td>'.absHumanTiming($row[11]).'</td>';
65 if($role==0) { $html .= '<td><a href="assignment_add.php?sched='.$row[7].'&action=edit">Edit</a></td>'; }
67 $html .= '</tr>';
72 <h3><?php echo $breadcrumb; ?> -> All Assignments</h3>
74 <table class="gridtable">
75 <tr>
77 <th>#</th><th>Status</th><th>Title</th><th>Type</th><th>Chapter</th><th>Section</th><th>Avalaible Date</th><th>Due Date</th><th>Human Time</th>
78 <?php if($role==0) { echo '<th>Update</th>'; } ?>
79 </tr>
80 <?php echo $html; ?>
81 </table>