Modified headers of pages to expire on load.
[Assignment-Trapper.git] / assignment.php
blobff7a8ecce841ecc1a9bb947a489d341eba8a7c7c
1 <?php
3 include_once("auth.php");
4 include_once("header.php");
5 include_once("time.php");
7 function need_help($user_id, $sched_id)
9 if(!isset($user_id)) { return -1; }
11 $sql = 'select help_me from sched_details where user_id = '.$user_id.' and sched_id = '.$sched_id;
12 $result = mysql_query($sql);
14 if (!$result) { die("SQL ERROR"); }
16 $row = mysql_fetch_array($result);
18 return $row[0];
21 if(!isset($_GET["class"])) { die("No Class ID Sent"); }
23 /* get class info */
25 $class = "";
27 $_GET["class"] = mysql_real_escape_string($_GET["class"]);
29 $sql = "select class_name, class_id from class where class_id =". $_GET['class'];
31 $result = mysql_query($sql);
33 if (!$result) { die("SQL ERROR"); }
35 $row = mysql_fetch_array($result);
37 $breadcrumb = '<a href=assignment.php?class='.$row['class_id'].'>'.$row['class_name'].'</a>&nbsp;';
40 /* get list of assignments */
41 $html = "";
43 if($role == 0) {
44 $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";
46 } else {
48 $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";
50 //$sql = "select chapter, section_id, title, class_id, schedule.assign_type, ava_date, due_date, schedule.sched_id, NOW()-due_date as due, type_name, NOW()-ava_date as ava, due_date, graded, help_me from schedule, types, sched_details where (schedule.assign_type = types.assign_type) and (sched_details.sched_id = schedule.sched_id) 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";
52 //$sql = "select chapter, section_id, title, class_id, schedule.assign_type, ava_date, due_date, schedule.sched_id, NOW()-due_date as due, type_name, NOW()-ava_date as ava, due_date, graded, help_me from schedule LEFT JOIN sched_details on (sched_details.sched_id = schedule.sched_id), types where schedule.sched_id = ANY (select sched_id from schedule where class_id = ". $_GET['class'].") and (schedule.assign_type = types.assign_type)order by due_date desc, ava_date desc, title, chapter, section_id, schedule.assign_type";
56 $result = mysql_query($sql);
58 //echo $sql;
60 if (!$result) { die("SQL ERROR"); }
61 while($row = mysql_fetch_row($result))
63 $html .= '<tr><td>'.$row[7].'</td>';
64 //$html .= '<tr><td>'.$row[10].'</td>';
66 // assignment open?
67 if($row[8] > 0 || $row[10] < 0) { $html .= "<td><img src=gfx/bullet_delete.png>"; } else { $html .= "<td><img src=gfx/bullet_add.png>"; }
69 // assignment graded?
70 if($row[12]) { $html .= "<img src=gfx/bullet_disk.png>"; } else { $html .= "<img src=gfx/bullet_wrench.png>"; }
72 if($role != 0 ) {
74 if(need_help($user_id, $row[7])) {
75 $html .= '<img src=gfx/flag_red.png></td>';
76 } else { $html .= '<img src=gfx/flag_white.png></td>'; } }
78 if($role == 0 ) {
79 $html .= '<td><a href="detail_root.php?sched='.$row[7].'">'.$row[2].'</a></td><td>'.$row[9].'</td><td>'.$row[0].'</td>';
80 } else {
81 $html .= '<td><a href="detail_root.php?sched='.$row[7].'">'.$row[2].'</a></td><td>'.$row[9].'</td><td>'.$row[0].'</td>';
84 $html .= '<td>'.$row[1].'</td><td>'.$row[5].'</td><td>'.$row[6].'</td>';
86 $html .= '<td>'.absHumanTiming($row[11]).'</td>';
88 if($role==0) { $html .= '<td><a href="assignment_add.php?sched='.$row[7].'&action=edit">Edit</a></td>'; }
90 $html .= '</tr>';
95 <h3><?php echo $breadcrumb; ?> -> All Assignments</h3>
97 <table class="gridtable">
98 <tr>
99 <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>
100 <?php if($role==0) { echo '<th>Update</th>'; } ?>
101 </tr>
102 <?php echo $html; ?>
103 <?php include("legend.php"); ?>
105 </table>