This commit is contained in:
cereci5049 2024-06-04 00:32:40 +05:30
parent b4184c457e
commit c2bf805b9a
21 changed files with 346 additions and 8 deletions

View File

@ -1,7 +1,7 @@
# Package
version = "0.1.0"
author = "cereci5049"
version = "0.1.1"
author = "fitel22348-molyg"
description = "School Management System"
license = "GPL-2.0-or-later"
srcDir = "src"
@ -11,3 +11,6 @@ bin = @["a4"]
# Dependencies
requires "nim >= 2.0.2"
requires "https://github.com/ire4ever1190/mike"
requires "db_connector"
requires "nimja"

BIN
db5.sqlite3 Normal file

Binary file not shown.

BIN
src/a4 Executable file

Binary file not shown.

View File

@ -0,0 +1,16 @@
import
mike,
segfaults,
./controllers/[student, faculty, index]
"/" -> get: ctx.index()
"/studentattendence" -> get: ctx.studentAttendance()
"/faculty" -> get: ctx.faculty()
"/faculty/login" -> get: ctx.facultyLogin()
servePublic("src/public", "/static")
run()

View File

@ -0,0 +1,23 @@
import
mike,
nimja/parser,
segfaults
proc faculty*(ctx: Context): string =
compileTemplateFile(getScriptDir() / "view" / "faculty_admin.html")
proc facultyLogin*(ctx: Context): string =
compileTemplateFile(getScriptDir() / "view" / "faculty_login.html")
proc facultySignUp*(ctx: Context): string =
compileTemplateFile(getScriptDir() / "view" / "faculty_signup.html")
proc postFacultyLogin*(ctx: Context)=
var
form = ctx.urlForm
username = form["username"]
password = form["password"]
ctx &= initCookie("username", username)
ctx &= initCookie("password", password)

View File

@ -0,0 +1,7 @@
import
mike,
nimja/parser,
segfaults
proc index*(ctx: Context): string =
compileTemplateFile(getScriptDir() / "view" / "index.html")

View File

@ -0,0 +1,7 @@
import
mike,
nimja/parser,
segfaults
proc studentAttendance*(ctx: Context): string =
compileTemplateFile(getScriptDir() / "view" / "student_attendance.html")

BIN
src/database/db_up Executable file

Binary file not shown.

7
src/database/db_up.nim Normal file
View File

@ -0,0 +1,7 @@
import
./faculty,
../lib/mics
var db = newDatabase()
db.setUpFaculty()

22
src/database/faculty.nim Normal file
View File

@ -0,0 +1,22 @@
import
db_connector/db_sqlite,
strutils,
../models/models
proc close*(db: DbConn)=
db.close()
proc setUpFaculty*(db: DbConn) =
## setupOrders creates the orders table if it does not exist
db.exec(sql"""
CREATE TABLE IF NOT EXISTS orders (
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
user_name VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
created_at TEXT DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TEXT DEFAULT CURRENT_TIMESTAMP NOT NULL,
access_level VARCHAR(255) NOT NULL
);
""")

6
src/lib/mics.nim Normal file
View File

@ -0,0 +1,6 @@
import
db_connector/db_sqlite,
../models/models
proc newDatabase*(filename = "db5.sqlite3"): DbConn =
result = open(filename, "", "", "")

19
src/models/models.nim Normal file
View File

@ -0,0 +1,19 @@
type
Faculty* = object
id*: int
firstName*: string
lastName*: string
userName*: string
password*: string
createdAt*: string
updatedAt*: string
accessLevel*: int
Student* = object
id*: int
firstName*: string
lastName*: string
userName*: string
attendance*: float
createdAt*: string
updatedAt*: string

BIN
src/public/faculty.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@ -0,0 +1,76 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
header {
background-color: #333;
color: white;
padding: 10px;
display: flex;
justify-content: space-between;
align-items: center;
}
header h1 {
margin: 0;
}
header nav ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
}
header nav li {
margin-left: 10px;
}
header nav a {
color: white;
text-decoration: none;
}
main {
max-width: 1000px;
margin: 0 auto;
padding: 20px;
}
.hero {
text-align: center;
padding: 40px;
background-color: #007bff;
color: white;
}
.features {
display: flex;
justify-content: space-around;
padding: 20px;
background-color: #fff;
}
.feature {
text-align: center;
flex: 1;
}
.feature img {
max-width: 150px;
}
.about {
padding: 20px;
background-color: #f9f9f9;
}
footer {
text-align: center;
background-color: #333;
color: white;
padding: 10px;
}

