Spaces:
Running

l-ghid / index.html
SWEE33's picture
fix logout buttom so it working. Do that you need a account for "dashboard" "exams" "results" and that. Make the stats real and make deliting exams. - Follow Up Deployment
8f8bd60 verified
Raw History Blame Contribute Delete
84.9 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>LöGhid - Exam Platform</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 CSS for features Tailwind can't handle */ .drawing-canvas { position: absolute; top: 0; left: 0; z-index: 10; pointer-events: none; } .fullscreen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999; background: white; } .loading-spinner { border: 4px solid rgba(0, 0, 0, 0.1); border-radius: 50%; border-top: 4px solid #3b82f6; width: 40px; height: 40px; animation: spin 1s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } .slide-fade-enter-active { transition: all 0.3s ease-out; } .slide-fade-leave-active { transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1); } .slide-fade-enter-from, .slide-fade-leave-to { transform: translateX(20px); opacity: 0; } </style> </head> <body class="bg-gray-50 font-sans"> <!-- Loading Screen --> <div id="loadingScreen" class="fixed inset-0 bg-white z-50 flex flex-col items-center justify-center"> <div class="loading-spinner mb-4"></div> <h1 class="text-3xl font-bold text-blue-600 mb-2">LöGhid</h1> <p class="text-gray-600">Loading exam platform...</p> </div> <!-- Main App Container --> <div id="app" class="min-h-screen hidden"> <!-- Navigation Bar --> <nav class="bg-blue-600 text-white shadow-lg"> <div class="container mx-auto px-4 py-3 flex justify-between items-center"> <div class="flex items-center space-x-2"> <i class="fas fa-graduation-cap text-2xl"></i> <span class="text-xl font-bold">LöGhid</span> </div> <div id="navLinks" class="hidden md:flex space-x-6"> <a href="#" class="hover:text-blue-200 transition" onclick="showDashboard()">Dashboard</a> <a href="#" class="hover:text-blue-200 transition" onclick="showExams()">Exams</a> <a href="#" class="hover:text-blue-200 transition" onclick="showResults()">Results</a> <div id="adminNav" class="hidden"> <a href="#" class="hover:text-blue-200 transition" onclick="showAdminPanel()">Admin Panel</a> </div> </div> <div class="flex items-center space-x-4"> <span id="userEmail" class="hidden md:inline"></span> <button id="logoutBtn" class="bg-blue-700 hover:bg-blue-800 px-4 py-1 rounded transition" onclick="logout()"> Logout </button> <button id="mobileMenuBtn" class="md:hidden text-xl" onclick="toggleMobileMenu()"> <i class="fas fa-bars"></i> </button> </div> </div> <!-- Mobile Menu --> <div id="mobileMenu" class="hidden md:hidden bg-blue-700 px-4 py-2"> <div class="flex flex-col space-y-2"> <a href="#" class="hover:text-blue-200 transition" onclick="showDashboard()">Dashboard</a> <a href="#" class="hover:text-blue-200 transition" onclick="showExams()">Exams</a> <a href="#" class="hover:text-blue-200 transition" onclick="showResults()">Results</a> <div id="adminNavMobile" class="hidden"> <a href="#" class="hover:text-blue-200 transition" onclick="showAdminPanel()">Admin Panel</a> </div> <div class="border-t border-blue-500 pt-2"> <span id="userEmailMobile">user@example.com</span> </div> </div> </div> </nav> <!-- Content Area --> <main class="container mx-auto px-4 py-6"> <!-- Login View --> <div id="loginView" class="max-w-md mx-auto bg-white rounded-lg shadow-md p-8"> <div class="text-center mb-6"> <i class="fas fa-graduation-cap text-5xl text-blue-600 mb-2"></i> <h1 class="text-3xl font-bold text-gray-800">LöGhid</h1> <p class="text-gray-600">Exam Platform</p> </div> <div class="mb-4"> <label class="block text-gray-700 mb-2" for="loginEmail">Email</label> <input type="email" id="loginEmail" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter your email"> </div> <div class="mb-6"> <label class="block text-gray-700 mb-2" for="loginPassword">Password</label> <input type="password" id="loginPassword" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter your password"> </div> <button onclick="login()" class="w-full bg-blue-600 text-white py-2 rounded-lg hover:bg-blue-700 transition mb-4"> Login </button> <div id="loginError" class="text-red-500 text-sm mb-4 hidden"></div> <div class="text-center"> <p class="text-gray-600">Don't have an account? <a href="#" class="text-blue-600 hover:underline" onclick="showRegistration()">Register</a></p> </div> </div> <!-- Registration View --> <div id="registrationView" class="max-w-md mx-auto bg-white rounded-lg shadow-md p-8 hidden"> <div class="text-center mb-6"> <i class="fas fa-user-plus text-4xl text-blue-600 mb-2"></i> <h1 class="text-2xl font-bold text-gray-800">Create Admin Account</h1> </div> <div class="mb-4"> <label class="block text-gray-700 mb-2" for="regName">Full Name</label> <input type="text" id="regName" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter your full name"> </div> <div class="mb-4"> <label class="block text-gray-700 mb-2" for="regEmail">Email</label> <input type="email" id="regEmail" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter your email"> </div> <div class="mb-4"> <label class="block text-gray-700 mb-2" for="regPassword">Password</label> <input type="password" id="regPassword" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Create a password"> </div> <div class="mb-6"> <label class="block text-gray-700 mb-2" for="regConfirmPassword">Confirm Password</label> <input type="password" id="regConfirmPassword" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Confirm your password"> </div> <button onclick="register()" class="w-full bg-blue-600 text-white py-2 rounded-lg hover:bg-blue-700 transition mb-4"> Register </button> <div id="regError" class="text-red-500 text-sm mb-4 hidden"></div> <div class="text-center"> <p class="text-gray-600">Already have an account? <a href="#" class="text-blue-600 hover:underline" onclick="showLogin()">Login</a></p> </div> </div> <!-- Dashboard View --> <div id="dashboardView" class="hidden"> <div class="bg-white rounded-lg shadow-md p-6 mb-6"> <h2 class="text-2xl font-bold text-gray-800 mb-4">Welcome to LöGhid</h2> <p class="text-gray-600 mb-4">Manage your exams and track student progress with our comprehensive exam platform.</p> <div class="grid grid-cols-1 md:grid-cols-3 gap-6"> <div class="bg-blue-50 rounded-lg p-4 border border-blue-100"> <div class="flex items-center mb-2"> <i class="fas fa-calendar-alt text-blue-600 mr-2"></i> <h3 class="font-semibold text-gray-800">Upcoming Exams</h3> </div> <p class="text-gray-600 text-sm mb-2">You have <span class="font-bold">3</span> upcoming exams</p> <a href="#" class="text-blue-600 text-sm hover:underline" onclick="showExams()">View all</a> </div> <div class="bg-green-50 rounded-lg p-4 border border-green-100"> <div class="flex items-center mb-2"> <i class="fas fa-check-circle text-green-600 mr-2"></i> <h3 class="font-semibold text-gray-800">Completed Exams</h3> </div> <p class="text-gray-600 text-sm mb-2"><span class="font-bold">12</span> exams completed</p> <a href="#" class="text-green-600 text-sm hover:underline" onclick="showResults()">View results</a> </div> <div class="bg-purple-50 rounded-lg p-4 border border-purple-100"> <div class="flex items-center mb-2"> <i class="fas fa-users text-purple-600 mr-2"></i> <h3 class="font-semibold text-gray-800">Active Students</h3> </div> <p class="text-gray-600 text-sm mb-2"><span class="font-bold">24</span> students active</p> <a href="#" class="text-purple-600 text-sm hover:underline" onclick="showAdminPanel()">Manage</a> </div> </div> </div> <div class="bg-white rounded-lg shadow-md p-6"> <h2 class="text-xl font-bold text-gray-800 mb-4">Quick Actions</h2> <div class="grid grid-cols-2 md:grid-cols-4 gap-4"> <button onclick="showCreateExam()" class="bg-blue-100 hover:bg-blue-200 text-blue-800 py-2 px-4 rounded-lg transition flex items-center justify-center"> <i class="fas fa-plus mr-2"></i> New Exam </button> <button onclick="showJoinExam()" class="bg-green-100 hover:bg-green-200 text-green-800 py-2 px-4 rounded-lg transition flex items-center justify-center"> <i class="fas fa-sign-in-alt mr-2"></i> Join Exam </button> <button onclick="showResults()" class="bg-purple-100 hover:bg-purple-200 text-purple-800 py-2 px-4 rounded-lg transition flex items-center justify-center"> <i class="fas fa-chart-bar mr-2"></i> Results </button> <button onclick="showAdminPanel()" id="adminQuickAction" class="bg-yellow-100 hover:bg-yellow-200 text-yellow-800 py-2 px-4 rounded-lg transition flex items-center justify-center hidden"> <i class="fas fa-cog mr-2"></i> Admin Panel </button> </div> </div> </div> <!-- Exams View --> <div id="examsView" class="hidden"> <div class="flex justify-between items-center mb-6"> <h2 class="text-2xl font-bold text-gray-800">Exams</h2> <button onclick="showCreateExam()" class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg transition flex items-center"> <i class="fas fa-plus mr-2"></i> Create Exam </button> </div> <div class="bg-white rounded-lg shadow-md overflow-hidden"> <div class="grid grid-cols-12 bg-gray-100 p-4 font-semibold text-gray-700 border-b"> <div class="col-span-5">Exam Name</div> <div class="col-span-2">Type</div> <div class="col-span-2">Date</div> <div class="col-span-2">Status</div> <div class="col-span-1">Actions</div> </div> <div class="divide-y"> <!-- Sample exam row --> <div class="grid grid-cols-12 p-4 items-center hover:bg-gray-50"> <div class="col-span-5 font-medium">Mathematics Final Exam</div> <div class="col-span-2 text-gray-600">Quiz</div> <div class="col-span-2 text-gray-600">2023-06-15</div> <div class="col-span-2"> <span class="bg-green-100 text-green-800 text-xs px-2 py-1 rounded">Active</span> </div> <div class="col-span-1 flex justify-end"> <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" onclick="deleteExam('${exam.id}')"> <i class="fas fa-trash"></i> </button> </div> </div> <!-- Another sample exam row --> <div class="grid grid-cols-12 p-4 items-center hover:bg-gray-50"> <div class="col-span-5 font-medium">History Midterm</div> <div class="col-span-2 text-gray-600">Essay</div> <div class="col-span-2 text-gray-600">2023-05-20</div> <div class="col-span-2"> <span class="bg-gray-100 text-gray-800 text-xs px-2 py-1 rounded">Completed</span> </div> <div class="col-span-1 flex justify-end"> <button class="text-blue-600 hover:text-blue-800 mr-2" onclick="viewExam('history-midterm')"> <i class="fas fa-eye"></i> </button> <button class="text-red-600 hover:text-red-800"> <i class="fas fa-trash"></i> </button> </div> </div> </div> </div> </div> <!-- Create Exam View --> <div id="createExamView" class="hidden"> <div class="flex justify-between items-center mb-6"> <h2 class="text-2xl font-bold text-gray-800">Create New Exam</h2> <button onclick="showExams()" class="text-gray-600 hover:text-gray-800"> <i class="fas fa-times"></i> </button> </div> <div class="bg-white rounded-lg shadow-md p-6"> <div class="mb-6"> <label class="block text-gray-700 mb-2 font-medium">Exam Type</label> <div class="grid grid-cols-1 md:grid-cols-3 gap-4"> <div class="border rounded-lg p-4 hover:border-blue-500 cursor-pointer exam-type" data-type="quiz"> <div class="flex items-center mb-2"> <i class="fas fa-list-ul text-blue-600 mr-2"></i> <h3 class="font-semibold">Multiple Choice</h3> </div> <p class="text-gray-600 text-sm">Create a quiz with multiple choice questions</p> </div> <div class="border rounded-lg p-4 hover:border-green-500 cursor-pointer exam-type" data-type="essay"> <div class="flex items-center mb-2"> <i class="fas fa-file-alt text-green-600 mr-2"></i> <h3 class="font-semibold">Essay</h3> </div> <p class="text-gray-600 text-sm">Create an exam with essay questions</p> </div> <div class="border rounded-lg p-4 hover:border-purple-500 cursor-pointer exam-type" data-type="mixed"> <div class="flex items-center mb-2"> <i class="fas fa-blender-phone text-purple-600 mr-2"></i> <h3 class="font-semibold">Mixed</h3> </div> <p class="text-gray-600 text-sm">Combine multiple choice and essay questions</p> </div> </div> </div> <div id="examForm" class="hidden"> <div class="mb-4"> <label class="block text-gray-700 mb-2 font-medium" for="examTitle">Exam Title</label> <input type="text" id="examTitle" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter exam title"> </div> <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4"> <div> <label class="block text-gray-700 mb-2 font-medium" for="examDate">Exam Date</label> <input type="date" id="examDate" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"> </div> <div> <label class="block text-gray-700 mb-2 font-medium" for="examDuration">Duration (minutes)</label> <input type="number" id="examDuration" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="60"> </div> </div> <div class="mb-4"> <label class="block text-gray-700 mb-2 font-medium" for="examDescription">Description</label> <textarea id="examDescription" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" rows="3" placeholder="Enter exam description"></textarea> </div> <div id="quizQuestionsSection" class="hidden"> <div class="flex justify-between items-center mb-4"> <h3 class="font-medium text-gray-700">Multiple Choice Questions</h3> <button onclick="addQuestion()" class="bg-blue-600 hover:bg-blue-700 text-white py-1 px-3 rounded text-sm"> <i class="fas fa-plus mr-1"></i> Add Question </button> </div> <div id="quizQuestionsContainer"> <!-- Questions will be added here dynamically --> </div> </div> <div id="essayQuestionsSection" class="hidden"> <div class="flex justify-between items-center mb-4"> <h3 class="font-medium text-gray-700">Essay Questions</h3> <button onclick="addEssayQuestion()" class="bg-green-600 hover:bg-green-700 text-white py-1 px-3 rounded text-sm"> <i class="fas fa-plus mr-1"></i> Add Question </button> </div> <div id="essayQuestionsContainer"> <!-- Essay questions will be added here dynamically --> </div> </div> <div class="flex justify-end mt-6"> <button onclick="showExams()" class="bg-gray-200 hover:bg-gray-300 text-gray-800 py-2 px-6 rounded-lg mr-4 transition"> Cancel </button> <button onclick="saveExam()" class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-6 rounded-lg transition"> Save Exam </button> </div> </div> </div> </div> <!-- Join Exam View --> <div id="joinExamView" class="hidden"> <div class="max-w-md mx-auto bg-white rounded-lg shadow-md p-8"> <div class="text-center mb-6"> <i class="fas fa-sign-in-alt text-4xl text-blue-600 mb-2"></i> <h1 class="text-2xl font-bold text-gray-800">Join an Exam</h1> </div> <div class="mb-6"> <label class="block text-gray-700 mb-2" for="examCode">Exam Code</label> <input type="text" id="examCode" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter exam code provided by your instructor"> </div> <button onclick="joinExam()" class="w-full bg-blue-600 text-white py-2 rounded-lg hover:bg-blue-700 transition mb-4"> Join Exam </button> <div id="joinExamError" class="text-red-500 text-sm mb-4 hidden"></div> </div> </div> <!-- Exam Taking View --> <div id="examView" class="hidden"> <div class="bg-white rounded-lg shadow-md p-6"> <div class="flex justify-between items-center mb-6"> <div> <h2 id="examTitleDisplay" class="text-2xl font-bold text-gray-800">Mathematics Final Exam</h2> <div class="flex items-center mt-2"> <div id="examTimer" class="bg-red-100 text-red-800 px-3 py-1 rounded-full text-sm font-medium"> 01:23:45 remaining </div> <div id="autoSaveStatus" class="ml-4 text-green-600 text-sm flex items-center"> <i class="fas fa-check-circle mr-1"></i> Auto-saved </div> </div> </div> <button id="fullscreenBtn" class="bg-gray-100 hover:bg-gray-200 text-gray-800 py-2 px-4 rounded-lg transition flex items-center" onclick="toggleFullscreen()"> <i class="fas fa-expand mr-2"></i> Fullscreen </button> </div> <div class="border-t pt-4"> <div class="flex items-center justify-between mb-4"> <h3 class="font-medium text-gray-700">Questions</h3> <div class="flex space-x-2"> <button id="drawingToolBtn" class="bg-blue-100 hover:bg-blue-200 text-blue-800 py-1 px-3 rounded text-sm flex items-center" onclick="toggleDrawingTool()"> <i class="fas fa-pencil-alt mr-1"></i> Drawing Tool </button> <button class="bg-green-600 hover:bg-green-700 text-white py-1 px-3 rounded text-sm flex items-center" onclick="submitExam()"> <i class="fas fa-paper-plane mr-1"></i> Submit Exam </button> </div> </div> <div id="examQuestionsContainer" class="relative"> <!-- Questions will be loaded here --> <canvas id="drawingCanvas" class="drawing-canvas" width="0" height="0"></canvas> </div> </div> </div> </div> <!-- Results View --> <div id="resultsView" class="hidden"> <div class="flex justify-between items-center mb-6"> <h2 class="text-2xl font-bold text-gray-800">Exam Results</h2> <div class="flex items-center"> <select id="resultFilter" class="border rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500"> <option value="all">All Results</option> <option value="last-month">Last Month</option> <option value="last-week">Last Week</option> </select> </div> </div> <div class="bg-white rounded-lg shadow-md overflow-hidden"> <div class="grid grid-cols-12 bg-gray-100 p-4 font-semibold text-gray-700 border-b"> <div class="col-span-4">Exam Name</div> <div class="col-span-3">Student</div> <div class="col-span-2">Date Taken</div> <div class="col-span-2">Score</div> <div class="col-span-1">Actions</div> </div> <div class="divide-y"> <!-- Sample result row --> <div class="grid grid-cols-12 p-4 items-center hover:bg-gray-50"> <div class="col-span-4 font-medium">Mathematics Final Exam</div> <div class="col-span-3 text-gray-600">John Doe (john@example.com)</div> <div class="col-span-2 text-gray-600">2023-06-15</div> <div class="col-span-2"> <span class="bg-blue-100 text-blue-800 px-2 py-1 rounded text-sm">85/100</span> </div> <div class="col-span-1 flex justify-end"> <button class="text-blue-600 hover:text-blue-800" onclick="viewResult('math-final-john')"> <i class="fas fa-eye"></i> </button> </div> </div> <!-- Another sample result row --> <div class="grid grid-cols-12 p-4 items-center hover:bg-gray-50"> <div class="col-span-4 font-medium">History Midterm</div> <div class="col-span-3 text-gray-600">Jane Smith (jane@example.com)</div> <div class="col-span-2 text-gray-600">2023-05-20</div> <div class="col-span-2"> <span class="bg-green-100 text-green-800 px-2 py-1 rounded text-sm">92/100</span> </div> <div class="col-span-1 flex justify-end"> <button class="text-blue-600 hover:text-blue-800" onclick="viewResult('history-midterm-jane')"> <i class="fas fa-eye"></i> </button> </div> </div> </div> </div> </div> <!-- Admin Panel View --> <div id="adminPanelView" class="hidden"> <div class="flex justify-between items-center mb-6"> <h2 class="text-2xl font-bold text-gray-800">Admin Panel</h2> <div class="flex items-center space-x-4"> <button onclick="showCreateUser()" class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg transition flex items-center"> <i class="fas fa-user-plus mr-2"></i> Create User </button> </div> </div> <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6"> <div class="bg-white rounded-lg shadow-md p-6"> <h3 class="font-semibold text-gray-800 mb-4">System Statistics</h3> <div class="space-y-4"> <div> <p class="text-gray-600 text-sm">Total Users</p> <p class="text-2xl font-bold">124</p> </div> <div> <p class="text-gray-600 text-sm">Active Exams</p> <p class="text-2xl font-bold">8</p> </div> <div> <p class="text-gray-600 text-sm">Completed Exams</p> <p class="text-2xl font-bold">56</p> </div> </div> </div> <div class="bg-white rounded-lg shadow-md p-6"> <h3 class="font-semibold text-gray-800 mb-4">Recent Activity</h3> <div class="space-y-3"> <div class="flex items-start"> <div class="bg-blue-100 p-2 rounded-full mr-3"> <i class="fas fa-user text-blue-600"></i> </div> <div> <p class="text-sm">John Doe completed "Mathematics Final Exam"</p> <p class="text-xs text-gray-500">2 hours ago</p> </div> </div> <div class="flex items-start"> <div class="bg-green-100 p-2 rounded-full mr-3"> <i class="fas fa-file-alt text-green-600"></i> </div> <div> <p class="text-sm">New exam "Chemistry Quiz" created</p> <p class="text-xs text-gray-500">5 hours ago</p> </div> </div> </div> </div> <div class="bg-white rounded-lg shadow-md p-6"> <h3 class="font-semibold text-gray-800 mb-4">System Monitoring</h3> <div class="space-y-4"> <div> <div class="flex justify-between mb-1"> <span class="text-sm text-gray-600">Storage</span> <span class="text-sm font-medium">65% used</span> </div> <div class="w-full bg-gray-200 rounded-full h-2"> <div class="bg-blue-600 h-2 rounded-full" style="width: 65%"></div> </div> </div> <div> <div class="flex justify-between mb-1"> <span class="text-sm text-gray-600">Memory</span> <span class="text-sm font-medium">42% used</span> </div> <div class="w-full bg-gray-200 rounded-full h-2"> <div class="bg-green-500 h-2 rounded-full" style="width: 42%"></div> </div> </div> </div> </div> </div> <div class="bg-white rounded-lg shadow-md p-6"> <h3 class="font-semibold text-gray-800 mb-4">User Management</h3> <div class="overflow-x-auto"> <table class="min-w-full divide-y divide-gray-200"> <thead class="bg-gray-50"> <tr> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Role</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Last Active</th> <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th> </tr> </thead> <tbody class="bg-white divide-y divide-gray-200"> <tr> <td class="px-6 py-4 whitespace-nowrap"> <div class="flex items-center"> <div class="flex-shrink-0 h-10 w-10"> <div class="bg-blue-100 text-blue-600 rounded-full h-10 w-10 flex items-center justify-center"> <i class="fas fa-user"></i> </div> </div> <div class="ml-4"> <div class="text-sm font-medium text-gray-900">Admin User</div> </div> </div> </td> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">admin@loghid.com</td> <td class="px-6 py-4 whitespace-nowrap"> <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-purple-100 text-purple-800">Admin</span> </td> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">Just now</td> <td class="px-6 py-4 whitespace-nowrap text-sm font-medium"> <button class="text-blue-600 hover:text-blue-900 mr-3">Edit</button> <button class="text-red-600 hover:text-red-900">Delete</button> </td> </tr> <tr> <td class="px-6 py-4 whitespace-nowrap"> <div class="flex items-center"> <div class="flex-shrink-0 h-10 w-10"> <div class="bg-green-100 text-green-600 rounded-full h-10 w-10 flex items-center justify-center"> <i class="fas fa-user-graduate"></i> </div> </div> <div class="ml-4"> <div class="text-sm font-medium text-gray-900">John Doe</div> </div> </div> </td> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">john@example.com</td> <td class="px-6 py-4 whitespace-nowrap"> <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-blue-100 text-blue-800">Student</span> </td> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">2 hours ago</td> <td class="px-6 py-4 whitespace-nowrap text-sm font-medium"> <button class="text-blue-600 hover:text-blue-900 mr-3">Edit</button> <button class="text-red-600 hover:text-red-900">Delete</button> </td> </tr> </tbody> </table> </div> </div> </div> <!-- Create User View --> <div id="createUserView" class="hidden"> <div class="flex justify-between items-center mb-6"> <h2 class="text-2xl font-bold text-gray-800">Create New User</h2> <button onclick="showAdminPanel()" class="text-gray-600 hover:text-gray-800"> <i class="fas fa-times"></i> </button> </div> <div class="bg-white rounded-lg shadow-md p-6"> <div class="mb-4"> <label class="block text-gray-700 mb-2 font-medium" for="userName">Full Name</label> <input type="text" id="userName" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter user's full name"> </div> <div class="mb-4"> <label class="block text-gray-700 mb-2 font-medium" for="userEmail">Email</label> <input type="email" id="userEmail" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter user's email"> </div> <div class="mb-4"> <label class="block text-gray-700 mb-2 font-medium" for="userRole">Role</label> <select id="userRole" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"> <option value="student">Student</option> <option value="admin">Admin</option> </select> </div> <div class="mb-6"> <label class="block text-gray-700 mb-2 font-medium" for="userPassword">Password</label> <input type="password" id="userPassword" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Set a password for the user"> </div> <div class="flex justify-end"> <button onclick="showAdminPanel()" class="bg-gray-200 hover:bg-gray-300 text-gray-800 py-2 px-6 rounded-lg mr-4 transition"> Cancel </button> <button onclick="createUser()" class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-6 rounded-lg transition"> Create User </button> </div> </div> </div> <!-- View Result View --> <div id="viewResultView" class="hidden"> <div class="flex justify-between items-center mb-6"> <h2 class="text-2xl font-bold text-gray-800">Exam Result</h2> <button onclick="showResults()" class="text-gray-600 hover:text-gray-800"> <i class="fas fa-times"></i> </button> </div> <div class="bg-white rounded-lg shadow-md p-6"> <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6"> <div> <h3 class="font-semibold text-gray-700 mb-2">Exam</h3> <p class="text-gray-800">Mathematics Final Exam</p> </div> <div> <h3 class="font-semibold text-gray-700 mb-2">Student</h3> <p class="text-gray-800">John Doe (john@example.com)</p> </div> <div> <h3 class="font-semibold text-gray-700 mb-2">Score</h3> <p class="text-2xl font-bold text-blue-600">85/100</p> </div> </div> <div class="border-t pt-4"> <h3 class="font-semibold text-gray-700 mb-4">Answers</h3> <div class="space-y-6"> <div class="border rounded-lg p-4"> <div class="flex justify-between mb-2"> <h4 class="font-medium">1. What is 2 + 2?</h4> <span class="text-green-600 font-medium">Correct</span> </div> <p class="text-gray-600 mb-2">Student answer: 4</p> <p class="text-sm text-gray-500">Points: 5/5</p> </div> <div class="border rounded-lg p-4"> <div class="flex justify-between mb-2"> <h4 class="font-medium">2. Solve for x: 3x + 5 = 20</h4> <span class="text-red-600 font-medium">Incorrect</span> </div> <p class="text-gray-600 mb-2">Student answer: 4</p> <p class="text-sm text-gray-500 mb-2">Correct answer: 5</p> <p class="text-sm text-gray-500">Points: 0/5</p> </div> <div class="border rounded-lg p-4"> <div class="flex justify-between mb-2"> <h4 class="font-medium">3. Essay: Explain the Pythagorean theorem</h4> <span class="text-blue-600 font-medium">Graded</span> </div> <p class="text-gray-600 mb-2">Student answer: The Pythagorean theorem states that in a right-angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides. This can be written as a² + b² = c² where c is the hypotenuse.</p> <p class="text-sm text-gray-500">Points: 8/10</p> </div> </div> </div> <div class="flex justify-end mt-6"> <button onclick="printResult()" class="bg-gray-200 hover:bg-gray-300 text-gray-800 py-2 px-6 rounded-lg mr-4 transition flex items-center"> <i class="fas fa-file-pdf mr-2"></i> Export PDF </button> <button onclick="showResults()" class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-6 rounded-lg transition"> Back to Results </button> </div> </div> </div> </main> </div> <script> // Simulate loading setTimeout(() => { document.getElementById('loadingScreen').classList.add('hidden'); document.getElementById('app').classList.remove('hidden'); showLogin(); }, 1500); // State management let currentUser = null; let isAdmin = false; let examType = null; let isDrawing = false; let isFullscreen = false; let canvas = null; let ctx = null; let isCanvasActive = false; let lastX = 0; let lastY = 0; // View management functions function hideAllViews() { document.querySelectorAll('main > div').forEach(view => { view.classList.add('hidden'); }); } function showLogin() { hideAllViews(); document.getElementById('loginView').classList.remove('hidden'); document.getElementById('registrationView').classList.add('hidden'); } function showRegistration() { hideAllViews(); document.getElementById('loginView').classList.add('hidden'); document.getElementById('registrationView').classList.remove('hidden'); } function showDashboard() { if (!currentUser) { showLogin(); return; } hideAllViews(); document.getElementById('dashboardView').classList.remove('hidden'); updateNav(); updateDashboardStats(); } function showExams() { if (!currentUser) { showLogin(); return; } hideAllViews(); document.getElementById('examsView').classList.remove('hidden'); updateNav(); loadExams(); } function showCreateExam() { hideAllViews(); document.getElementById('createExamView').classList.remove('hidden'); updateNav(); } function showJoinExam() { hideAllViews(); document.getElementById('joinExamView').classList.remove('hidden'); updateNav(); } function showExamView() { hideAllViews(); document.getElementById('examView').classList.remove('hidden'); updateNav(); } function showResults() { if (!currentUser) { showLogin(); return; } hideAllViews(); document.getElementById('resultsView').classList.remove('hidden'); updateNav(); loadResults(); } function showAdminPanel() { hideAllViews(); document.getElementById('adminPanelView').classList.remove('hidden'); updateNav(); } function showCreateUser() { hideAllViews(); document.getElementById('createUserView').classList.remove('hidden'); updateNav(); } function showViewResult() { hideAllViews(); document.getElementById('viewResultView').classList.remove('hidden'); updateNav(); } function updateNav() { if (currentUser) { document.getElementById('userEmail').textContent = currentUser.email; document.getElementById('userEmailMobile').textContent = currentUser.email; if (isAdmin) { document.getElementById('adminNav').classList.remove('hidden'); document.getElementById('adminNavMobile').classList.remove('hidden'); document.getElementById('adminQuickAction').classList.remove('hidden'); } else { document.getElementById('adminNav').classList.add('hidden'); document.getElementById('adminNavMobile').classList.add('hidden'); document.getElementById('adminQuickAction').classList.add('hidden'); } } } function toggleMobileMenu() { const menu = document.getElementById('mobileMenu'); menu.classList.toggle('hidden'); } // Auth functions function login() { const email = document.getElementById('loginEmail').value; const password = document.getElementById('loginPassword').value; const errorElement = document.getElementById('loginError'); // Validation if (!email || !password) { errorElement.textContent = 'Please enter both email and password'; errorElement.classList.remove('hidden'); return; } // Basic email validation if (!/^\S+@\S+\.\S+$/.test(email)) { errorElement.textContent = 'Please enter a valid email address'; errorElement.classList.remove('hidden'); return; } // Password length check if (password.length < 6) { errorElement.textContent = 'Password must be at least 6 characters'; errorElement.classList.remove('hidden'); return; } // Simulate successful login currentUser = { email: email, name: email.split('@')[0] // Use first part of email as name }; // Determine if admin (for demo purposes) isAdmin = email.includes('admin') || email.includes('teacher'); // Store auth data localStorage.setItem('authToken', 'simulated-jwt-token'); localStorage.setItem('user', JSON.stringify(currentUser)); localStorage.setItem('isAdmin', isAdmin); // Update UI errorElement.classList.add('hidden'); // Redirect based on role if (isAdmin) { showDashboard(); } else { showJoinExam(); } } function register() { const name = document.getElementById('regName').value; const email = document.getElementById('regEmail').value; const password = document.getElementById('regPassword').value; const confirmPassword = document.getElementById('regConfirmPassword').value; const errorElement = document.getElementById('regError'); // Validation if (!name || !email || !password || !confirmPassword) { errorElement.textContent = 'Please fill in all fields'; errorElement.classList.remove('hidden'); return; } if (password !== confirmPassword) { errorElement.textContent = 'Passwords do not match'; errorElement.classList.remove('hidden'); return; } if (password.length < 6) { errorElement.textContent = 'Password must be at least 6 characters'; errorElement.classList.remove('hidden'); return; } // Simulate API call setTimeout(() => { errorElement.classList.add('hidden'); alert('Registration successful! You can now login.'); showLogin(); }, 500); } function logout() { // Clear all auth data localStorage.removeItem('authToken'); localStorage.removeItem('user'); localStorage.removeItem('isAdmin'); // Reset state currentUser = null; isAdmin = false; // Clear form fields document.getElementById('loginEmail').value = ''; document.getElementById('loginPassword').value = ''; // Hide any errors document.getElementById('loginError').classList.add('hidden'); // Show login screen showLogin(); // Hide all authenticated views document.getElementById('dashboardView').classList.add('hidden'); document.getElementById('examsView').classList.add('hidden'); document.getElementById('resultsView').classList.add('hidden'); document.getElementById('adminPanelView').classList.add('hidden'); } // Check if user is already logged in function checkAuth() { const token = localStorage.getItem('authToken'); const user = localStorage.getItem('user'); const admin = localStorage.getItem('isAdmin'); if (token && user) { try { currentUser = JSON.parse(user); isAdmin = admin === 'true'; // Update UI with user info document.getElementById('userEmail').textContent = currentUser.email; document.getElementById('userEmailMobile').textContent = currentUser.email; // Redirect based on role if (isAdmin) { showDashboard(); } else { showJoinExam(); } } catch (e) { console.error('Error parsing user data:', e); logout(); } } else { showLogin(); } } // Exam functions function setExamType(type) { examType = type; document.getElementById('examForm').classList.remove('hidden'); // Hide all question sections first document.getElementById('quizQuestionsSection').classList.add('hidden'); document.getElementById('essayQuestionsSection').classList.add('hidden'); // Show the appropriate section if (type === 'quiz') { document.getElementById('quizQuestionsSection').classList.remove('hidden'); addQuestion(); // Add first question by default } else if (type === 'essay') { document.getElementById('essayQuestionsSection').classList.remove('hidden'); addEssayQuestion(); // Add first question by default } else if (type === 'mixed') { document.getElementById('quizQuestionsSection').classList.remove('hidden'); document.getElementById('essayQuestionsSection').classList.remove('hidden'); addQuestion(); addEssayQuestion(); } } function addQuestion() { const container = document.getElementById('quizQuestionsContainer'); const questionCount = container.children.length + 1; const questionDiv = document.createElement('div'); questionDiv.className = 'border rounded-lg p-4 mb-4'; questionDiv.innerHTML = ` <div class="flex justify-between items-center mb-3"> <h4 class="font-medium">Question ${questionCount}</h4> <button class="text-red-500 hover:text-red-700 text-sm" onclick="this.parentElement.parentElement.remove(); renumberQuestions()"> <i class="fas fa-trash"></i> Remove </button> </div> <div class="mb-3"> <input type="text" class="w-full px-3 py-2 border rounded question-text" placeholder="Enter question text"> </div> <div class="space-y-2 mb-3"> <div class="flex items-center"> <input type="radio" name="correct-${questionCount}" value="1" class="mr-2" checked> <input type="text" class="w-full px-3 py-1 border rounded option-text" placeholder="Option 1"> </div> <div class="flex items-center"> <input type="radio" name="correct-${questionCount}" value="2" class="mr-2"> <input type="text" class="w-full px-3 py-1 border rounded option-text" placeholder="Option 2"> </div> <div class="flex items-center"> <input type="radio" name="correct-${questionCount}" value="3" class="mr-2"> <input type="text" class="w-full px-3 py-1 border rounded option-text" placeholder="Option 3"> </div> <div class="flex items-center"> <input type="radio" name="correct-${questionCount}" value="4" class="mr-2"> <input type="text" class="w-full px-3 py-1 border rounded option-text" placeholder="Option 4"> </div> </div> <div class="flex items-center"> <label class="mr-2 text-sm">Points:</label> <input type="number" class="w-16 px-2 py-1 border rounded" value="1" min="1"> </div> `; container.appendChild(questionDiv); } function addEssayQuestion() { const container = document.getElementById('essayQuestionsContainer'); const questionCount = container.children.length + 1; const questionDiv = document.createElement('div'); questionDiv.className = 'border rounded-lg p-4 mb-4'; questionDiv.innerHTML = ` <div class="flex justify-between items-center mb-3"> <h4 class="font-medium">Essay Question ${questionCount}</h4> <button class="text-red-500 hover:text-red-700 text-sm" onclick="this.parentElement.parentElement.remove(); renumberEssayQuestions()"> <i class="fas fa-trash"></i> Remove </button> </div> <div class="mb-3"> <textarea class="w-full px-3 py-2 border rounded question-text" rows="3" placeholder="Enter essay question"></textarea> </div> <div class="flex items-center"> <label class="mr-2 text-sm">Max Points:</label> <input type="number" class="w-16 px-2 py-1 border rounded" value="10" min="1"> </div> `; container.appendChild(questionDiv); } function renumberQuestions() { const container = document.getElementById('quizQuestionsContainer'); Array.from(container.children).forEach((child, index) => { const title = child.querySelector('h4'); if (title) { title.textContent = `Question ${index + 1}`; } }); } function renumberEssayQuestions() { const container = document.getElementById('essayQuestionsContainer'); Array.from(container.children).forEach((child, index) => { const title = child.querySelector('h4'); if (title) { title.textContent = `Essay Question ${index + 1}`; } }); } function saveExam() { const title = document.getElementById('examTitle').value; const date = document.getElementById('examDate').value; const duration = document.getElementById('examDuration').value; const description = document.getElementById('examDescription').value; if (!title || !date || !duration) { alert('Please fill in all required fields'); return; } // Collect questions let questions = []; if (examType === 'quiz' || examType === 'mixed') { const questionElements = document.getElementById('quizQuestionsContainer').children; Array.from(questionElements).forEach(q => { const questionText = q.querySelector('.question-text').value; const options = Array.from(q.querySelectorAll('.option-text')).map(o => o.value); const correctAnswer = q.querySelector('input[type="radio"]:checked').value; const points = q.querySelector('input[type="number"]').value; if (questionText && options.every(o => o)) { questions.push({ type: 'multiple_choice', question: questionText, options: options, correct_answer: parseInt(correctAnswer), points: parseInt(points) }); } }); } if (examType === 'essay' || examType === 'mixed') { const essayElements = document.getElementById('essayQuestionsContainer').children; Array.from(essayElements).forEach(q => { const questionText = q.querySelector('.question-text').value; const points = q.querySelector('input[type="number"]').value; if (questionText) { questions.push({ type: 'essay', question: questionText, points: parseInt(points) }); } }); } if (questions.length === 0) { alert('Please add at least one question'); return; } // In a real app, you would send this data to your backend const examData = { title, date, duration, description, type: examType, questions, code: generateExamCode() }; console.log('Exam data to save:', examData); alert(`Exam saved successfully!\nExam Code: ${examData.code}\nShare this code with students.`); showExams(); } function generateExamCode() { return Math.random().toString(36).substring(2, 8).toUpperCase(); } function joinExam() { const code = document.getElementById('examCode').value; const errorElement = document.getElementById('joinExamError'); if (!code) { errorElement.textContent = 'Please enter an exam code'; errorElement.classList.remove('hidden'); return; } // Simulate checking exam code setTimeout(() => { // In a real app, you'd check with your backend if (code === 'DEMO123') { errorElement.classList.add('hidden'); startExam(); } else { errorElement.textContent = 'Invalid exam code. Please check with your instructor.'; errorElement.classList.remove('hidden'); } }, 500); } function startExam() { // Set exam title document.getElementById('examTitleDisplay').textContent = 'Demo Exam'; // Start timer (1 hour for demo) startTimer(60 * 60); // Load questions loadExamQuestions(); // Initialize drawing canvas initDrawingCanvas(); // Start auto-save simulation setInterval(() => { const status = document.getElementById('autoSaveStatus'); status.classList.remove('text-red-600', 'text-green-600'); status.classList.add('text-red-600'); status.innerHTML = '<i class="fas fa-sync-alt mr-1 animate-spin"></i> Saving...'; setTimeout(() => { status.classList.remove('text-red-600'); status.classList.add('text-green-600'); status.innerHTML = '<i class="fas fa-check-circle mr-1"></i> Auto-saved'; }, 1000); }, 30000); // Start screenshots simulation (would be handled by backend in real app) setInterval(() => { console.log('Taking screenshot...'); }, 5 * 60 * 1000); showExamView(); } function startTimer(totalSeconds) { const timerElement = document.getElementById('examTimer'); function updateTimer() { const hours = Math.floor(totalSeconds / 3600); const minutes = Math.floor((totalSeconds % 3600) / 60); const seconds = totalSeconds % 60; timerElement.textContent = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')} remaining`; if (totalSeconds <= 0) { timerElement.textContent = "Time's up!"; timerElement.classList.add('bg-red-500', 'text-white'); timerElement.classList.remove('bg-red-100', 'text-red-800'); alert("Time's up! Your exam will be submitted automatically."); submitExam(); return; } totalSeconds--; setTimeout(updateTimer, 1000); } updateTimer(); } function loadExamQuestions() { const container = document.getElementById('examQuestionsContainer'); container.innerHTML = ''; // Clear existing // Add some demo questions const questions = [ { type: 'multiple_choice', question: 'What is 2 + 2?', options: ['3', '4', '5', '6'], points: 5 }, { type: 'multiple_choice', question: 'What is the capital of France?', options: ['London', 'Berlin', 'Paris', 'Madrid'], points: 5 }, { type: 'essay', question: 'Explain the Pythagorean theorem', points: 10 } ]; questions.forEach((q, index) => { const questionDiv = document.createElement('div'); questionDiv.className = 'mb-8 p-4 border rounded-lg'; if (q.type === 'multiple_choice') { questionDiv.innerHTML = ` <div class="mb-4"> <h4 class="font-medium mb-2">${index + 1}. ${q.question} <span class="text-sm text-gray-500">(${q.points} points)</span></h4> <div class="space-y-2 ml-4"> ${q.options.map((opt, i) => ` <div class="flex items-center"> <input type="radio" name="q${index}" id="q${index}o${i}" value="${i}" class="mr-2"> <label for="q${index}o${i}">${opt}</label> </div> `).join('')} </div> </div> `; } else if (q.type === 'essay') { questionDiv.innerHTML = ` <div class="mb-4"> <h4 class="font-medium mb-2">${index + 1}. ${q.question} <span class="text-sm text-gray-500">(${q.points} points)</span></h4> <textarea class="w-full px-3 py-2 border rounded" rows="4" placeholder="Type your answer here..."></textarea> </div> `; } container.appendChild(questionDiv); }); // Add the canvas for drawing (positioned absolutely over the questions) const canvas = document.createElement('canvas'); canvas.id = 'drawingCanvas'; canvas.className = 'drawing-canvas'; canvas.width = container.offsetWidth; canvas.height = container.offsetHeight; container.appendChild(canvas); } function initDrawingCanvas() { canvas = document.getElementById('drawingCanvas'); ctx = canvas.getContext('2d'); // Set canvas size to match container const container = document.getElementById('examQuestionsContainer'); canvas.width = container.offsetWidth; canvas.height = container.offsetHeight; // Set canvas styles ctx.strokeStyle = '#FF0000'; ctx.lineWidth = 3; ctx.lineCap = 'round'; // Event listeners for drawing canvas.addEventListener('mousedown', startDrawing); canvas.addEventListener('mousemove', draw); canvas.addEventListener('mouseup', stopDrawing); canvas.addEventListener('mouseout', stopDrawing); // Touch support canvas.addEventListener('touchstart', handleTouchStart); canvas.addEventListener('touchmove', handleTouchMove); canvas.addEventListener('touchend', stopDrawing); } function startDrawing(e) { if (!isCanvasActive) return; isDrawing = true; const rect = canvas.getBoundingClientRect(); lastX = e.clientX - rect.left; lastY = e.clientY - rect.top; } function handleTouchStart(e) { if (!isCanvasActive) return; e.preventDefault(); isDrawing = true; const rect = canvas.getBoundingClientRect(); const touch = e.touches[0]; lastX = touch.clientX - rect.left; lastY = touch.clientY - rect.top; } function draw(e) { if (!isDrawing || !isCanvasActive) return; const rect = canvas.getBoundingClientRect(); let currentX, currentY; if (e.type === 'mousemove') { currentX = e.clientX - rect.left; currentY = e.clientY - rect.top; } else if (e.type === 'touchmove') { e.preventDefault(); const touch = e.touches[0]; currentX = touch.clientX - rect.left; currentY = touch.clientY - rect.top; } ctx.beginPath(); ctx.moveTo(lastX, lastY); ctx.lineTo(currentX, currentY); ctx.stroke(); lastX = currentX; lastY = currentY; } function stopDrawing() { isDrawing = false; } function toggleDrawingTool() { isCanvasActive = !isCanvasActive; const btn = document.getElementById('drawingToolBtn'); if (isCanvasActive) { btn.innerHTML = '<i class="fas fa-pencil-alt mr-1"></i> Drawing (Active)'; btn.classList.add('bg-blue-600', 'text-white'); btn.classList.remove('bg-blue-100', 'text-blue-800'); canvas.style.pointerEvents = 'auto'; } else { btn.innerHTML = '<i class="fas fa-pencil-alt mr-1"></i> Drawing Tool'; btn.classList.remove('bg-blue-600', 'text-white'); btn.classList.add('bg-blue-100', 'text-blue-800'); canvas.style.pointerEvents = 'none'; } } function clearDrawing() { ctx.clearRect(0, 0, canvas.width, canvas.height); } function toggleFullscreen() { const elem = document.getElementById('examView'); const btn = document.getElementById('fullscreenBtn'); if (!isFullscreen) { if (elem.requestFullscreen) { elem.requestFullscreen(); } else if (elem.webkitRequestFullscreen) { /* Safari */ elem.webkitRequestFullscreen(); } else if (elem.msRequestFullscreen) { /* IE11 */ elem.msRequestFullscreen(); } btn.innerHTML = '<i class="fas fa-compress mr-2"></i> Exit Fullscreen'; isFullscreen = true; } else { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.webkitExitFullscreen) { /* Safari */ document.webkitExitFullscreen(); } else if (document.msExitFullscreen) { /* IE11 */ document.msExitFullscreen(); } btn.innerHTML = '<i class="fas fa-expand mr-2"></i> Fullscreen'; isFullscreen = false; } } function submitExam() { // In a real app, you'd send the answers to your backend alert('Exam submitted successfully!'); showDashboard(); } // Store exams and stats in memory let exams = [ { id: 'math-final', title: 'Mathematics Final Exam', type: 'Quiz', date: '2023-06-15', status: 'Active', code: 'DEMO123', students: 24 }, { id: 'history-midterm', title: 'History Midterm', type: 'Essay', date: '2023-05-20', status: 'Completed', code: 'HIST456', students: 18 } ]; let results = [ { id: 'math-final-john', examId: 'math-final', student: 'John Doe', email: 'john@example.com', date: '2023-06-15', score: 85, total: 100 }, { id: 'history-midterm-jane', examId: 'history-midterm', student: 'Jane Smith', email: 'jane@example.com', date: '2023-05-20', score: 92, total: 100 } ]; function updateDashboardStats() { const activeExams = exams.filter(e => e.status === 'Active').length; const completedExams = exams.filter(e => e.status === 'Completed').length; const totalStudents = exams.reduce((sum, exam) => sum + (exam.students || 0), 0); document.querySelector('#dashboardView [data-stat="upcoming"]').textContent = activeExams; document.querySelector('#dashboardView [data-stat="completed"]').textContent = completedExams; document.querySelector('#dashboardView [data-stat="students"]').textContent = totalStudents; } function loadExams() { const container = document.querySelector('#examsView .divide-y'); container.innerHTML = ''; exams.forEach(exam => { const examDiv = document.createElement('div'); examDiv.className = 'grid grid-cols-12 p-4 items-center hover:bg-gray-50'; examDiv.innerHTML = ` <div class="col-span-5 font-medium">${exam.title}</div> <div class="col-span-2 text-gray-600">${exam.type}</div> <div class="col-span-2 text-gray-600">${exam.date}</div> <div class="col-span-2"> <span class="${exam.status === 'Active' ? 'bg-green-100 text-green-800' : 'bg-gray-100 text-gray-800'} text-xs px-2 py-1 rounded"> ${exam.status} </span> </div> <div class="col-span-1 flex justify-end"> <button class="text-blue-600 hover:text-blue-800 mr-2" onclick="viewExam('${exam.id}')"> <i class="fas fa-eye"></i> </button> <button class="text-red-600 hover:text-red-800" onclick="deleteExam('${exam.id}')"> <i class="fas fa-trash"></i> </button> </div> `; container.appendChild(examDiv); }); } function loadResults() { const container = document.querySelector('#resultsView .divide-y'); container.innerHTML = ''; results.forEach(result => { const exam = exams.find(e => e.id === result.examId); if (!exam) return; const resultDiv = document.createElement('div'); resultDiv.className = 'grid grid-cols-12 p-4 items-center hover:bg-gray-50'; resultDiv.innerHTML = ` <div class="col-span-4 font-medium">${exam.title}</div> <div class="col-span-3 text-gray-600">${result.student} (${result.email})</div> <div class="col-span-2 text-gray-600">${result.date}</div> <div class="col-span-2"> <span class="bg-blue-100 text-blue-800 px-2 py-1 rounded text-sm"> ${result.score}/${result.total} </span> </div> <div class="col-span-1 flex justify-end"> <button class="text-blue-600 hover:text-blue-800" onclick="viewResult('${result.id}')"> <i class="fas fa-eye"></i> </button> </div> `; container.appendChild(resultDiv); }); } function viewExam(examId) { 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 (!currentUser) { showLogin(); return; } if (confirm('Are you sure you want to delete this exam? This action cannot be undone.')) { exams = exams.filter(e => e.id !== examId); // Also remove any results for this exam results = results.filter(r => r.examId !== examId); // Update UI loadExams(); if (document.getElementById('dashboardView').classList.contains('hidden')) { updateDashboardStats(); } alert('Exam deleted successfully'); } } function viewResult(resultId) { // In a real app, you'd fetch result details console.log('Viewing result:', resultId); showViewResult(); } function printResult() { // In a real app, you'd generate a PDF alert('Generating PDF...'); } function createUser() { const name = document.getElementById('userName').value; const email = document.getElementById('userEmail').value; const role = document.getElementById('userRole').value; const password = document.getElementById('userPassword').value; if (!name || !email || !password) { alert('Please fill in all fields'); return; } // In a real app, you'd send this to your backend console.log('Creating user:', { name, email, role, password }); alert('User created successfully!'); showAdminPanel(); } // Initialize exam type selection document.querySelectorAll('.exam-type').forEach(el => { el.addEventListener('click', () => { document.querySelectorAll('.exam-type').forEach(e => { e.classList.remove('border-blue-500', 'border-green-500', 'border-purple-500'); }); el.classList.add(`border-${el.dataset.type === 'quiz' ? 'blue' : el.dataset.type === 'essay' ? 'green' : 'purple'}-500`); setExamType(el.dataset.type); }); }); // Check auth on page load checkAuth(); </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=SWEE33/l-ghid" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> </html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LöGhid - Exam Platform</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 CSS for features Tailwind can't handle */
.drawing-canvas {
position: absolute;
top: 0;
left: 0;
z-index: 10;
pointer-events: none;
}
.fullscreen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 9999;
background: white;
}
.loading-spinner {
border: 4px solid rgba(0, 0, 0, 0.1);
border-radius: 50%;
border-top: 4px solid #3b82f6;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.slide-fade-enter-active {
transition: all 0.3s ease-out;
}
.slide-fade-leave-active {
transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1);
}
.slide-fade-enter-from,
.slide-fade-leave-to {
transform: translateX(20px);
opacity: 0;
}
</style>
</head>
<body class="bg-gray-50 font-sans">
<!-- Loading Screen -->
<div id="loadingScreen" class="fixed inset-0 bg-white z-50 flex flex-col items-center justify-center">
<div class="loading-spinner mb-4"></div>
<h1 class="text-3xl font-bold text-blue-600 mb-2">LöGhid</h1>
<p class="text-gray-600">Loading exam platform...</p>
</div>
<!-- Main App Container -->
<div id="app" class="min-h-screen hidden">
<!-- Navigation Bar -->
<nav class="bg-blue-600 text-white shadow-lg">
<div class="container mx-auto px-4 py-3 flex justify-between items-center">
<div class="flex items-center space-x-2">
<i class="fas fa-graduation-cap text-2xl"></i>
<span class="text-xl font-bold">LöGhid</span>
</div>
<div id="navLinks" class="hidden md:flex space-x-6">
<a href="#" class="hover:text-blue-200 transition" onclick="showDashboard()">Dashboard</a>
<a href="#" class="hover:text-blue-200 transition" onclick="showExams()">Exams</a>
<a href="#" class="hover:text-blue-200 transition" onclick="showResults()">Results</a>
<div id="adminNav" class="hidden">
<a href="#" class="hover:text-blue-200 transition" onclick="showAdminPanel()">Admin Panel</a>
</div>
</div>
<div class="flex items-center space-x-4">
<span id="userEmail" class="hidden md:inline"></span>
<button id="logoutBtn" class="bg-blue-700 hover:bg-blue-800 px-4 py-1 rounded transition" onclick="logout()">
Logout
</button>
<button id="mobileMenuBtn" class="md:hidden text-xl" onclick="toggleMobileMenu()">
<i class="fas fa-bars"></i>
</button>
</div>
</div>
<!-- Mobile Menu -->
<div id="mobileMenu" class="hidden md:hidden bg-blue-700 px-4 py-2">
<div class="flex flex-col space-y-2">
<a href="#" class="hover:text-blue-200 transition" onclick="showDashboard()">Dashboard</a>
<a href="#" class="hover:text-blue-200 transition" onclick="showExams()">Exams</a>