Added discussion feature to site.
[Assignment-Trapper.git] / assignment.php
blob079d323f77ce0b3fbe4959f8ab6a8b09b52c725c
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;';
26 /* get list of assignments */
27 $html = "";
29 if($role == 0) {
30 $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";
32 } else {
34 $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";
36 //$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";
38 //$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";
42 $result = mysql_query($sql);
44 //echo $sql;
46 if (!$result) { die("SQL ERROR"); }
47 while($row = mysql_fetch_row($result)){
48 $html .= "\n<tr><td>".$row[7]."</td>";
50 // assignment started?
51 if($row[10] < 0){
52 $html .= "<td><img src=gfx/bullet_black.png>";
53 $started = false;
54 } else {
55 // assignment open?
56 if($row[8] > 0 || $row[10] < 0) { $html .= "<td><img src=gfx/bullet_delete.png>"; } else { $html .= "<td><img src=gfx/bullet_add.png>"; }
57 $started = true;
60 // assignment graded?
61 if($row[12]) { $html .= "<img src=gfx/bullet_disk.png>"; } else { $html .= "<img src=gfx/bullet_wrench.png>"; }
63 if($role != 0 ) {
65 if(need_help($user_id, $row[7])) {
66 $html .= '<img src=gfx/flag_red.png>';
67 } else { $html .= '<img src=gfx/flag_white.png>'; }
69 if(assignment_late($user_id, $row[7])) {
70 $html .= '<img src=gfx/tick_off.png>';
71 } else {
72 if(file_count($user_id, $row[7])) {
73 $html .= '<img src=gfx/star.png>';
74 } else { $html .= '<img src=gfx/error.png>'; }
78 $html .= '<a href="discussion.php?sched='.$row[7].'"><img src="./gfx/comments_small.png"></a></td>';
80 if($role == 0 ) {
81 $html .= '<td><a href="detail_root.php?sched='.$row[7].'">'.$row[2].'</a></td><td>'.$row[9].'</td><td>'.$row[0].'</td>';
82 } else {
83 $html .= '<td><a href="detail_root.php?sched='.$row[7].'">'.$row[2].'</a></td><td>'.$row[9].'</td><td>'.$row[0].'</td>';
86 $html .= '<td>'.$row[1].'</td><td>'.$row[5].'</td><td>'.$row[6].'</td>';
88 if($started) {
89 $html .= '<td>'.absHumanTiming($row[11]).'</td>';
90 } else {
91 $html .= '<td>'.absHumanTiming($row[5]).'</td>';
94 if($role==0) { $html .= '<td><a href="assignment_add.php?sched='.$row[7].'&action=edit">Edit</a></td>'; }
96 $html .= '</tr>';
101 <h3><?php echo $breadcrumb; ?> -> All Assignments</h3>
103 <table class="gridtable">
104 <tr>
105 <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>
106 <?php if($role==0) { echo '<th>Update</th>'; } ?>
107 </tr>
108 <?php echo $html; ?>
109 <?php include("legend.php"); ?>
111 </table>