Upgrade to Bootstrap 5. TODO: nav tab does not work in Admin.php.

Bug430-Eden2
Lan Hui 2023-08-06 17:43:36 +08:00
parent 7d28f987d2
commit 9c529e0022
6 changed files with 207 additions and 269 deletions

211
Admin.php
View File

@ -15,65 +15,48 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") {
}
?>
<div class="container">
<br>
<div style="width: 80%;margin: auto;">
<h2> Administration panel </h2>
</div>
<br>
<div>
<h2> Administration panel </h2>
</div>
<hr>
<div class="row" style="width: 80%;margin: auto;">
<hr>
<div class="row">
<div class="col-md-6">
<!-- <?php
if ($_SESSION['user_type'] == "Lecturer") {
echo " <h4> TA Account Management </h4> <hr> " ;
echo "<b>TA Accounts </b><br>" ;
}
else if($_SESSION['user_type'] == "Admin"){
echo " <h4> Lecturer Account Management </h4>
<hr> ";
echo "<b>Lecturer Accounts </b><br>";
}
?> -->
<div class="container">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<div class="col-md-6">
<!-- Nav tabs -->
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#home">Create TA account</a>
<a class="nav-link active" id="home" href="#home">Create TA account</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#menu1" id="batch_tab">Batch create student accounts</a>
<a class="nav-link" href="#menu1" id="batch_tab">Batch create student accounts</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#menu2" id="existing_accounts_tab">Existing accounts</a>
<a class="nav-link" href="#menu2" id="existing_accounts_tab">Existing accounts</a>
</li>
</ul>
<!-- Tab panes -->
<!-- Tab panes -->
<div class="tab-content">
<div id="home" class="container tab-pane active"><br>
<div id="home" class="tab-pane active"><br>
<?php
<?php
if ($_SESSION['user_type'] == "Lecturer") {
echo "<b>Create TA Accounts </b>";
}
else if($_SESSION['user_type'] == "Admin"){
echo "<b>Create Lecturer Accounts </b>";
}
?>
<form method="post" action="Script.php" id="create_account_form">
<input type="hidden" name="frm_createlecturrer" value="true" required="" />
@ -86,23 +69,23 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") {
<input type="text" class="form-control" name="passport" placeholder="Passport No./ID" required="">
<br> User type:
<?php
<?php
if ($_SESSION['user_type'] == "Lecturer") {
echo ' <input type="radio" name="type" value="TA" required="" id="role_TA"> TA (Teaching Assistant) ';
}
else if($_SESSION['user_type'] == "Admin"){
echo " <input type='radio' name = 'type' value = 'Lecturer' required = '' id='role_lecturer' > Lecturer ";
}
?>
?>
<input type="submit" class="btn btn-primary" value="Create" id="create_btn"><br>
<?php
error_reporting(E_ALL);
@ -125,7 +108,7 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") {
<!-- code contributed by Xu Xiaopeng (https://github.com/xxp1999) -->
<div id="menu1" class="container tab-pane fade" style="margin-top:10px">
<div id="menu1" class="tab-pane fade" style="margin-top:10px">
<b>Separate two student numbers with a space</b><br>
<form action="batch_insert.php" method="post" id="batch_form">
<p>
@ -136,7 +119,7 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") {
</div>
<div id="menu2" class="container tab-pane fade"><br>
<div id="menu2" class="tab-pane fade"><br>
<table class="table-bordered" style="font-size: 10pt;">
<tr style="font-size:10pt;">
@ -150,7 +133,7 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") {
<?php
if ($_SESSION['user_type'] == "Lecturer") {
$result = mysqli_query(
$con,
"SELECT * FROM users_table WHERE UserType in ('TA')"
@ -179,83 +162,79 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") {
}
?>
</table>
</div>
</div>
</div>
<div class="col-md-6">
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" href="#menu3" id="existing_courses">Existing courses</a>
</li>
</ul>
<div id="menu3" class="container tab-pane active"><br>
<b> Past courses </b>
<hr>
<table class="table-bordered" style="font-size: 10pt;">
<tr>
<th>Course Name</th>
<th>Faculty</th>
<th>Lecturer</th>
<th>TAs</th>
<th>Assign new TA </th>
</tr>
<?php
$user_id = $_SESSION['user_id'];
$result = mysqli_query($con, "SELECT `Course_ID`, `Course_Name`, `Academic_Year`, `Faculty`, `TA_User_ID`, `Course_Code`, `Full_Name` FROM courses_table INNER JOIN users_table ON users_table.User_ID=courses_table.Lecturer_User_ID WHERE User_ID=$user_id ORDER BY Academic_Year DESC;");
if (mysqli_num_rows($result) == 0) {
} else {
$counter = 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'];
$c_id = $row['Course_ID'];
$counter += 1;
$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=$c_id");
$ta = "";
while ($rowTA = mysqli_fetch_assoc($resultTA)) {
$ta = $ta . " - " . $rowTA['TA_NAME'];
}
echo "
<tr> <td>$code - $name</td> <td>$faculty </td> <td>$lecturer</td><td>$ta</td> <td><form method='get' action='Script.php' id='drop_menu_form_$counter'> <select name='ta' class=''>";
$resultx = mysqli_query($con, "SELECT * FROM users_table WHERE UserType='TA'");
if (mysqli_num_rows($resultx) == 0) {
} else {
while ($row = mysqli_fetch_assoc($resultx)) {
$id = $row['User_ID'];
$name = $row['Full_Name'];
echo "<option value='$id'> $name </option>";
}
}
echo "</select> <input type='hidden' name='assignTA' value='true'> <input type='hidden' name='id' value='$c_id'> <input type='submit' value='assign' id='assign_btn_$counter'></form> </td></tr>
";
}
} ?>
</table>
</div>
</div>
</div>
<div class="col-md-6">
<div class="container">
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#menu3" id="existing_courses">Existing courses</a>
</li>
</ul>
</div>
<div id="menu3" class="container tab-pane active"><br>
<b> Past courses </b>
<hr>
<table class="table-bordered" style="font-size: 10pt;">
<tr>
<th>Course Name</th>
<th>Faculty</th>
<th>Lecturer</th>
<th>TAs</th>
<th>Assign new TA </th>
</tr>
<?php
$user_id = $_SESSION['user_id'];
$result = mysqli_query($con, "SELECT `Course_ID`, `Course_Name`, `Academic_Year`, `Faculty`, `TA_User_ID`, `Course_Code`, `Full_Name` FROM courses_table INNER JOIN users_table ON users_table.User_ID=courses_table.Lecturer_User_ID WHERE User_ID=$user_id ORDER BY Academic_Year DESC;");
if (mysqli_num_rows($result) == 0) {
} else {
$counter = 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'];
$c_id = $row['Course_ID'];
$counter += 1;
$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=$c_id");
$ta = "";
while ($rowTA = mysqli_fetch_assoc($resultTA)) {
$ta = $ta . " - " . $rowTA['TA_NAME'];
}
echo "
<tr> <td>$code - $name</td> <td>$faculty </td> <td>$lecturer</td><td>$ta</td> <td><form method='get' action='Script.php' id='drop_menu_form_$counter'> <select name='ta' class=''>";
$resultx = mysqli_query($con, "SELECT * FROM users_table WHERE UserType='TA'");
if (mysqli_num_rows($resultx) == 0) {
} else {
while ($row = mysqli_fetch_assoc($resultx)) {
$id = $row['User_ID'];
$name = $row['Full_Name'];
echo "<option value='$id'> $name </option>";
}
}
echo "</select> <input type='hidden' name='assignTA' value='true'> <input type='hidden' name='id' value='$c_id'> <input type='submit' value='assign' id='assign_btn_$counter'></form> </td></tr>
";
}
} ?>
</table>
</div>
</div>
</div>
<script>

