huge updates

This commit is contained in:
sankalp committed 2025-04-03 16:30:28 +05:45
1 parent 861d64c95a
commit ee89d38489
56 files changed
+10130 -4185

No files matched your search

+356 -5
View File
@@ -2,21 +2,372 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script>
// Force cache clear for JavaScript files
if (window.location.href.indexOf('cache=clear') === -1) {
// Only run once to avoid redirect loop
const allScripts = document.querySelectorAll('script[src]');
for (const script of allScripts) {
if (script.src.indexOf('static/js/') !== -1) {
const originalSrc = script.src;
script.src = originalSrc + '?v=' + new Date().getTime();
}
}
}
</script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, user-scalable=yes">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<title>{% block title %}Student Management System{% endblock %}</title>
<!-- Favicon -->
<link rel="shortcut icon" href="{% static 'favicon.ico' %}">
<link rel="icon" type="image/x-icon" href="{% static 'img/favicon.ico' %}">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<!-- Base CSS -->
<link rel="stylesheet" href="{% static 'css/base.css' %}">
{% block extrastyle %}{% endblock %}
<!-- Custom Dashboard CSS -->
<link href="{% static 'css/dashboard.css' %}" rel="stylesheet">
<!-- Common Responsive Styles -->
<style>
/* Base responsive styles */
html {
font-size: 16px;
-webkit-text-size-adjust: 100%;
}
body {
overflow-x: hidden;
width: 100%;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* Responsive typography */
@media (max-width: 768px) {
html {
font-size: 14px;
}
h1 { font-size: 1.8rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.9rem; }
}
/* Responsive containers and spacing */
@media (max-width: 768px) {
.container, .container-fluid {
padding-left: 15px;
padding-right: 15px;
}
.row {
margin-left: -10px;
margin-right: -10px;
}
.col-md-6, .col-lg-3 {
padding-left: 10px;
padding-right: 10px;
}
.card {
margin-bottom: 1rem;
}
.table-responsive {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
.welcome-section h2 {
font-size: 1.5rem;
}
.summary-card .card-body {
padding: 0.75rem;
}
.bottom-nav {
padding-bottom: env(safe-area-inset-bottom);
}
}
/* Small screen optimizations */
@media (max-width: 576px) {
html {
font-size: 13px;
}
.container-fluid {
padding-left: 10px;
padding-right: 10px;
}
.col-md-6, .col-lg-3 {
padding-left: 5px;
padding-right: 5px;
}
.row {
margin-left: -5px;
margin-right: -5px;
}
.card {
border-radius: 0.5rem;
}
.btn {
padding: 0.375rem 0.75rem;
font-size: 0.875rem;
}
.form-control {
font-size: 0.875rem;
}
.table th, .table td {
padding: 0.5rem;
font-size: 0.875rem;
}
.modal-dialog {
margin: 0.5rem;
}
.toast {
width: 100%;
max-width: none;
}
}
/* Responsive navigation */
@media (max-width: 768px) {
.navbar-nav {
padding: 1rem 0;
}
.navbar-toggler {
padding: 0.25rem 0.5rem;
}
.dropdown-menu {
border: none;
box-shadow: none;
}
}
/* Responsive forms */
@media (max-width: 576px) {
.form-group {
margin-bottom: 0.75rem;
}
.form-label {
font-size: 0.875rem;
margin-bottom: 0.25rem;
}
.form-control {
height: calc(1.5em + 0.5rem + 2px);
}
}
/* Responsive images and media */
img {
max-width: 100%;
height: auto;
}
/* Profile picture responsive styles */
.profile-picture-container {
position: relative;
border-radius: 50%;
overflow: hidden;
background-color: #f5f5f5;
border: 2px solid #3F51B5;
margin-right: 1rem;
flex-shrink: 0;
aspect-ratio: 1;
}
.profile-picture {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 50%;
}
/* Profile picture sizes */
.profile-picture-container.profile-lg {
width: 120px;
height: 120px;
}
.profile-picture-container.profile-md {
width: 80px;
height: 80px;
}
.profile-picture-container.profile-sm {
width: 60px;
height: 60px;
}
/* Mobile optimizations for profile pictures */
@media (max-width: 576px) {
.profile-picture-container {
border-width: 1.5px;
}
.profile-picture-container.profile-lg {
width: 100px;
height: 100px;
}
.profile-picture-container.profile-md {
width: 60px;
height: 60px;
}
.profile-picture-container.profile-sm {
width: 40px;
height: 40px;
}
}
/* Responsive embed containers */
.embed-responsive {
position: relative;
display: block;
width: 100%;
padding: 0;
overflow: hidden;
}
.embed-responsive::before {
display: block;
content: "";
}
.embed-responsive .embed-responsive-item,
.embed-responsive iframe,
.embed-responsive embed,
.embed-responsive object,
.embed-responsive video {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
border: 0;
}
.embed-responsive-16by9::before {
padding-top: 56.25%;
}
/* Touch device optimizations */
@media (hover: none) {
.btn, .nav-link, .dropdown-item {
padding: 0.75rem 1rem; /* Larger touch targets */
}
.form-control, .form-select {
padding: 0.75rem 1rem; /* Larger input fields */
}
}
/* High contrast mode support */
@media (prefers-contrast: high) {
.btn, .nav-link, .dropdown-item {
border: 2px solid currentColor;
}
.form-control, .form-select {
border: 2px solid currentColor;
}
}
/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
* {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
}
</style>
{% block extrahead %}{% endblock %}
</head>
<body>
{% if messages %}
<div class="position-fixed top-0 end-0 p-3" style="z-index: 11">
{% for message in messages %}
<div class="toast show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header {% if message.tags == 'error' %}bg-danger text-white{% elif message.tags == 'success' %}bg-success text-white{% else %}bg-info text-white{% endif %}">
<strong class="me-auto">{% if message.tags == 'error' %}Error{% elif message.tags == 'success' %}Success{% else %}Info{% endif %}</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
{{ message }}
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% block content %}{% endblock %}
{% block extrahead %}{% endblock %}
<!-- Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<!-- Firebase SDK -->
<script src="https://www.gstatic.com/firebasejs/9.22.0/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.22.0/firebase-messaging-compat.js"></script>
<!-- Firebase Initialization -->
<script src="{% static 'js/firebase-init.js' %}"></script>
<!-- Custom Dashboard Components - No type="module" -->
<script src="{% static 'js/rating.js' %}?v={% now 'U' %}"></script>
<script src="{% static 'js/tabs.js' %}?v={% now 'U' %}"></script>
<script src="{% static 'js/bootstrap-init.js' %}?v={% now 'U' %}"></script>
<script src="{% static 'js/notifications.js' %}?v={% now 'U' %}"></script>
<script src="{% static 'js/form-validation.js' %}?v={% now 'U' %}"></script>
<!-- Navigation JS -->
<script src="{% static 'js/navigation.js' %}?v={% now 'U' %}"></script>
<!-- Main Dashboard JS - Must come after all supporting scripts -->
<script src="{% static 'js/dashboard.js' %}?v={% now 'U' %}"></script>
<!-- Common Modal Functions -->
<script>
function openLeaveModal() {
document.getElementById('customLeaveModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closeLeaveModal() {
document.getElementById('customLeaveModal').style.display = 'none';
document.body.style.overflow = '';
}
function openProfileModal() {
document.getElementById('profileModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closeProfileModal() {
document.getElementById('profileModal').style.display = 'none';
document.body.style.overflow = '';
}
function openPasswordModal() {
document.getElementById('passwordModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closePasswordModal() {
document.getElementById('passwordModal').style.display = 'none';
document.body.style.overflow = '';
}
// Auto-hide toasts
document.addEventListener('DOMContentLoaded', function() {
var toasts = document.querySelectorAll('.toast');
toasts.forEach(function(toast) {
setTimeout(function() {
var bsToast = new bootstrap.Toast(toast);
bsToast.hide();
}, 5000); // Hide after 5 seconds
});
});
</script>
{% block extrajs %}{% endblock %}
</body>
</html>
+134
View File
@@ -0,0 +1,134 @@
<!-- Bottom Navigation -->
<div class="bottom-nav">
<div class="nav-container">
<a href="#" class="nav-item active" data-section="dashboard">
<i class="fas fa-home"></i>
<span>Dashboard</span>
</a>
{% if user.designation == 'Teacher' %}
<a href="#subjectsSection" class="nav-item" data-section="subjects" onclick="showSection('subjectsSection'); return false;">
<i class="fas fa-graduation-cap"></i>
<span>Subjects</span>
</a>
<a href="#" class="nav-item" data-section="schedule">
<i class="fas fa-clock"></i>
<span>Schedule</span>
</a>
<a href="#" class="nav-item" data-section="attendance">
<i class="fas fa-user-check"></i>
<span>Attendance</span>
</a>
<a href="#" class="nav-item" data-section="leave">
<i class="fas fa-calendar-times"></i>
<span>Leaves</span>
</a>
<a href="#" class="nav-item" data-section="notice">
<i class="fas fa-bullhorn"></i>
<span>Notices</span>
</a>
<a href="#" class="nav-item" data-section="feedback">
<i class="fas fa-star"></i>
<span>Feedback</span>
</a>
<a href="#" class="nav-item" data-section="profile">
<i class="fas fa-id-card"></i>
<span>Profile</span>
</a>
{% else %}
<a href="#" class="nav-item" data-section="subjects">
<i class="fas fa-graduation-cap"></i>
<span>Subjects</span>
</a>
<a href="#" class="nav-item" data-section="routine">
<i class="fas fa-calendar-week"></i>
<span>Routine</span>
</a>
<a href="#" class="nav-item" data-section="attendance">
<i class="fas fa-user-check"></i>
<span>Attendance</span>
</a>
<a href="#" class="nav-item" data-section="leave">
<i class="fas fa-calendar-times"></i>
<span>Leaves</span>
</a>
<a href="#" class="nav-item" data-section="feedback">
<i class="fas fa-star"></i>
<span>Feedback</span>
</a>
<a href="#" class="nav-item" data-section="notice">
<i class="fas fa-bullhorn"></i>
<span>Notices</span>
</a>
<a href="#" class="nav-item" data-section="profile">
<i class="fas fa-id-card"></i>
<span>Profile</span>
</a>
{% endif %}
<a href="#" class="nav-item" onclick="document.getElementById('logoutForm').submit(); return false;">
<i class="fas fa-sign-out-alt"></i>
<span>Logout</span>
</a>
<form id="logoutForm" method="post" action="{% url 'logout' %}" style="display: none;">
{% csrf_token %}
</form>
</div>
</div>
<!-- Navigation Styles -->
<style>
.bottom-nav {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: white;
box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
z-index: 1000;
}
.nav-container {
display: flex;
justify-content: space-around;
align-items: center;
padding: 10px 0;
max-width: 1200px;
margin: 0 auto;
}
.nav-item {
display: flex;
flex-direction: column;
align-items: center;
color: #666;
text-decoration: none;
font-size: 0.9rem;
transition: color 0.3s ease;
}
.nav-item i {
font-size: 1.2rem;
margin-bottom: 4px;
}
.nav-item.active {
color: #3F51B5;
}
.nav-item:hover {
color: #3F51B5;
}
@media (max-width: 768px) {
.nav-container {
padding: 8px 0;
}
.nav-item {
font-size: 0.8rem;
}
.nav-item i {
font-size: 1rem;
}
}
</style>
+114
View File
@@ -0,0 +1,114 @@
{% load static %}
<!-- Profile Modal -->
<div id="profileModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeProfileModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 500px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Update Profile Picture</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeProfileModal()">&times;</button>
</div>
<div style="padding: 20px;">
<form action="{% url 'update_profile' %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<div style="text-align: center; margin-bottom: 20px;">
{% if user.image %}
<div class="profile-picture-container profile-lg mx-auto">
<img src="{{ user.image.url }}" alt="{{ user.name }}" class="profile-picture">
</div>
{% else %}
<div class="profile-picture-container profile-lg mx-auto">
<img src="{% static 'img/user.png' %}" alt="Default User" class="profile-picture">
</div>
{% endif %}
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 8px; font-weight: 500;">Select New Profile Picture</label>
<input type="file" name="profile_image" required style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
</div>
<div style="display: flex; justify-content: space-between;">
<button type="button" onclick="closeProfileModal()" style="background-color: #9E9E9E; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer;">Cancel</button>
<button type="submit" style="background-color: #3F51B5; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer;">Update Picture</button>
</div>
</form>
</div>
</div>
</div>
<!-- Password Change Modal -->
<div id="passwordModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closePasswordModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 500px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Change Password</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closePasswordModal()">&times;</button>
</div>
<div style="padding: 20px;">
<form action="{% url 'change_password' %}" method="post">
{% csrf_token %}
<div style="margin-bottom: 15px;">
<label for="current_password" style="display: block; margin-bottom: 8px; font-weight: 500;">Current Password</label>
<input type="password" id="current_password" name="current_password" required style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
</div>
<div style="margin-bottom: 15px;">
<label for="new_password" style="display: block; margin-bottom: 8px; font-weight: 500;">New Password</label>
<input type="password" id="new_password" name="new_password" required style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
</div>
<div style="margin-bottom: 15px;">
<label for="confirm_password" style="display: block; margin-bottom: 8px; font-weight: 500;">Confirm New Password</label>
<input type="password" id="confirm_password" name="confirm_password" required style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
</div>
<button type="submit" style="background-color: #3F51B5; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; width: 100%;">Change Password</button>
</form>
</div>
</div>
</div>
<!-- Leave Request Modal -->
<div id="customLeaveModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeLeaveModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 500px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Request Leave</h5>
<button id="closeCustomModal" style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeLeaveModal()">&times;</button>
</div>
<form action="{% if user.is_teacher %}{% url 'request_staff_leave' %}{% else %}{% url 'request_leave' %}{% endif %}" method="post">
{% csrf_token %}
<div style="padding: 20px;">
<div style="margin-bottom: 15px;">
<label for="startDate" style="display: block; margin-bottom: 8px; font-weight: 500;">Start Date</label>
<input type="date" id="startDate" name="start_date" style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;" required>
</div>
<div style="margin-bottom: 15px;">
<label for="endDate" style="display: block; margin-bottom: 8px; font-weight: 500;">End Date</label>
<input type="date" id="endDate" name="end_date" style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;" required>
</div>
<div style="margin-bottom: 15px;">
<label for="customLeaveMessage" style="display: block; margin-bottom: 8px; font-weight: 500;">Reason</label>
<textarea id="customLeaveMessage" name="message" rows="3" style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;" required></textarea>
</div>
</div>
<div style="padding: 15px; border-top: 1px solid #EEEEEE; text-align: right; display: flex; flex-wrap: wrap; justify-content: flex-end;">
<button type="button" id="cancelCustomModal" style="background-color: #9E9E9E; color: white; border: none; padding: 8px 16px; border-radius: 4px; margin-right: 10px; margin-bottom: 10px; cursor: pointer; font-size: 14px;" onclick="closeLeaveModal()">Cancel</button>
<button type="submit" style="background-color: #3F51B5; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px; margin-bottom: 10px;">Submit Request</button>
</div>
</form>
</div>
</div>
<!-- Confirmation Modal -->
<div id="confirmationModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeConfirmationModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 400px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #f44336; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Confirm Deletion</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeConfirmationModal()">&times;</button>
</div>
<div style="padding: 20px;">
<p class="mb-4">Are you sure you want to delete this file? This action cannot be undone.</p>
<div class="d-flex justify-content-end">
<button type="button" class="btn btn-secondary me-2" onclick="closeConfirmationModal()">Cancel</button>
<button type="button" class="btn btn-danger" id="confirmDeleteBtn">
<i class="fas fa-trash me-1"></i> Delete
</button>
</div>
</div>
</div>
</div>
@@ -0,0 +1,230 @@
<!-- Student Feedback Modal -->
<div id="feedbackModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeFeedbackModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 600px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Give Feedback</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeFeedbackModal()">&times;</button>
</div>
<div style="padding: 20px;">
<!-- Custom Tab Navigation -->
<div class="feedback-tabs">
<div id="teacher-tab-btn" class="feedback-tab-btn active" onclick="switchFeedbackTab('teacher')">
Teacher Feedback
</div>
<div id="institute-tab-btn" class="feedback-tab-btn" onclick="switchFeedbackTab('institute')">
Institute Feedback
</div>
</div>
<!-- Tab Content -->
<div class="tab-content">
<!-- Teacher Feedback Form -->
<div id="teacher-tab-content" class="tab-pane active">
<form method="post" action="{% url 'submit_feedback' %}" id="teacherFeedbackForm">
{% csrf_token %}
<input type="hidden" name="feedback_type" value="teacher">
<div class="mb-3">
<label for="teacher_select" class="form-label">Select Teacher</label>
<select class="form-select" id="teacher_select" name="teacher_id" required style="border-color: #BDBDBD;">
<option value="">Select Teacher</option>
{% for teacher in teachers %}
<option value="{{ teacher.id }}">{{ teacher.name }} - {{ teacher.designation }}</option>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label class="form-label">Rating</label>
<div class="rating-stars d-flex">
<i class="far fa-star fs-4 text-warning rating-star" data-value="1" onclick="selectRating(this, 'teacher_rating')"></i>
<i class="far fa-star fs-4 text-warning rating-star" data-value="2" onclick="selectRating(this, 'teacher_rating')"></i>
<i class="far fa-star fs-4 text-warning rating-star" data-value="3" onclick="selectRating(this, 'teacher_rating')"></i>
<i class="far fa-star fs-4 text-warning rating-star" data-value="4" onclick="selectRating(this, 'teacher_rating')"></i>
<i class="far fa-star fs-4 text-warning rating-star" data-value="5" onclick="selectRating(this, 'teacher_rating')"></i>
<input type="hidden" name="rating" id="teacher_rating" value="" required>
<div class="invalid-feedback d-block" id="teacher-rating-error" style="display: none;">Please select a rating</div>
</div>
</div>
<div class="mb-3">
<label for="teacher_feedback" class="form-label">Your Feedback</label>
<textarea class="form-control" id="teacher_feedback" name="feedback_text" rows="3" required style="border-color: #BDBDBD;"></textarea>
</div>
<div class="d-flex justify-content-end gap-2">
<button type="button" class="btn" style="background-color: #9E9E9E; color: white;" onclick="closeFeedbackModal()">Cancel</button>
<button type="submit" class="btn" style="background-color: #3F51B5; color: white;">Submit Feedback</button>
</div>
</form>
</div>
<!-- Institute Feedback Form -->
<div id="institute-tab-content" class="tab-pane">
<form method="post" action="{% url 'submit_institute_feedback' %}" id="instituteFeedbackForm">
{% csrf_token %}
<input type="hidden" name="feedback_type" value="institute">
<div class="mb-3">
<label for="feedback_type_select" class="form-label">Feedback Category</label>
<select class="form-select" id="feedback_type_select" name="feedback_type" required style="border-color: #BDBDBD;">
<option value="">Select Category</option>
<option value="General">General</option>
<option value="Facilities">Facilities</option>
<option value="Teaching">Teaching Quality</option>
<option value="Infrastructure">Infrastructure</option>
<option value="Administration">Administration</option>
</select>
</div>
<div class="mb-3">
<label class="form-label">Rating</label>
<div class="rating-stars d-flex">
<i class="far fa-star fs-4 text-warning rating-star" data-value="1" onclick="selectRating(this, 'institute_rating')"></i>
<i class="far fa-star fs-4 text-warning rating-star" data-value="2" onclick="selectRating(this, 'institute_rating')"></i>
<i class="far fa-star fs-4 text-warning rating-star" data-value="3" onclick="selectRating(this, 'institute_rating')"></i>
<i class="far fa-star fs-4 text-warning rating-star" data-value="4" onclick="selectRating(this, 'institute_rating')"></i>
<i class="far fa-star fs-4 text-warning rating-star" data-value="5" onclick="selectRating(this, 'institute_rating')"></i>
<input type="hidden" name="rating" id="institute_rating" value="" required>
<div class="invalid-feedback d-block" id="institute-rating-error" style="display: none;">Please select a rating</div>
</div>
</div>
<div class="mb-3">
<label for="institute_feedback" class="form-label">Your Feedback</label>
<textarea class="form-control" id="institute_feedback" name="feedback_text" rows="3" required placeholder="Please provide your feedback about the institute" style="border-color: #BDBDBD;"></textarea>
</div>
<div class="mb-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="is_anonymous" id="isAnonymous" style="border-color: #BDBDBD;">
<label class="form-check-label" for="isAnonymous">
Submit anonymously
</label>
</div>
</div>
<div class="d-flex justify-content-end gap-2">
<button type="button" class="btn" style="background-color: #9E9E9E; color: white;" onclick="closeFeedbackModal()">Cancel</button>
<button type="submit" class="btn" style="background-color: #3F51B5; color: white;">Submit Feedback</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- Student Feedback Modal Scripts -->
<script>
function openFeedbackModal() {
document.getElementById('feedbackModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closeFeedbackModal() {
document.getElementById('feedbackModal').style.display = 'none';
document.body.style.overflow = '';
}
function switchFeedbackTab(tabName) {
const teacherTabBtn = document.getElementById('teacher-tab-btn');
const instituteTabBtn = document.getElementById('institute-tab-btn');
const teacherContent = document.getElementById('teacher-tab-content');
const instituteContent = document.getElementById('institute-tab-content');
teacherTabBtn.classList.remove('active');
instituteTabBtn.classList.remove('active');
teacherContent.classList.remove('active');
instituteContent.classList.remove('active');
if (tabName === 'teacher') {
teacherTabBtn.classList.add('active');
teacherContent.classList.add('active');
} else if (tabName === 'institute') {
instituteTabBtn.classList.add('active');
instituteContent.classList.add('active');
}
}
function selectRating(star, inputId) {
const value = parseInt(star.getAttribute('data-value'));
document.getElementById(inputId).value = value;
// Update star display
const allStars = star.parentNode.querySelectorAll('.rating-star');
allStars.forEach(s => {
const starValue = parseInt(s.getAttribute('data-value'));
if (starValue <= value) {
s.classList.remove('far');
s.classList.add('fas');
s.classList.add('selected');
} else {
s.classList.remove('fas');
s.classList.add('far');
s.classList.remove('selected');
}
});
// Hide error message if any
const errorId = inputId === 'teacher_rating' ? 'teacher-rating-error' : 'institute-rating-error';
document.getElementById(errorId).style.display = 'none';
}
</script>
<!-- Additional Feedback Styles -->
<style>
.feedback-tabs {
display: flex;
gap: 0;
border: none;
margin-bottom: 1.5rem;
background-color: #f5f5f5;
padding: 4px;
border-radius: 8px;
width: 100%;
}
.feedback-tab-btn {
flex: 1;
padding: 12px 24px;
cursor: pointer;
border: none !important;
background-color: transparent;
color: #333;
font-weight: 500;
transition: all 0.3s ease;
border-radius: 6px;
text-align: center;
}
.feedback-tab-btn:hover:not(.active) {
background-color: rgba(63, 81, 181, 0.1);
}
.feedback-tab-btn.active {
background-color: #3F51B5 !important;
color: white !important;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.tab-pane {
display: none;
opacity: 0;
transition: opacity 0.3s ease;
}
.tab-pane.active {
display: block;
opacity: 1;
}
.rating-stars {
display: flex;
gap: 8px;
padding: 8px 0;
}
.rating-star {
cursor: pointer;
transition: all 0.2s ease;
}
.rating-star:hover,
.rating-star.active,
.rating-star.selected {
color: #FFD700 !important;
transform: scale(1.1);
}
</style>
+32
View File
@@ -0,0 +1,32 @@
{% load static %}
<!-- PDF Viewer Modal -->
<div id="pdfViewerModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closePdfViewerModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 95%; max-width: 1000px; height: 90vh; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Subject Syllabus</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closePdfViewerModal()">&times;</button>
</div>
<div style="height: calc(90vh - 60px); padding: 0;">
<iframe id="pdfViewer" style="width: 100%; height: 100%; border: none;"></iframe>
</div>
</div>
</div>
<!-- Subject Files Modal -->
<div id="subjectFilesModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeSubjectFilesModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 800px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Subject Materials</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeSubjectFilesModal()">&times;</button>
</div>
<div style="padding: 20px;">
<div id="subjectFilesList" class="list-group">
<!-- Files will be loaded here -->
</div>
</div>
</div>
</div>
<!-- Include student modals JavaScript -->
<script src="{% static 'js/student_modals.js' %}"></script>
@@ -0,0 +1,109 @@
<!-- Teacher Feedback Modal -->
<div id="feedbackModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeFeedbackModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 600px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Give Institute Feedback</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeFeedbackModal()">&times;</button>
</div>
<div style="padding: 20px;">
<form method="post" action="{% url 'submit_staff_institute_feedback' %}" id="instituteFeedbackForm">
{% csrf_token %}
<div class="mb-3">
<label for="feedback_type" class="form-label">Feedback Type</label>
<select class="form-select" id="feedback_type" name="feedback_type" required>
<option value="">Select Type</option>
{% for value, name in feedback_types %}
<option value="{{ value }}">{{ name }}</option>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label class="form-label">Rating</label>
<div class="rating-stars d-flex">
<i class="far fa-star fs-4 text-warning rating-star" data-value="1" onclick="selectRatingTeacher(this, 'teacher_modal_rating')"></i>
<i class="far fa-star fs-4 text-warning rating-star" data-value="2" onclick="selectRatingTeacher(this, 'teacher_modal_rating')"></i>
<i class="far fa-star fs-4 text-warning rating-star" data-value="3" onclick="selectRatingTeacher(this, 'teacher_modal_rating')"></i>
<i class="far fa-star fs-4 text-warning rating-star" data-value="4" onclick="selectRatingTeacher(this, 'teacher_modal_rating')"></i>
<i class="far fa-star fs-4 text-warning rating-star" data-value="5" onclick="selectRatingTeacher(this, 'teacher_modal_rating')"></i>
<input type="hidden" name="rating" id="teacher_modal_rating" value="" required>
<div class="invalid-feedback d-block" id="teacher-modal-rating-error" style="display: none;">Please select a rating</div>
</div>
</div>
<div class="mb-3">
<label for="feedback_text" class="form-label">Feedback</label>
<textarea class="form-control" id="feedback_text" name="feedback_text" rows="4" required></textarea>
</div>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="is_anonymous" name="is_anonymous">
<label class="form-check-label" for="is_anonymous">Submit anonymously</label>
</div>
<div class="d-flex justify-content-end gap-2">
<button type="button" class="btn" style="background-color: #9E9E9E; color: white;" onclick="closeFeedbackModal()">Cancel</button>
<button type="submit" class="btn" style="background-color: #3F51B5; color: white;">Submit Feedback</button>
</div>
</form>
</div>
</div>
</div>
<!-- Teacher Feedback Modal Scripts -->
<script>
function openFeedbackModal() {
document.getElementById('feedbackModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closeFeedbackModal() {
document.getElementById('feedbackModal').style.display = 'none';
document.body.style.overflow = '';
}
function selectRatingTeacher(star, inputId) {
const value = parseInt(star.getAttribute('data-value'));
document.getElementById(inputId).value = value;
// Update star display
const allStars = star.parentNode.querySelectorAll('.rating-star');
allStars.forEach(s => {
const starValue = parseInt(s.getAttribute('data-value'));
if (starValue <= value) {
s.classList.remove('far');
s.classList.add('fas');
s.classList.add('selected');
} else {
s.classList.remove('fas');
s.classList.add('far');
s.classList.remove('selected');
}
});
// Hide error message if any
const errorId = 'teacher-modal-rating-error';
document.getElementById(errorId).style.display = 'none';
}
</script>
<!-- Additional Feedback Styles -->
<style>
.rating-stars {
display: flex;
gap: 8px;
padding: 8px 0;
}
.rating-star {
cursor: pointer;
transition: all 0.2s ease;
}
.rating-star:hover,
.rating-star.active,
.rating-star.selected {
color: #FFD700 !important;
transform: scale(1.1);
}
</style>
+63
View File
@@ -0,0 +1,63 @@
<!-- Attendance Modal -->
<div id="attendanceModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeAttendanceModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 800px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Take Attendance</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeAttendanceModal()">&times;</button>
</div>
<div style="padding: 20px; max-height: 80vh; overflow-y: auto;">
<form method="post" action="/app/save-attendance/" id="quickAttendanceForm">
{% csrf_token %}
<input type="hidden" name="routine_id" id="modalRoutineId">
<input type="hidden" name="date" id="modalDate">
<div class="row mb-3">
<div class="col-md-6">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="modalTeacherAttend" name="teacher_attend">
<label class="form-check-label" for="modalTeacherAttend">Teacher Present</label>
</div>
</div>
<div class="col-md-6">
<select class="form-select" id="modalClassStatus" name="class_status">
<option value="True" selected>Conducted</option>
<option value="False">Not Conducted</option>
</select>
</div>
</div>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th width="5%">#</th>
<th width="40%">Name</th>
<th width="40%">Student ID</th>
<th width="15%">Present</th>
</tr>
</thead>
<tbody id="modalStudentList">
<!-- Students will be loaded here -->
</tbody>
</table>
</div>
<div class="mt-3 d-flex justify-content-between">
<div>
<button type="button" class="btn btn-outline-success me-2" onclick="markAllPresent()">
<i class="fas fa-check-double me-1"></i> Mark All Present
</button>
<button type="button" class="btn btn-outline-danger" onclick="markAllAbsent()">
<i class="fas fa-times-circle me-1"></i> Mark All Absent
</button>
</div>
<button type="submit" class="btn btn-primary">
<i class="fas fa-save me-1"></i> Save Attendance
</button>
</div>
</form>
</div>
</div>
</div>
<!-- Other modals can be added here -->
+32
View File
@@ -0,0 +1,32 @@
{% load static %}
<!-- Welcome Section -->
<div class="row mb-4">
<div class="col-12">
<div class="content-card welcome-section">
<div class="d-flex justify-content-between align-items-center flex-wrap">
<div class="d-flex align-items-center">
{% if user.image %}
<div class="profile-picture-container profile-sm">
<img src="{{ user.image.url }}" alt="{{ user.name }}" class="profile-picture">
</div>
{% else %}
<div class="profile-picture-container profile-sm">
<img src="{% static 'img/user.png' %}" alt="Default User" class="profile-picture">
</div>
{% endif %}
<div class="flex-grow-1">
<h2 class="mb-1">Welcome, {{ user.name }}!</h2>
<p class="text-muted mb-0">
{% if user.designation %}
{{ user.designation }} <span class="ms-2 badge bg-info text-white">ID: {{ user.id }}</span>
{% else %}
Student <span class="ms-2 badge bg-info text-white">ID: {{ user.id }}</span>
{% endif %}
</p>
</div>
</div>
</div>
</div>
</div>
</div>
+831 -601
View File
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,9 @@
Dear {{ user_name }},
Your OTP for secure access is: {{ otp }}. Valid for {{ expiry_time }} minutes.
For security, do not share this OTP. If you didn't request this, please ignore.
Best regards,
Student Management System
support@sms.com
+189 -443
View File
@@ -1,94 +1,19 @@
{% extends "base.html" %}
{% extends 'base.html' %}
{% load static %}
{% load tz %}
{% load app_filters %}
{% block extrastyle %}
{{ block.super }}
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet" />
<!-- Viewport meta tag for responsiveness -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- Custom Dashboard CSS -->
<link href="{% static 'css/dashboard.css' %}" rel="stylesheet" />
<!-- Responsive overrides -->
<style>
@media (max-width: 768px) {
.welcome-section h2 {
font-size: 1.5rem;
}
.summary-card .card-body {
padding: 0.75rem;
}
.table-responsive {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
.bottom-nav {
padding-bottom: env(safe-area-inset-bottom);
}
.profile-actions {
margin-top: 1rem;
width: 100%;
justify-content: center;
}
}
@media (max-width: 576px) {
.container-fluid {
padding-left: 10px;
padding-right: 10px;
}
.col-md-6, .col-lg-3, .col-md-4, .col-md-3 {
padding-left: 5px;
padding-right: 5px;
}
.row {
margin-left: -5px;
margin-right: -5px;
}
.modal-body {
padding: 10px;
}
}
</style>
{% endblock %}
{% block extrahead %}
{{ block.super }}
<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- Bootstrap JS Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<!-- Custom Dashboard JS -->
<script src="{% static 'js/dashboard.js' %}"></script>
{% endblock %}
{% block content %}
<!-- Add CSRF token to the page -->
{% csrf_token %}
<div class="container-fluid py-4">
<!-- Welcome Section -->
<div class="row mb-4">
<div class="col-12">
<div class="content-card welcome-section">
<div class="d-flex justify-content-between align-items-center flex-wrap">
{% if student.image %}
<img src="{{ student.image.url }}" alt="{{ student.name }}" class="rounded-circle me-3" style="width: 60px; height: 60px; object-fit: cover;">
{% else %}
<img src="{% static 'img/user.png' %}" alt="Default User" class="rounded-circle me-3" style="width: 60px; height: 60px; object-fit: cover;">
{% endif %}
<div class="flex-grow-1">
<h2 class="mb-1">Welcome, {{ student.name }}!</h2>
<p class="text-muted mb-0">Student <span class="ms-2 badge bg-info text-white">ID: {{ student.id }}</span></p>
</div>
</div>
</div>
</div>
</div>
{% include 'components/welcome_section.html' with user=student %}
<!-- Content Sections -->
<div class="content-section active" id="dashboardSection">
<!-- Dashboard Content -->
<div id="dashboardSection" class="content-section" style="display: block;">
<!-- Summary Cards -->
<div class="row mb-4">
<!-- Attendance Summary Card -->
@@ -98,20 +23,48 @@
<h5 class="card-title mb-0 small"><i class="fas fa-calendar-check me-1"></i> Attendance Summary</h5>
</div>
<div class="card-body p-2">
<div class="d-flex justify-content-between align-items-center mb-2">
<div class="d-flex justify-content-between align-items-center mb-3">
<div>
<small class="text-muted d-block mb-1">Total Classes</small>
<h3 class="fw-bold mb-0">{{ attendance_summary.total_classes }}</h3>
<span class="d-block text-muted small">Days Attended</span>
<h3>{{ attendance_summary.classes_attended }}</h3>
{% if attendance_summary.actual_classes %}
<span class="d-block text-muted small mt-2">Classes Recorded</span>
<h5>{{ attendance_summary.actual_classes }}</h5>
{% endif %}
</div>
<div class="text-end">
<small class="text-muted d-block mb-1">Attendance Rate</small>
<h3 class="fw-bold text-primary mb-0">{{ attendance_summary.attendance_percentage|floatformat:1 }}%</h3>
<span class="d-block text-muted small">Attendance Rate</span>
<h3 class="text-primary">{{ attendance_summary.attendance_percentage|floatformat:1 }}%</h3>
{% if attendance_summary.actual_percentage %}
<span class="d-block text-muted small mt-2">Rate (Recorded Only)</span>
<h5 class="text-primary">{{ attendance_summary.actual_percentage|floatformat:1 }}%</h5>
{% endif %}
</div>
</div>
<div class="d-flex justify-content-between mt-3">
<span class="badge bg-success p-2"><i class="fas fa-fire me-1"></i> Current: {{ attendance_summary.current_streak }} days</span>
<span class="badge bg-info p-2"><i class="fas fa-trophy me-1"></i> Best: {{ attendance_summary.longest_streak }} days</span>
<div class="d-flex justify-content-between mb-1">
<div><small>0%</small></div>
<div><small>100%</small></div>
</div>
<div class="progress mb-2 position-relative" style="height: 15px; border-radius: 20px; background-color: #f0f0f0;">
<!-- Target marker at 75% -->
<div class="position-absolute" style="left: 75%; top: -10px; bottom: -10px; width: 2px; background-color: #dc3545;"></div>
<div class="progress-bar {% if attendance_summary.attendance_percentage < 75 %}bg-danger{% else %}bg-success{% endif %}"
role="progressbar"
style="width: {{ attendance_summary.attendance_percentage }}%;"
aria-valuenow="{{ attendance_summary.attendance_percentage }}"
aria-valuemin="0"
aria-valuemax="100"></div>
</div>
<div class="d-flex justify-content-between align-items-center">
<small class="text-muted">Minimum required: 75%</small>
{% if attendance_summary.attendance_percentage < 75 %}
<small class="text-danger"><i class="fas fa-exclamation-triangle"></i> Below minimum requirement</small>
{% endif %}
</div>
<!-- <small class="text-muted d-block text-center">
Based on attendance out of {% if student.course and student.course.duration_type == "Year" %}365 days per year{% else %}180 days per semester{% endif %}
</small> -->
</div>
</div>
</div>
@@ -348,7 +301,7 @@
</div>
</div>
<div class="content-section" id="subjectsSection">
<div class="content-section" id="subjectsSection" style="display: none;">
<div class="content-card">
<h3 class="text-xl font-semibold mb-4">
<i class="fas fa-book me-2"></i>Current Semester Subjects
@@ -381,7 +334,7 @@
</div>
</div>
<div class="content-section" id="routineSection">
<div class="content-section" id="routineSection" style="display: none;">
<div class="content-card">
<h3 class="text-xl font-semibold mb-4">
<i class="fas fa-calendar-alt mr-2"></i> Class Routine
@@ -416,47 +369,10 @@
</tbody>
</table>
</div>
<!-- Attendance Record Section -->
<div class="content-card mt-4">
<h3 class="text-xl font-semibold mb-4">
<i class="fas fa-history mr-2"></i> Attendance Record
</h3>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Subject</th>
<th>Teacher</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for record in attendance_records %}
<tr>
<td>{{ record.attendance.date|date:"M d, Y" }}</td>
<td>{{ record.attendance.routine.name }}</td>
<td>{{ record.attendance.teacher.name }}</td>
<td>
<span class="status-badge {% if record.student_attend %}bg-success{% else %}bg-danger{% endif %}">
{% if record.student_attend %}Present{% else %}Absent{% endif %}
</span>
</td>
</tr>
{% empty %}
<tr>
<td colspan="4" class="text-center">No attendance records found.</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="content-section" id="leaveSection">
<div class="content-section" id="leaveSection" style="display: none;">
<div class="content-card">
<h3 class="text-xl font-semibold mb-4">
<i class="fas fa-calendar-times mr-2"></i> Leave Management
@@ -472,7 +388,8 @@
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Start Date</th>
<th>End Date</th>
<th>Message</th>
<th>Status</th>
<th>Created At</th>
@@ -481,7 +398,8 @@
<tbody>
{% for leave in student_leaves %}
<tr>
<td>{{ leave.date|date:"M d, Y" }}</td>
<td>{{ leave.start_date|date:"M d, Y" }}</td>
<td>{{ leave.end_date|date:"M d, Y" }}</td>
<td>{{ leave.message }}</td>
<td>
<span class="status-badge {% if leave.status == 1 %}bg-success{% elif leave.status == 2 %}bg-danger{% else %}bg-warning{% endif %}">
@@ -492,7 +410,7 @@
</tr>
{% empty %}
<tr>
<td colspan="4" class="text-center">No leave requests found.</td>
<td colspan="5" class="text-center">No leave requests found.</td>
</tr>
{% endfor %}
</tbody>
@@ -501,7 +419,7 @@
</div>
</div>
<div class="content-section" id="feedbackSection">
<div class="content-section" id="feedbackSection" style="display: none;">
<div class="content-card">
<h3 class="text-xl font-semibold mb-4">
<i class="fas fa-comments mr-2"></i> Feedback
@@ -589,7 +507,7 @@
</div>
</div>
<div class="content-section" id="noticeSection">
<div class="content-section" id="noticeSection" style="display: none;">
<div class="content-card">
<h3 class="text-xl font-semibold mb-4">
<i class="fas fa-bullhorn mr-2"></i> Notices
@@ -624,7 +542,7 @@
</div>
</div>
<div class="content-section" id="profileSection">
<div class="content-section" id="profileSection" style="display: none;">
<div class="content-card">
<h3 class="text-xl font-semibold mb-4">
<i class="fas fa-user mr-2"></i> Profile Information
@@ -635,9 +553,13 @@
<div class="d-flex flex-wrap align-items-center justify-content-between">
<div class="d-flex align-items-center mb-3 mb-md-0">
{% if student.image %}
<img src="{{ student.image.url }}" alt="{{ student.name }}" class="rounded-circle me-3" style="width: 80px; height: 80px; object-fit: cover;">
<div class="profile-picture-container profile-md">
<img src="{{ student.image.url }}" alt="{{ student.name }}" class="profile-picture">
</div>
{% else %}
<img src="{% static 'img/user.png' %}" alt="Default User" class="rounded-circle me-3" style="width: 80px; height: 80px; object-fit: cover;">
<div class="profile-picture-container profile-md">
<img src="{% static 'img/user.png' %}" alt="Default User" class="profile-picture">
</div>
{% endif %}
<div>
<h4 class="mb-1">{{ student.name }}</h4>
@@ -779,319 +701,143 @@
</div>
</div>
</div>
<!-- Edit Profile Modal -->
<div id="profileModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeProfileModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 500px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Update Profile Picture</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeProfileModal()">&times;</button>
</div>
<div style="padding: 20px;">
<!-- Profile Picture Upload Form -->
<form action="{% url 'update_profile' %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<div style="text-align: center; margin-bottom: 20px;">
{% if student.image %}
<img src="{{ student.image.url }}" alt="{{ student.name }}" class="rounded-circle" style="width: 120px; height: 120px; object-fit: cover; border: 3px solid #3F51B5;">
{% else %}
<img src="{% static 'img/user.png' %}" alt="Default User" class="rounded-circle" style="width: 120px; height: 120px; object-fit: cover; border: 3px solid #3F51B5;">
{% endif %}
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 8px; font-weight: 500;">Select New Profile Picture</label>
<input type="file" name="image" required style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
</div>
<div style="display: flex; justify-content: space-between;">
<button type="button" onclick="closeProfileModal()" style="background-color: #9E9E9E; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer;">Cancel</button>
<button type="submit" style="background-color: #3F51B5; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer;">Update Picture</button>
</div>
</form>
</div>
</div>
</div>
<!-- Change Password Modal -->
<div id="passwordModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closePasswordModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 500px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Change Password</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closePasswordModal()">&times;</button>
</div>
<div style="padding: 20px;">
<!-- Change Password Form -->
<form action="{% url 'change_password' %}" method="post">
{% csrf_token %}
<div style="margin-bottom: 15px;">
<label for="current_password" style="display: block; margin-bottom: 8px; font-weight: 500;">Current Password</label>
<input type="password" id="current_password" name="current_password" required style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
</div>
<div style="margin-bottom: 15px;">
<label for="new_password" style="display: block; margin-bottom: 8px; font-weight: 500;">New Password</label>
<input type="password" id="new_password" name="new_password" required style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
</div>
<div style="margin-bottom: 15px;">
<label for="confirm_password" style="display: block; margin-bottom: 8px; font-weight: 500;">Confirm New Password</label>
<input type="password" id="confirm_password" name="confirm_password" required style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;">
</div>
<button type="submit" style="background-color: #3F51B5; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; width: 100%;">Change Password</button>
</form>
</div>
</div>
</div>
</div>
<!-- Leave Request Modal -->
<div id="customLeaveModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeLeaveModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 500px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Request Leave</h5>
<button id="closeCustomModal" style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeLeaveModal()">&times;</button>
</div>
<form action="{% url 'request_leave' %}" method="post">
{% csrf_token %}
<div style="padding: 20px;">
<div style="margin-bottom: 15px;">
<label for="customLeaveDate" style="display: block; margin-bottom: 8px; font-weight: 500;">Date</label>
<input type="date" id="customLeaveDate" name="date" style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;" required>
</div>
<div style="margin-bottom: 15px;">
<label for="customLeaveMessage" style="display: block; margin-bottom: 8px; font-weight: 500;">Reason</label>
<textarea id="customLeaveMessage" name="message" rows="3" style="width: 100%; padding: 10px; border: 1px solid #BDBDBD; border-radius: 4px; box-sizing: border-box;" required></textarea>
</div>
</div>
<div style="padding: 15px; border-top: 1px solid #EEEEEE; text-align: right; display: flex; flex-wrap: wrap; justify-content: flex-end;">
<button type="button" id="cancelCustomModal" style="background-color: #9E9E9E; color: white; border: none; padding: 8px 16px; border-radius: 4px; margin-right: 10px; margin-bottom: 10px; cursor: pointer; font-size: 14px;" onclick="closeLeaveModal()">Cancel</button>
<button type="submit" style="background-color: #3F51B5; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px; margin-bottom: 10px;">Submit Request</button>
</div>
</form>
</div>
</div>
<!-- Common Modals -->
{% include 'components/common_modals.html' with user=student %}
<!-- Feedback Modal -->
<div id="feedbackModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeFeedbackModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 600px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Give Feedback</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeFeedbackModal()">&times;</button>
</div>
<div style="padding: 20px;">
<!-- Custom Tab Navigation -->
<div class="feedback-tabs d-flex mb-4">
<div id="teacher-tab-btn" class="feedback-tab-btn active" onclick="switchFeedbackTab('teacher')" style="background-color: #3F51B5; color: white;">
Teacher Feedback
</div>
<div id="institute-tab-btn" class="feedback-tab-btn" onclick="switchFeedbackTab('institute')" style="border-color: #3F51B5;">
Institute Feedback
</div>
</div>
<!-- Tab Content -->
<div class="tab-content">
<!-- Teacher Feedback Form -->
<div id="teacher-tab-content" class="tab-pane active">
<form method="post" action="{% url 'submit_feedback' %}" id="teacherFeedbackForm">
{% csrf_token %}
<input type="hidden" name="feedback_type" value="teacher">
<div class="mb-3">
<label for="teacher_select" class="form-label">Select Teacher</label>
<select class="form-select" id="teacher_select" name="teacher_id" required style="border-color: #BDBDBD;">
<option value="">Select Teacher</option>
{% for teacher in teachers %}
<option value="{{ teacher.id }}">{{ teacher.name }} - {{ teacher.designation }}</option>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label class="form-label">Rating</label>
<div id="teacher-rating" class="rating-container d-flex justify-content-start gap-2">
{% for i in "12345"|make_list %}
<div class="form-check">
<input class="form-check-input visually-hidden" type="radio" name="rating" value="{{ i }}" id="teacherStar{{ i }}" required>
<label class="form-check-label" for="teacherStar{{ i }}">
<i class="far fa-star fs-4" style="color: #FFC107;"></i>
</label>
</div>
{% endfor %}
</div>
</div>
<div class="mb-3">
<label for="teacher_feedback" class="form-label">Your Feedback</label>
<textarea class="form-control" id="teacher_feedback" name="feedback_text" rows="3" required style="border-color: #BDBDBD;"></textarea>
</div>
<div class="d-flex justify-content-end gap-2">
<button type="button" class="btn" style="background-color: #9E9E9E; color: white;" onclick="closeFeedbackModal()">Cancel</button>
<button type="submit" class="btn" style="background-color: #3F51B5; color: white;">Submit Feedback</button>
</div>
</form>
</div>
<!-- Institute Feedback Form -->
<div id="institute-tab-content" class="tab-pane">
<form method="post" action="{% url 'submit_feedback' %}" id="instituteFeedbackForm">
{% csrf_token %}
<input type="hidden" name="feedback_type" value="institute">
<div class="mb-3">
<label for="feedback_type_select" class="form-label">Feedback Category</label>
<select class="form-select" id="feedback_type_select" name="category" required style="border-color: #BDBDBD;">
<option value="">Select Category</option>
<option value="General">General</option>
<option value="Facilities">Facilities</option>
<option value="Teaching">Teaching Quality</option>
<option value="Infrastructure">Infrastructure</option>
<option value="Administration">Administration</option>
</select>
</div>
<div class="mb-3">
<label class="form-label">Rating</label>
<div id="institute-rating" class="rating-container d-flex justify-content-start gap-2">
{% for i in "12345"|make_list %}
<div class="form-check">
<input class="form-check-input visually-hidden" type="radio" name="rating" value="{{ i }}" id="instituteStar{{ i }}" required>
<label class="form-check-label" for="instituteStar{{ i }}">
<i class="far fa-star fs-4" style="color: #FFC107;"></i>
</label>
</div>
{% endfor %}
</div>
</div>
<div class="mb-3">
<label for="institute_feedback" class="form-label">Your Feedback</label>
<textarea class="form-control" id="institute_feedback" name="feedback_text" rows="3" required placeholder="Please provide your feedback about the institute" style="border-color: #BDBDBD;"></textarea>
</div>
<div class="mb-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="is_anonymous" id="isAnonymous" style="border-color: #BDBDBD;">
<label class="form-check-label" for="isAnonymous">
Submit anonymously
</label>
</div>
</div>
<div class="d-flex justify-content-end gap-2">
<button type="button" class="btn" style="background-color: #9E9E9E; color: white;" onclick="closeFeedbackModal()">Cancel</button>
<button type="submit" class="btn" style="background-color: #3F51B5; color: white;">Submit Feedback</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- Student-specific Modals -->
{% include 'components/student_modals.html' %}
{% include 'components/student_feedback_modal.html' %}
<!-- PDF Viewer Modal -->
<div id="pdfViewerModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closePdfViewerModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 95%; max-width: 1000px; height: 90vh; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Subject Syllabus</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closePdfViewerModal()">&times;</button>
</div>
<div style="height: calc(90vh - 60px); padding: 0;">
<iframe id="pdfViewer" style="width: 100%; height: 100%; border: none;"></iframe>
</div>
</div>
</div>
<!-- Subject Files Modal -->
<div id="subjectFilesModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeSubjectFilesModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 800px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Subject Files</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeSubjectFilesModal()">&times;</button>
</div>
<div style="padding: 20px;">
<div id="subjectFilesList" class="list-group">
<!-- Files will be loaded here -->
</div>
</div>
</div>
</div>
<!-- Additional responsive scripts -->
<script>
document.addEventListener("DOMContentLoaded", function() {
// Make all tables responsive
const tables = document.querySelectorAll('table:not(.table-responsive)');
tables.forEach(table => {
const wrapper = document.createElement('div');
wrapper.classList.add('table-responsive');
table.parentNode.insertBefore(wrapper, table);
wrapper.appendChild(table);
});
// Adjust card layout on small screens
function adjustLayout() {
const windowWidth = window.innerWidth;
if (windowWidth < 768) {
// Smaller screens adjustments
document.querySelectorAll('.card-title').forEach(title => {
title.style.fontSize = '1rem';
});
} else {
// Reset for larger screens
document.querySelectorAll('.card-title').forEach(title => {
title.style.fontSize = '';
});
}
}
// Run on load and resize
adjustLayout();
window.addEventListener('resize', adjustLayout);
});
</script>
<!-- Add fix script -->
<script src="{% static 'js/navigation.js' %}"></script>
<script src="{% static 'js/rating.js' %}"></script>
<!-- Bottom Navigation -->
<div class="bottom-nav">
<div class="nav-container">
<a href="#" class="nav-item active" data-section="dashboard">
<i class="fas fa-home"></i>
<span class="d-none d-sm-block">Dashboard</span>
</a>
<a href="#" class="nav-item" data-section="subjects">
<i class="fas fa-book"></i>
<span class="d-none d-sm-block">Subjects</span>
</a>
<a href="#" class="nav-item" data-section="routine">
<i class="fas fa-calendar-alt"></i>
<span class="d-none d-sm-block">Routine</span>
</a>
<a href="#" class="nav-item" data-section="leave">
<i class="fas fa-calendar-times"></i>
<span class="d-none d-sm-block">Leaves</span>
</a>
<a href="#" class="nav-item" data-section="feedback">
<i class="fas fa-comments"></i>
<span class="d-none d-sm-block">Feedback</span>
</a>
<a href="#" class="nav-item" data-section="notice">
<i class="fas fa-bullhorn"></i>
<span class="d-none d-sm-block">Notices</span>
</a>
<a href="#" class="nav-item" data-section="profile">
<i class="fas fa-user"></i>
<span class="d-none d-sm-block">Profile</span>
</a>
<a href="#" class="nav-item" onclick="document.getElementById('logoutForm').submit(); return false;">
<i class="fas fa-sign-out-alt"></i>
<span class="d-none d-sm-block">Logout</span>
</a>
<form id="logoutForm" method="post" action="{% url 'logout' %}" style="display: none;">
{% csrf_token %}
</form>
{% include 'components/bottom_nav.html' with user=student %}
<!-- Add a new attendance section -->
<div class="content-section" id="attendanceSection" style="display: none;">
<div class="content-card">
<h3 class="text-xl font-semibold mb-4">
<i class="fas fa-clipboard-check me-2"></i> Attendance Record
</h3>
<!-- Attendance Summary -->
<div class="row mb-4">
<div class="col-md-4">
<div class="card border-0 shadow-sm mb-3">
<div class="card-body">
<h5 class="card-title mb-3"><i class="fas fa-chart-pie text-primary me-2"></i>Attendance Summary</h5>
<div class="d-flex justify-content-between align-items-center mb-3">
<div>
<span class="d-block text-muted small">Days Attended</span>
<h3>{{ attendance_summary.classes_attended }}</h3>
{% if attendance_summary.actual_classes %}
<span class="d-block text-muted small mt-2">Classes Recorded</span>
<h5>{{ attendance_summary.actual_classes }}</h5>
{% endif %}
</div>
<div class="text-end">
<span class="d-block text-muted small">Attendance Rate</span>
<h3 class="text-primary">{{ attendance_summary.attendance_percentage|floatformat:1 }}%</h3>
{% if attendance_summary.actual_percentage %}
<span class="d-block text-muted small mt-2">Rate (Recorded Only)</span>
<h5 class="text-primary">{{ attendance_summary.actual_percentage|floatformat:1 }}%</h5>
{% endif %}
</div>
</div>
<div class="progress mb-2 position-relative" style="height: 15px; border-radius: 20px; background-color: #f0f0f0;">
<!-- Target marker at 75% -->
<div class="position-absolute" style="left: 75%; top: -10px; bottom: -10px; width: 2px; background-color: #dc3545;"></div>
<div class="progress-bar {% if attendance_summary.attendance_percentage < 75 %}bg-danger{% else %}bg-success{% endif %}"
role="progressbar"
style="width: {{ attendance_summary.attendance_percentage }}%;"
aria-valuenow="{{ attendance_summary.attendance_percentage }}"
aria-valuemin="0"
aria-valuemax="100"></div>
</div>
<div class="d-flex justify-content-between align-items-center">
<small class="text-muted">Minimum required: 75%</small>
{% if attendance_summary.attendance_percentage < 75 %}
<small class="text-danger"><i class="fas fa-exclamation-triangle"></i> Below minimum requirement</small>
{% endif %}
</div>
<!-- <small class="text-muted d-block text-center">
Based on attendance out of {% if student.course and student.course.duration_type == "Year" %}365 days per year{% else %}180 days per semester{% endif %}
</small> -->
</div>
</div>
</div>
<div class="col-md-8">
<div class="card border-0 shadow-sm mb-3">
<div class="card-body">
<h5 class="card-title mb-3"><i class="fas fa-info-circle text-info me-2"></i>Attendance Details</h5>
<div class="row">
<div class="col-md-3 mb-3">
<div class="text-center p-3 bg-light rounded">
<div class="display-6 text-success mb-1">{{ attendance_summary.present_count }}</div>
<div class="small text-muted">Present</div>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="text-center p-3 bg-light rounded">
<div class="display-6 text-danger mb-1">{{ attendance_summary.absent_count }}</div>
<div class="small text-muted">Absent</div>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="text-center p-3 bg-light rounded">
<div class="display-6 text-success mb-1">{{ attendance_summary.current_streak }}</div>
<div class="small text-muted">Current Streak</div>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="text-center p-3 bg-light rounded">
<div class="display-6 text-info mb-1">{{ attendance_summary.longest_streak }}</div>
<div class="small text-muted">Best Streak</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Attendance Records Table -->
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Subject</th>
<th>Teacher</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for record in attendance_records %}
<tr>
<td>{{ record.attendance.date|date:"M d, Y" }}</td>
<td>{{ record.attendance.routine.subject.name }}</td>
<td>{{ record.attendance.teacher.name }}</td>
<td>
<span class="status-badge {% if record.student_attend %}bg-success{% else %}bg-danger{% endif %}">
{% if record.student_attend %}Present{% else %}Absent{% endif %}
</span>
</td>
</tr>
{% empty %}
<tr>
<td colspan="4" class="text-center">No attendance records found.</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<!-- Toast Notification -->
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11000">
<div id="notificationToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<i class="fas fa-bell me-2"></i>
<strong class="me-auto" id="toastTitle">Notification</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body" id="toastMessage">
<!-- Notification message will appear here -->
</div>
</div>
</div>
{% endblock %}
+327
View File
@@ -0,0 +1,327 @@
{% extends 'base.html' %}
{% load static %}
{% block content %}
<!-- Add CSRF token to the page -->
{% csrf_token %}
<div class="container-fluid py-4">
<!-- Welcome Section -->
{% include 'components/welcome_section.html' with user=teacher %}
<!-- Subject Files Content -->
<div class="content-section active">
<div class="content-card">
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h3 class="text-xl font-semibold mb-0">
<i class="fas fa-book me-2"></i>Manage Subject Materials
</h3>
<a href="{% url 'teacherDashboard' %}#subjectsSection" class="btn btn-sm btn-link text-decoration-none ps-0" id="backToSubjectsBtn">
<i class="fas fa-arrow-left me-1"></i> Back to Subjects
</a>
</div>
<button class="btn btn-primary" onclick="openUploadModal()">
<i class="fas fa-file-upload me-1"></i> Upload New Material
</button>
</div>
{% if subjects %}
<div class="row">
{% for subject in subjects %}
<div class="col-md-6 col-lg-4 mb-4">
<div class="card border-0 shadow-sm h-100">
<div class="card-header bg-light py-3">
<h5 class="card-title mb-0">{{ subject.name }}</h5>
<p class="text-muted mb-0 small">{{ subject.course }} - {{ subject.semester_or_year }}</p>
</div>
<div class="card-body">
<p class="text-muted small mb-3">
<i class="fas fa-file me-1"></i> {{ subject.files_count }} file(s) available
</p>
{% if subject.files %}
<div class="list-group">
{% for file in subject.files %}
<div class="list-group-item list-group-item-action {% if file.file_type == 'syllabus' %}bg-light{% endif %}">
<div class="d-flex w-100 justify-content-between align-items-start">
<div>
<h6 class="mb-1">
{% if file.file_type == 'syllabus' %}
<i class="fas fa-file-pdf text-danger me-2"></i>
{% else %}
<i class="fas fa-file-alt text-primary me-2"></i>
{% endif %}
{{ file.title }}
</h6>
<p class="mb-1 small">
{% if file.description %}{{ file.description }}{% endif %}
</p>
<small class="text-muted">
{% if file.file_type == 'syllabus' %}
<span class="badge bg-info">Syllabus</span>
{% else %}
<span class="badge bg-primary">Study Material</span>
{% endif %}
{% if file.uploaded_at %}
<span class="ms-1">Uploaded {{ file.uploaded_at|timesince }} ago</span>
{% endif %}
{% if file.uploaded_by %}
<span class="ms-1">by {{ file.uploaded_by }}</span>
{% endif %}
</small>
</div>
<div class="d-flex flex-column align-items-end">
<a href="{{ file.file_url }}" class="btn btn-sm btn-outline-primary mb-1" target="_blank">
<i class="fas fa-download me-1"></i> Download
</a>
{% if file.file_type == 'syllabus' %}
<a href="{{ file.file_url }}" class="btn btn-sm btn-outline-secondary" target="_blank">
<i class="fas fa-eye me-1"></i> View Syllabus
</a>
{% else %}
<button class="btn btn-sm btn-outline-danger" onclick="deleteFile('{{ file.id }}')">
<i class="fas fa-trash"></i>
</button>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
{% else %}
<div class="alert alert-info">
<i class="fas fa-info-circle me-2"></i>No files available for this subject.
</div>
{% endif %}
<div class="mt-3">
<button class="btn btn-sm btn-primary w-100" onclick="openUploadModal('{{ subject.id }}')">
<i class="fas fa-file-upload me-1"></i> Upload to {{ subject.name }}
</button>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% else %}
<div class="alert alert-info">
<i class="fas fa-info-circle me-2"></i>You don't have any subjects assigned.
</div>
{% endif %}
</div>
</div>
</div>
<!-- Upload File Modal -->
<div id="uploadFileModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeUploadModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 600px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #3F51B5; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Upload Study Material</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeUploadModal()">&times;</button>
</div>
<div style="padding: 20px;">
<form id="uploadFileForm" method="post" action="/app/manage-subject-files/" enctype="multipart/form-data">
{% csrf_token %}
<div class="mb-3">
<label for="subject_id" class="form-label">Subject</label>
<select class="form-select" id="subject_id" name="subject_id" required>
<option value="">Select a subject</option>
{% for subject in subjects %}
<option value="{{ subject.id }}">{{ subject.name }} ({{ subject.course }})</option>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label for="title" class="form-label">Title</label>
<input type="text" class="form-control" id="title" name="title" required placeholder="e.g. Chapter 1 Notes">
</div>
<div class="mb-3">
<label for="description" class="form-label">Description (Optional)</label>
<textarea class="form-control" id="description" name="description" rows="2" placeholder="Brief description of the material"></textarea>
</div>
<div class="mb-3">
<label for="file" class="form-label">File</label>
<input type="file" class="form-control" id="file" name="file" required>
<div class="form-text">Upload PDF, DOCX, PPT or other study materials. Max file size: 10MB</div>
</div>
<div id="uploadResponse" style="display: none;" class="alert mb-3"></div>
<div class="d-flex justify-content-end">
<button type="button" class="btn btn-secondary me-2" onclick="closeUploadModal()">Cancel</button>
<button type="submit" class="btn btn-primary">
<i class="fas fa-upload me-1"></i> Upload
</button>
</div>
</form>
</div>
</div>
</div>
<!-- Confirmation Modal -->
<div id="confirmationModal" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10000;" onclick="if(event.target === this) closeConfirmationModal();">
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 400px; background-color: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">
<div style="background-color: #f44336; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center;">
<h5 style="margin: 0; font-size: 18px;">Confirm Deletion</h5>
<button style="background: none; border: none; color: white; font-size: 24px; cursor: pointer; line-height: 24px;" onclick="closeConfirmationModal()">&times;</button>
</div>
<div style="padding: 20px;">
<p class="mb-4">Are you sure you want to delete this file? This action cannot be undone.</p>
<div class="d-flex justify-content-end">
<button type="button" class="btn btn-secondary me-2" onclick="closeConfirmationModal()">Cancel</button>
<button type="button" class="btn btn-danger" id="confirmDeleteBtn">
<i class="fas fa-trash me-1"></i> Delete
</button>
</div>
</div>
</div>
</div>
<!-- Bottom Navigation -->
{% include 'components/bottom_nav.html' with user=teacher %}
<script>
// Modal Functions
function openUploadModal(subjectId = '') {
const modal = document.getElementById('uploadFileModal');
const subjectSelect = document.getElementById('subject_id');
const responseDiv = document.getElementById('uploadResponse');
// Reset the form
document.getElementById('uploadFileForm').reset();
responseDiv.style.display = 'none';
// If a subject ID was provided, pre-select it
if (subjectId) {
subjectSelect.value = subjectId;
}
modal.style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closeUploadModal() {
document.getElementById('uploadFileModal').style.display = 'none';
document.body.style.overflow = '';
}
let fileIdToDelete = null;
function deleteFile(fileId) {
fileIdToDelete = fileId;
document.getElementById('confirmationModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closeConfirmationModal() {
document.getElementById('confirmationModal').style.display = 'none';
document.body.style.overflow = '';
fileIdToDelete = null;
}
// Form Submission and AJAX Functions
document.addEventListener('DOMContentLoaded', function() {
// File upload form submission
const uploadForm = document.getElementById('uploadFileForm');
uploadForm.addEventListener('submit', function(e) {
e.preventDefault();
const formData = new FormData(uploadForm);
const submitBtn = uploadForm.querySelector('button[type="submit"]');
const responseDiv = document.getElementById('uploadResponse');
// Disable the submit button and show loading state
submitBtn.disabled = true;
submitBtn.innerHTML = '<i class="fas fa-spinner fa-spin me-1"></i> Uploading...';
fetch('/app/manage-subject-files/', {
method: 'POST',
body: formData,
credentials: 'same-origin',
})
.then(response => response.json())
.then(data => {
responseDiv.style.display = 'block';
if (data.success) {
responseDiv.className = 'alert alert-success mb-3';
responseDiv.innerHTML = '<i class="fas fa-check-circle me-1"></i> ' + data.message;
// Reload the page after a short delay to show the new file
setTimeout(() => {
window.location.reload();
}, 1500);
} else {
responseDiv.className = 'alert alert-danger mb-3';
responseDiv.innerHTML = '<i class="fas fa-exclamation-circle me-1"></i> ' + data.message;
}
})
.catch(error => {
responseDiv.style.display = 'block';
responseDiv.className = 'alert alert-danger mb-3';
responseDiv.innerHTML = '<i class="fas fa-exclamation-circle me-1"></i> An error occurred while uploading the file.';
console.error('Error:', error);
})
.finally(() => {
// Re-enable the submit button
submitBtn.disabled = false;
submitBtn.innerHTML = '<i class="fas fa-upload me-1"></i> Upload';
});
});
// Delete file confirmation
const confirmDeleteBtn = document.getElementById('confirmDeleteBtn');
confirmDeleteBtn.addEventListener('click', function() {
if (!fileIdToDelete) return;
// Disable the button and show loading state
confirmDeleteBtn.disabled = true;
confirmDeleteBtn.innerHTML = '<i class="fas fa-spinner fa-spin me-1"></i> Deleting...';
const formData = new FormData();
formData.append('file_id', fileIdToDelete);
formData.append('csrfmiddlewaretoken', document.querySelector('[name=csrfmiddlewaretoken]').value);
fetch('/app/delete-subject-file/', {
method: 'POST',
body: formData,
credentials: 'same-origin',
})
.then(response => response.json())
.then(data => {
if (data.success) {
// Close the modal and reload the page to show the updated list
closeConfirmationModal();
window.location.reload();
} else {
alert('Error: ' + data.message);
closeConfirmationModal();
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while deleting the file.');
closeConfirmationModal();
});
});
});
// Ensure back button properly navigates to subjects section
document.addEventListener('DOMContentLoaded', function() {
const backBtn = document.getElementById('backToSubjectsBtn');
if (backBtn) {
backBtn.addEventListener('click', function(e) {
// Store in sessionStorage that we should activate subjects section
sessionStorage.setItem('activateSection', 'subjectsSection');
});
}
});
</script>
{% endblock %}
File diff suppressed because it is too large. Load diff