| <!DOCTYPE html>
|
| <html lang="en">
|
| <head>
|
| <meta charset="UTF-8">
|
| <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| <title>Teacher Dashboard</title>
|
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/css/bootstrap.min.css">
|
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
| <style>
|
| :root {
|
| --primary: #1a4a7c;
|
| --secondary: #3498db;
|
| --success: #2ecc71;
|
| --warning: #f39c12;
|
| --danger: #e74c3c;
|
| --info: #2980b9;
|
| --light: #ecf0f1;
|
| --dark: #2c3e50;
|
| --white: #ffffff;
|
| --gray: #bdc3c7;
|
| --border-radius: 8px;
|
| --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| }
|
| body {
|
| background: linear-gradient(135deg, #f0f4f8 0%, #d7e1ec 100%);
|
| min-height: 100vh;
|
| font-family: var(--font-main);
|
| padding: 40px 20px;
|
| color: var(--dark);
|
| }
|
| .container {
|
| max-width: 1140px;
|
| }
|
| .dashboard-box {
|
| background-color: var(--white);
|
| border-radius: var(--border-radius);
|
| padding: 30px;
|
| box-shadow: 0 4px 12px rgba(0,0,0,0.08);
|
| margin-bottom: 30px;
|
| border-top: 4px solid var(--primary);
|
| transition: all 0.3s ease;
|
| }
|
| .dashboard-box:hover {
|
| box-shadow: 0 6px 16px rgba(0,0,0,0.12);
|
| }
|
| h1 {
|
| color: var(--primary);
|
| margin-bottom: 25px;
|
| text-align: center;
|
| font-weight: 600;
|
| font-size: 2.2rem;
|
| }
|
| h2 {
|
| color: var(--primary);
|
| margin-bottom: 20px;
|
| font-weight: 500;
|
| font-size: 1.6rem;
|
| border-bottom: 2px solid rgba(26, 74, 124, 0.2);
|
| padding-bottom: 10px;
|
| }
|
| h3 {
|
| color: var(--primary);
|
| font-weight: 500;
|
| }
|
| p {
|
| font-size: 16px;
|
| color: var(--dark);
|
| margin-bottom: 15px;
|
| }
|
| .btn {
|
| border-radius: var(--border-radius);
|
| font-weight: 500;
|
| letter-spacing: 0.5px;
|
| transition: all 0.3s ease;
|
| }
|
| .btn-primary {
|
| background: linear-gradient(to right, var(--primary), var(--secondary));
|
| border: none;
|
| padding: 12px 20px;
|
| margin-top: 20px;
|
| box-shadow: 0 3px 6px rgba(0,0,0,0.16);
|
| }
|
| .btn-primary:hover {
|
| background: linear-gradient(to right, #155785, #2980b9);
|
| box-shadow: 0 4px 8px rgba(0,0,0,0.24);
|
| transform: translateY(-2px);
|
| }
|
| .btn-secondary {
|
| background: var(--light);
|
| color: var(--dark);
|
| border: 1px solid var(--gray);
|
| padding: 12px 20px;
|
| margin-top: 10px;
|
| }
|
| .btn-secondary:hover {
|
| background: var(--gray);
|
| color: var(--white);
|
| }
|
| button {
|
| background-color: var(--primary);
|
| color: var(--white);
|
| border: none;
|
| padding: 8px 16px;
|
| border-radius: var(--border-radius);
|
| cursor: pointer;
|
| font-weight: 500;
|
| transition: all 0.2s ease;
|
| }
|
| button:hover {
|
| background-color: var(--secondary);
|
| }
|
| .profile-section {
|
| background-color: var(--light);
|
| padding: 20px;
|
| border-radius: var(--border-radius);
|
| margin-bottom: 25px;
|
| border-left: 4px solid var(--primary);
|
| }
|
| .profile-section p {
|
| margin-bottom: 8px;
|
| }
|
| .profile-section h2 {
|
| margin-bottom: 16px;
|
| }
|
| #editForm {
|
| background-color: var(--light);
|
| padding: 20px;
|
| border-radius: var(--border-radius);
|
| margin-bottom: 20px;
|
| border-left: 4px solid var(--secondary);
|
| }
|
| #editForm input {
|
| width: 100%;
|
| padding: 10px 12px;
|
| margin-bottom: 15px;
|
| border: 1px solid var(--gray);
|
| border-radius: var(--border-radius);
|
| font-size: 16px;
|
| transition: border 0.3s ease;
|
| }
|
| #editForm input:focus {
|
| border-color: var(--secondary);
|
| outline: none;
|
| box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.25);
|
| }
|
| #editForm button {
|
| padding: 10px 20px;
|
| margin-right: 10px;
|
| }
|
| select {
|
| width: 100%;
|
| padding: 12px;
|
| border: 1px solid var(--gray);
|
| border-radius: var(--border-radius);
|
| margin-bottom: 20px;
|
| font-size: 16px;
|
| background-color: var(--white);
|
| color: var(--dark);
|
| }
|
| select:focus {
|
| border-color: var(--secondary);
|
| outline: none;
|
| box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.25);
|
| }
|
| .table {
|
| width: 100%;
|
| border-collapse: separate;
|
| border-spacing: 0;
|
| border-radius: var(--border-radius);
|
| overflow: hidden;
|
| box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
| margin-top: 20px;
|
| }
|
| .table th {
|
| background-color: var(--primary);
|
| color: var(--white);
|
| padding: 12px 16px;
|
| text-align: left;
|
| font-weight: 500;
|
| border: none;
|
| }
|
| .table td {
|
| padding: 12px 16px;
|
| border-bottom: 1px solid var(--gray);
|
| color: var(--dark);
|
| }
|
| .table tr:last-child td {
|
| border-bottom: none;
|
| }
|
| .table tr:nth-child(even) {
|
| background-color: #f9f9f9;
|
| }
|
| .table tr:hover {
|
| background-color: #f1f1f1;
|
| }
|
| .table a {
|
| color: var(--secondary);
|
| text-decoration: none;
|
| font-weight: 500;
|
| }
|
| .table a:hover {
|
| text-decoration: underline;
|
| color: var(--primary);
|
| }
|
| .modal {
|
| display: none;
|
| position: fixed;
|
| top: 0;
|
| left: 0;
|
| width: 100%;
|
| height: 100%;
|
| background-color: rgba(0,0,0,0.5);
|
| z-index: 1000;
|
| overflow-y: auto;
|
| padding: 40px 0;
|
| }
|
| .modal-content {
|
| background-color: var(--white);
|
| margin: 0% auto;
|
| padding: 25px;
|
| border-radius: var(--border-radius);
|
| width: 90%;
|
| max-width: 700px;
|
| box-shadow: 0 10px 25px rgba(0,0,0,0.2);
|
| position: relative;
|
| }
|
| .close-modal {
|
| position: absolute;
|
| top: 15px;
|
| right: 15px;
|
| color: var(--gray);
|
| font-size: 24px;
|
| font-weight: bold;
|
| cursor: pointer;
|
| transition: all 0.2s ease;
|
| width: 30px;
|
| height: 30px;
|
| text-align: center;
|
| line-height: 30px;
|
| border-radius: 50%;
|
| }
|
| .close-modal:hover {
|
| color: var(--dark);
|
| background-color: #f1f1f1;
|
| }
|
| .modal-content h3 {
|
| color: var(--primary);
|
| margin-bottom: 20px;
|
| padding-bottom: 10px;
|
| border-bottom: 2px solid rgba(26, 74, 124, 0.2);
|
| font-size: 1.5rem;
|
| }
|
| .modal-content h4 {
|
| margin-top: 25px;
|
| margin-bottom: 15px;
|
| color: var(--primary);
|
| font-size: 1.2rem;
|
| font-weight: 500;
|
| }
|
| .modal-content table {
|
| width: 100%;
|
| border-collapse: collapse;
|
| margin-top: 10px;
|
| margin-bottom: 20px;
|
| box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
| border-radius: var(--border-radius);
|
| overflow: hidden;
|
| }
|
| .modal-content th {
|
| background-color: var(--light);
|
| color: var(--primary);
|
| padding: 12px;
|
| text-align: left;
|
| font-weight: 500;
|
| }
|
| .modal-content td {
|
| padding: 10px 12px;
|
| border-bottom: 1px solid #ddd;
|
| }
|
| .modal-content tr:last-child td {
|
| border-bottom: none;
|
| }
|
| .modal-content tr:nth-child(even) {
|
| background-color: #f9f9f9;
|
| }
|
| .status {
|
| display: inline-block;
|
| padding: 5px 10px;
|
| border-radius: 20px;
|
| font-size: 14px;
|
| font-weight: 500;
|
| }
|
| .status-registered {
|
| background-color: #e8f5e9;
|
| color: #388e3c;
|
| }
|
| .status-not-registered {
|
| background-color: #ffebee;
|
| color: #d32f2f;
|
| }
|
| .mt-4 {
|
| margin-top: 1.5rem;
|
| }
|
| .mb-4 {
|
| margin-bottom: 1.5rem;
|
| }
|
| .text-center {
|
| text-align: center;
|
| }
|
| </style>
|
| </head>
|
| <body>
|
| <div class="container">
|
| <div class="dashboard-box">
|
| <h1><i class="fas fa-chalkboard-teacher mr-2"></i>Welcome, {{ user.full_name }}</h1>
|
| <div class="profile-section">
|
| <h2><i class="fas fa-user mr-2"></i>Profile</h2>
|
| <p><strong>Name:</strong> {{ user.full_name }}</p>
|
| <p><strong>Email:</strong> {{ user.email }}</p>
|
| <p><strong>Phone:</strong> {{ user.phone_number or 'Not provided' }}</p>
|
| <button onclick="openEdit()"><i class="fas fa-edit mr-1"></i> Edit Profile</button>
|
| </div>
|
| <div id="editForm" style="display:none;">
|
| <h2><i class="fas fa-pen mr-2"></i>Edit Profile</h2>
|
| <div class="form-group">
|
| <label for="editFullname">Full Name</label>
|
| <input type="text" id="editFullname" class="form-control" value="{{ user.full_name }}">
|
| </div>
|
| <div class="form-group">
|
| <label for="editEmail">Email</label>
|
| <input type="email" id="editEmail" class="form-control" value="{{ user.email }}">
|
| </div>
|
| <div class="form-group">
|
| <label for="editPhone">Phone Number</label>
|
| <input type="text" id="editPhone" class="form-control" value="{{ user.phone_number or '' }}">
|
| </div>
|
| <div>
|
| <button onclick="saveProfile()"><i class="fas fa-save mr-1"></i> Save Changes</button>
|
| <button onclick="cancelEdit()" style="background-color: #757575;"><i class="fas fa-times mr-1"></i> Cancel</button>
|
| </div>
|
| </div>
|
| <div class="button-group mt-4">
|
| <button class="btn btn-primary" onclick="window.location.href='/timetable'"><i class="fas fa-calendar-alt mr-2"></i> View Timetable</button>
|
| <a href="/logout" class="btn btn-secondary"><i class="fas fa-sign-out-alt mr-2"></i> Logout</a>
|
| {% if daily_pin %}
|
| <div class="daily-pin" style="margin-top: 20px;">
|
| <h3>Today's PIN for {{ selected_class }}</h3>
|
| <p><strong>PIN:</strong> {{ daily_pin }}</p>
|
| </div>
|
| {% endif %}
|
| </div>
|
| </div>
|
| <div class="dashboard-box">
|
| <h2><i class="fas fa-users mr-2"></i>Class Management</h2>
|
| <div class="form-group">
|
| <label for="classSelect"><strong>Select Class</strong></label>
|
| <select id="classSelect" class="form-control" onchange="loadStudents()">
|
| <option value="">--Select Class--</option>
|
| <option value="SY-19" {% if selected_class == 'SY-19' %}selected{% endif %}>SY-19</option>
|
| <option value="SY-20" {% if selected_class == 'SY-20' %}selected{% endif %}>SY-20</option>
|
| <option value="SY-21" {% if selected_class == 'SY-21' %}selected{% endif %}>SY-21</option>
|
| <option value="SY-22" {% if selected_class == 'SY-22' %}selected{% endif %}>SY-22</option>
|
| </select>
|
| </div>
|
| <table id="studentsTable" style="display:none;" class="table">
|
| <thead>
|
| <tr>
|
| <th><i class="fas fa-user-graduate mr-1"></i> Student Name</th>
|
| <th><i class="fas fa-id-card mr-1"></i> Enrollment No</th>
|
| </tr>
|
| </thead>
|
| <tbody id="studentsBody">
|
| </tbody>
|
| </table>
|
| </div>
|
| </div>
|
| <div class="modal" id="studentModal">
|
| <div class="modal-content">
|
| <span class="close-modal" onclick="closeStudentModal()">✕</span>
|
| <h3 id="studentName"><i class="fas fa-user-graduate mr-2"></i>Student Name</h3>
|
| <div id="studentDetails"></div>
|
| </div>
|
| </div>
|
| <script>
|
| function openEdit() {
|
| document.getElementById('editForm').style.display = 'block';
|
| }
|
| function cancelEdit() {
|
| document.getElementById('editForm').style.display = 'none';
|
| }
|
| function saveProfile() {
|
| const full_name = document.getElementById('editFullname').value;
|
| const email = document.getElementById('editEmail').value;
|
| const phone_number = document.getElementById('editPhone').value;
|
| fetch('/api/update_teacher_profile', {
|
| method: 'POST',
|
| headers: {'Content-Type': 'application/json'},
|
| body: JSON.stringify({full_name, email, phone_number})
|
| })
|
| .then(response => response.json())
|
| .then(data => {
|
| if (data.success) {
|
| alert('Profile updated');
|
| location.reload();
|
| } else {
|
| alert(data.message);
|
| }
|
| });
|
| }
|
| function loadStudents() {
|
| const classSelected = document.getElementById('classSelect').value;
|
| if (!classSelected) {
|
| document.getElementById('studentsTable').style.display = 'none';
|
| return;
|
| }
|
| fetch(`/get_students?class=${classSelected}`)
|
| .then(response => response.json())
|
| .then(data => {
|
| const tbody = document.getElementById('studentsBody');
|
| tbody.innerHTML = '';
|
| data.students.forEach(student => {
|
| const tr = document.createElement('tr');
|
| tr.innerHTML = `<td><a href="#" onclick="showStudentDetails('${student.id}', '${student.full_name}')">${student.full_name}</a></td><td>${student.enrollment_number}</td>`;
|
| tbody.appendChild(tr);
|
| });
|
| document.getElementById('studentsTable').style.display = 'table';
|
| });
|
| fetch('/api/select_teacher_class', {
|
| method: 'POST',
|
| headers: {'Content-Type': 'application/json'},
|
| body: JSON.stringify({class: classSelected})
|
| });
|
| }
|
| function showStudentDetails(studentId, fullName) {
|
| fetch(`/get_student_details?id=${studentId}`)
|
| .then(response => response.json())
|
| .then(data => {
|
| document.getElementById('studentName').innerHTML = `<i class="fas fa-user-graduate mr-2"></i>${fullName}`;
|
| let all_percentages = [];
|
|
|
| const regular_rows = data.regular_subjects.map(sub => {
|
| const percent = sub.total_count > 0 ? (sub.attendance_count / sub.total_count * 100).toFixed(2) : 'N/A';
|
| if (percent !== 'N/A') all_percentages.push(parseFloat(percent));
|
| const percentClass = percent !== 'N/A' ?
|
| (parseFloat(percent) >= 75 ? 'text-success' : 'text-danger') : '';
|
| return `
|
| <tr>
|
| <td>${sub.name}</td>
|
| <td>${sub.attendance_count}</td>
|
| <td>${sub.total_count}</td>
|
| <td class="${percentClass}">${percent === 'N/A' ? 'N/A' : percent + '%'}</td>
|
| </tr>
|
| `;
|
| }).join('');
|
|
|
| const specialization_rows = data.specialization_subjects.map(sub => {
|
| const percent = sub.total_count > 0 ? (sub.attendance_count / sub.total_count * 100).toFixed(2) : 'N/A';
|
| if (percent !== 'N/A') all_percentages.push(parseFloat(percent));
|
| const percentClass = percent !== 'N/A' ?
|
| (parseFloat(percent) >= 75 ? 'text-success' : 'text-danger') : '';
|
| return `
|
| <tr>
|
| <td>${sub.name}</td>
|
| <td>${sub.attendance_count}</td>
|
| <td>${sub.total_count}</td>
|
| <td class="${percentClass}">${percent === 'N/A' ? 'N/A' : percent + '%'}</td>
|
| </tr>
|
| `;
|
| }).join('');
|
|
|
| const practical_rows = data.practical_subjects.map(sub => {
|
| const percent = sub.total_count > 0 ? (sub.attendance_count / sub.total_count * 100).toFixed(2) : 'N/A';
|
| if (percent !== 'N/A') all_percentages.push(parseFloat(percent));
|
| const percentClass = percent !== 'N/A' ?
|
| (parseFloat(percent) >= 75 ? 'text-success' : 'text-danger') : '';
|
| return `
|
| <tr>
|
| <td>${sub.name}</td>
|
| <td>${sub.batch}</td>
|
| <td>${sub.attendance_count}</td>
|
| <td>${sub.total_count}</td>
|
| <td class="${percentClass}">${percent === 'N/A' ? 'N/A' : percent + '%'}</td>
|
| </tr>
|
| `;
|
| }).join('');
|
|
|
| const average = all_percentages.length > 0 ? (all_percentages.reduce((a, b) => a + b, 0) / all_percentages.length).toFixed(2) + '%' : 'N/A';
|
| const averageClass = average !== 'N/A' ?
|
| (parseFloat(average) >= 75 ? 'text-success' : 'text-danger') : '';
|
|
|
| const detailsDiv = document.getElementById('studentDetails');
|
| detailsDiv.innerHTML = `
|
| <div class="row">
|
| <div class="col-md-6">
|
| <p><strong><i class="fas fa-id-card mr-1"></i> Enrollment No:</strong> ${data.enrollment_number}</p>
|
| <p><strong><i class="fas fa-envelope mr-1"></i> Email:</strong> ${data.email}</p>
|
| <p><strong><i class="fas fa-phone mr-1"></i> Student No:</strong> ${data.student_number || '-'}</p>
|
| </div>
|
| <div class="col-md-6">
|
| <p><strong><i class="fas fa-phone-alt mr-1"></i> Parent No:</strong> ${data.parent_number || '-'}</p>
|
| <p><strong><i class="fas fa-envelope mr-1"></i> Parent Email:</strong> ${data.parent_email || '-'}</p>
|
| <p><strong><i class="fas fa-percentage mr-1"></i> Overall Attendance Average:</strong> <span class="${averageClass}">${average}</span></p>
|
| </div>
|
| </div>
|
|
|
| <div class="mb-2 mt-4">
|
| <p><strong><i class="fas fa-camera mr-1"></i> Face Registration:</strong>
|
| <span class="status ${data.face_registered ? 'status-registered' : 'status-not-registered'}">
|
| ${data.face_registered ? 'Registered' : 'Not Registered'}
|
| </span>
|
| </p>
|
| </div>
|
|
|
| <h4><i class="fas fa-book mr-2"></i>Regular Subjects</h4>
|
| <table>
|
| <thead>
|
| <tr>
|
| <th>Subject</th>
|
| <th>Attendance Count</th>
|
| <th>Total Count</th>
|
| <th>Percentage</th>
|
| </tr>
|
| </thead>
|
| <tbody>
|
| ${regular_rows}
|
| </tbody>
|
| </table>
|
|
|
| <h4><i class="fas fa-graduation-cap mr-2"></i>Specialization Subjects</h4>
|
| <table>
|
| <thead>
|
| <tr>
|
| <th>Specialization Subject</th>
|
| <th>Attendance Count</th>
|
| <th>Total Count</th>
|
| <th>Percentage</th>
|
| </tr>
|
| </thead>
|
| <tbody>
|
| ${specialization_rows}
|
| </tbody>
|
| </table>
|
|
|
| <h4><i class="fas fa-flask mr-2"></i>Practical Subjects</h4>
|
| <table>
|
| <thead>
|
| <tr>
|
| <th>Practical Subject</th>
|
| <th>Batch</th>
|
| <th>Attendance Count</th>
|
| <th>Total Count</th>
|
| <th>Percentage</th>
|
| </tr>
|
| </thead>
|
| <tbody>
|
| ${practical_rows}
|
| </tbody>
|
| </table>
|
| `;
|
| document.getElementById('studentModal').style.display = 'block';
|
| });
|
| }
|
| function closeStudentModal() {
|
| document.getElementById('studentModal').style.display = 'none';
|
| }
|
| window.onload = function() {
|
| const classSelect = document.getElementById('classSelect');
|
| if (classSelect.value) {
|
| loadStudents();
|
| }
|
| }
|
| </script>
|
| </body>
|
| </html> |