From 64c625ae58b78786d505db11bdfa6a910c8dfd27 Mon Sep 17 00:00:00 2001 From: Lan Hui Date: Fri, 1 Sep 2023 19:11:11 +0800 Subject: [PATCH] SubmitLab.php: improve student's tab 'Submitted' --- Course.php | 111 +++++++++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 54 deletions(-) diff --git a/Course.php b/Course.php index 01ea8a7..892467a 100644 --- a/Course.php +++ b/Course.php @@ -259,85 +259,88 @@ include 'Header.php'; $group_id = -1; } // This fixes "Submitted report not shown" http://118.25.96.118/bugzilla/show_bug.cgi?id=176 - - $sql_stmt = "SELECT Lab_Report_ID, Marks, `Course_ID`, `Posted_Date`, `Deadline`, `Instructions`, lab_reports_table.Title, `Attachment_link_1`, `Attachment_link_2`, `Attachment_link_3`, `Attachment_link_4` - FROM `lab_reports_table` - WHERE Lab_Report_ID in (select Lab_Report_ID from lab_report_submissions" - . " where Status='Pending' and (Student_id=$student_id or Course_Group_id=$group_id) and Course_ID=$course_id) ORDER by Lab_Report_ID DESC"; + $sql_stmt = "SELECT Lab_Report_ID, Marks, Course_ID, Posted_Date, Deadline, Instructions, lab_reports_table.Title, Attachment_link_1, Attachment_link_2, Attachment_link_3, Attachment_link_4 + FROM lab_reports_table + WHERE Lab_Report_ID IN + ( + SELECT Lab_Report_ID + FROM lab_report_submissions + WHERE Status='Pending' AND (Student_id=$student_id OR Course_Group_id=$group_id) AND Course_ID=$course_id + ) + ORDER BY Lab_Report_ID DESC"; $resultx = mysqli_query($con, $sql_stmt); if(mysqli_num_rows($resultx) == 0) { echo '
You have no unmarked submissions. Check the Marked tab for your marked submissions (if any).
'; } else { while($row = mysqli_fetch_assoc($resultx)) { - $lab_repo_id=$row['Lab_Report_ID']; - $title=$row['Title']; - $marks=$row['Marks']; - $ins=$row['Instructions']; - $posted=$row['Posted_Date']; - $deadline=$row['Deadline']; - $att1=$row['Attachment_link_1']; - $att2=$row['Attachment_link_2']; - $att3=$row['Attachment_link_3']; - $att4=$row['Attachment_link_4']; + $lab_repo_id = $row['Lab_Report_ID']; + $title = $row['Title']; + $marks = $row['Marks']; + $ins = $row['Instructions']; + $posted = $row['Posted_Date']; + $deadline = $row['Deadline']; + $att1 = $row['Attachment_link_1']; + $att2 = $row['Attachment_link_2']; + $att3 = $row['Attachment_link_3']; + $att4 = $row['Attachment_link_4']; $id = $row['Lab_Report_ID']; - if( $c_date < $deadline) { - $submittedx="Re-submit"; + if ($c_date < $deadline) { + $submittedx = "Re-submit"; } $full_link = "$att1"; - if($att2!="") { - $full_link= $full_link."| $att2"; - } - if($att3!="") { - $full_link= $full_link."| $att3"; + if ($att2 != "") { + $full_link = $full_link."| $att2"; } - if($att4!="") { - $full_link= $full_link."| $att4"; + if ($att3 != "") { + $full_link = $full_link."| $att3"; } - echo "
- $title ($marks Marks) Submitted
$ins -
Posted: $posted   Deadline: $deadline       $submittedx   -
Submitted files: "; + if ($att4 != "") { + $full_link = $full_link."| $att4"; + } - $Sub_result = mysqli_query($con,"SELECT `Submission_ID`, `Submission_Date`, lab_report_submissions.Lab_Report_ID, -lab_report_submissions.Student_id sub_std, lab_report_submissions.Course_Group_id, `Attachment1`, -`Notes`, `Attachment2`, `Attachment3`, `Attachment4`, `Marks`, lab_report_submissions.Status, -`Title`,users_table.Full_Name,course_group_members_table.Student_ID -FROM `lab_report_submissions` -Left JOIN users_table on users_table.Student_ID=lab_report_submissions.Student_id -left JOIN course_group_members_table on course_group_members_table.Course_Group_id=lab_report_submissions.Course_Group_id -where Lab_Report_ID=$lab_repo_id and (lab_report_submissions.Student_id='$student_id')"); + echo "
+ $title ($marks Marks)   SUBMITTED
+ $ins
+ Posted: $posted   Deadline: $deadline     $submittedx  
+ Submitted files: "; + + $Sub_result = mysqli_query($con,"SELECT Submission_ID, Submission_Date, lab_report_submissions.Lab_Report_ID, lab_report_submissions.Student_id sub_std, lab_report_submissions.Course_Group_id, Attachment1, Notes, Attachment2, Attachment3, Attachment4, Marks, lab_report_submissions.Status, Title,users_table.Full_Name, course_group_members_table.Student_ID + FROM lab_report_submissions + LEFT JOIN users_table ON users_table.Student_ID=lab_report_submissions.Student_id + LEFT JOIN course_group_members_table ON course_group_members_table.Course_Group_id=lab_report_submissions.Course_Group_id + WHERE Lab_Report_ID=$lab_repo_id AND lab_report_submissions.Student_id='$student_id'"); if(mysqli_num_rows($Sub_result) == 0) { echo "No Attachments found."; } else { while($row = mysqli_fetch_assoc($Sub_result)) { - $at1=$row['Attachment1']; - $at2=$row['Attachment2']; - $at3=$row['Attachment3']; - $at4=$row['Attachment4']; + $att1 = $row['Attachment1']; + $att2 = $row['Attachment2']; + $att3 = $row['Attachment3']; + $att4 = $row['Attachment4']; + $base_att1 = basename($att1); + $base_att2 = basename($att2); + $base_att3 = basename($att3); + $base_att4 = basename($att4); - $base_at1 = basename($at1); - $base_at2 = basename($at2); - $base_at3 = basename($at3); - $base_at4 = basename($at4); + $full_link = "$base_att1"; // prevent students from directly accessing their classmates' submissions - $full_link = "$base_at1"; // prevent students from directly accessing their classmates' submissions - - if($at2!=""){ - $full_link= $full_link." | $base_at2"; - } - if($at3!=""){ - $full_link= $full_link." | $base_at3"; + if ($att2 != "") { + $full_link= $full_link." | $base_att2"; } - if($at4!=""){ - $full_link= $full_link." | $base_at4"; + if ($att3 != "") { + $full_link= $full_link." | $base_att3"; + } + + if ($att4 != "") { + $full_link= $full_link." | $base_att4"; } echo $full_link; @@ -345,7 +348,7 @@ where Lab_Report_ID=$lab_repo_id and (lab_report_submissions.Student_id='$studen } } - echo "
"; + echo "
"; } } echo "";