Indent Courses.php using Emacs web-mode.

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,10 +52,10 @@ if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA")
} }
} }
}); });
} catch(e) { } catch(e) {
alert(e); alert(e);
}
} }
}
</script> </script>
@ -482,73 +482,109 @@ WHERE Lecturer_User_ID=$lecturer_id and course_students_table.Status='Pending'"
<!-- 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>
</div>
<div class="col-md-6"></div>
</div>
<div class="row">
<div class="col-md-6">
<?php
error_reporting(0);
$student_id= $_SESSION['user_student_id'];
// current academic year - i.e 2021 - 2022 , so we will show in search result:
// course containing either 2021 or 2022 as academic year.
$oldest_academic_year = date('Y') - 1;
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>";
$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 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 <br><br>
</div>
<div class="col-md-6"></div>
</div>
<div class="row">
<div class="col-md-6">
<?php
error_reporting(0);
$student_id= $_SESSION['user_student_id'];
// current academic year - i.e 2021 - 2022 , so we will show in search result:
// course containing either 2021 or 2022 as academic year.
$oldest_academic_year = date('Y') - 1;
if(!empty($_GET["search"]) || !empty($_GET["faculty"]))
{ {
echo "<h3> Find courses under faculty: $faculty</h3>"; $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']);
$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>";
$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 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` `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 {
while($row = mysqli_fetch_assoc($result)) {
$name=$row['Course_Name'];
$code=$row['Course_Code'];
$faculty=$row['Faculty'];
$lecturer=$row['Full_Name'];
$academic=$row['Academic_Year'];
$url=$row['URL'];
$id=$row['Course_ID'];
$v=$row['Verify_New_Members'];
if($v>0)
{
$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>
<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
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`
INNER JOIN users_table
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
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 "No results. <hr>"; 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'];
@ -557,62 +593,26 @@ if( $_SESSION['user_type']=="Student")
$academic=$row['Academic_Year']; $academic=$row['Academic_Year'];
$url=$row['URL']; $url=$row['URL'];
$id=$row['Course_ID']; $id=$row['Course_ID'];
$v=$row['Verify_New_Members']; $Status=$row['Status'];
if($v>0)
if($Status=="Joined")
{ {
$msg="<i class='fa fa-exclamation-circle'></i> Lecturer verification required"; echo "<a href='~\..\Course.php?url=$url'> <div class='btn btn-default' style='word-wrap:break-word'>
$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>
<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
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`
INNER JOIN users_table
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
where course_students_table.Student_ID=$student_id ORDER BY Academic_Year DESC, URL ASC");
if(mysqli_num_rows($result)==0)
{
echo "<i class='fa fa-exclamation-circle'></i> You are not enrolled in any Course";
} else {
while($row = mysqli_fetch_assoc($result)) {
$name=$row['Course_Name'];
$code=$row['Course_Code'];
$faculty=$row['Faculty'];
$lecturer=$row['Full_Name'];
$academic=$row['Academic_Year'];
$url=$row['URL'];
$id=$row['Course_ID'];
$Status=$row['Status'];
if($Status=="Joined")
{
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'>
@ -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>
@ -648,13 +648,13 @@ INNER JOIN course_students_table on course_students_table.Course_ID=courses_tabl
</div></div>"; </div></div>";
} }
?> ?>
<?php include 'Footer.php';?> <?php include 'Footer.php';?>
</div> </div>
</body> </body>
</html> </html>