Make posting assignment attachment work.

Bug430-Eden2
Lan Hui 2023-08-29 21:34:58 +08:00
parent 84083981de
commit 0e3e5aec8d
4 changed files with 42 additions and 27 deletions

View File

@ -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;'>

View File

@ -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." &nbsp|&nbsp <a href='~\..\Lab_Report_Assignments\\$att2'>$att2</a>";
$full_link= $full_link." &nbsp|&nbsp <a href='~\..\Download.php?file=$att2'>$att2</a>";
}
if($att3!=""){
$full_link= $full_link." &nbsp|&nbsp <a href='~\..\Lab_Report_Assignments\\$att3'>$att3</a>";
$full_link= $full_link." &nbsp|&nbsp <a href='~\..\Download.php?file=$att3'>$att3</a>";
}
if($att4!=""){
$full_link= $full_link." &nbsp; | &nbsp <a href='~\..\Lab_Report_Assignments\\$att4'>$att4</a>";
$full_link= $full_link." &nbsp; | &nbsp <a href='~\..\Download.php?file=$att4'>$att4</a>";
}

View File

@ -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).'"');

View File

@ -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;