2020-03-16 15:23:14 +08:00
< ? php
2022-06-11 13:44:42 +08:00
include 'NoDirectPhpAcess.php' ;
?>
2020-03-16 15:23:14 +08:00
2022-05-19 12:35:27 +08:00
2022-06-11 03:19:44 +08:00
< ? php
2022-06-11 13:44:42 +08:00
$page = 'Courses' ;
include 'Header.php' ;
2023-08-08 15:02:26 +08:00
?>
2022-06-11 03:19:44 +08:00
2023-08-08 15:02:26 +08:00
< div class = " container " >
2022-06-11 03:19:44 +08:00
2023-08-10 22:48:12 +08:00
< ? php
$user_d = $_SESSION [ 'user_id' ];
if ( $_SESSION [ 'user_type' ] == " Lecturer " || $_SESSION [ 'user_type' ] == " TA " )
{
?>
2022-05-19 12:35:27 +08:00
2023-08-08 15:02:26 +08:00
<!-- FOR LECTURER -->
2022-05-19 12:35:27 +08:00
2020-03-16 15:23:14 +08:00
2023-08-08 15:02:26 +08:00
< div class = " row " >
2023-08-12 20:56:27 +08:00
< link rel = " stylesheet " href = " https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/themes/base/jquery-ui.min.css " integrity = " sha512-ELV+xyi8IhEApPS/pSj66+Jiw+sOT1Mqkzlh8ExXihe4zfqbWkxPRi8wptXIO9g73FSlhmquFlUOuMSoXz5IRw== " crossorigin = " anonymous " referrerpolicy = " no-referrer " />
< script src = " https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js " integrity = " sha512-3gJwYpMe3QewGELv8k/BX9vcqhryRdzRMxVfq6ngyWXwo03GFEzjsUm8Q7RZcHPHksttq7/GFoxjCVUjkjvPdw== " crossorigin = " anonymous " referrerpolicy = " no-referrer " ></ script >
< 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 >
2023-09-04 20:20:43 +08:00
< script >
function extendDeadline ( id ) {
const dropstudents = $ ( " #dropstudents " ) . html ();
try {
$ ( ` < form id = " frm " method = " get " action = " Script.php " >
2023-08-02 15:27:51 +08:00
< input type = " hidden " name = " extenddeadline " value = " true " >
< input type = " hidden " name = " id " value = " ${ id } " >
New date and time < br >
< input type = " date " name = " date " required = " " >
< input type = " time " name = " time " required = " " >
< br >
< input type = " radio " value = " 1 " name = " type " required = " " > Extend for all
< br >
< input type = " radio " value = " 2 " name = " type " required = " " > Extend for one
< br >
$ { dropstudents }
</ form > ` ) . dialog ({
2023-09-04 20:20:43 +08:00
modal : true ,
title : 'Extend deadline' ,
close : function () {
var closeBtn = $ ( '.ui-dialog-titlebar-close' );
closeBtn . html ( '' );
},
buttons : {
'Submit' : function () {
$ ( '#frm' ) . submit ();
$ ( this ) . dialog ( 'close' );
},
'Cancel' : function () {
$ ( this ) . dialog ( 'close' );
}
}
});
} catch ( e ) {
alert ( e );
}
}
</ script >
2023-08-08 15:02:26 +08:00
< ? php
2023-09-04 20:25:36 +08:00
if ( ! empty ( $_GET [ " course " ])) {
$course_url = mysqli_real_escape_string ( $con , $_GET [ " course " ]);
$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 URL = '$course_url' " );
2023-08-10 22:48:12 +08:00
2023-09-05 20:51:19 +08:00
if ( mysqli_num_rows ( $result ) > 0 ) {
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' ];
$course_id = $row [ 'Course_ID' ];
echo " <p class='mt-md-1 mb-md-1'> <strong>( $code ) - $name </strong> </p>
< br >
< small > Faculty : $faculty & nbsp ; & nbsp ; Year : $academic & nbsp ; & nbsp ; Lecturer : $lecturer </ small >
< hr >
< div class = 'row' > " ;
2023-08-08 15:02:26 +08:00
echo " <div class='col-md-5'> " ;
2023-09-05 20:51:19 +08:00
}
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
// ------------------------------Editing Lab Assignment by Lecturer ------------------------------------
2023-09-05 20:51:19 +08:00
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' ];
}
if ( isset ( $_POST [ 'form_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 " Serious error happened while updating assignment information. " ;
}
}
if ( isset ( $_POST [ 'form_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 " Serious error happened while deleting the 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 " <h3><a href='Courses.php?course= " . $url . " '>Edit assignment information</a></h3> " ;
2023-08-10 22:48:12 +08:00
?>
2023-09-05 20:51:19 +08:00
< form method = 'post' enctype = 'multipart/form-data' action = '' >
2023-09-03 20:42:15 +08:00
< input type = 'hidden' name = 'form_uploadlab' value = 'true' required = '' />
2023-08-08 15:02:26 +08:00
< input type = 'hidden' name = 'course_id' value = '<?php echo "$id" ?>' required = '' />
< input type = 'hidden' name = 'url' value = '<?php echo ".$course_url." ?>' required = '' />
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
Deadline Date / Time
2023-08-10 22:48:12 +08:00
< div class = 'row' >
2023-09-05 20:51:19 +08:00
< 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 >
2023-08-08 15:02:26 +08:00
</ div >
2022-05-19 12:35:27 +08:00
2023-08-08 15:02:26 +08:00
Title
< input type = 'text' name = 'title' placeholder = 'Title' class = 'form-control' required = '' value = " <?php echo isset( $_GET['act'] ) && $_GET['act'] == " edit " ? $Title : " " ; ?> " >
Instructions
< textarea name = 'instructions' placeholder = 'Assignment Instructions' class = 'form-control' required = '' >< ? php echo isset ( $_GET [ 'act' ]) && $_GET [ 'act' ] == 'edit' ? $Instructions : '' ; ?> </textarea>
Marks
< input type = 'text' name = 'marks' placeholder = 'Marks' class = 'form-control' required = '' value = " <?php echo isset( $_GET['act'] ) && $_GET['act'] == " edit " ? $Marks : " " ; ?> " >
Attachment 1
< input type = 'file' name = 'attachment1' placeholder = 'Attachment 1' class = 'form-control' >
Attachment 2
< input type = 'file' name = 'attachment2' placeholder = 'Attachment 1' class = 'form-control' >
Attachment 3
< input type = 'file' name = 'attachment3' placeholder = 'Attachment 1' class = 'form-control' >
Attachment 4
< input type = 'file' name = 'attachment4' placeholder = 'Attachment 4' class = 'form-control' >
< br >
< ? php
if ( $Type == " Individual " ) {
2023-09-05 20:51:19 +08:00
echo " Submission Type <input type='radio' name='type' value='Individual' checked /> Individual <input type='radio' name='type' value='Group' /> Group " ;
2023-08-08 15:02:26 +08:00
} else {
2023-09-05 20:51:19 +08:00
echo " Submission Type <input type='radio' name='type' value='Individual' /> Individual <input type='radio' name='type' value='Group' checked> Group " ;
2023-08-10 22:48:12 +08:00
}
2023-08-08 15:02:26 +08:00
?>
2023-08-29 21:34:58 +08:00
< br >
< input type = 'submit' class = 'btn btn-primary' value = 'Update assignment' >< br >
2023-09-05 20:51:19 +08:00
</ form >< br >< br >< br >< br >
2023-08-10 22:52:28 +08:00
2023-09-05 20:51:19 +08:00
< form method = 'post' action = '' >
2023-09-03 20:42:15 +08:00
< input type = 'hidden' name = 'form_deletelab' value = 'true' required = '' />
2023-08-29 21:34:58 +08:00
< input type = 'submit' class = 'btn btn-danger' value = 'Delete assignment' >< br >
2023-09-05 20:51:19 +08:00
</ form >
2023-08-08 15:02:26 +08:00
< ? php
2023-09-05 20:51:19 +08:00
}
} else {
2022-06-11 13:44:42 +08:00
2023-08-08 15:02:26 +08:00
// ------------------------------Posting New Lab Assignment------------------------------------
2020-04-06 23:45:30 +08:00
2023-08-08 15:02:26 +08:00
// 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
2020-10-02 17:02:20 +08:00
2023-09-05 20:51:19 +08:00
if ( $_SESSION [ 'user_type' ] == " Lecturer " ) {
2023-08-10 22:48:12 +08:00
?>
2022-06-11 13:44:42 +08:00
2023-08-11 22:26:40 +08:00
< h3 > New assignment </ h3 >
2023-08-10 22:48:12 +08:00
2023-09-05 20:51:19 +08:00
< form method = 'post' enctype = 'multipart/form-data' action = 'Script.php' >
< ? php
$_SESSION [ 'url' ] = $url ;
?>
2023-09-03 20:42:15 +08:00
< input type = 'hidden' name = 'form_uploadlab' value = 'true' required = '' />
2023-08-08 15:02:26 +08:00
< input type = 'hidden' name = 'course_id' value = '<?php echo "$id" ?>' required = '' />
< input type = 'hidden' name = 'url' value = '<?php echo ".$course_url." ?>' required = '' />
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
Deadline ( date and time )
2023-08-10 22:48:12 +08:00
< div class = 'row' >
2023-09-05 20:51:19 +08:00
< 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 >
2023-08-08 15:02:26 +08:00
</ div >
2023-07-31 17:15:35 +08:00
2023-08-08 15:02:26 +08:00
Title
< input type = 'text' name = 'title' placeholder = 'Title' class = 'form-control' required = '' value = " " >
Instruction
< textarea name = 'instructions' placeholder = 'Assignment Instructions' class = 'form-control' required = '' value = " " ></ textarea >
Mark
< input type = 'text' name = 'marks' placeholder = 'Marks' class = 'form-control' required = '' value = " " >
Attachment 1
< input type = 'file' name = 'attachment1' placeholder = 'Attachment 1' class = 'form-control' >
Attachment 2
< input type = 'file' name = 'attachment2' placeholder = 'Attachment 1' class = 'form-control' >
Attachment 3
< input type = 'file' name = 'attachment3' placeholder = 'Attachment 1' class = 'form-control' >
Attachment 4
< input type = 'file' name = 'attachment4' placeholder = 'Attachment 4' class = 'form-control' >
< br >
Submission type : < input type = 'radio' name = 'type' value = 'Individual' required = '' > Individual
< input type = 'radio' name = 'type' value = 'Group' required = '' > Group
< hr >
< input type = 'submit' class = 'btn btn-primary' value = 'Post' >< br >
2023-09-05 20:51:19 +08:00
</ form >< br >< br >< br >< br >
2023-08-08 15:02:26 +08:00
< ? php
2023-09-05 20:51:19 +08:00
}
2023-08-10 22:48:12 +08:00
}
2023-09-05 20:51:19 +08:00
}
2023-08-10 22:48:12 +08:00
echo " </div> " ;
echo " <div class='col-md-7'><h3>Assignment list</h3> " ;
2023-08-08 15:02:26 +08:00
error_reporting ( 0 );
2023-09-05 20:51:19 +08:00
if ( isset ( $_SESSION [ " info_Updated " ])) {
echo '<hr><div class="alert alert-warning" role="alert">' . $_SESSION [ 'info_Updated' ] . '</div>' ;
$_SESSION [ 'info_Updated' ] = null ;
2023-07-31 17:15:35 +08:00
}
2023-08-08 15:02:26 +08:00
if ( isset ( $_SESSION [ 'info_courses' ])) {
2023-09-05 20:51:19 +08:00
echo '<hr><div class="alert alert-warning" role="alert">' . $_SESSION [ 'info_courses' ] . '</div>' ;
$_SESSION [ 'info_courses' ] = null ;
2023-07-31 17:15:35 +08:00
}
2023-08-08 15:02:26 +08:00
if ( isset ( $_SESSION [ 'info_courses' ])) {
2023-09-05 20:51:19 +08:00
echo '<hr><div class="alert alert-warning" role="alert">' . $_SESSION [ 'info_courses' ] . '</div>' ;
$_SESSION [ 'info_courses' ] = null ;
2023-07-31 17:15:35 +08:00
}
2023-08-08 15:02:26 +08:00
2023-09-05 20:51:19 +08:00
if ( $_SESSION [ 'user_type' ] == " TA " ) {
echo " <b style='color:gray'>Only Lecturer can post assignments.</b><br> " ;
2023-08-08 15:02:26 +08:00
}
2023-08-10 22:48:12 +08:00
2023-09-05 20:51:19 +08:00
$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 ( 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 = " <a href='~ \ .. \ Download.php?file= $att1 '> $att1 </a> " ;
if ( $att2 != " " ) {
$full_link = $full_link . "  |  <a href='~ \ .. \ Download.php?file= $att2 '> $att2 </a> " ;
}
if ( $att3 != " " ) {
$full_link = $full_link . "  |  <a href='~ \ .. \ Download.php?file= $att3 '> $att3 </a> " ;
}
if ( $att4 != " " ) {
$full_link = $full_link . " |   <a href='~ \ .. \ Download.php?file= $att4 '> $att4 </a> " ;
}
2023-08-10 22:48:12 +08:00
2023-09-05 20:51:19 +08:00
$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' ];
}
2023-08-10 22:48:12 +08:00
2023-09-05 20:51:19 +08:00
$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' ];
}
}
2023-08-10 22:48:12 +08:00
2023-09-05 20:51:19 +08:00
$header = " Courses > " . $name . " ( $code ) > Assignments > " . $title ;
2023-08-10 22:48:12 +08:00
2023-09-05 20:51:19 +08:00
echo " <div class='card mt-md-2'>
< div class = 'card-body' >
2023-08-11 22:12:59 +08:00
< h5 class = 'card-title' > $title ( $marks Marks , $as_type ) </ h5 >
< h6 class = 'card-subtitle' > $ins </ h6 >
< p class = 'card-text text-muted' >< small > Posted : $posted & nbsp ; & nbsp ; Deadline : $deadline </ small ></ p >
< p class = 'card-text' > $count_subs Submissions ( $count_marked Marked ) </ p >
< a class = 'card-link' href = 'Courses.php?course=".$url."&act=edit&cid=".$id."' > Edit </ a >
< a class = 'card-link' href = '~\..\Submissions.php?id=$id&header=$header&total=$marks' onclick = '' > View </ a >
< a class = 'card-link' href = '#' onclick = 'extendDeadline($id)' > Extend Deadline </ a >
< p class = 'card-text' > Attachments : $full_link </ p >
</ div >
2023-09-05 20:51:19 +08:00
</ div > " ;
2023-08-10 22:48:12 +08:00
2023-09-05 20:51:19 +08:00
}
}
2023-08-08 15:02:26 +08:00
echo " </div> " ;
2023-08-10 22:48:12 +08:00
2023-09-06 19:30:38 +08:00
$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 " );
2023-08-10 22:48:12 +08:00
2023-09-06 19:33:59 +08:00
echo " <span id='dropstudents' style='display:none;'> <select name='studentid'> " ;
2023-08-10 22:48:12 +08:00
while ( $row = mysqli_fetch_assoc ( $resultx1 ))
2023-08-08 15:02:26 +08:00
{
2023-09-06 19:33:59 +08:00
$studentid = $row [ 'Student_ID' ];
2023-08-08 15:02:26 +08:00
$stdname = $row [ 'Full_Name' ];
2023-08-10 22:48:12 +08:00
2023-09-06 19:33:59 +08:00
echo " <option value=' $studentid '> $stdname ( $studentid ) </option> " ;
2023-08-10 22:48:12 +08:00
}
2023-08-08 15:02:26 +08:00
echo " </select><br>Reason <input type='text' name='reason'> "
. " <input type='hidden' name='url' value=' $course_url '> "
. " </span> " ;
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
return ;
2022-05-19 12:35:27 +08:00
2023-08-08 15:02:26 +08:00
}
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
?>
2020-10-02 17:02:20 +08:00
2021-10-20 23:21:07 +08:00
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
< div class = " col-md-8 " >
2023-08-10 22:48:12 +08:00
< ? php
2023-08-08 15:02:26 +08:00
$user_name = $_SESSION [ 'user_fullname' ];
2023-08-10 22:48:12 +08:00
2023-08-09 14:18:05 +08:00
echo " <h1 class='display-6'>My courses</h1> " ;
2023-08-10 22:48:12 +08:00
2023-08-19 20:56:03 +08:00
$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 " );
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
if ( $_SESSION [ 'user_type' ] == " TA " )
{
2023-08-10 22:48:12 +08:00
$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
2022-06-11 13:44:42 +08:00
course_ta ON course_ta . Course_ID = courses_table . Course_ID where course_ta . TA = $user_d " );
2022-06-11 03:19:44 +08:00
2023-08-08 15:02:26 +08:00
}
2023-08-10 22:48:12 +08:00
2023-08-19 20:53:12 +08:00
if ( mysqli_num_rows ( $result ) != 0 )
{
while ( $row = mysqli_fetch_assoc ( $result )) {
2023-08-19 21:11:48 +08:00
$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` INNER JOIN users_table on users_table.User_ID=course_ta.TA where course_ta.Course_ID= $id " );
$ta = " " ;
2023-08-19 20:53:12 +08:00
while ( $rowTA = mysqli_fetch_assoc ( $resultTA )) {
2023-08-19 21:11:48 +08:00
$ta = $ta . " " . $rowTA [ 'TA_NAME' ];
}
if ( $ta == " " ) {
$ta = " None " ;
2023-08-19 20:53:12 +08:00
}
2023-08-10 22:48:12 +08:00
2023-08-19 20:53:12 +08:00
echo " <a href='~ \ .. \ Courses.php?course= $url '>
2023-08-13 21:30:56 +08:00
< div class = 'btn btn-default' >
( $code ) - $name
2023-08-19 21:11:48 +08:00
< p class = 'text-muted' >< small > 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 </ small ></ p >
2023-08-13 21:30:56 +08:00
</ div >
</ a > " ;
2023-08-10 22:48:12 +08:00
2023-08-19 20:53:12 +08:00
}
}
?>
2023-08-08 15:02:26 +08:00
</ div >
< div class = " col-md-4 " >
< br >
< b > Course joining requests </ b >
2023-08-10 22:48:12 +08:00
2022-05-19 12:35:27 +08:00
2020-03-16 15:23:14 +08:00
2023-08-08 15:02:26 +08:00
< ? php
$lecturer_id = $_SESSION [ 'user_id' ];
2023-08-10 22:48:12 +08:00
$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`
2020-03-16 15:23:14 +08:00
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
2022-06-11 13:44:42 +08:00
WHERE Lecturer_User_ID = $lecturer_id and course_students_table . Status = 'Pending' " );
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
if ( mysqli_num_rows ( $result ) == 0 )
{
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
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 )) {
2023-08-10 22:48:12 +08:00
$id = $row [ 'ID' ];
2023-08-08 15:02:26 +08:00
$name = $row [ 'Course_Name' ];
$code = $row [ 'Course_Code' ];
2023-08-10 22:48:12 +08:00
$faculty = $row [ 'Faculty' ];
2023-08-08 15:02:26 +08:00
$std_name = $row [ 'Full_Name' ];
$academic = $row [ 'Academic_Year' ];
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
echo " <div class='btn btn-default'>
2023-08-07 16:39:19 +08:00
$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>
2021-10-20 23:21:07 +08:00
</ div > " ;
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
}
}
?>
2020-03-16 15:23:14 +08:00
2023-08-10 22:48:12 +08:00
< ? php
2023-08-08 15:02:26 +08:00
if ( $_SESSION [ 'user_type' ] == " TA " )
{
echo " <center>Only Lecturer can post assignments</center> " ;
}
if ( $_SESSION [ 'user_type' ] == " Lecturer " ){ ?>
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
< b > Create a new course </ b >
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
< form method = " post " action = " Script.php " >
2023-09-03 20:42:15 +08:00
< input type = " hidden " name = " form_createCourse " value = " true " required = " " />
2023-08-08 15:02:26 +08:00
< input type = " hidden " name = " l " value = " l " required = " " />
Course name
< input type = " text " name = " name " placeholder = " Course Name " class = " form-control " required = " " >
2020-03-16 15:23:14 +08:00
2023-08-08 15:02:26 +08:00
Course code
< input type = " text " name = " code " placeholder = " Course Code " class = " form-control " required = " " >
2020-03-16 15:23:14 +08:00
2023-08-08 15:02:26 +08:00
URL ( leave blank to use course code & year )
< input type = " text " name = " url " placeholder = " Choose Custom URL " class = " form-control " >
2020-03-16 15:23:14 +08:00
2023-08-08 15:02:26 +08:00
Academic year
< input type = " text " name = " academic " placeholder = " Academic Year " class = " form-control " required = " " >
2020-03-16 15:23:14 +08:00
2023-08-08 15:02:26 +08:00
Faculty < br >
< input type = " text " name = " faculty " placeholder = " Faculty " class = " form-control " required = " " >
2020-03-16 15:23:14 +08:00
2023-08-08 15:02:26 +08:00
< input type = " hidden " name = " lecturer " value = " <?php echo $_SESSION['user_id'] ; ?> " >
2020-03-16 15:23:14 +08:00
2023-08-10 22:48:12 +08:00
Verify joining students ?
2023-08-08 15:02:26 +08:00
< input type = " radio " name = " verify " value = " 1 " > Yes
< input type = " radio " name = " verify " value = " 0 " checked = " " > No
2020-03-16 15:23:14 +08:00
2023-08-08 15:02:26 +08:00
< br >< br >
< input type = " submit " class = " btn btn-primary " value = " Create " >< br >
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
</ form >
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
< ? php } ?>
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
</ div >
2023-08-10 22:48:12 +08:00
2023-08-08 15:02:26 +08:00
<!-- END LECTURER -->
2020-03-16 15:23:14 +08:00
2023-08-10 22:48:12 +08:00
< ? php
}
2023-07-31 17:15:35 +08:00
2023-08-02 15:27:51 +08:00
2023-08-10 22:48:12 +08:00
if ( $_SESSION [ 'user_type' ] == " Student " )
{
?>
2020-03-16 15:23:14 +08:00
2023-08-10 22:48:12 +08:00
<!-- STUDENT CODE -->
< div class = " row " >
< div class = " col-md-6 " >
2023-08-05 16:11:27 +08:00
2023-08-10 22:48:12 +08:00
< ? php
error_reporting ( 0 );
if ( isset ( $_SESSION [ 'info_Courses_student' ])) {
echo '<hr><span class="alert alert-success" role="alert">' . $_SESSION [ 'info_Courses_student' ] . '</span>' ;
$_SESSION [ 'info_Courses_student' ] = null ;
}
?>
< br >< br >
</ div >
< div class = " col-md-6 " ></ div >
2023-07-31 17:15:35 +08:00
</ div >
2023-08-10 22:48:12 +08:00
< 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 " ]))
2023-07-31 17:15:35 +08:00
{
2023-08-10 22:48:12 +08:00
$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
{
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`
2020-03-16 15:23:14 +08:00
, users_table . Full_Name FROM `courses_table` INNER JOIN users_table
2022-06-11 14:44:34 +08:00
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 " );
2023-08-10 22:48:12 +08:00
}
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 >
" ;
}
}
2023-07-31 17:15:35 +08:00
}
2023-08-10 22:48:12 +08:00
// 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 " );
2022-05-19 12:35:27 +08:00
2023-07-31 17:15:35 +08:00
if ( mysqli_num_rows ( $result ) == 0 )
{
2023-08-10 22:48:12 +08:00
echo " <i class='fa fa-exclamation-circle'></i> You are not enrolled in any Course " ;
2023-07-31 17:15:35 +08:00
} else {
while ( $row = mysqli_fetch_assoc ( $result )) {
$name = $row [ 'Course_Name' ];
$code = $row [ 'Course_Code' ];
2023-08-10 22:48:12 +08:00
$faculty = $row [ 'Faculty' ];
2023-07-31 17:15:35 +08:00
$lecturer = $row [ 'Full_Name' ];
$academic = $row [ 'Academic_Year' ];
$url = $row [ 'URL' ];
$id = $row [ 'Course_ID' ];
2023-08-10 22:48:12 +08:00
$Status = $row [ 'Status' ];
2020-03-16 15:23:14 +08:00
2023-08-10 22:48:12 +08:00
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 ;
2023-08-04 15:24:51 +08:00
< br > < span style = 'font-size:8pt' > Faculty : $faculty & nbsp ; Year : $academic & nbsp ; Lecturer : $lecturer </ span ></ div ></ a >
2023-08-10 22:48:12 +08:00
" ;
}
else
{
echo " <div class='btn btn-default'>
2023-08-07 16:39:19 +08:00
( $code ) - $name < i class = 'btn btn-sm btn-danger' > $Status </ i >
2023-08-04 15:24:51 +08:00
< br > < span style = 'font-size:8pt' > Faculty : $faculty & nbsp ; Year : $academic & nbsp ; Lecturer : $lecturer </ span ></ div >
2023-08-10 22:48:12 +08:00
" ;
}
2023-07-31 17:15:35 +08:00
}
}
2023-08-10 22:48:12 +08:00
echo " </div><div class='col-md-6'>
2020-03-16 15:23:14 +08:00
< form method = 'get' action = 'Courses.php' >
2023-08-10 22:48:12 +08:00
< div class = 'row' >
2023-08-05 16:11:27 +08:00
< div class = 'col-md-12' >
< div class = 'row' >
< div class = 'col-md-5' >
Find new course by course code
< input type = 'text' class = 'form-control' name = 'search' maxlength = '11' placeholder = 'Enter course code' >
</ div >
< div class = 'col-md-5' >
List courses by faculty
< select name = 'faculty' class = 'form-control' > " ;
2023-08-10 22:48:12 +08:00
$result = mysqli_query ( $con , " SELECT DISTINCT(Faculty) as Faculty FROM `courses_table` " );
if ( mysqli_num_rows ( $result ) == 0 ){
} else {
echo " <option value=''>Search by faculty</option> " ;
while ( $row = mysqli_fetch_assoc ( $result )) {
$fname = $row [ 'Faculty' ];
echo " <option value=' $fname '> $fname </option> " ;
}}
2020-03-16 15:23:14 +08:00
2023-08-10 22:48:12 +08:00
echo " </select>
2023-08-05 16:11:27 +08:00
</ div >
2020-03-16 15:23:14 +08:00
2023-08-05 16:11:27 +08:00
< div class = 'col-md-2' > < br >
2023-08-09 16:40:26 +08:00
< button type = 'submit' class = 'btn btn-primary' > Find </ button >
2023-08-05 16:11:27 +08:00
</ div >
</ div >
</ div >
2020-03-16 15:23:14 +08:00
</ div >
</ form >
2022-05-19 12:35:27 +08:00
2023-08-10 22:48:12 +08:00
</ div ></ div > " ;
}
?>
< ? php include 'Footer.php' ; ?>
</ div >
2023-08-08 15:02:26 +08:00
</ body >
</ html >