diff --git a/Course.php b/Course.php index c469163..5b9f25a 100644 --- a/Course.php +++ b/Course.php @@ -152,7 +152,7 @@ include 'Header.php'; $att3 = $row['Attachment_link_3']; $att4 = $row['Attachment_link_4']; $labid = $row['Lab_Report_ID']; - $days_remaining = "Days remaining: ".date_diff(date_create($deadline), date_create())->format('%a days, %h hours, %i minutes'); + $days_remaining = date_diff(date_create($deadline), date_create())->format('%a days, %h hours, %i minutes'); $full_link = "$att1"; if($att2 != "") { @@ -165,11 +165,6 @@ include 'Header.php'; $full_link = $full_link."| $att4"; } - // check if the student has already submitted the assignment - $query_result = mysqli_query($con, "SELECT * FROM lab_report_submissions WHERE Student_id=$student_id AND Lab_Report_ID=$labid"); - if (mysqli_num_rows($query_result) > 0) - $days_remaining = 'You have already submitted this assignment.'; - echo "
$title
@@ -177,7 +172,7 @@ include 'Header.php';

$ins

Attachments: $full_link

Posted: $posted    Deadline: $deadline

-
$days_remaining
+
Time left: $days_remaining

Submit

"; @@ -199,13 +194,34 @@ include 'Header.php'; $group_id = -1; } - $result = mysqli_query($con,"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 not in (select Lab_Report_ID from lab_report_submissions where (Student_id=$student_id or Course_Group_id=$group_id)) and Course_ID=$course_id and Deadline < '$c_date' ORDER by Lab_Report_ID DESC"); +$submitted_query = "SELECT Lab_Report_ID FROM lab_report_submissions WHERE (Student_id = $student_id OR Course_Group_id = $group_id)"; +$submitted_result = mysqli_query($con, $submitted_query); - if(mysqli_num_rows($result) == 0) - { - echo '
You missed no lab reports.
'; +if (!$submitted_result) { + die('Query failed: ' . mysqli_error($con)); +} - } else { +// We initialized an empty array to hold the Lab_Report_IDs +$submitted_lab_report_ids = []; + +// Then we fetched all Lab_Report_IDs and stored them in the array +while ($row = mysqli_fetch_assoc($submitted_result)) { + $submitted_lab_report_ids[] = $row['Lab_Report_ID']; +} + +// We converted the array to a comma-separated string, for use in the main query +$submitted_lab_report_ids_list = implode(',', $submitted_lab_report_ids); + +// Check if the list is empty and handle it +if (empty($submitted_lab_report_ids_list)) { + $submitted_lab_report_ids_list = 'NULL'; // Handle appropriately +} + +// Now, we use the variable in our main query +$result = mysqli_query($con, "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 NOT IN ($submitted_lab_report_ids_list) AND Course_ID = $course_id AND Deadline < '$c_date' ORDER BY Lab_Report_ID DESC"); +if(mysqli_num_rows($result) == 0) { + echo '
You missed no lab reports.
'; +} else { while($row = mysqli_fetch_assoc($result)) { $title = $row['Title']; $marks = $row['Marks']; @@ -256,108 +272,101 @@ include 'Header.php'; - @@ -652,12 +661,11 @@ include 'Header.php'; - function remarking(url) + function remarking(data) { const details = prompt("Please enter your remarking reasons",""); - if (details != null) { - window.location.href = url+"&details="+details; - } + + window.location.href = data+"&details="+details; }