Skip to content

Commit

Permalink
1st Release for Test Run - Basic
Browse files Browse the repository at this point in the history
  • Loading branch information
DasunNethsara-04 committed Jun 15, 2023
1 parent 1f7d191 commit 69dbc69
Show file tree
Hide file tree
Showing 38 changed files with 2,471 additions and 1,172 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Student Management System for Richmond College Technology Section
> Coding :
- Version : 1.0
- Base Language : PHP (v8.1)
- Used Language/s : HTML, CSS, JavaScript (Also known as JS), SQL (MySQL)
- Used Language/s : HTML, CSS, JavaScript, SQL (MySQL)
- Framework : Bootstrap (CSS Framework)
- Used Pre Trained models/ APIs : -
- Platform : Any (Windows, MacOS, Linux, iOS, Android etc.)
Expand All @@ -17,4 +17,4 @@ Student Management System for Richmond College Technology Section
- Start Date : 12.03.2023
- End Date : Pending...
- Release Date : Pending...
- Further Updates : Disabled
- Further Updates : Disabled
21 changes: 19 additions & 2 deletions data/admin_operations.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ function getAllGrades()
function getAllClasses()
{
require '../../controls/connection.php';
$currentYear = date("Y");
$currentYear1 = date("Y") + 1;
$sql = "SELECT * FROM grade_class_tbl";
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) >= 1) {
Expand All @@ -119,3 +117,22 @@ function getAllSubjects()
return 0;
}
}

function getSelectedStudents($id)
{
require '../../controls/connection.php';
$sql1 = "SELECT grade_class_id FROM grade_class_tbl WHERE staff_id='$id'";
$result1 = mysqli_query($con, $sql1);
if (mysqli_num_rows($result1) == 1) {
$row1 = mysqli_fetch_assoc($result1);
$grade_class_id = $row1['grade_class_id'];
$sql2 = "SELECT std_id FROM student_class_tbl WHERE grade_class_id='$grade_class_id'";
$result2 = mysqli_query($con, $sql2);
if (mysqli_num_rows($result2) > 0) {
$students = mysqli_fetch_all($result2);
return $students;
} else {
return 0;
}
}
}
21 changes: 21 additions & 0 deletions data/change-status.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
include '../controls/connection.php';
if (isset($_POST['change'])) {
$admission_no = $_GET['admission_no'];

$sql1 = "SELECT std_id FROM student_tbl WHERE admission_no='$admission_no'";
$result1 = mysqli_query($con, $sql1);
$row = mysqli_fetch_assoc($result1);
$std_id = $row['std_id'];

$sql2 = "UPDATE student_marks_watched_tbl SET is_watched='1' WHERE std_id='$std_id'";
if (mysqli_query($con, $sql2)) {
$sm = "Updated!";
header("Location: ../pages/students/show-marks.php?success=$sm");
exit;
} else {
$em = "Unknown error occurred";
header("Location: ../pages/students/show-marks.php?success=$em");
exit;
}
}
34 changes: 34 additions & 0 deletions data/change-std-password.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
if (isset($_POST['change_pwd'])) {
require_once '../controls/connection.php';
$old_pwd = $_POST['old_pwd'];
$new_pwd = $_POST['new_pwd'];
$c_new_pwd = $_POST['c_new_pwd'];
$std_id = $_GET['id'];
$admission_no = $_GET['admission'];

$sql1 = "SELECT password, admission_no FROM user_tbl WHERE username='$admission_no'";
$result1 = mysqli_query($con, $sql1);
if (mysqli_num_rows($result1) < 2) {
$data = mysqli_fetch_assoc($result1);
$o_pwd = $data['password'];
if (password_verify($old_pwd, $o_pwd)) {
if ($new_pwd == $c_new_pwd) {
$sql2 = "UPDATE user_tbl SET password='" . password_hash($new_pwd, PASSWORD_DEFAULT) . "' WHERE admission_no='$admission_no'";
if (mysqli_query($con, $sql2)) {
$sm = "The password has been changed successfully!";
header("Location: ../pages/students/settings.php?success=$sm");
exit;
}
} else {
$em = "Enter the New Password Correctly!";
header("Location: ../pages/admin/settings.php?error=$em");
exit;
}
} else {
$em = "Incorrect Old Passowrd";
header("Location: ../pages/admin/settings.php?error=$em");
exit;
}
}
}
34 changes: 34 additions & 0 deletions data/change-teacher-password.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
if (isset($_POST['change_pwd'])) {
require_once '../controls/connection.php';
$old_pwd = $_POST['old_pwd'];
$new_pwd = $_POST['new_pwd'];
$c_new_pwd = $_POST['c_new_pwd'];
// $staff_id = $_GET['id'];
$nic = $_GET['nic'];

$sql1 = "SELECT password, nic FROM user_tbl WHERE username='$nic'";
$result1 = mysqli_query($con, $sql1);
if (mysqli_num_rows($result1) < 2) {
$data = mysqli_fetch_assoc($result1);
$o_pwd = $data['password'];
if (password_verify($old_pwd, $o_pwd)) {
if ($new_pwd == $c_new_pwd) {
$sql2 = "UPDATE user_tbl SET password='" . password_hash($new_pwd, PASSWORD_DEFAULT) . "' WHERE nic='$nic'";
if (mysqli_query($con, $sql2)) {
$sm = "The password has been changed successfully!";
header("Location: ../pages/teachers/settings.php?success=$sm");
exit;
}
} else {
$em = "Enter the New Password Correctly!";
header("Location: ../pages/teachers/settings.php?error=$em");
exit;
}
} else {
$em = "Incorrect Old Passowrd";
header("Location: ../pages/teachers/settings.php?error=$em");
exit;
}
}
}
11 changes: 11 additions & 0 deletions data/enter-marks.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