View File

@ -21,8 +21,6 @@ if( $_SESSION['user_type']=="Lecturer" || $_SESSION['user_type']=="TA")
<div class="row" style="width:80%;margin:auto; text-align:left;">
<script src="./css/jquery-1.11.1.min.js"></script>
<script src="./css/jquery-ui.min.js"></script>
<link rel="stylesheet" href="./css/jquery-ui.css" />
@ -473,7 +471,7 @@ WHERE Lecturer_User_ID=$lecturer_id and course_students_table.Status='Pending'"
<input type="radio" name="verify" value="1"> Yes
<input type="radio" name="verify" value="0" checked=""> No
<br>
<br><br>
<input type="submit" class="btn btn-primary" value="Create"><br>
</form>

View File

@ -14,21 +14,23 @@ if (mysqli_connect_errno()) {
<!DOCTYPE html>
<html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Lab Report Repository</title>
<link href="./css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href=" https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.1/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="./font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<!-- *this css file can be used across all the websites
<!-- *this css file can be used across all the websites
and any new css class can be added there.
* The reason is to make the css code reusable.
* the css file is used by submissions.php
-->
<link href = "./css/main.css" rel="stylesheet" type="text/css" />
<script src="./css/jquery.min.js" type="text/javascript"></script>
<script src="./css/bootsrap.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.1/js/bootstrap.min.js"></script>
<script src=">https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.1/js/bootstrap.bundle.min.js"></script>
<script src="./css/jquery.datetimepicker.min.js" type="text/javascript"></script>
@ -113,20 +115,6 @@ if (mysqli_connect_errno()) {
width:100%;
}
.txt1 {
font-family: Poppins-Regular;
font-size: 18px;
line-height: 1.5;
color: #666666;
}
.txt2 {
font-family: Poppins-Regular;
font-size: 19px;
line-height: 1.5;
color: #2471A3;
}
.form-control{
padding-top: 1px;
padding-bottom:1px;
@ -142,8 +130,8 @@ if (mysqli_connect_errno()) {
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark" style="padding-left:150px;padding-right:150px;margin:auto;">
<a class="navbar-brand" href="~\..\index.php"> <img src="logo.png" style="width:30px;height:30px;"> LRR </a>
<nav class="navbar navbar-expand-lg" style="padding-left:150px;padding-right:150px;margin:auto;">
<a class="navbar-brand" href="~\..\index.php"> <img src="logo.png" style="width:30px;height:30px;" alt="LRR Logo"> LRR </a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor02" aria-controls="navbarColor02" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
@ -159,7 +147,7 @@ if (mysqli_connect_errno()) {
</li>
</ul>
<form class="form-inline my-2 my-lg-0" style="color:#fff;">
<form class="form-inline my-2 my-lg-0">
Welcome &nbsp;
<b> <?php echo $_SESSION['user_fullname']; ?> </b>
&nbsp;
@ -174,18 +162,18 @@ if (mysqli_connect_errno()) {
<?php
if ($_SESSION['user_type'] == "Lecturer") { // Show Admin link
echo "&nbsp;&nbsp;&nbsp; <i class=\"fa fa-cog\" style=\"color:#fff;\"> </i>";
echo "&nbsp;<a style='color:#fff !important' href=\"~\..\Admin.php\" id=\"admin_tab\">Admin</a>";
echo "&nbsp;&nbsp;&nbsp; <i class=\"fa fa-cog\"> </i>";
echo "&nbsp;<a href=\"~\..\Admin.php\" id=\"admin_tab\">Admin</a>";
}
?>
&nbsp;&nbsp;&nbsp; <i class="fa fa-user" style="color:#fff;"> </i>
&nbsp;<a href="#" style='color:#fff !important' onclick="updatePass(<?php echo $_SESSION['user_id']; ?>)">Update password</a>
&nbsp;&nbsp;&nbsp; <i class="fa fa-user"> </i>
&nbsp;<a href="#" onclick="updatePass(<?php echo $_SESSION['user_id']; ?>)">Update password</a>
&nbsp;&nbsp;&nbsp; <i class="fa fa-lock" style="color:#fff;"> </i>
&nbsp;<a style='color:#fff !important' href="~\..\logout.php">Logout </a>
&nbsp;&nbsp;&nbsp; <i class="fa fa-lock"> </i>
&nbsp;<a href="~\..\logout.php">Logout </a>
<?php
} // Confusing. What is this for?

110
index.php
View File

@ -15,72 +15,62 @@ if (isset($_SESSION["user_fullname"])) {
<br><br><br>
<div class="row" style="width:85%;margin:auto;">
<div class="col-md-4">
<br><br>
<img src="logo.png" style="width:40%; position:relative; right:-95px; top:1px;">
<br><br>
<div style="width:20%; position:relative; right:-90px; font-family: Poppins-Regular;">
<h1>Lab Report Repository</h1>
</div>
</div>
<div style = "position:relative; left:240px; top:-2px;">
<h4 class="list-group-item active" style="font-weight:normal;font-family: Poppins-Regular;"> Sign in </h4>
<div class="list-group-item">
<div class="panel-body">
<form method="post" action="Script.php" name="frm_login">
<input type="hidden" name="frm_login" value="true"/>
Account name
<input type="text" name="user" placeholder="Student Number / Email address" class="form-control" required="required" id="user_name" />
<br>
Password
<input type="password" class="form-control" name="password" placeholder="password" required="required" id="user_password" />
<div class="text-left">
<br><input type="submit" class="btn-primary" value="Login" id="login_btn">
</div>
<div class="text-left">
<span class="txt1">Don't have an account yet?</span>
<a class="txt2" href="signup.php" style="font-weight:normal" id="signup_link">Sign Up</a>
</div>
<div class="text-left">
<span class="txt1">Forget your password?</span>
<a class="txt2" href="recover_password.php" style="font-weight:normal">Reset my password</a>
</div>
<?php
error_reporting(E_ALL);
if(isset($_SESSION['info_login'])) {
echo '<hr><div class="alert alert-danger" role="alert">'.$_SESSION['info_login'].'</div>';
$_SESSION['info_login'] = null;
}
// wrong pass
if(isset($_SESSION['wrong_pass'])) {
echo '<hr><div class="alert alert-danger" role="alert">'.$_SESSION['wrong_pass'].'</div>';
$_SESSION['wrong_pass'] = null;
}
if(isset($_SESSION['infoChangePassword'])) {
echo '<hr><div class="alert alert-danger" role="alert">'.$_SESSION['infoChangePassword'].'</div>';
$_SESSION['infoChangePassword'] = null;
}
?>
</form>
<div class="container">
<div class="row">
<div class="col">
<img src="logo.png" style="width:32%; position:relative; right:-95px; top:1px;" alt="LRR Logo">
<br><br>
<div style="width:32%; position:relative; right:-90px; font-family: Poppins-Regular;">
<h1>Lab Report Repository</h1>
</div>
</div>
<div class="col">
<form method="post" action="Script.php" name="frm_login">
<input type="hidden" name="frm_login" value="true"/>
<label for="user_name" class="form-label">Account name</label>
<input type="text" name="user" placeholder="Student Number / Email address" class="form-control" required="required" id="user_name" />
<br>
<label for="user_password" class="form-label">Password</label>
<input type="password" class="form-control" name="password" placeholder="password" required="required" id="user_password" />
<br>
<button type="submit" class="btn btn-primary" id="login_btn">Sign in</button>
<br>
<label class="form-text">Don't have an account yet?</label> <a href="signup.php" id="signup_link">Sign up</a>
<br>
<label class="form-text">Forget your password?</label> <a href="recover_password.php">Recover</a>
<?php
error_reporting(E_ALL);
if(isset($_SESSION['info_login'])) {
echo '<hr><div class="alert alert-danger" role="alert">'.$_SESSION['info_login'].'</div>';
$_SESSION['info_login'] = null;
}
// wrong pass
if(isset($_SESSION['wrong_pass'])) {
echo '<hr><div class="alert alert-danger" role="alert">'.$_SESSION['wrong_pass'].'</div>';
$_SESSION['wrong_pass'] = null;
}
if(isset($_SESSION['infoChangePassword'])) {
echo '<hr><div class="alert alert-danger" role="alert">'.$_SESSION['infoChangePassword'].'</div>';
$_SESSION['infoChangePassword'] = null;
}
?>
</form>
</div>
</div>
</div>
<div id="footer">
LRR was originally developed as a <a href="http://lanlab.org/course/2018f/se/homepage.html" style="color:white;">software engineering course project</a> by Mohamed Nor and Elmahdi Houzi. Please submit your suggestions or bug reports to Mr Lan. <a href="./homepage" style="color:white;">More information ...</a>
</div>

View File

@ -7,37 +7,26 @@ include 'Header.php';
?>
<div class="row">
<div class="col-md-4 list-group" style="margin:auto;">
<br>
<h4 class="list-group-item active"> Recover password </h4>
<div class="list-group-item">
<div class="panel-body">
<form method="post" action="Script.php">
<input type="hidden" name="frm_recover_password" value="true"/>
Student number <input type="text" name="sno" placeholder="Enter your student number" class="form-control" required="required" value="<?php echo htmlspecialchars($_SESSION['student_number']); ?>">
<br/>
Email <input type="text" name="email" placeholder="Enter your email address" class="form-control" required="required" value="<?php echo htmlspecialchars($_SESSION['user_email']); ?>">
<br/>
<input type="submit" class="btn-primary" value="Recover">
</form>
<?php
if(isset($_SESSION['info_recover_password'])) {
echo '<hr><div class="alert alert-danger" role="alert">'.htmlspecialchars($_SESSION['info_recover_password']).'</div>';
$_SESSION['info_recover_password'] = null;
}
?>
</div>
<div class="container">
<div class="row justify-content-md-center">
<div class="col-md-auto">
<form method="post" action="Script.php">
<input type="hidden" name="frm_recover_password" value="true"/>
Student number <input type="text" name="sno" placeholder="Enter your student number" class="form-control" required="required" value="<?php echo htmlspecialchars($_SESSION['student_number']); ?>">
<br/>
Email <input type="text" name="email" placeholder="Enter your email address" class="form-control" required="required" value="<?php echo htmlspecialchars($_SESSION['user_email']); ?>">
<br/>
<button type="submit" class="btn btn-primary">Recover</button>
</form>
</div>
</div>
<?php
if(isset($_SESSION['info_recover_password'])) {
echo '<hr><div class="alert alert-danger" role="alert">'.htmlspecialchars($_SESSION['info_recover_password']).'</div>';
$_SESSION['info_recover_password'] = null;
}
?>
</div>

View File

@ -6,45 +6,39 @@ include 'NoDirectPhpAcess.php';
include 'Header.php';
?>
<div class="row">
<div class="container">
<div class="col-md-4 list-group" style="margin:auto;">
<div class="row justify-content-md-center">
<div class="col-md-auto">
<br>
<form method="post" action="Script.php" id="signup_form">
<h4 class="list-group-item active"> Please fill in each field below </h4>
<div class="list-group-item">
<input type="hidden" name="form_signup" value="true" />
Full Name
<input type="text" name="fullname" placeholder="Your full name" class="form-control" value="<?php echo $_SESSION['user_fullname']; ?>" required="required" id="full_name"/>
<div class="panel-body">
Student ID
<input type="text" name="user_student_id" placeholder="Entre your student ID" class="form-control" value="<?php echo $_SESSION['user_student_id']; ?>" required="required" id="student_id">
<form method="post" action="Script.php" id="signup_form">
<input type="hidden" name="form_signup" value="true" />
Full Name
<input type="text" name="fullname" placeholder="Your full name" class="form-control" value="<?php echo $_SESSION['user_fullname']; ?>" required="required" id="full_name"/>
Email
<input type="text" name="email" placeholder="Email" class="form-control" value="<?php echo $_SESSION['user_email']; ?>" required="required" id="email" />
Student ID
<input type="text" name="user_student_id" placeholder="Entre your student ID" class="form-control" value="<?php echo $_SESSION['user_student_id']; ?>" required="required" id="student_id">
Password <label class="form-text">must include uppercase and lowercase letters, digits and special characters</label>
<input type="password" class="form-control" name="password" placeholder="Enter password" required="required" id="password1" />
Email
<input type="text" name="email" placeholder="Email" class="form-control" value="<?php echo $_SESSION['user_email']; ?>" required="required" id="email" />
Confirm Password
<input type="password" class="form-control" name="confirmpassword" placeholder="Confirm password" required="required" id="password2" />
<br>
<button type="submit" class="btn btn-primary" id="signup_btn">Sign up</button>
<?php
error_reporting(E_ALL);
if (isset($_SESSION['info_signup'])) {
echo '<hr><div class="alert alert-danger" role="alert">' . $_SESSION['info_signup'] . '</div>';
$_SESSION['info_signup'] = null;
}
?>
Password (<i>must include uppercase and lowercase letters, digits and special characters</i>)
<input type="password" class="form-control" name="password" placeholder="Enter password" required="required" id="password1" />
Confirm Password
<input type="password" class="form-control" name="confirmpassword" placeholder="Confirm password" required="required" id="password2" />
<br>
<input type="submit" class="btn-primary" value="Sign up" id="signup_btn">
<?php
error_reporting(E_ALL);
if (isset($_SESSION['info_signup'])) {
echo '<hr><div class="alert alert-danger" role="alert">' . $_SESSION['info_signup'] . '</div>';
$_SESSION['info_signup'] = null;
}
?>
</form>
</div>
</div>
</form>
</div>
</div>
</div>