BIN
src/public/student.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="/static/styles.css">
<title>Faculty Admin</title>
</head>
<body>
@ -11,7 +11,7 @@
<h1>Faculty Admin</h1>
<nav>
<ul>
<li><a href="faculty_login.html">Logout</a></li>
<li><a href="/faculty/login">Logout</a></li>
</ul>
</nav>
</header>

View File

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="/static/styles.css">
<title>Faculty Login</title>
</head>
<body>

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/static/styles.css">
<title>Faculty Login</title>
</head>
<body>
<header>
<h1>Faculty Sign Up</h1>
</header>
<main>
<form action="process_login.php" method="post"> <!-- Replace with actual server-side script -->
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<button type="submit">Login</button>
</form>
</main>
</body>
</html>

52
src/view/index.html Normal file
View File

@ -0,0 +1,52 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/static/index_styles.css">
<title>School Management System</title>
</head>
<body>
<header>
<h1>School Management System</h1>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/studentattendence">Student Attendance</a></li>
<li><a href="/faculty/login">Faculty Login</a></li>
</ul>
</nav>
</header>
<main>
<section class="hero">
<h2>Welcome to Our School Management System</h2>
<p>A comprehensive platform for managing student and faculty information.</p>
</section>
<section class="features">
<h3>Features</h3>
<div class="feature">
<img src="/static/student.jpg" alt="Student Icon">
<h4>Student Attendance</h4>
<p>Students can easily check their attendance records by entering their email address.</p>
</div>
<div class="feature">
<img src="/static/faculty.jpg" alt="Faculty Icon">
<h4>Faculty Administration</h4>
<p>Faculty members can log in to manage their profiles and student attendance.</p>
</div>
<!-- Add more features as needed -->
</section>
<section class="about">
<h3>About Us</h3>
<p>Our school management system is designed to streamline the administrative tasks of educational institutions. We aim to provide an efficient and user-friendly platform for both students and faculty members.</p>
</section>
</main>
<footer>
<p>&copy; 2024 School Management System. All rights reserved.</p>
</footer>
</body>
</html>

View File

@ -1,9 +1,9 @@
<!DOCTYPE html>
{# <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="/static/styles.css">
<title>Student Attendance</title>
</head>
<body>
@ -31,4 +31,78 @@
</table>
</main>
</body>
</html> #}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/static/styles.css">
<title>Student Attendance</title>
</head>
<body>
<header>
<h1>Student Attendance</h1>
</header>
<main>
<h2>Check Your Attendance</h2>
<form id="attendanceForm">
<label for="studentEmail">Enter your email:</label>
<input type="email" id="studentEmail" name="studentEmail" required>
<button type="submit">Check Attendance</button>
</form>
<div id="attendanceResult" style="display: none;">
<h3>Attendance for <span id="studentName"></span></h3>
<table>
<thead>
<tr>
<th>Date</th>
<th>Status</th>
</tr>
</thead>
<tbody id="attendanceTableBody">
<!-- Attendance data will be populated here -->
</tbody>
</table>
</div>
</main>
<script>
document.getElementById('attendanceForm').addEventListener('submit', function(event) {
event.preventDefault();
const studentEmail = document.getElementById('studentEmail').value;
// Here, you would send a request to the server to fetch attendance data
// For simplicity, let's assume we have the following sample data:
const sampleData = [
{ date: '2023-08-25', status: 'Present' },
{ date: '2023-08-26', status: 'Absent' },
// ...
];
// Simulate an asynchronous request
setTimeout(() => {
const studentName = 'John Doe'; // Replace with actual student name
document.getElementById('studentName').textContent = studentName;
const attendanceTableBody = document.getElementById('attendanceTableBody');
attendanceTableBody.innerHTML = '';
sampleData.forEach(entry => {
const row = attendanceTableBody.insertRow();
row.insertCell(0).textContent = entry.date;
row.insertCell(1).textContent = entry.status;
});
document.getElementById('attendanceResult').style.display = 'block';
}, 1000);
});
</script>
</body>
</html>