From 0e3e5aec8dc1f4f70472dfd7b935d2425fe65537 Mon Sep 17 00:00:00 2001 From: Lan Hui Date: Tue, 29 Aug 2023 21:34:58 +0800 Subject: [PATCH] Make posting assignment attachment work. --- Course.php | 8 ++++---- Courses.php | 47 +++++++++++++++++++++++++++++++---------------- Download.php | 2 +- Script.php | 12 ++++++------ 4 files changed, 42 insertions(+), 27 deletions(-) diff --git a/Course.php b/Course.php index 2957b9e..5ad410e 100644 --- a/Course.php +++ b/Course.php @@ -153,16 +153,16 @@ include 'Header.php'; $att4 = $row['Attachment_link_4']; $labid = $row['Lab_Report_ID']; $days_remaining = date_diff(date_create($deadline), date_create())->format('%a days, %h hours, %i minutes'); - $full_link = "$att1"; + $full_link = "$att1"; if($att2 != "") { - $full_link = $full_link."| $att2"; + $full_link = $full_link."| $att2"; } if($att3 != "") { - $full_link = $full_link."| $att3"; + $full_link = $full_link."| $att3"; } if($att4 != "") { - $full_link = $full_link."| $att4"; + $full_link = $full_link."| $att4"; } echo "
diff --git a/Courses.php b/Courses.php index 24daaef..fcea06e 100644 --- a/Courses.php +++ b/Courses.php @@ -26,10 +26,10 @@ include 'Header.php'; @@ -126,10 +126,21 @@ include 'Header.php'; } else { // echo "Error: " . $sql . "
" . $con->error; - echo "Serious error happened whiling updating assignment information."; + echo "Serious error happened while updating assignment information."; } } + if(isset($_POST['frm_deletelab'])) { + $sql = "DELETE FROM lab_reports_table WHERE Lab_Report_ID='$getid'"; + if ($con->query($sql) === TRUE) { + $_SESSION["info_Updated"]="Assignment deleted successfully."; + } else { + // echo "Error: " . $sql . "
" . $con->error; + echo "Serious error happened while deleting the assignment."; + } + } + + if( $_SESSION['user_type']=="Lecturer"){ $Date = $_SESSION['Date']; $Time = $_SESSION['Time']; @@ -179,11 +190,15 @@ include 'Header.php'; } ?> - -
-
+
+




+
+ +
+
+ $att1"; + $full_link="$att1"; if($att2!=""){ - $full_link= $full_link."  |  $att2"; + $full_link= $full_link."  |  $att2"; } if($att3!=""){ - $full_link= $full_link."  |  $att3"; + $full_link= $full_link."  |  $att3"; } if($att4!=""){ - $full_link= $full_link."   |   $att4"; + $full_link= $full_link."   |   $att4"; } diff --git a/Download.php b/Download.php index d59e90e..42db7d4 100644 --- a/Download.php +++ b/Download.php @@ -25,7 +25,7 @@ $type = filetype($file); $today = date("F j, Y, g:i a"); $time = time(); -if ((isset($_SESSION["user_student_id"]) && strpos($file, $_SESSION["user_student_id"]) > 0) || $_SESSION['user_type'] == "Lecturer" || $_SESSION['user_type'] == "TA" ) { +if ((isset($_SESSION["user_student_id"]) && (strpos($file, $_SESSION["user_student_id"]) > 0 || strpos($file, "Lab_Report_Assignments"))) || $_SESSION['user_type'] == "Lecturer" || $_SESSION['user_type'] == "TA" ) { // 发送文件头部 header("Content-type: $type"); header('Content-Disposition: attachment;filename="'.urldecode($filename).'"'); diff --git a/Script.php b/Script.php index 73a6a63..ab88509 100644 --- a/Script.php +++ b/Script.php @@ -357,7 +357,7 @@ if (!empty($_POST["frm_uploadlab"])) { // GET UPLOADED FILES - $target_dir = Create_dir("Lab_Report_Assignments/" . $title . "/"); + $target_dir = Create_dir("./../../lrr_submission/Lab_Report_Assignments/$course_id/" . $title . "/"); $rnd = rand(10, 1000); $rnd = ""; // no more required , creating folder for each lab @@ -416,16 +416,16 @@ if (!empty($_POST["frm_uploadlab"])) { $targetfile4 = ""; if ($_FILES['attachment1']['name'] != "") { - $targetfile = "/" . $title . "/" . $_FILES['attachment1']['name']; + $targetfile = "/Lab_Report_Assignments/$course_id/" . $title . "/" . $_FILES['attachment1']['name']; } if ($_FILES['attachment2']['name'] != "") { - $targetfile2 = "/" . $title . "/" . $_FILES['attachment2']['name']; + $targetfile2 = "/Lab_Report_Assignments/$course_id" . $title . "/" . $_FILES['attachment2']['name']; } if ($_FILES['attachment3']['name'] != "") { - $targetfile3 = "/" . $title . "/" . $_FILES['attachment3']['name']; + $targetfile3 = "/Lab_Report_Assignments/$course_id" . $title . "/" . $_FILES['attachment3']['name']; } if ($_FILES['attachment4']['name'] != "") { - $targetfile4 = "/" . $title . "/" . $_FILES['attachment4']['name']; + $targetfile4 = "/Lab_Report_Assignments/$course_id" . $title . "/" . $_FILES['attachment4']['name']; } $sql = "INSERT INTO `lab_reports_table`(`Course_ID`, `Posted_Date`, `Deadline`, `Instructions`, @@ -434,7 +434,7 @@ if (!empty($_POST["frm_uploadlab"])) { if ($con->query($sql) === TRUE) { - $_SESSION["info_courses"] = $type . " lab report assignment posted successfully."; + $_SESSION["info_courses"] = $type . " lab report assignment posted successfully. "; header("Location: Courses.php?course=" . $url); } else { echo "Error: " . $sql . "
" . $con->error;