Indent Courses.php using Emacs web-mode.

Bug430-Eden2
Lan Hui 2023-08-10 22:48:12 +08:00
parent 2fa24bba94
commit 380c79fd8a
1 changed files with 247 additions and 247 deletions

View File

@ -10,11 +10,11 @@ include 'Header.php';
<div class="container"> <div class="container">
<?php <?php
$user_d = $_SESSION['user_id']; $user_d = $_SESSION['user_id'];
if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA") if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA")
{ {
?> ?>
<!-- FOR LECTURER--> <!-- FOR LECTURER-->
@ -24,10 +24,10 @@ if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA")
<script src="./css/jquery-ui.min.js"></script> <script src="./css/jquery-ui.min.js"></script>
<link rel="stylesheet" href="./css/jquery-ui.css" /> <link rel="stylesheet" href="./css/jquery-ui.css" />
<script> <script>
function extendDeadline(id) { function extendDeadline(id) {
const dropstudents = $("#dropstudents").html(); const dropstudents = $("#dropstudents").html();
try { try {
$(`<form id="frm" method="get" action="Script.php"> $(`<form id="frm" method="get" action="Script.php">
<input type="hidden" name="extenddeadline" value="true" > <input type="hidden" name="extenddeadline" value="true" >
<input type="hidden" name="id" value="${id}" > <input type="hidden" name="id" value="${id}" >
New date and time<br> New date and time<br>
@ -52,12 +52,12 @@ if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA")
} }
} }
}); });
} catch(e) { } catch(e) {
alert(e); alert(e);
}
} }
}
</script> </script>
<?php <?php
if(!empty($_GET["course"])) if(!empty($_GET["course"]))
@ -67,33 +67,33 @@ if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA")
. " `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` " . " `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` "
. " , users_table.Full_Name FROM `courses_table` INNER JOIN users_table" . " , users_table.Full_Name FROM `courses_table` INNER JOIN users_table"
. " ON users_table.User_ID=courses_table.Lecturer_User_ID where URL='$course_url' "); . " ON users_table.User_ID=courses_table.Lecturer_User_ID where URL='$course_url' ");
if(mysqli_num_rows($result)==0) if(mysqli_num_rows($result)==0)
{} else { while($row = mysqli_fetch_assoc($result)) { {} else { while($row = mysqli_fetch_assoc($result)) {
$name=$row['Course_Name']; $name=$row['Course_Name'];
$code=$row['Course_Code']; $code=$row['Course_Code'];
$faculty=$row['Faculty']; $faculty=$row['Faculty'];
$lecturer=$row['Full_Name']; $lecturer=$row['Full_Name'];
$academic=$row['Academic_Year']; $academic=$row['Academic_Year'];
$url=$row['URL']; $url=$row['URL'];
$id=$row['Course_ID']; $id=$row['Course_ID'];
$course_id=$row['Course_ID']; $course_id=$row['Course_ID'];
echo " echo "
<div class='alert> <a href='~\..\Courses.php?course=$url'> <div class='panel'> <div class='alert> <a href='~\..\Courses.php?course=$url'> <div class='panel'>
($code) - $name ($code) - $name
<br> <span style='font-size:8pt'>Faculty:$faculty &nbsp; Year: $academic &nbsp; Lecturer: $lecturer </span> <br> <span style='font-size:8pt'>Faculty:$faculty &nbsp; Year: $academic &nbsp; Lecturer: $lecturer </span>
</div></a> </div></a>
<hr></div></div> <div class='row' style='width:80%;margin:auto; text-align:left;'> <hr></div></div> <div class='row' style='width:80%;margin:auto; text-align:left;'>
"; ";
echo "<div class='col-md-5'>"; echo "<div class='col-md-5'>";
} }
// ------------------------------Editing Lab Assignment by Lecturer ------------------------------------ // ------------------------------Editing Lab Assignment by Lecturer ------------------------------------
if($_GET['act']=="edit"){ if($_GET['act']=="edit"){
$getid = mysqli_real_escape_string($con, $_GET["cid"]); $getid = mysqli_real_escape_string($con, $_GET["cid"]);
$result1 = mysqli_query($con, "SELECT * from lab_reports_table WHERE Lab_Report_ID = '$getid'"); $result1 = mysqli_query($con, "SELECT * from lab_reports_table WHERE Lab_Report_ID = '$getid'");
@ -106,7 +106,7 @@ if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA")
$_SESSION['Marks'] = $row1['Marks']; $_SESSION['Marks'] = $row1['Marks'];
$_SESSION['Type'] = $row1['Type']; $_SESSION['Type'] = $row1['Type'];
} }
if(isset($_POST['frm_uploadlab'])){ if(isset($_POST['frm_uploadlab'])){
$deadlinedate = trim(mysqli_real_escape_string($con, $_POST["deadlinedate"])); // remove spaces $deadlinedate = trim(mysqli_real_escape_string($con, $_POST["deadlinedate"])); // remove spaces
$deadlinetime = trim(mysqli_real_escape_string($con, $_POST["deadlinetime"])); // remove spaces $deadlinetime = trim(mysqli_real_escape_string($con, $_POST["deadlinetime"])); // remove spaces
@ -116,36 +116,36 @@ if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA")
$type = mysqli_real_escape_string($con, $_POST["type"]); $type = mysqli_real_escape_string($con, $_POST["type"]);
$Deadline = $deadlinedate." ".$deadlinetime; $Deadline = $deadlinedate." ".$deadlinetime;
$date = date("Y-m-d H:i"); $date = date("Y-m-d H:i");
$sql = "UPDATE `lab_reports_table` SET `Deadline` = ('" . $Deadline . "'), `Instructions` = ('" . $instructions . "'), `Title` = ('" . $title . "'), `Marks` = ('" . $marks . "'), `Type` = ('" . $type . "') WHERE `lab_reports_table`.`Lab_Report_ID` = '$getid'"; $sql = "UPDATE `lab_reports_table` SET `Deadline` = ('" . $Deadline . "'), `Instructions` = ('" . $instructions . "'), `Title` = ('" . $title . "'), `Marks` = ('" . $marks . "'), `Type` = ('" . $type . "') WHERE `lab_reports_table`.`Lab_Report_ID` = '$getid'";
if ($con->query($sql) === TRUE) { if ($con->query($sql) === TRUE) {
$_SESSION["info_Updated"]="Assignment information updated successfully."; $_SESSION["info_Updated"]="Assignment information updated successfully.";
} else { } else {
// echo "Error: " . $sql . "<br>" . $con->error; // echo "Error: " . $sql . "<br>" . $con->error;
echo "Serious error happened whiling updating assignment information."; echo "Serious error happened whiling updating assignment information.";
} }
} }
if( $_SESSION['user_type']=="Lecturer"){ if( $_SESSION['user_type']=="Lecturer"){
$Date = $_SESSION['Date']; $Date = $_SESSION['Date'];
$Time = $_SESSION['Time']; $Time = $_SESSION['Time'];
$Instructions = $_SESSION['Instructions']; $Instructions = $_SESSION['Instructions'];
$Title = $_SESSION['Title']; $Title = $_SESSION['Title'];
$Marks = $_SESSION['Marks']; $Marks = $_SESSION['Marks'];
$Type = $_SESSION['Type']; $Type = $_SESSION['Type'];
echo " <h3><a href='Courses.php?course=".$url."'>Editing assignment information</a></h3>"; echo " <h3><a href='Courses.php?course=".$url."'>Editing assignment information</a></h3>";
?> ?>
<form method='post' enctype='multipart/form-data' action=''> <form method='post' enctype='multipart/form-data' action=''>
<input type='hidden' name='frm_uploadlab' value='true' required=''/> <input type='hidden' name='frm_uploadlab' value='true' required=''/>
<input type='hidden' name='course_id' value='<?php echo "$id" ?>' required=''/> <input type='hidden' name='course_id' value='<?php echo "$id" ?>' required=''/>
<input type='hidden' name='url' value='<?php echo ".$course_url." ?>' required=''/> <input type='hidden' name='url' value='<?php echo ".$course_url." ?>' required=''/>
Deadline Date/Time Deadline Date/Time
<div class='row'> <div class='row'>
<div class='col-md-7'><input type='date' id='date' name='deadlinedate' placeholder='' class='form-control' required='' value="<?php echo isset($_GET['act']) && $_GET['act']=="edit" ? $Date : ""; ?>"> </div> <div class='col-md-7'><input type='date' id='date' name='deadlinedate' placeholder='' class='form-control' required='' value="<?php echo isset($_GET['act']) && $_GET['act']=="edit" ? $Date : ""; ?>"> </div>
<div class='col-md-5'> <input type='text' id='time' class='form-control' name='deadlinetime' value="<?php echo isset($_GET['act']) && $_GET['act']=="edit" ? $Time : ""; ?>"> </div> <div class='col-md-5'> <input type='text' id='time' class='form-control' name='deadlinetime' value="<?php echo isset($_GET['act']) && $_GET['act']=="edit" ? $Time : ""; ?>"> </div>
</div> </div>
Title Title
@ -173,7 +173,7 @@ if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA")
echo "Submission Type <input type='radio' name='type' value='Individual' checked /> Individual <input type='radio' name='type' value='Group' /> Group"; echo "Submission Type <input type='radio' name='type' value='Individual' checked /> Individual <input type='radio' name='type' value='Group' /> Group";
} else { } else {
echo "Submission Type <input type='radio' name='type' value='Individual' /> Individual <input type='radio' name='type' value='Group' checked> Group"; echo "Submission Type <input type='radio' name='type' value='Individual' /> Individual <input type='radio' name='type' value='Group' checked> Group";
} }
?> ?>
@ -188,12 +188,12 @@ if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA")
// Mysql to split 1 string into 2 similar to the tsrstr in php // Mysql to split 1 string into 2 similar to the tsrstr in php
// SELECT SUBSTRING_INDEX(Deadline, ' ', 1) as Date, SUBSTRING_INDEX(Deadline, ' ', -1) as Time from lab_reports_table // SELECT SUBSTRING_INDEX(Deadline, ' ', 1) as Date, SUBSTRING_INDEX(Deadline, ' ', -1) as Time from lab_reports_table
if( $_SESSION['user_type']=="Lecturer"){ if( $_SESSION['user_type']=="Lecturer"){
?>
?>
<h3>New an assignment</h3> <h3>New an assignment</h3>
<form method='post' enctype='multipart/form-data' action='Script.php'> <form method='post' enctype='multipart/form-data' action='Script.php'>
<?php <?php
$_SESSION['url']=$url; $_SESSION['url']=$url;
@ -201,11 +201,11 @@ if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA")
<input type='hidden' name='frm_uploadlab' value='true' required=''/> <input type='hidden' name='frm_uploadlab' value='true' required=''/>
<input type='hidden' name='course_id' value='<?php echo "$id" ?>' required=''/> <input type='hidden' name='course_id' value='<?php echo "$id" ?>' required=''/>
<input type='hidden' name='url' value='<?php echo ".$course_url." ?>' required=''/> <input type='hidden' name='url' value='<?php echo ".$course_url." ?>' required=''/>
Deadline (date and time) Deadline (date and time)
<div class='row'> <div class='row'>
<div class='col-md-7'><input type='date' id='date' name='deadlinedate' placeholder='' class='form-control' required='' value=""> </div> <div class='col-md-7'><input type='date' id='date' name='deadlinedate' placeholder='' class='form-control' required='' value=""> </div>
<div class='col-md-5'> <input type='time' class='form-control' name='deadlinetime' value=""> </div> <div class='col-md-5'> <input type='time' class='form-control' name='deadlinetime' value=""> </div>
</div> </div>
Title Title
@ -234,14 +234,14 @@ if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA")
<input type='submit' class='btn btn-primary' value='Post'><br> <input type='submit' class='btn btn-primary' value='Post'><br>
</form><br><br><br><br> </form><br><br><br><br>
<?php <?php
} }
} }
} }
echo "</div>"; echo "</div>";
echo "<div class='col-md-7'><h3>Assignment list</h3>"; echo "<div class='col-md-7'><h3>Assignment list</h3>";
error_reporting(0); error_reporting(0);
if(isset($_SESSION["info_Updated"])){ if(isset($_SESSION["info_Updated"])){
echo '<hr><div class="alert alert-info" role="alert">' . $_SESSION['info_Updated'] . '</div>'; echo '<hr><div class="alert alert-info" role="alert">' . $_SESSION['info_Updated'] . '</div>';
@ -257,12 +257,12 @@ if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA")
} }
$result = mysqli_query($con," SELECT `Lab_Report_ID`,Type,Marks, `Course_ID`, `Posted_Date`, `Deadline`, `Instructions`, `Title`, `Attachment_link_1`, `Attachment_link_2`, `Attachment_link_3`, " $result = mysqli_query($con," SELECT `Lab_Report_ID`,Type,Marks, `Course_ID`, `Posted_Date`, `Deadline`, `Instructions`, `Title`, `Attachment_link_1`, `Attachment_link_2`, `Attachment_link_3`, "
. "`Attachment_link_4` FROM `lab_reports_table` WHERE Course_ID=$id ORDER by Lab_Report_ID DESC"); . "`Attachment_link_4` FROM `lab_reports_table` WHERE Course_ID=$id ORDER by Lab_Report_ID DESC");
if( $_SESSION['user_type']=="TA") if( $_SESSION['user_type']=="TA")
{ {
echo "<b style='color:gray'>Only Lecturer can post assignments.</b><br>"; echo "<b style='color:gray'>Only Lecturer can post assignments.</b><br>";
@ -270,12 +270,12 @@ if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA")
if(mysqli_num_rows($result)==0) if(mysqli_num_rows($result)==0)
{ {
echo "No assignments posted so far."; echo "No assignments posted so far.";
} else { while($row = mysqli_fetch_assoc($result)) { } else { while($row = mysqli_fetch_assoc($result)) {
$marks=$row['Marks']; $marks=$row['Marks'];
$title=$row['Title']; $title=$row['Title'];
$ins=$row['Instructions']; $ins=$row['Instructions'];
$posted=$row['Posted_Date']; $posted=$row['Posted_Date'];
$deadline=$row['Deadline']; $deadline=$row['Deadline'];
$att1=$row['Attachment_link_1']; $att1=$row['Attachment_link_1'];
$att2=$row['Attachment_link_2']; $att2=$row['Attachment_link_2'];
@ -284,166 +284,166 @@ if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA")
$id=$row['Lab_Report_ID']; $id=$row['Lab_Report_ID'];
$cours_id=$row['Course_ID']; $cours_id=$row['Course_ID'];
$as_type=$row['Type']; $as_type=$row['Type'];
$full_link="<a href='~\..\Lab_Report_Assignments\\$att1'>$att1</a>"; $full_link="<a href='~\..\Lab_Report_Assignments\\$att1'>$att1</a>";
if($att2!=""){ if($att2!=""){
$full_link= $full_link." &nbsp|&nbsp <a href='~\..\Lab_Report_Assignments\\$att2'>$att2</a>"; $full_link= $full_link." &nbsp|&nbsp <a href='~\..\Lab_Report_Assignments\\$att2'>$att2</a>";
} }
if($att3!=""){ if($att3!=""){
$full_link= $full_link." &nbsp|&nbsp <a href='~\..\Lab_Report_Assignments\\$att3'>$att3</a>"; $full_link= $full_link." &nbsp|&nbsp <a href='~\..\Lab_Report_Assignments\\$att3'>$att3</a>";
} }
if($att4!=""){ if($att4!=""){
$full_link= $full_link." &nbsp; | &nbsp <a href='~\..\Lab_Report_Assignments\\$att4'>$att4</a>"; $full_link= $full_link." &nbsp; | &nbsp <a href='~\..\Lab_Report_Assignments\\$att4'>$att4</a>";
} }
$resultx1 = mysqli_query($con,"Select Count(*) as cnt from lab_report_submissions where lab_report_submissions.Lab_Report_ID=$id"); $resultx1 = mysqli_query($con,"Select Count(*) as cnt from lab_report_submissions where lab_report_submissions.Lab_Report_ID=$id");
while($row = mysqli_fetch_assoc($resultx1)) {$count_subs=$row['cnt'];} while($row = mysqli_fetch_assoc($resultx1)) {$count_subs=$row['cnt'];}
$resultx2 = mysqli_query($con,"Select COUNT(*) as cnt from lab_report_submissions where lab_report_submissions.Lab_Report_ID=$id and Marks is not null"); $resultx2 = mysqli_query($con,"Select COUNT(*) as cnt from lab_report_submissions where lab_report_submissions.Lab_Report_ID=$id and Marks is not null");
if(mysqli_num_rows($resultx2)==0){$count_marked=0;} else { while($row = mysqli_fetch_assoc($resultx2)) {$count_marked =$row['cnt'];}} if(mysqli_num_rows($resultx2)==0){$count_marked=0;} else { while($row = mysqli_fetch_assoc($resultx2)) {$count_marked =$row['cnt'];}}
$header="Courses > ".$name."($code) > Assignments > ".$title; $header="Courses > ".$name."($code) > Assignments > ".$title;
echo " <div class='break-word btn btn-default' style='word-wrap: break-word;border-color:grey;'> echo " <div class='break-word btn btn-default' style='word-wrap: break-word;border-color:grey;'>
$title ($marks Marks, $as_type) <br> $ins $title ($marks Marks, $as_type) <br> $ins
<br> <span style='font-size:8pt'>Posted: $posted &nbsp; Deadline: $deadline" <br> <span style='font-size:8pt'>Posted: $posted &nbsp; Deadline: $deadline"
. "<br>" . "<br>"
. "<span class='btn-default'> &nbsp;&nbsp; $count_subs Submissions ( $count_marked Marked ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='Courses.php?course=".$url."&act=edit&cid=".$id."'>Edit</a>&nbsp;&nbsp; |&nbsp;&nbsp;<a href='~\..\Submissions.php?id=$id&header=$header&total=$marks' onclick=''> View </a> &nbsp;&nbsp; |&nbsp;&nbsp; <a href='#' onclick='extendDeadline($id)'> Extend Deadline </a> </span> <hr> Attachments : $full_link </span>" . "<span class='btn-default'> &nbsp;&nbsp; $count_subs Submissions ( $count_marked Marked ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='Courses.php?course=".$url."&act=edit&cid=".$id."'>Edit</a>&nbsp;&nbsp; |&nbsp;&nbsp;<a href='~\..\Submissions.php?id=$id&header=$header&total=$marks' onclick=''> View </a> &nbsp;&nbsp; |&nbsp;&nbsp; <a href='#' onclick='extendDeadline($id)'> Extend Deadline </a> </span> <hr> Attachments : $full_link </span>"
. "&nbsp;&nbsp;</div> . "&nbsp;&nbsp;</div>
"; ";
}} }}
echo "</div>"; echo "</div>";
$resultx1 = mysqli_query($con,"SELECT course_students_table.Student_ID,users_table.Full_Name FROM $resultx1 = mysqli_query($con,"SELECT course_students_table.Student_ID,users_table.Full_Name FROM
`course_students_table` `course_students_table`
INNER JOIN users_table on users_table.Student_ID=course_students_table.Student_ID INNER JOIN users_table on users_table.Student_ID=course_students_table.Student_ID
WHERE Course_ID=$course_id"); WHERE Course_ID=$course_id");
echo "<span id='dropstudents' style='display:none;'> <select name='stdid'>"; echo "<span id='dropstudents' style='display:none;'> <select name='stdid'>";
while($row = mysqli_fetch_assoc($resultx1)) while($row = mysqli_fetch_assoc($resultx1))
{ {
$stdid=$row['Student_ID']; $stdid=$row['Student_ID'];
$stdname=$row['Full_Name']; $stdname=$row['Full_Name'];
echo "<option value='$stdid'> $stdname($stdid) </option> "; echo "<option value='$stdid'> $stdname($stdid) </option> ";
} }
echo "</select><br>Reason <input type='text' name='reason'>" echo "</select><br>Reason <input type='text' name='reason'>"
. "<input type='hidden' name='url' value='$course_url'>" . "<input type='hidden' name='url' value='$course_url'>"
. " </span>"; . " </span>";
return; return;
} }
?> ?>
<div class="col-md-8"> <div class="col-md-8">
<?php <?php
$user_name=$_SESSION['user_fullname']; $user_name=$_SESSION['user_fullname'];
echo "<h1 class='display-6'>My courses</h1>"; echo "<h1 class='display-6'>My courses</h1>";
$result = mysqli_query($con,"SELECT `Course_ID`, `Course_Name`, `Academic_Year`, `Faculty`, " $result = mysqli_query($con,"SELECT `Course_ID`, `Course_Name`, `Academic_Year`, `Faculty`, "
. "`Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` , users_table.Full_Name FROM `courses_table` INNER JOIN users_table ON users_table.User_ID=courses_table.Lecturer_User_ID where courses_table.Lecturer_User_ID=$user_d ORDER BY Academic_Year DESC, URL ASC"); . "`Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` , users_table.Full_Name FROM `courses_table` INNER JOIN users_table ON users_table.User_ID=courses_table.Lecturer_User_ID where courses_table.Lecturer_User_ID=$user_d ORDER BY Academic_Year DESC, URL ASC");
if($_SESSION['user_type']=="TA") if($_SESSION['user_type']=="TA")
{ {
$result = mysqli_query($con,"SELECT course_ta.Course_ID, `Course_Name`, $result = mysqli_query($con,"SELECT course_ta.Course_ID, `Course_Name`,
`Academic_Year`, `Faculty`, `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` FROM `courses_table` `Academic_Year`, `Faculty`, `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` FROM `courses_table`
INNER JOIN INNER JOIN
course_ta ON course_ta.Course_ID=courses_table.Course_ID where course_ta.TA=$user_d"); course_ta ON course_ta.Course_ID=courses_table.Course_ID where course_ta.TA=$user_d");
} }
if(mysqli_num_rows($result)==0) if(mysqli_num_rows($result)==0)
{} else { while($row = mysqli_fetch_assoc($result)) { {} else { while($row = mysqli_fetch_assoc($result)) {
$id=$row['Course_ID']; $id=$row['Course_ID'];
$name=$row['Course_Name']; $name=$row['Course_Name'];
$code=$row['Course_Code']; $code=$row['Course_Code'];
$faculty=$row['Faculty']; $faculty=$row['Faculty'];
$lecturer=$row['Full_Name']; $lecturer=$row['Full_Name'];
$academic=$row['Academic_Year']; $academic=$row['Academic_Year'];
$url=$row['URL']; $url=$row['URL'];
$resultTA = mysqli_query($con,"SELECT `Course_ID`, `TA`,users_table.Full_Name as TA_NAME FROM `course_ta` $resultTA = mysqli_query($con,"SELECT `Course_ID`, `TA`,users_table.Full_Name as TA_NAME FROM `course_ta`
INNER JOIN users_table on users_table.User_ID=course_ta.TA INNER JOIN users_table on users_table.User_ID=course_ta.TA
where course_ta.Course_ID=$id"); where course_ta.Course_ID=$id");
$ta=""; $ta="";
while($rowTA = mysqli_fetch_assoc($resultTA)) { while($rowTA = mysqli_fetch_assoc($resultTA)) {
$ta=$ta." - ".$rowTA['TA_NAME']; $ta=$ta." - ".$rowTA['TA_NAME'];
} }
echo" echo"
<a href='~\..\Courses.php?course=$url'> <div class='btn btn-default'> <a href='~\..\Courses.php?course=$url'> <div class='btn btn-default'>
($code) - $name ($code) - $name
<br> <span style='font-size:8pt'>Faculty : $faculty &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Year : $academic &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lecturer :$lecturer &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TA:$ta </span> <br> <span style='font-size:8pt'>Faculty : $faculty &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Year : $academic &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lecturer :$lecturer &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TA:$ta </span>
</div></a> </div></a>
"; ";
}}?> }}?>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<br> <br>
<b> Course joining requests </b> <b> Course joining requests </b>
<?php <?php
$lecturer_id= $_SESSION['user_id']; $lecturer_id= $_SESSION['user_id'];
$result = mysqli_query($con,"SELECT course_students_table.ID,users_table.Full_Name, courses_table.Course_ID, `Course_Name`, `Academic_Year`, `Faculty`, `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` FROM `courses_table` $result = mysqli_query($con,"SELECT course_students_table.ID,users_table.Full_Name, courses_table.Course_ID, `Course_Name`, `Academic_Year`, `Faculty`, `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` FROM `courses_table`
INNER JOIN course_students_table on course_students_table.Course_ID=courses_table.Course_ID INNER JOIN course_students_table on course_students_table.Course_ID=courses_table.Course_ID
INNER JOIN users_table on users_table.Student_ID=course_students_table.Student_ID INNER JOIN users_table on users_table.Student_ID=course_students_table.Student_ID
WHERE Lecturer_User_ID=$lecturer_id and course_students_table.Status='Pending'"); WHERE Lecturer_User_ID=$lecturer_id and course_students_table.Status='Pending'");
if(mysqli_num_rows($result)==0) if(mysqli_num_rows($result)==0)
{ {
echo "<br> <i class='fa fa-info-circle'></i>No course-joining request so far for your courses<hr>"; echo "<br> <i class='fa fa-info-circle'></i>No course-joining request so far for your courses<hr>";
} else { while($row = mysqli_fetch_assoc($result)) { } else { while($row = mysqli_fetch_assoc($result)) {
$id=$row['ID']; $id=$row['ID'];
$name=$row['Course_Name']; $name=$row['Course_Name'];
$code=$row['Course_Code']; $code=$row['Course_Code'];
$faculty=$row['Faculty']; $faculty=$row['Faculty'];
$std_name=$row['Full_Name']; $std_name=$row['Full_Name'];
$academic=$row['Academic_Year']; $academic=$row['Academic_Year'];
echo "<div class='btn btn-default'> echo "<div class='btn btn-default'>
$std_name is Requesting to join <br> [($code) - $name ] &nbsp;&nbsp;&nbsp;&nbsp; <br><a href='~\..\Script.php?AcceptStudent=y&id=$id&rs=yes' class='btn btn-sm btn-success' onclick=return confirm(\"are you sure to join this course?\")' > Accept </a> $std_name is Requesting to join <br> [($code) - $name ] &nbsp;&nbsp;&nbsp;&nbsp; <br><a href='~\..\Script.php?AcceptStudent=y&id=$id&rs=yes' class='btn btn-sm btn-success' onclick=return confirm(\"are you sure to join this course?\")' > Accept </a>
&nbsp;&nbsp;<a href='~\..\Script.php?AcceptStudent=y&id=$id&rs=no' class='btn btn-sm btn-danger' onclick=return confirm(\"are you sure to join this course?\")' > Decline </a> &nbsp;&nbsp;<a href='~\..\Script.php?AcceptStudent=y&id=$id&rs=no' class='btn btn-sm btn-danger' onclick=return confirm(\"are you sure to join this course?\")' > Decline </a>
</div>"; </div>";
} }
} }
?> ?>
<?php <?php
if( $_SESSION['user_type']=="TA") if( $_SESSION['user_type']=="TA")
{ {
echo "<center>Only Lecturer can post assignments</center>"; echo "<center>Only Lecturer can post assignments</center>";
} }
if( $_SESSION['user_type']=="Lecturer"){ ?> if( $_SESSION['user_type']=="Lecturer"){ ?>
<b>Create a new course</b> <b>Create a new course</b>
<form method="post" action="Script.php"> <form method="post" action="Script.php">
<input type="hidden" name="frm_createCourse" value="true" required=""/> <input type="hidden" name="frm_createCourse" value="true" required=""/>
<input type="hidden" name="l" value="l" required=""/> <input type="hidden" name="l" value="l" required=""/>
@ -466,156 +466,156 @@ WHERE Lecturer_User_ID=$lecturer_id and course_students_table.Status='Pending'"
<input type="hidden" name="lecturer" value="<?php echo $_SESSION['user_id']; ?>"> <input type="hidden" name="lecturer" value="<?php echo $_SESSION['user_id']; ?>">
Verify joining students? Verify joining students?
<input type="radio" name="verify" value="1"> Yes <input type="radio" name="verify" value="1"> Yes
<input type="radio" name="verify" value="0" checked=""> No <input type="radio" name="verify" value="0" checked=""> No
<br><br> <br><br>
<input type="submit" class="btn btn-primary" value="Create"><br> <input type="submit" class="btn btn-primary" value="Create"><br>
</form> </form>
<?php } ?> <?php } ?>
</div> </div>
<!-- END LECTURER --> <!-- END LECTURER -->
<?php <?php
} }
if( $_SESSION['user_type']=="Student") if( $_SESSION['user_type']=="Student")
{ {
?> ?>
<!--STUDENT CODE--> <!--STUDENT CODE-->
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<?php <?php
error_reporting(0); error_reporting(0);
if (isset($_SESSION['info_Courses_student'])) { if (isset($_SESSION['info_Courses_student'])) {
echo '<hr><span class="alert alert-success" role="alert">' . $_SESSION['info_Courses_student'] . '</span>'; echo '<hr><span class="alert alert-success" role="alert">' . $_SESSION['info_Courses_student'] . '</span>';
$_SESSION['info_Courses_student'] = null; $_SESSION['info_Courses_student'] = null;
} }
?> ?>
<br><br> <br><br>
</div>
<div class="col-md-6"></div>
</div> </div>
<div class="col-md-6"></div>
</div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<?php <?php
error_reporting(0); error_reporting(0);
$student_id= $_SESSION['user_student_id']; $student_id= $_SESSION['user_student_id'];
// current academic year - i.e 2021 - 2022 , so we will show in search result: // current academic year - i.e 2021 - 2022 , so we will show in search result:
// course containing either 2021 or 2022 as academic year. // course containing either 2021 or 2022 as academic year.
$oldest_academic_year = date('Y') - 1; $oldest_academic_year = date('Y') - 1;
if(!empty($_GET["search"]) || !empty($_GET["faculty"])) if(!empty($_GET["search"]) || !empty($_GET["faculty"]))
{
$search = trim(mysqli_real_escape_string($con, $_GET["search"]));
$search = strtoupper($_GET['search']);
$faculty = mysqli_real_escape_string($con, $_GET["faculty"]);
// the user has not entered something under "Find course by Code"
if($faculty=="")
{ {
echo "<h4> Search results for course code: $search </h4><hr>"; $search = trim(mysqli_real_escape_string($con, $_GET["search"]));
$result = mysqli_query($con,"SELECT `Course_ID`, `Course_Name`, `Academic_Year`, `Faculty`," $search = strtoupper($_GET['search']);
. " `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` " $faculty = mysqli_real_escape_string($con, $_GET["faculty"]);
. " , users_table.Full_Name FROM `courses_table` INNER JOIN users_table"
. " ON users_table.User_ID=courses_table.Lecturer_User_ID where Academic_Year >= $oldest_academic_year and Course_Code like '%{$search}%' and courses_table.Course_ID not in (select course_id from course_students_table where Student_ID=$student_id) order by Academic_Year desc"); // the user has not entered something under "Find course by Code"
} if($faculty=="")
// the user has entered something under "Find course by Code" {
else echo "<h4> Search results for course code: $search </h4><hr>";
{ $result = mysqli_query($con,"SELECT `Course_ID`, `Course_Name`, `Academic_Year`, `Faculty`,"
echo "<h3> Find courses under faculty: $faculty</h3>"; . " `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` "
$result = mysqli_query($con,"SELECT `Course_ID`, `Course_Name`, `Academic_Year`, `Faculty`, . " , users_table.Full_Name FROM `courses_table` INNER JOIN users_table"
`Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` . " ON users_table.User_ID=courses_table.Lecturer_User_ID where Academic_Year >= $oldest_academic_year and Course_Code like '%{$search}%' and courses_table.Course_ID not in (select course_id from course_students_table where Student_ID=$student_id) order by Academic_Year desc");
}
// the user has entered something under "Find course by Code"
else
{
echo "<h3> Find courses under faculty: $faculty</h3>";
$result = mysqli_query($con,"SELECT `Course_ID`, `Course_Name`, `Academic_Year`, `Faculty`,
`Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members`
, users_table.Full_Name FROM `courses_table` INNER JOIN users_table , users_table.Full_Name FROM `courses_table` INNER JOIN users_table
ON users_table.User_ID=courses_table.Lecturer_User_ID where Academic_Year >= $oldest_academic_year and Faculty='$faculty' and courses_table.Course_ID not in (select course_id from course_students_table where Student_ID=$student_id) order by Academic_Year desc"); ON users_table.User_ID=courses_table.Lecturer_User_ID where Academic_Year >= $oldest_academic_year and Faculty='$faculty' and courses_table.Course_ID not in (select course_id from course_students_table where Student_ID=$student_id) order by Academic_Year desc");
} }
if(mysqli_num_rows($result)==0)
{
echo "No results. <hr>";
} else { if(mysqli_num_rows($result)==0)
{
while($row = mysqli_fetch_assoc($result)) { echo "No results. <hr>";
$name=$row['Course_Name'];
$code=$row['Course_Code']; } else {
$faculty=$row['Faculty'];
$lecturer=$row['Full_Name']; while($row = mysqli_fetch_assoc($result)) {
$academic=$row['Academic_Year']; $name=$row['Course_Name'];
$url=$row['URL']; $code=$row['Course_Code'];
$id=$row['Course_ID']; $faculty=$row['Faculty'];
$v=$row['Verify_New_Members']; $lecturer=$row['Full_Name'];
if($v>0) $academic=$row['Academic_Year'];
{ $url=$row['URL'];
$msg="<i class='fa fa-exclamation-circle'></i> Lecturer verification required"; $id=$row['Course_ID'];
$msg2="Send Joining Request"; $v=$row['Verify_New_Members'];
} if($v>0)
{
echo "<div class='btn btn-default' style='word-wrap:break-word'> $msg="<i class='fa fa-exclamation-circle'></i> Lecturer verification required";
$msg2="Send Joining Request";
}
echo "<div class='btn btn-default' style='word-wrap:break-word'>
($code) $name <br>($url) <br> <a href='~\..\Script.php?JoinCourse=y&id=$id&std=$student_id&joining=$v' class='btn btn-sm btn-success' onclick=return confirm(\"Are you sure to join this course?\")' >Join</a> ($code) $name <br>($url) <br> <a href='~\..\Script.php?JoinCourse=y&id=$id&std=$student_id&joining=$v' class='btn btn-sm btn-success' onclick=return confirm(\"Are you sure to join this course?\")' >Join</a>
<br> <span style='font-size:10pt'>Faculty: $faculty &nbsp; Year: $academic &nbsp; Lecturer: $lecturer </span><br>$msg</div> <br> <span style='font-size:10pt'>Faculty: $faculty &nbsp; Year: $academic &nbsp; Lecturer: $lecturer </span><br>$msg</div>
"; ";
}
} }
} }
} // Otherwise, list the student's joined courses (already done), in reverse chronological order
// Otherwise, list the student's joined courses (already done), in reverse chronological order echo "<h1 class='display-6'> My courses </h1>";
echo "<h1 class='display-6'> My courses </h1>"; $result = mysqli_query($con,"SELECT users_table.Full_Name, course_students_table.Status, courses_table.Course_ID, `Course_Name`, `Academic_Year`, `Faculty`, `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` FROM `courses_table`
$result = mysqli_query($con,"SELECT users_table.Full_Name, course_students_table.Status, courses_table.Course_ID, `Course_Name`, `Academic_Year`, `Faculty`, `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` FROM `courses_table`
INNER JOIN users_table INNER JOIN users_table
ON users_table.User_ID=courses_table.Lecturer_User_ID ON users_table.User_ID=courses_table.Lecturer_User_ID
INNER JOIN course_students_table on course_students_table.Course_ID=courses_table.Course_ID INNER JOIN course_students_table on course_students_table.Course_ID=courses_table.Course_ID
where course_students_table.Student_ID=$student_id ORDER BY Academic_Year DESC, URL ASC"); where course_students_table.Student_ID=$student_id ORDER BY Academic_Year DESC, URL ASC");
if(mysqli_num_rows($result)==0) if(mysqli_num_rows($result)==0)
{ {
echo "<i class='fa fa-exclamation-circle'></i> You are not enrolled in any Course"; echo "<i class='fa fa-exclamation-circle'></i> You are not enrolled in any Course";
} else { } else {
while($row = mysqli_fetch_assoc($result)) { while($row = mysqli_fetch_assoc($result)) {
$name=$row['Course_Name']; $name=$row['Course_Name'];
$code=$row['Course_Code']; $code=$row['Course_Code'];
$faculty=$row['Faculty']; $faculty=$row['Faculty'];
$lecturer=$row['Full_Name']; $lecturer=$row['Full_Name'];
$academic=$row['Academic_Year']; $academic=$row['Academic_Year'];
$url=$row['URL']; $url=$row['URL'];
$id=$row['Course_ID']; $id=$row['Course_ID'];
$Status=$row['Status']; $Status=$row['Status'];
if($Status=="Joined") if($Status=="Joined")
{ {
echo "<a href='~\..\Course.php?url=$url'> <div class='btn btn-default' style='word-wrap:break-word'> echo "<a href='~\..\Course.php?url=$url'> <div class='btn btn-default' style='word-wrap:break-word'>
($code) - $name <br>($url) &nbsp;&nbsp;&nbsp; <i class='fa fa-check-circle'></i> $Status &nbsp;&nbsp;&nbsp;&nbsp; ($code) - $name <br>($url) &nbsp;&nbsp;&nbsp; <i class='fa fa-check-circle'></i> $Status &nbsp;&nbsp;&nbsp;&nbsp;
<br> <span style='font-size:8pt'>Faculty: $faculty &nbsp; Year: $academic &nbsp; Lecturer: $lecturer </span></div></a> <br> <span style='font-size:8pt'>Faculty: $faculty &nbsp; Year: $academic &nbsp; Lecturer: $lecturer </span></div></a>
"; ";
} }
else else
{ {
echo "<div class='btn btn-default'> echo "<div class='btn btn-default'>
($code) - $name <i class='btn btn-sm btn-danger'> $Status</i> ($code) - $name <i class='btn btn-sm btn-danger'> $Status</i>
<br> <span style='font-size:8pt'>Faculty: $faculty &nbsp; Year: $academic &nbsp; Lecturer: $lecturer </span></div> <br> <span style='font-size:8pt'>Faculty: $faculty &nbsp; Year: $academic &nbsp; Lecturer: $lecturer </span></div>
"; ";
}
} }
} }
}
echo "</div><div class='col-md-6'>
echo "</div><div class='col-md-6'>
<form method='get' action='Courses.php'> <form method='get' action='Courses.php'>
<div class='row'> <div class='row'>
<div class='col-md-12'> <div class='col-md-12'>
<div class='row'> <div class='row'>
<div class='col-md-5'> <div class='col-md-5'>
@ -626,16 +626,16 @@ INNER JOIN course_students_table on course_students_table.Course_ID=courses_tabl
<div class='col-md-5'> <div class='col-md-5'>
List courses by faculty List courses by faculty
<select name='faculty' class='form-control'>"; <select name='faculty' class='form-control'>";
$result = mysqli_query($con,"SELECT DISTINCT(Faculty) as Faculty FROM `courses_table`"); $result = mysqli_query($con,"SELECT DISTINCT(Faculty) as Faculty FROM `courses_table`");
if(mysqli_num_rows($result)==0){ if(mysqli_num_rows($result)==0){
} else { } else {
echo" <option value=''>Search by faculty</option>"; echo" <option value=''>Search by faculty</option>";
while($row = mysqli_fetch_assoc($result)) { while($row = mysqli_fetch_assoc($result)) {
$fname=$row['Faculty']; $fname=$row['Faculty'];
echo " <option value='$fname'> $fname </option>"; echo " <option value='$fname'> $fname </option>";
}} }}
echo " </select> echo " </select>
</div> </div>
<div class='col-md-2'> <br> <div class='col-md-2'> <br>
@ -646,15 +646,15 @@ INNER JOIN course_students_table on course_students_table.Course_ID=courses_tabl
</div> </div>
</form> </form>
</div></div>"; </div></div>";
} }
?> ?>
<?php include 'Footer.php';?>
</div>
<?php include 'Footer.php';?>
</div>
</body> </body>
</html> </html>