Chat window now opens with no messages inside.
[Assignment-Trapper.git] / assignment.php
blob705d2c313ba4a14cb1a4b46bb4ec69439e2bdd4a
1 <?php
3 include_once("auth.php");
4 include_once("header.php");
5 include_once("time.php");
6 include_once("user_details.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";
37 //$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";
39 //$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";
43 $result = mysql_query($sql);
45 //echo $sql;
47 if (!$result) { die("SQL ERROR"); }
48 while($row = mysql_fetch_row($result))
50 $html .= '<tr><td>'.$row[7].'</td>';
51 //$html .= '<tr><td>'.$row[10].'</td>';
53 // assignment started?
54 if($row[10] < 0){
55 $html .= "<td><img src=gfx/bullet_black.png>";
56 $started = false;
57 } else {
58 // assignment open?
59 if($row[8] > 0 || $row[10] < 0) { $html .= "<td><img src=gfx/bullet_delete.png>"; } else { $html .= "<td><img src=gfx/bullet_add.png>"; }
60 $started = true;
63 // assignment graded?
64 if($row[12]) { $html .= "<img src=gfx/bullet_disk.png>"; } else { $html .= "<img src=gfx/bullet_wrench.png>"; }
66 if($role != 0 ) {
68 if(need_help($user_id, $row[7])) {
69 $html .= '<img src=gfx/flag_red.png>';
70 } else { $html .= '<img src=gfx/flag_white.png>'; }
72 if(assignment_late($user_id, $row[7])) {
73 $html .= '<img src=gfx/tick_off.png></td>';
74 } else {
75 if(file_count($user_id, $row[7])) {
76 $html .= '<img src=gfx/star.png></td>';
77 } else { $html .= '<img src=gfx/error.png></td>'; }
81 if($role == 0 ) {
82 $html .= '<td><a href="detail_root.php?sched='.$row[7].'">'.$row[2].'</a></td><td>'.$row[9].'</td><td>'.$row[0].'</td>';
83 } else {
84 $html .= '<td><a href="detail_root.php?sched='.$row[7].'">'.$row[2].'</a></td><td>'.$row[9].'</td><td>'.$row[0].'</td>';
87 $html .= '<td>'.$row[1].'</td><td>'.$row[5].'</td><td>'.$row[6].'</td>';
89 if($started) {
90 $html .= '<td>'.absHumanTiming($row[11]).'</td>';
91 } else {
92 $html .= '<td>'.absHumanTiming($row[5]).'</td>';
95 if($role==0) { $html .= '<td><a href="assignment_add.php?sched='.$row[7].'&action=edit">Edit</a></td>'; }
97 $html .= '</tr>';
102 <h3><?php echo $breadcrumb; ?> -> All Assignments</h3>
104 <table class="gridtable">
105 <tr>
106 <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>
107 <?php if($role==0) { echo '<th>Update</th>'; } ?>
108 </tr>
109 <?php echo $html; ?>
110 <?php include("legend.php"); ?>
112 </table>