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 = "<a href='~\..\Lab_Report_Assignments\\$att1'>$att1</a>"; + $full_link = "<a href='~\..\Download.php?file=$att1'>$att1</a>"; if($att2 != "") { - $full_link = $full_link."| <a href='~\..\Lab_Report_Assignments\\$att2'>$att2</a>"; + $full_link = $full_link."| <a href='~\..\Download.php?file=$att2'>$att2</a>"; } if($att3 != "") { - $full_link = $full_link."| <a href='~\..\Lab_Report_Assignments\\$att3'>$att3</a>"; + $full_link = $full_link."| <a href='~\..\Download.php?file=$att3'>$att3</a>"; } if($att4 != "") { - $full_link = $full_link."| <a href='~\..\Lab_Report_Assignments\\$att4'>$att4</a>"; + $full_link = $full_link."| <a href='~\..\Download.php?file=$att4'>$att4</a>"; } echo "<div class='card mt-md-2' style='word-wrap: break-word;'> 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'; <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js" integrity="sha512-57oZ/vW8ANMjR/KQ6Be9v/+/h6bq9/l3f0Oc7vn6qMqyhvPd1cvKBRWWpzu0QoneImqr2SkmO4MSqU+RpHom3Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script> - function extendDeadline(id) { - const dropstudents = $("#dropstudents").html(); - try { - $(`<form id="frm" method="get" action="Script.php"> + function extendDeadline(id) { + const dropstudents = $("#dropstudents").html(); + try { + $(`<form id="frm" method="get" action="Script.php"> <input type="hidden" name="extenddeadline" value="true" > <input type="hidden" name="id" value="${id}" > New date and time<br> @@ -58,10 +58,10 @@ include 'Header.php'; } } }); - } catch(e) { - alert(e); - } - } + } catch(e) { + alert(e); + } + } </script> @@ -126,10 +126,21 @@ include 'Header.php'; } else { // echo "Error: " . $sql . "<br>" . $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 . "<br>" . $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'; } ?> - - <hr> - <input type='submit' class='btn btn-primary' value='Post Lab Assignment'><br> + <br> + <input type='submit' class='btn btn-primary' value='Update assignment'><br> </form><br><br><br><br> + <form method='post' action=''> + <input type='hidden' name='frm_deletelab' value='true' required=''/> + <input type='submit' class='btn btn-danger' value='Delete assignment'><br> + </form> + <?php }}else{ @@ -289,17 +304,17 @@ include 'Header.php'; $id=$row['Lab_Report_ID']; $cours_id=$row['Course_ID']; $as_type=$row['Type']; - $full_link="<a href='~\..\Lab_Report_Assignments\\$att1'>$att1</a>"; + $full_link="<a href='~\..\Download.php?file=$att1'>$att1</a>"; if($att2!=""){ - $full_link= $full_link."  |  <a href='~\..\Lab_Report_Assignments\\$att2'>$att2</a>"; + $full_link= $full_link."  |  <a href='~\..\Download.php?file=$att2'>$att2</a>"; } if($att3!=""){ - $full_link= $full_link."  |  <a href='~\..\Lab_Report_Assignments\\$att3'>$att3</a>"; + $full_link= $full_link."  |  <a href='~\..\Download.php?file=$att3'>$att3</a>"; } if($att4!=""){ - $full_link= $full_link." |   <a href='~\..\Lab_Report_Assignments\\$att4'>$att4</a>"; + $full_link= $full_link." |   <a href='~\..\Download.php?file=$att4'>$att4</a>"; } 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 . "<br>" . $con->error;