Managment page has better look and feel.
[Assignment-Trapper.git] / assignment.php
blob18c1031773d97d065930a541644eec402215432a
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 open?
54 if($row[8] > 0 || $row[10] < 0) { $html .= "<td><img src=gfx/bullet_delete.png>"; } else { $html .= "<td><img src=gfx/bullet_add.png>"; }
56 // assignment graded?
57 if($row[12]) { $html .= "<img src=gfx/bullet_disk.png>"; } else { $html .= "<img src=gfx/bullet_wrench.png>"; }
59 if($role != 0 ) {
61 if(need_help($user_id, $row[7])) {
62 $html .= '<img src=gfx/flag_red.png>';
63 } else { $html .= '<img src=gfx/flag_white.png>'; }
65 if(file_count($user_id, $row[7])) {
66 $html .= '<img src=gfx/star.png></td>';
67 } else { $html .= '<img src=gfx/error.png></td>'; }
70 if($role == 0 ) {
71 $html .= '<td><a href="detail_root.php?sched='.$row[7].'">'.$row[2].'</a></td><td>'.$row[9].'</td><td>'.$row[0].'</td>';
72 } else {
73 $html .= '<td><a href="detail_root.php?sched='.$row[7].'">'.$row[2].'</a></td><td>'.$row[9].'</td><td>'.$row[0].'</td>';
76 $html .= '<td>'.$row[1].'</td><td>'.$row[5].'</td><td>'.$row[6].'</td>';
78 $html .= '<td>'.absHumanTiming($row[11]).'</td>';
80 if($role==0) { $html .= '<td><a href="assignment_add.php?sched='.$row[7].'&action=edit">Edit</a></td>'; }
82 $html .= '</tr>';
87 <h3><?php echo $breadcrumb; ?> -> All Assignments</h3>
89 <table class="gridtable">
90 <tr>
91 <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>
92 <?php if($role==0) { echo '<th>Update</th>'; } ?>
93 </tr>
94 <?php echo $html; ?>
95 <?php include("legend.php"); ?>
97 </table>