From eee1a5e8ad5be070f6ee99e55e03f65022408f52 Mon Sep 17 00:00:00 2001 From: SayidCali jamac Date: Fri, 10 Jun 2022 22:19:44 +0300 Subject: [PATCH] courses filter current year and ordering --- Courses.php | 907 +++++++++++++++++++++++++--------------------------- 1 file changed, 440 insertions(+), 467 deletions(-) diff --git a/Courses.php b/Courses.php index 2ccbbff..eab2d52 100644 --- a/Courses.php +++ b/Courses.php @@ -1,19 +1,17 @@ +include 'NoDirectPhpAcess.php'; ?> + +if ($_SESSION['user_type'] == 'Lecturer' || $_SESSION['user_type'] == 'TA') { ?> + + @@ -70,26 +68,28 @@ New Date/Time
-
($code) - $name @@ -97,74 +97,117 @@ New Date/Time

"; - - echo "
"; + + echo "
"; + } + + // ------------------------------Editing Lab Assignment by Lecturer ------------------------------------ + + if ($_GET['act'] == 'edit') { + $getid = mysqli_real_escape_string($con, $_GET['cid']); + $result1 = mysqli_query( + $con, + "SELECT * from lab_reports_table WHERE Lab_Report_ID = '$getid'" + ); + + while ($row1 = mysqli_fetch_assoc($result1)) { + $Deadline = $row1['Deadline']; + $_SESSION['Date'] = trim(strstr($Deadline, ' ', true)); + $_SESSION['Time'] = trim(strstr($Deadline, ' ')); + $_SESSION['Instructions'] = $row1['Instructions']; + $_SESSION['Title'] = $row1['Title']; + $_SESSION['Marks'] = $row1['Marks']; + $_SESSION['Type'] = $row1['Type']; } - - // ------------------------------Editing Lab Assignment by Lecturer ------------------------------------ + if (isset($_POST['frm_uploadlab'])) { + $deadlinedate = trim( + mysqli_real_escape_string($con, $_POST['deadlinedate']) + ); // remove spaces + $deadlinetime = trim( + mysqli_real_escape_string($con, $_POST['deadlinetime']) + ); // remove spaces + $instructions = mysqli_real_escape_string( + $con, + $_POST['instructions'] + ); + $title = mysqli_real_escape_string($con, $_POST['title']); + $marks = mysqli_real_escape_string($con, $_POST['marks']); + $type = mysqli_real_escape_string($con, $_POST['type']); + $Deadline = $deadlinedate . ' ' . $deadlinetime; + $date = date('Y-m-d H:i'); - if($_GET['act']=="edit"){ - $getid = mysqli_real_escape_string($con, $_GET["cid"]); - $result1 = mysqli_query($con, "SELECT * from lab_reports_table WHERE Lab_Report_ID = '$getid'"); - - while($row1 = mysqli_fetch_assoc($result1)) { - $Deadline = $row1['Deadline']; - $_SESSION['Date'] = trim( strstr($Deadline, ' ', true) ); - $_SESSION['Time'] = trim( strstr($Deadline, ' ') ); - $_SESSION['Instructions'] = $row1['Instructions']; - $_SESSION['Title'] = $row1['Title']; - $_SESSION['Marks'] = $row1['Marks']; - $_SESSION['Type'] = $row1['Type']; + $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) { + $_SESSION['info_Updated'] = + 'Assignment information updated successfully.'; + } else { + // echo "Error: " . $sql . "
" . $con->error; + echo 'Serious error happened whiling updating assignment information.'; } - - if(isset($_POST['frm_uploadlab'])){ - $deadlinedate = trim(mysqli_real_escape_string($con, $_POST["deadlinedate"])); // remove spaces - $deadlinetime = trim(mysqli_real_escape_string($con, $_POST["deadlinetime"])); // remove spaces - $instructions = mysqli_real_escape_string($con, $_POST["instructions"]); - $title = mysqli_real_escape_string($con, $_POST["title"]); - $marks = mysqli_real_escape_string($con, $_POST["marks"]); - $type = mysqli_real_escape_string($con, $_POST["type"]); - $Deadline = $deadlinedate." ".$deadlinetime; - $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'"; - if ($con->query($sql) === TRUE) { - $_SESSION["info_Updated"]="Assignment information updated successfully."; - - } else { - // echo "Error: " . $sql . "
" . $con->error; - echo "Serious error happened whiling updating assignment information."; - } - } - - if( $_SESSION['user_type']=="Lecturer"){ - $Date = $_SESSION['Date']; - $Time = $_SESSION['Time']; - $Instructions = $_SESSION['Instructions']; - $Title = $_SESSION['Title']; - $Marks = $_SESSION['Marks']; - $Type = $_SESSION['Type']; - - echo "

Editing Lab Assignment

"; - ?> + } + + if ($_SESSION['user_type'] == 'Lecturer') { + + $Date = $_SESSION['Date']; + $Time = $_SESSION['Time']; + $Instructions = $_SESSION['Instructions']; + $Title = $_SESSION['Title']; + $Marks = $_SESSION['Marks']; + $Type = $_SESSION['Type']; + + echo "

Editing Lab Assignment

"; + ?>
- - + + Dealine Date/Time
-
">
-
">
+
+
Title - "> + Instructions - + Marks - "> + Attachment 1 @@ -179,39 +222,33 @@ New Date/Time

- Invidual Group"; - } else { - echo "Submission Type Invidual Group"; - } - ?> + Invidual Group"; +} else { + echo "Submission Type Invidual Group"; +} ?>





+ if ($_SESSION['user_type'] == 'Lecturer') { ?>

Post new Lab Assignment

- + - - + + Dealine Date/Time
@@ -244,186 +281,201 @@ New Date/Time





-"; - - echo "

Lab Report Assignment list

"; - - error_reporting(0); - if(isset($_SESSION["info_Updated"])){ - echo '
'; - $_SESSION['info_Updated'] = null; - } - if (isset($_SESSION['info_courses'])) { - echo '
'; - $_SESSION['info_courses'] = null; - } - if (isset($_SESSION['info_courses'])) { - echo '
'; - $_SESSION['info_courses']=null; +'; + echo "

Lab Report Assignment list

"; - - - $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"); - - - if( $_SESSION['user_type']=="TA") - { - echo "*Only Lecturer can post a new lab report assignment
"; - } - if(mysqli_num_rows($result)==0) - { - echo "No assignments posted so far."; - - } else { while($row = mysqli_fetch_assoc($result)) { - $marks=$row['Marks']; - $title=$row['Title']; - $ins=$row['Instructions']; - $posted=$row['Posted_Date']; - $deadline=$row['Deadline']; - $att1=$row['Attachment_link_1']; - $att2=$row['Attachment_link_2']; - $att3=$row['Attachment_link_3']; - $att4=$row['Attachment_link_4']; - $id=$row['Lab_Report_ID']; - $cours_id=$row['Course_ID']; - $as_type=$row['Type']; - $full_link="$att1"; - - if($att2!=""){ - $full_link= $full_link."  |  $att2"; + error_reporting(0); + if (isset($_SESSION['info_Updated'])) { + echo '
'; + $_SESSION['info_Updated'] = null; + } + if (isset($_SESSION['info_courses'])) { + echo '
'; + $_SESSION['info_courses'] = null; + } + if (isset($_SESSION['info_courses'])) { + echo '
'; + $_SESSION['info_courses'] = null; + } + + $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" + ); + + if ($_SESSION['user_type'] == 'TA') { + echo "*Only Lecturer can post a new lab report assignment
"; + } + if (mysqli_num_rows($result) == 0) { + echo 'No assignments posted so far.'; + } else { + while ($row = mysqli_fetch_assoc($result)) { + $marks = $row['Marks']; + $title = $row['Title']; + $ins = $row['Instructions']; + $posted = $row['Posted_Date']; + $deadline = $row['Deadline']; + $att1 = $row['Attachment_link_1']; + $att2 = $row['Attachment_link_2']; + $att3 = $row['Attachment_link_3']; + $att4 = $row['Attachment_link_4']; + $id = $row['Lab_Report_ID']; + $cours_id = $row['Course_ID']; + $as_type = $row['Type']; + $full_link = "$att1"; + + if ($att2 != '') { + $full_link = + $full_link . + "  |  $att2"; + } + if ($att3 != '') { + $full_link = + $full_link . + "  |  $att3"; + } + + if ($att4 != '') { + $full_link = + $full_link . + "   |   $att4"; + } + + $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']; + } + + $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($att3!=""){ - $full_link= $full_link."  |  $att3"; - } - - if($att4!=""){ - $full_link= $full_link."   |   $att4"; - } - - - - - $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'];} - - $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'];}} - - - $header="Courses > ".$name."($code) > Assignments > ".$title; - - echo "
+ } + + $header = + 'Courses > ' . $name . "($code) > Assignments > " . $title; + + echo "
$title ($as_type)
$ins -
Posted : $posted Deadline : $deadline   ($marks Marks)           " - . "
" - - . "    $count_subs Submissions ( $count_marked Marked )       Edit   |   View    |   Extend Deadline
Attachments : $full_link
" - . "  
+
Posted : $posted Deadline : $deadline   ($marks Marks)           " . + '
' . + "    $count_subs Submissions ( $count_marked Marked )       Edit   |   View    |   Extend Deadline
Attachments : $full_link
" . + "  
"; - - - - }} - echo "
"; - - - - - - $resultx1 = mysqli_query($con,"SELECT course_students_table.Student_ID,users_table.Full_Name FROM + } + } + echo '
'; + + $resultx1 = mysqli_query( + $con, + "SELECT course_students_table.Student_ID,users_table.Full_Name FROM `course_students_table` INNER JOIN users_table on users_table.Student_ID=course_students_table.Student_ID -WHERE Course_ID=$course_id"); - - - echo ""; - - - - - return; +WHERE Course_ID=$course_id" + ); + echo "'; + + return; +} ?> "; - - - $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"); - - if($_SESSION['user_type']=="TA") - { - $result = mysqli_query($con,"SELECT course_ta.Course_ID, `Course_Name`, + +$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" +); + +if ($_SESSION['user_type'] == 'TA') { + $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` 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" + ); +} +// $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"); - } - // $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"); +if (mysqli_num_rows($result) == 0) { +} else { + while ($row = mysqli_fetch_assoc($result)) { + $id = $row['Course_ID']; + $name = $row['Course_Name']; + $code = $row['Course_Code']; + $faculty = $row['Faculty']; + $lecturer = $row['Full_Name']; + $academic = $row['Academic_Year']; + $url = $row['URL']; - - if(mysqli_num_rows($result)==0) - {} else { while($row = mysqli_fetch_assoc($result)) { - $id=$row['Course_ID']; - $name=$row['Course_Name']; - $code=$row['Course_Code']; - $faculty=$row['Faculty']; - $lecturer=$row['Full_Name']; - $academic=$row['Academic_Year']; - $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 -where course_ta.Course_ID=$id"); - - $ta=""; - while($rowTA = mysqli_fetch_assoc($resultTA)) { - $ta=$ta." - ".$rowTA['TA_NAME']; - } - - - - echo" +where course_ta.Course_ID=$id" + ); + + $ta = ''; + while ($rowTA = mysqli_fetch_assoc($resultTA)) { + $ta = $ta . ' - ' . $rowTA['TA_NAME']; + } + + echo "
($code) - $name
Faculty : $faculty        Year : $academic        Lecturer :$lecturer        TA:$ta
"; - - }}?> + } +} +?>

@@ -432,47 +484,45 @@ where course_ta.Course_ID=$id"); No Course joining request so far for all your courses
"; - } else { while($row = mysqli_fetch_assoc($result)) { - $id=$row['ID']; - - $name=$row['Course_Name']; - $code=$row['Course_Code']; - $faculty=$row['Faculty']; - $std_name=$row['Full_Name']; - $academic=$row['Academic_Year']; - - echo "
+WHERE Lecturer_User_ID=$lecturer_id and course_students_table.Status='Pending'" +); + +if (mysqli_num_rows($result) == 0) { + echo "
No Course joining request so far for all your courses
"; +} else { + while ($row = mysqli_fetch_assoc($result)) { + $id = $row['ID']; + + $name = $row['Course_Name']; + $code = $row['Course_Code']; + $faculty = $row['Faculty']; + $std_name = $row['Full_Name']; + $academic = $row['Academic_Year']; + + echo "
$std_name is Requesting to join
[($code) - $name ]     
Accept    Decline
"; - - - - } } - ?> +} +?> -Only Lecturers can Post new Lab report Assignments"; - } - if( $_SESSION['user_type']=="Lecturer"){ ?> +Only Lecturers can Post new Lab report Assignments'; +} +if ($_SESSION['user_type'] == 'Lecturer') { ?> Create new Course Portal @@ -495,7 +545,9 @@ WHERE Lecturer_User_ID=$lecturer_id and course_students_table.Status='Pending'" - + Verify Joining Students @@ -507,34 +559,31 @@ WHERE Lecturer_User_ID=$lecturer_id and course_students_table.Status='Pending'" - +
- +

Course Portal > Students
' . $_SESSION['info_Courses_student'] . ''; - $_SESSION['info_Courses_student'] = null; - } - ?> +error_reporting(0); +if (isset($_SESSION['info_Courses_student'])) { + echo '
' . + $_SESSION['info_Courses_student'] . + ''; + $_SESSION['info_Courses_student'] = null; +} +?>

@@ -549,130 +598,105 @@ if( $_SESSION['user_type']=="Student") - Search Results for Course Code $search
"; - $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 Course_Code like '%{$search}%' and courses_table.Course_ID not in (select course_id from course_students_table where Student_ID=$student_id)"); - } - else - { - echo "

Find Courses under faculty $faculty

"; - $result = mysqli_query($con,"SELECT `Course_ID`, `Course_Name`, `Academic_Year`, `Faculty`, + Search Results for Course Code $search
"; + $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 not entered something under "Find course by Code" + else { + echo "

Find Courses under faculty $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 Faculty='$faculty' and courses_table.Course_ID not in (select course_id from course_students_table where Student_ID=$student_id)"); - } - + 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 found for your Search
"; + if (mysqli_num_rows($result) == 0) { + echo 'No results found for your Search
'; + } 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']; + $msg2 = 'Join Course'; + if ($v > 0) { + $msg = + " Lecturer verification required"; + $msg2 = 'Send Joining Request'; + } - } 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']; - $msg2="Join Course"; - if($v>0) - { - $msg=" Lecturer verification required"; - $msg2="Send Joining Request"; - } - - echo "
+ echo "
[$code] $name
($url)
$msg2
Faculty: $faculty | Year: $academic | Lecturer: $lecturer
$msg
"; - } } } - - echo "

My Courses

"; - $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` +} +// Otherwise, list the student's joined courses (already done), in reverse chronological order +echo '

My Courses

'; +$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"); - - if(mysqli_num_rows($result)==0) - { - echo " 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 "
+ where course_students_table.Student_ID=$student_id" +); + +if (mysqli_num_rows($result) == 0) { + echo " 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 "
($code) - $name
($url)     $Status     
Open
Faculty : $faculty Year : $academic Lecturer :$lecturer
- "; - } - else - { - echo "
+ "; + } else { + echo "
($code) - $name $Status
Faculty : $faculty Year : $academic Lecturer :$lecturer
- "; - } + "; } - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - echo "
+ } +} + +echo "
@@ -683,15 +707,20 @@ INNER JOIN course_students_table on course_students_table.Course_ID=courses_tabl List courses by faculty
+ echo " "; + } +} + +echo "

@@ -705,64 +734,8 @@ List courses by faculty -
"; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
"; } - ?>