require_once '../controls/connection.php';
if (isset($_POST['save'])) {
$std_id = "";
$term = "";
$year = "";
$std_array = array();
$marks = $_POST['marks'];
foreach ($marks as $mark) {
foreach ($mark as $m) {
Expand All @@ -18,6 +22,8 @@
$term = $data[3];
$year = $data[4];

array_push($std_array, $std_id);

if ($m == "") {
$sql3 = "SELECT * FROM al_absent_tbl WHERE std_id='$std_id' AND grade_class_id='$grade_class_id' AND sub_id='$sub_id' AND term='$term' AND year='$year'";
$result3 = mysqli_query($con, $sql3);
Expand Down Expand Up @@ -102,6 +108,11 @@
}
}

foreach (array_unique($std_array) as $std_id) {
$sql3 = "INSERT INTO student_marks_watched_tbl (std_id, term, year, is_watched) VALUES ('$std_id', '$term', '$year', '0')";
$result3 = mysqli_query($con, $sql3);
}

if ($state == 1) {
if ($result2) {
$sm = "Marks added successfully!";
Expand Down
146 changes: 146 additions & 0 deletions pages/admin/analytics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?php
session_start();
if (isset($_SESSION['username']) && isset($_SESSION['admin_role'])) {
?>

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<link rel="shortcut icon" href="../../Media/Richmond Colleg LOGO.png" type="image/x-icon">
<meta name="description" content="" />
<meta name="author" content="" />
<title>Marks Analytics - Admin</title>
<link href="../css/styles.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/releases/v6.3.0/js/all.js" crossorigin="anonymous"></script>
<!-- <script src="../../js/jquery-3.6.3.min.js"></script> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>

<body class="sb-nav-fixed">

<?php include '../top-navbar.php'; ?>
<?php include 'left-side-bar.php'; ?>

<div id="layoutSidenav_content">

<!-- content goes here. do not remove any code -->
<div class="container-fluid">
<h1 class="mt-4">Marks Analytics</h1>
<ol class="breadcrumb mb-4"></ol>

<div class="container mt-5">
<div class="shadow p-3 mt-5 form-w">
<div class="row">
<div class="col-md-4">
<div class="mb-3">
<label class="form-label">Search by Admission No.</label>
<input type="text" id="admission_no" class="form-control">
</div>
</div>
<div class="col-md-4">
<div class="mb-3">
<label class="form-label">Year</label>
<select name="year" class="form-select yearSelect" required></select>
</div>
</div>
<!-- <div class="col-md-4">
<div class="mb-3">
<label class="form-label">Term</label>
<select name="term" class="form-select termSelect" required></select>
</div>
</div> -->
<!-- <div class="col-md-5"> -->
<div class="mb-3">
<button class="btn btn-success" id="search">Search</button>
</div>
<!-- </div> -->
</div>
</div>
</div>

<div class="container mt-5">
<h3>Filtered Results</h3>
<hr>
<div id="data" class=""></div>
</div>


</div>

<!-- footer -->
<?php include '../footer.php'; ?>
</div>
</div>

<script>
$(document).ready(function() {
// get-years.php
$('#admission_no').keyup(function() {
var query = $(this).val();
if (query != '') {
$.ajax({
url: 'get-years.php',
method: 'POST',
data: {
query: query
},
success: function(data) {
$('.yearSelect').html(data);
}
});
}
});
// $('#admission_no').keyup(function() {
// var query = $(this).val();
// if (query != '') {
// $.ajax({
// url: 'get-terms.php',
// method: 'POST',
// data: {
// query: query
// },
// success: function(data) {
// $('.termSelect').html(data);
// }
// });
// }
// });
$("#search").click(function(event) {
event.preventDefault();
$.ajax({
url: "load-charts.php",
type: "POST",
data: {
res_year: $(".yearSelect option:selected").val(),
// term: $(".termSelect option:selected").val(),
query: $("#admission_no").val()
},
success: function(data) {
$("#data").html(data);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log("Error: " + textStatus + " - " + errorThrown);
}
});
});
});
</script>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="../js/scripts.js"></script>

</body>

</html>

<?php } else {
header("Location:../../login.php");
exit;
}
?>
2 changes: 1 addition & 1 deletion pages/admin/class-reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@

<form action="../../data/enter-marks.php" method='post'>
<table class="table table-bordered" id='tableData'></table>
<!-- <input type="submit" name="save" class="btn btn-success" value="Save"> -->
<input type="submit" name="save" class="btn btn-success" value="Save">
</form>

</div>
Expand Down
23 changes: 23 additions & 0 deletions pages/admin/get-terms.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
// get-terms.php
include '../../controls/connection.php';

$query = $_POST['query'];

$sql1 = "SELECT std_id FROM student_tbl WHERE admission_no='$query'";
$result1 = mysqli_query($con, $sql1);
if (mysqli_num_rows($result1) == 1) {
$row1 = mysqli_fetch_assoc($result1);
$std_id = $row1['std_id'];

$sql2 = "SELECT DISTINCT term FROM al_marks_tbl WHERE std_id='$std_id'";
$result2 = mysqli_query($con, $sql2);
if (mysqli_num_rows($result2) > 0) {
while ($row2 = mysqli_fetch_assoc($result2)) {
$term = $row2['term'];
echo "<option value='$term'>$term</option>";
}
} else {
}
} else {
}
22 changes: 22 additions & 0 deletions pages/admin/get-years.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
include '../../controls/connection.php';

$query = $_POST['query'];

$sql1 = "SELECT std_id FROM student_tbl WHERE admission_no='$query'";
$result1 = mysqli_query($con, $sql1);
if (mysqli_num_rows($result1) == 1) {
$row1 = mysqli_fetch_assoc($result1);
$std_id = $row1['std_id'];

$sql2 = "SELECT DISTINCT year FROM al_marks_tbl WHERE std_id='$std_id'";
$result2 = mysqli_query($con, $sql2);
if (mysqli_num_rows($result2) > 0) {
while ($row2 = mysqli_fetch_assoc($result2)) {
$year = $row2['year'];
echo "<option value='$year'>$year</option>";
}
} else {
}
} else {
}
Loading

0 comments on commit 69dbc69

Please sign in to comment.