Download index.html from Amanvid/srm: direct link, hf CLI and curl.
- Browser
- Download file 46.5 kB
-
https://huggingface.co/spaces/Amanvid/srm/resolve/main/index.html
- Command line
-
hf download hf://spaces/Amanvid/srm/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Amanvid/srm/resolve/main/index.html
46.5 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Grades Management System</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| /* Custom styles */ | |
| .gradient-bg { | |
| background: linear-gradient(135deg, #6b73ff 0%, #000dff 100%); | |
| } | |
| .grade-input:focus { | |
| box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5); | |
| } | |
| .transition-all { | |
| transition: all 0.3s ease; | |
| } | |
| .scrollbar-hide::-webkit-scrollbar { | |
| display: none; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-100 min-h-screen"> | |
| <div class="min-h-screen flex flex-col"> | |
| <!-- Header --> | |
| <header class="gradient-bg text-white shadow-lg"> | |
| <div class="container mx-auto px-4 py-4"> | |
| <div class="flex justify-between items-center"> | |
| <h1 class="text-2xl font-bold">📊 Grades Management System</h1> | |
| <div class="flex items-center space-x-4"> | |
| <span class="hidden md:inline-block">Welcome, Admin</span> | |
| <button class="bg-white text-blue-600 px-4 py-1 rounded-full hover:bg-blue-50 transition-all"> | |
| <i class="fas fa-sign-out-alt"></i> Logout | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </header> | |
| <!-- Main Content --> | |
| <main class="flex-grow container mx-auto px-4 py-8"> | |
| <h1 class="text-3xl font-bold text-center mb-8 text-blue-800">SCHOOL BASED ASSESSMENT (S.B.A)</h1> | |
| <div class="grid grid-cols-1 lg:grid-cols-3 gap-8"> | |
| <!-- Student Selection --> | |
| <div class="lg:col-span-1 bg-white rounded-lg shadow-md p-6 h-fit sticky top-4"> | |
| <h2 class="text-xl font-semibold mb-4 text-gray-800 border-b pb-2">Student Selection</h2> | |
| <div class="mb-4"> | |
| <label class="block text-gray-700 text-sm font-bold mb-2" for="class-select"> | |
| Select Class | |
| </label> | |
| <select id="class-select" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> | |
| <option value="">-- Select Class --</option> | |
| <option value="Creche">Creche</option> | |
| <option value="Nursery 1">Nursery 1</option> | |
| <option value="Nursery 2">Nursery 2</option> | |
| <option value="KG 1">KG 1</option> | |
| <option value="KG 2">KG 2</option> | |
| <option value="BS 1">BS 1</option> | |
| <option value="BS 2">BS 2</option> | |
| <option value="BS 3">BS 3</option> | |
| <option value="BS 4">BS 4</option> | |
| <option value="BS 5">BS 5</option> | |
| <option value="BS 6">BS 6</option> | |
| </select> | |
| </div> | |
| <div class="mb-6"> | |
| <label class="block text-gray-700 text-sm font-bold mb-2" for="student-select"> | |
| Select Student | |
| </label> | |
| <select id="student-select" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> | |
| <option value="">-- Select Student --</option> | |
| <!-- Students will be populated here via JS --> | |
| </select> | |
| </div> | |
| <!-- Selected Student Info --> | |
| <div id="student-info" class="hidden border-t pt-4"> | |
| <div class="flex items-center mb-3"> | |
| <div class="w-12 h-12 rounded-full bg-blue-100 flex items-center justify-center"> | |
| <i class="fas fa-user text-blue-500 text-xl"></i> | |
| </div> | |
| <div class="ml-3"> | |
| <h3 id="student-name" class="font-semibold text-gray-800">Student Name</h3> | |
| <p id="student-class" class="text-sm text-gray-600">Class 8A</p> | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-2 gap-2 text-sm"> | |
| <div> | |
| <span class="text-gray-500">ID:</span> | |
| <span id="student-id" class="font-medium">S001</span> | |
| </div> | |
| <div> | |
| <span class="text-gray-500">Average:</span> | |
| <span id="student-avg" class="font-medium">85%</span> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Grades Form --> | |
| <div class="lg:col-span-2"> | |
| <div class="bg-white rounded-lg shadow-md overflow-hidden"> | |
| <!-- Form Header --> | |
| <div class="gradient-bg px-6 py-4 flex justify-between items-center"> | |
| <h2 class="text-xl font-semibold text-white">Grades Information</h2> | |
| <div id="form-actions" class="hidden"> | |
| <button id="save-btn" class="bg-green-500 hover:bg-green-600 text-white px-4 py-1 rounded-full text-sm transition-all"> | |
| <i class="fas fa-save mr-1"></i> Save | |
| </button> | |
| <button id="cancel-btn" class="bg-red-500 hover:bg-red-600 text-white px-4 py-1 rounded-full text-sm ml-2 transition-all"> | |
| <i class="fas fa-times mr-1"></i> Cancel | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Grades Form --> | |
| <div class="p-6"> | |
| <div id="no-student-selected" class="text-center py-8"> | |
| <i class="fas fa-users text-4xl text-gray-300 mb-3"></i> | |
| <h3 class="text-lg text-gray-500">Please select a student to view or edit grades</h3> | |
| </div> | |
| <div id="grades-form" class="hidden"> | |
| <!-- Subject Selection --> | |
| <div class="mb-6"> | |
| <label class="block text-gray-700 text-sm font-bold mb-2" for="subject-select"> | |
| Subject | |
| </label> | |
| <select id="subject-select" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> | |
| <option value="">-- Select Subject --</option> | |
| <option value="math">Mathematics</option> | |
| <option value="science">Science</option> | |
| <option value="english">English</option> | |
| <option value="history">History</option> | |
| <option value="geography">Geography</option> | |
| </select> | |
| </div> | |
| <!-- Term Selection --> | |
| <div class="mb-6"> | |
| <label class="block text-gray-700 text-sm font-bold mb-2" for="term-select"> | |
| Term | |
| </label> | |
| <select id="term-select" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> | |
| <option value="">-- Select Term --</option> | |
| <option value="term1">Term 1</option> | |
| <option value="term2">Term 2</option> | |
| <option value="term3">Term 3</option> | |
| </select> | |
| </div> | |
| <!-- Class Score Form --> | |
| <div class="mb-6 p-4 border border-gray-200 rounded-lg bg-blue-50"> | |
| <h3 class="font-semibold text-gray-800 mb-3 flex items-center"> | |
| <i class="fas fa-book-open text-blue-500 mr-2"></i> Class Score (40%) | |
| </h3> | |
| <div class="grid md:grid-cols-2 gap-4"> | |
| <div> | |
| <label class="block text-gray-700 text-sm font-bold mb-2" for="assignment"> | |
| Assignments (30%) | |
| </label> | |
| <div class="flex"> | |
| <input type="number" id="assignment" min="0" max="30" | |
| class="grade-input flex-grow px-3 py-2 border border-gray-300 rounded-l-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> | |
| <span class="inline-flex items-center px-3 rounded-r-md bg-gray-50 text-gray-500 text-sm">/30</span> | |
| </div> | |
| <span id="assignment-percent" class="text-xs text-gray-500">0%</span> | |
| </div> | |
| <div> | |
| <label class="block text-gray-700 text-sm font-bold mb-2" for="quiz"> | |
| Quizzes (30%) | |
| </label> | |
| <div class="flex"> | |
| <input type="number" id="quiz" min="0" max="30" | |
| class="grade-input flex-grow px-3 py-2 border border-gray-300 rounded-l-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> | |
| <span class="inline-flex items-center px-3 rounded-r-md bg-gray-50 text-gray-500 text-sm">/30</span> | |
| </div> | |
| <span id="quiz-percent" class="text-xs text-gray-500">0%</span> | |
| </div> | |
| <div> | |
| <label class="block text-gray-700 text-sm font-bold mb-2" for="project"> | |
| Projects (20%) | |
| </label> | |
| <div class="flex"> | |
| <input type="number" id="project" min="0" max="20" | |
| class="grade-input flex-grow px-3 py-2 border border-gray-300 rounded-l-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> | |
| <span class="inline-flex items-center px-3 rounded-r-md bg-gray-50 text-gray-500 text-sm">/20</span> | |
| </div> | |
| <span id="project-percent" class="text-xs text-gray-500">0%</span> | |
| </div> | |
| <div> | |
| <label class="block text-gray-700 text-sm font-bold mb-2" for="participation"> | |
| Participation (20%) | |
| </label> | |
| <div class="flex"> | |
| <input type="number" id="participation" min="0" max="20" | |
| class="grade-input flex-grow px-3 py-2 border border-gray-300 rounded-l-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> | |
| <span class="inline-flex items-center px-3 rounded-r-md bg-gray-50 text-gray-500 text-sm">/20</span> | |
| </div> | |
| <span id="participation-percent" class="text-xs text-gray-500">0%</span> | |
| </div> | |
| </div> | |
| <div class="mt-4 pt-2 border-t border-gray-200"> | |
| <div class="flex justify-between items-center"> | |
| <span class="text-sm font-medium text-gray-700">Total Class Score:</span> | |
| <span id="class-total" class="font-semibold text-blue-600">0%</span> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Exam Score Form --> | |
| <div class="p-4 border border-gray-200 rounded-lg bg-green-50"> | |
| <h3 class="font-semibold text-gray-800 mb-3 flex items-center"> | |
| <i class="fas fa-file-alt text-green-500 mr-2"></i> Exam Score (60%) | |
| </h3> | |
| <div class="grid md:grid-cols-2 gap-4"> | |
| <div> | |
| <label class="block text-gray-700 text-sm font-bold mb-2" for="written"> | |
| Written Exam (80%) | |
| </label> | |
| <div class="flex"> | |
| <input type="number" id="written" min="0" max="80" | |
| class="grade-input flex-grow px-3 py-2 border border-gray-300 rounded-l-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> | |
| <span class="inline-flex items-center px-3 rounded-r-md bg-gray-50 text-gray-500 text-sm">/80</span> | |
| </div> | |
| <span id="written-percent" class="text-xs text-gray-500">0%</span> | |
| </div> | |
| <div> | |
| <label class="block text-gray-700 text-sm font-bold mb-2" for="practical"> | |
| Practical Exam (20%) | |
| </label> | |
| <div class="flex"> | |
| <input type="number" id="practical" min="0" max="20" | |
| class="grade-input flex-grow px-3 py-2 border border-gray-300 rounded-l-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> | |
| <span class="inline-flex items-center px-3 rounded-r-md bg-gray-50 text-gray-500 text-sm">/20</span> | |
| </div> | |
| <span id="practical-percent" class="text-xs text-gray-500">0%</span> | |
| </div> | |
| </div> | |
| <div class="mt-4 pt-2 border-t border-gray-200"> | |
| <div class="flex justify-between items-center"> | |
| <span class="text-sm font-medium text-gray-700">Total Exam Score:</span> | |
| <span id="exam-total" class="font-semibold text-green-600">0%</span> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Final Grade --> | |
| <div class="mt-6 p-4 border border-gray-200 rounded-lg bg-purple-50"> | |
| <div class="flex justify-between items-center"> | |
| <span class="text-sm font-medium text-gray-700">Overall Grade:</span> | |
| <span id="overall-grade" class="font-bold text-purple-600 text-lg">0%</span> | |
| </div> | |
| <div class="mt-2 flex justify-between items-center"> | |
| <span class="text-sm font-medium text-gray-700">Grade Letter:</span> | |
| <span id="grade-letter" class="font-bold text-lg">-</span> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Grades History --> | |
| <div id="grades-history" class="mt-8 bg-white rounded-lg shadow-md overflow-hidden hidden"> | |
| <div class="gradient-bg px-6 py-4"> | |
| <h2 class="text-xl font-semibold text-white">Grades History</h2> | |
| </div> | |
| <div class="p-4 overflow-x-auto scrollbar-hide"> | |
| <table class="min-w-full divide-y divide-gray-200"> | |
| <thead class="bg-gray-50"> | |
| <tr> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Subject</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Term</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Class (40%)</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Exam (60%)</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Total</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Grade</th> | |
| <th scope="col" class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th> | |
| </tr> | |
| </thead> | |
| <tbody id="history-body" class="bg-white divide-y divide-gray-200"> | |
| <!-- Will be populated by JavaScript --> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </main> | |
| <!-- Footer --> | |
| <footer class="bg-gray-800 text-white py-4 mt-8"> | |
| <div class="container mx-auto px-4 text-center"> | |
| <p>© 2023 School Management System. All rights reserved.</p> | |
| </div> | |
| </footer> | |
| </div> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Mock database data | |
| const students = { | |
| "Creche": [ | |
| { id: 'S001', name: 'Emma Johnson', class: 'Creche', avg: '90%' }, | |
| { id: 'S002', name: 'Noah Williams', class: 'Creche', avg: '85%' } | |
| ], | |
| "Nursery 1": [ | |
| { id: 'S003', name: 'Olivia Brown', class: 'Nursery 1', avg: '88%' }, | |
| { id: 'S004', name: 'Liam Jones', class: 'Nursery 1', avg: '92%' } | |
| ], | |
| "Nursery 2": [ | |
| { id: 'S005', name: 'Ava Garcia', class: 'Nursery 2', avg: '95%' }, | |
| { id: 'S006', name: 'William Miller', class: 'Nursery 2', avg: '87%' } | |
| ], | |
| "KG 1": [ | |
| { id: 'S007', name: 'Sophia Davis', class: 'KG 1', avg: '90%' }, | |
| { id: 'S008', name: 'Benjamin Wilson', class: 'KG 1', avg: '93%' } | |
| ], | |
| "KG 2": [ | |
| { id: 'S009', name: 'Isabella Moore', class: 'KG 2', avg: '94%' }, | |
| { id: 'S010', name: 'James Taylor', class: 'KG 2', avg: '89%' } | |
| ], | |
| "BS 1": [ | |
| { id: 'S011', name: 'Mia Anderson', class: 'BS 1', avg: '85%' }, | |
| { id: 'S012', name: 'Ethan Thomas', class: 'BS 1', avg: '91%' } | |
| ], | |
| "BS 2": [ | |
| { id: 'S013', name: 'Charlotte Jackson', class: 'BS 2', avg: '92%' }, | |
| { id: 'S014', name: 'Alexander White', class: 'BS 2', avg: '88%' } | |
| ], | |
| "BS 3": [ | |
| { id: 'S015', name: 'Amelia Harris', class: 'BS 3', avg: '90%' }, | |
| { id: 'S016', name: 'Michael Martin', class: 'BS 3', avg: '94%' } | |
| ], | |
| "BS 4": [ | |
| { id: 'S017', name: 'Harrison Thompson', class: 'BS 4', avg: '87%' }, | |
| { id: 'S018', name: 'Evelyn Martinez', class: 'BS 4', avg: '92%' } | |
| ], | |
| "BS 5": [ | |
| { id: 'S019', name: 'Abigail Robinson', class: 'BS 5', avg: '93%' }, | |
| { id: 'S020', name: 'Daniel Clark', class: 'BS 5', avg: '89%' } | |
| ], | |
| "BS 6": [ | |
| { id: 'S021', name: 'Elizabeth Rodriguez', class: 'BS 6', avg: '95%' }, | |
| { id: 'S022', name: 'Matthew Lewis', class: 'BS 6', avg: '91%' } | |
| ] | |
| }; | |
| // Mock grades history data | |
| const gradesHistory = { | |
| 'S001': [ | |
| { subject: 'Mathematics', term: 'Term 1', classScore: 32, examScore: 52, total: 84, grade: 'A' }, | |
| { subject: 'Science', term: 'Term 1', classScore: 28, examScore: 45, total: 73, grade: 'B' }, | |
| { subject: 'English', term: 'Term 1', classScore: 36, examScore: 54, total: 90, grade: 'A+' } | |
| ], | |
| 'S002': [ | |
| { subject: 'Mathematics', term: 'Term 1', classScore: 25, examScore: 42, total: 67, grade: 'B-' }, | |
| { subject: 'Science', term: 'Term 1', classScore: 30, examScore: 48, total: 78, grade: 'B+' }, | |
| { subject: 'History', term: 'Term 1', classScore: 28, examScore: 51, total: 79, grade: 'B+' } | |
| ], | |
| 'S003': [ | |
| { subject: 'Mathematics', term: 'Term 1', classScore: 38, examScore: 57, total: 95, grade: 'A+' }, | |
| { subject: 'Science', term: 'Term 1', classScore: 35, examScore: 55, total: 90, grade: 'A+' }, | |
| { subject: 'Geography', term: 'Term 1', classScore: 34, examScore: 52, total: 86, grade: 'A' } | |
| ], | |
| 'S004': [ | |
| { subject: 'Mathematics', term: 'Term 1', classScore: 30, examScore: 45, total: 75, grade: 'B' }, | |
| { subject: 'Science', term: 'Term 1', classScore: 32, examScore: 48, total: 80, grade: 'A-' }, | |
| { subject: 'English', term: 'Term 1', classScore: 28, examScore: 42, total: 70, grade: 'B-' } | |
| ], | |
| 'S005': [ | |
| { subject: 'Mathematics', term: 'Term 1', classScore: 36, examScore: 54, total: 90, grade: 'A+' }, | |
| { subject: 'Science', term: 'Term 1', classScore: 35, examScore: 53, total: 88, grade: 'A' } | |
| ] | |
| }; | |
| // DOM elements | |
| const classSelect = document.getElementById('class-select'); | |
| const studentSelect = document.getElementById('student-select'); | |
| const studentInfo = document.getElementById('student-info'); | |
| const studentName = document.getElementById('student-name'); | |
| const studentClass = document.getElementById('student-class'); | |
| const studentId = document.getElementById('student-id'); | |
| const studentAvg = document.getElementById('student-avg'); | |
| const noStudentSelected = document.getElementById('no-student-selected'); | |
| const gradesForm = document.getElementById('grades-form'); | |
| const formActions = document.getElementById('form-actions'); | |
| const saveBtn = document.getElementById('save-btn'); | |
| const cancelBtn = document.getElementById('cancel-btn'); | |
| const gradesHistorySection = document.getElementById('grades-history'); | |
| const historyBody = document.getElementById('history-body'); | |
| const gradeInputs = document.querySelectorAll('.grade-input'); | |
| // Populate class select options | |
| classSelect.addEventListener('change', function() { | |
| const selectedClass = this.value; | |
| studentSelect.innerHTML = '<option value="">-- Select Student --</option>'; | |
| if (selectedClass && students[selectedClass]) { | |
| students[selectedClass].forEach(student => { | |
| const option = document.createElement('option'); | |
| option.value = student.id; | |
| option.textContent = student.name; | |
| studentSelect.appendChild(option); | |
| }); | |
| studentSelect.disabled = false; | |
| // Focus on student select to trigger dropdown | |
| setTimeout(() => { | |
| studentSelect.focus(); | |
| }, 100); | |
| } else { | |
| studentSelect.disabled = true; | |
| resetForm(); | |
| studentInfo.classList.add('hidden'); | |
| noStudentSelected.classList.remove('hidden'); | |
| gradesForm.classList.add('hidden'); | |
| gradesHistorySection.classList.add('hidden'); | |
| } | |
| }); | |
| // Make student select clickable at all times | |
| studentSelect.addEventListener('mousedown', function(e) { | |
| e.preventDefault(); | |
| this.size = this.options.length > 5 ? 5 : this.options.length; | |
| this.focus(); | |
| }); | |
| studentSelect.addEventListener('change', function() { | |
| this.size = 1; | |
| this.blur(); | |
| }); | |
| studentSelect.addEventListener('blur', function() { | |
| this.size = 1; | |
| }); | |
| // Populate student info when selected | |
| studentSelect.addEventListener('change', function() { | |
| const selectedClass = classSelect.value; | |
| const selectedStudentId = this.value; | |
| if (selectedClass && selectedStudentId) { | |
| const student = students[selectedClass].find(s => s.id === selectedStudentId); | |
| if (student) { | |
| // Show student info | |
| studentName.textContent = student.name; | |
| studentClass.textContent = student.class; | |
| studentId.textContent = student.id; | |
| studentAvg.textContent = student.avg; | |
| studentInfo.classList.remove('hidden'); | |
| // Show grades form | |
| noStudentSelected.classList.add('hidden'); | |
| gradesForm.classList.remove('hidden'); | |
| // Load grades history if available | |
| if (gradesHistory[selectedStudentId]) { | |
| loadGradesHistory(gradesHistory[selectedStudentId]); | |
| gradesHistorySection.classList.remove('hidden'); | |
| } else { | |
| gradesHistorySection.classList.add('hidden'); | |
| } | |
| return; | |
| } | |
| } | |
| // If no student selected | |
| studentInfo.classList.add('hidden'); | |
| noStudentSelected.classList.remove('hidden'); | |
| gradesForm.classList.add('hidden'); | |
| gradesHistorySection.classList.add('hidden'); | |
| resetForm(); | |
| }); | |
| // Load grades history | |
| function loadGradesHistory(history) { | |
| historyBody.innerHTML = ''; | |
| history.forEach(grade => { | |
| const row = document.createElement('tr'); | |
| row.className = 'hover:bg-gray-50'; | |
| row.innerHTML = ` | |
| <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${grade.subject}</td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${grade.term}</td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${grade.classScore}%</td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${grade.examScore}%</td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm font-medium ${getGradeColor(grade.total)}">${grade.total}%</td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm font-bold ${getGradeLetterColor(grade.grade)}">${grade.grade}</td> | |
| <td class="px-6 py-4 whitespace-nowrap text-center text-sm font-medium"> | |
| <button class="edit-grade text-blue-600 hover:text-blue-900 mr-3" data-subject="${grade.subject}" data-term="${grade.term}"> | |
| <i class="fas fa-edit"></i> | |
| </button> | |
| <button class="delete-grade text-red-600 hover:text-red-900" data-subject="${grade.subject}" data-term="${grade.term}"> | |
| <i class="fas fa-trash-alt"></i> | |
| </button> | |
| </td> | |
| `; | |
| historyBody.appendChild(row); | |
| }); | |
| // Add event listeners to edit/delete buttons | |
| document.querySelectorAll('.edit-grade').forEach(btn => { | |
| btn.addEventListener('click', function() { | |
| const subject = this.getAttribute('data-subject'); | |
| const term = this.getAttribute('data-term'); | |
| editGrade(subject, term); | |
| }); | |
| }); | |
| document.querySelectorAll('.delete-grade').forEach(btn => { | |
| btn.addEventListener('click', function() { | |
| const subject = this.getAttribute('data-subject'); | |
| const term = this.getAttribute('data-term'); | |
| deleteGrade(subject, term); | |
| }); | |
| }); | |
| } | |
| // Edit grade | |
| function editGrade(subject, term) { | |
| // In a real app, this would fetch the grade details from the database | |
| // For this example, we'll just simulate finding the grade | |
| const selectedStudentId = studentSelect.value; | |
| const history = gradesHistory[selectedStudentId]; | |
| if (history) { | |
| const grade = history.find(g => g.subject === subject && g.term === term); | |
| if (grade) { | |
| // Populate form with grade data | |
| document.getElementById('subject-select').value = subject.toLowerCase(); | |
| document.getElementById('term-select').value = term.toLowerCase().replace(' ', ''); | |
| // Calculate component scores from percentages | |
| // These calculations are simplified for the example | |
| document.getElementById('assignment').value = Math.round(grade.classScore * 0.3 * 0.4); | |
| document.getElementById('quiz').value = Math.round(grade.classScore * 0.3 * 0.4); | |
| document.getElementById('project').value = Math.round(grade.classScore * 0.2 * 0.4); | |
| document.getElementById('participation').value = Math.round(grade.classScore * 0.2 * 0.4); | |
| document.getElementById('written').value = Math.round(grade.examScore * 0.8 * 0.6); | |
| document.getElementById('practical').value = Math.round(grade.examScore * 0.2 * 0.6); | |
| // Trigger calculation updates | |
| calculateScores(); | |
| // Show save/cancel buttons | |
| formActions.classList.remove('hidden'); | |
| } | |
| } | |
| } | |
| // Delete grade | |
| function deleteGrade(subject, term) { | |
| if (confirm(`Are you sure you want to delete the ${subject} grade for ${term}?`)) { | |
| // In a real app, this would make an AJAX request to delete from the database | |
| // For this example, we'll just simulate it | |
| const selectedStudentId = studentSelect.value; | |
| if (gradesHistory[selectedStudentId]) { | |
| gradesHistory[selectedStudentId] = gradesHistory[selectedStudentId].filter( | |
| g => !(g.subject === subject && g.term === term) | |
| ); | |
| // Reload history | |
| loadGradesHistory(gradesHistory[selectedStudentId]); | |
| // Show success message | |
| alert('Grade deleted successfully'); | |
| } | |
| } | |
| } | |
| // Save grade | |
| saveBtn.addEventListener('click', function() { | |
| const selectedStudentId = studentSelect.value; | |
| const subject = document.getElementById('subject-select').value; | |
| const term = document.getElementById('term-select').value; | |
| const classTotal = parseInt(document.getElementById('class-total').textContent); | |
| const examTotal = parseInt(document.getElementById('exam-total').textContent); | |
| const overallGrade = parseInt(document.getElementById('overall-grade').textContent); | |
| const gradeLetter = document.getElementById('grade-letter').textContent; | |
| // Validate form | |
| if (!subject || !term || isNaN(classTotal) || isNaN(examTotal)) { | |
| alert('Please fill in all fields with valid values'); | |
| return; | |
| } | |
| // Prepare grade data | |
| const gradeData = { | |
| subject: capitalizeFirstLetter(subject), | |
| term: capitalizeFirstLetter(term.replace('term', 'Term ')), | |
| classScore: classTotal, | |
| examScore: examTotal, | |
| total: overallGrade, | |
| grade: gradeLetter | |
| }; | |
| // In a real app, this would make an AJAX request to save to the database | |
| // For this example, we'll just simulate it | |
| if (!gradesHistory[selectedStudentId]) { | |
| gradesHistory[selectedStudentId] = []; | |
| } | |
| // Check if this grade already exists (for update) | |
| const existingIndex = gradesHistory[selectedStudentId].findIndex( | |
| g => g.subject === gradeData.subject && g.term === gradeData.term | |
| ); | |
| if (existingIndex >= 0) { | |
| // Update existing grade | |
| gradesHistory[selectedStudentId][existingIndex] = gradeData; | |
| } else { | |
| // Add new grade | |
| gradesHistory[selectedStudentId].push(gradeData); | |
| } | |
| // Reload history | |
| loadGradesHistory(gradesHistory[selectedStudentId]); | |
| // Hide save/cancel buttons | |
| formActions.classList.add('hidden'); | |
| // Show success message | |
| alert('Grade saved successfully'); | |
| }); | |
| // Cancel editing | |
| cancelBtn.addEventListener('click', function() { | |
| resetForm(); | |
| formActions.classList.add('hidden'); | |
| }); | |
| // Reset form | |
| function resetForm() { | |
| document.getElementById('subject-select').value = ''; | |
| document.getElementById('term-select').value = ''; | |
| // Reset class score inputs | |
| document.getElementById('assignment').value = ''; | |
| document.getElementById('quiz').value = ''; | |
| document.getElementById('project').value = ''; | |
| document.getElementById('participation').value = ''; | |
| // Reset exam score inputs | |
| document.getElementById('written').value = ''; | |
| document.getElementById('practical').value = ''; | |
| // Reset calculated values | |
| document.getElementById('assignment-percent').textContent = '0%'; | |
| document.getElementById('quiz-percent').textContent = '0%'; | |
| document.getElementById('project-percent').textContent = '0%'; | |
| document.getElementById('participation-percent').textContent = '0%'; | |
| document.getElementById('written-percent').textContent = '0%'; | |
| document.getElementById('practical-percent').textContent = '0%'; | |
| document.getElementById('class-total').textContent = '0%'; | |
| document.getElementById('exam-total').textContent = '0%'; | |
| document.getElementById('overall-grade').textContent = '0%'; | |
| document.getElementById('grade-letter').textContent = '-'; | |
| } | |
| // Calculate scores when input values change | |
| gradeInputs.forEach(input => { | |
| input.addEventListener('input', calculateScores); | |
| }); | |
| // Calculate all scores and percentages | |
| function calculateScores() { | |
| // Class score components (40% total) | |
| const assignment = parseFloat(document.getElementById('assignment').value) || 0; | |
| const quiz = parseFloat(document.getElementById('quiz').value) || 0; | |
| const project = parseFloat(document.getElementById('project').value) || 0; | |
| const participation = parseFloat(document.getElementById('participation').value) || 0; | |
| // Calculate component percentages (each component is out of its max) | |
| const assignmentPercent = Math.round((assignment / 30) * 100); | |
| const quizPercent = Math.round((quiz / 30) * 100); | |
| const projectPercent = Math.round((project / 20) * 100); | |
| const participationPercent = Math.round((participation / 20) * 100); | |
| // Update component percentage displays | |
| document.getElementById('assignment-percent').textContent = assignmentPercent + '%'; | |
| document.getElementById('quiz-percent').textContent = quizPercent + '%'; | |
| document.getElementById('project-percent').textContent = projectPercent + '%'; | |
| document.getElementById('participation-percent').textContent = participationPercent + '%'; | |
| // Calculate total class score (weighted) | |
| const classTotal = Math.min( | |
| Math.round((assignment + quiz + project + participation) / 100 * 40), | |
| 40 | |
| ); | |
| document.getElementById('class-total').textContent = classTotal + '%'; | |
| // Exam score components (60% total) | |
| const written = parseFloat(document.getElementById('written').value) || 0; | |
| const practical = parseFloat(document.getElementById('practical').value) || 0; | |
| // Calculate component percentages | |
| const writtenPercent = Math.round((written / 80) * 100); | |
| const practicalPercent = Math.round((practical / 20) * 100); | |
| // Update component percentage displays | |
| document.getElementById('written-percent').textContent = writtenPercent + '%'; | |
| document.getElementById('practical-percent').textContent = practicalPercent + '%'; | |
| // Calculate total exam score (weighted) | |
| const examTotal = Math.min( | |
| Math.round((written + practical) / 100 * 60), | |
| 60 | |
| ); | |
| document.getElementById('exam-total').textContent = examTotal + '%'; | |
| // Calculate overall grade | |
| const overallGrade = classTotal + examTotal; | |
| document.getElementById('overall-grade').textContent = overallGrade + '%'; | |
| // Calculate grade letter | |
| const gradeLetter = calculateGradeLetter(overallGrade); | |
| document.getElementById('grade-letter').textContent = gradeLetter; | |
| document.getElementById('grade-letter').className = `font-bold text-lg ${getGradeLetterColor(gradeLetter)}`; | |
| // Show save/cancel buttons if subject and term are selected | |
| const subject = document.getElementById('subject-select').value; | |
| const term = document.getElementById('term-select').value; | |
| if (subject && term && (classTotal > 0 || examTotal > 0)) { | |
| formActions.classList.remove('hidden'); | |
| } | |
| } | |
| // Calculate grade letter from percentage | |
| function calculateGradeLetter(percentage) { | |
| if (percentage >= 90) return 'A+'; | |
| if (percentage >= 85) return 'A'; | |
| if (percentage >= 80) return 'A-'; | |
| if (percentage >= 77) return 'B+'; | |
| if (percentage >= 73) return 'B'; | |
| if (percentage >= 70) return 'B-'; | |
| if (percentage >= 67) return 'C+'; | |
| if (percentage >= 63) return 'C'; | |
| if (percentage >= 60) return 'C-'; | |
| if (percentage >= 57) return 'D+'; | |
| if (percentage >= 53) return 'D'; | |
| if (percentage >= 50) return 'D-'; | |
| return 'F'; | |
| } | |
| // Helper function to capitalize first letter | |
| function capitalizeFirstLetter(string) { | |
| return string.charAt(0).toUpperCase() + string.slice(1); | |
| } | |
| // Helper function to get color based on grade percentage | |
| function getGradeColor(percentage) { | |
| if (percentage >= 90) return 'text-green-700'; | |
| if (percentage >= 80) return 'text-green-600'; | |
| if (percentage >= 70) return 'text-blue-600'; | |
| if (percentage >= 60) return 'text-yellow-600'; | |
| return 'text-red-600'; | |
| } | |
| // Helper function to get color based on grade letter | |
| function getGradeLetterColor(grade) { | |
| if (grade.includes('A')) return 'text-green-600'; | |
| if (grade.includes('B')) return 'text-blue-600'; | |
| if (grade.includes('C')) return 'text-yellow-600'; | |
| if (grade.includes('D')) return 'text-orange-600'; | |
| return 'text-red-600'; | |
| } | |
| }); | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Amanvid/srm" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |