Make a exam code inlog for students and make så admin can view exams when them ar submited. - Follow Up Deployment
Browse files263 unmodified lines264265266267267268269270629 unmodified lines900901902903904905906907908909910911912903904905906907908909910911912913914915916917918919920921922923924925926927928929930238 unmodified lines11691170117111571172117311741175280 unmodified lines145614571458145914601461146214631464146514451446144714661467146814691470147114721473147414751476147714781479148014811482263 unmodified lines <button class="text-blue-600 hover:text-blue-800 mr-2" onclick="viewExam('math-final')"> <i class="fas fa-eye"></i> </button> <button class="text-red-600 hover:text-red-800"> <button class="text-red-600 hover:text-red-800" onclick="deleteExam('${exam.id}')"> <i class="fas fa-trash"></i> </button> </div>629 unmodified lines // Simulate API call setTimeout(() => { // This is just for demo - in a real app, you'd call your backend currentUser = { email, name: email.split('@')[0] }; isAdmin = email.includes('admin'); // Store token in localStorage (simulated) localStorage.setItem('authToken', 'simulated-jwt-token'); localStorage.setItem('user', JSON.stringify(currentUser)); localStorage.setItem('isAdmin', isAdmin); showDashboard(); // Admin login if (email.includes('@admin.com') && password === 'admin123') { currentUser = { email, name: 'Admin User' }; isAdmin = true; localStorage.setItem('authToken', 'simulated-jwt-token'); localStorage.setItem('user', JSON.stringify(currentUser)); localStorage.setItem('isAdmin', true); showDashboard(); } // Student login else if (email.includes('@student.com') && password === 'student123') { currentUser = { email, name: 'Student User' }; isAdmin = false; localStorage.setItem('authToken', 'simulated-jwt-token'); localStorage.setItem('user', JSON.stringify(currentUser)); localStorage.setItem('isAdmin', false); showJoinExam(); // Students go directly to join exam } else { errorElement.textContent = 'Invalid credentials'; errorElement.classList.remove('hidden'); } }, 500); } 238 unmodified lines }; console.log('Exam data to save:', examData); alert('Exam saved successfully!'); alert(`Exam saved successfully!\nExam Code: ${examData.code}\nShare this code with students.`); showExams(); } 280 unmodified lines showDashboard(); } // Store exams in memory for demo purposes let exams = [ { id: 'math-final', title: 'Mathematics Final Exam', type: 'Quiz', date: '2023-06-15', status: 'Active', code: 'DEMO123' }, { id: 'history-midterm', title: 'History Midterm', type: 'Essay', date: '2023-05-20', status: 'Completed', code: 'HIST456' } ];
function viewExam(examId) { // In a real app, you'd fetch exam details console.log('Viewing exam:', examId); alert(`Viewing exam ${examId}. In a real app, this would show exam details.`); const exam = exams.find(e => e.id === examId); if (exam) { alert(`Exam Details:\nTitle: ${exam.title}\nType: ${exam.type}\nDate: ${exam.date}\nStatus: ${exam.status}\nCode: ${exam.code}`); } else { alert('Exam not found'); } }
function deleteExam(examId) { if (confirm('Are you sure you want to delete this exam?')) { exams = exams.filter(e => e.id !== examId); alert('Exam deleted successfully'); showExams(); // Refresh the view } } function viewResult(resultId) {index.html+47-15