// Learning Management System JavaScript class LearningManagementSystem { constructor() { this.currentUser = this.loadUserData(); this.courseData = this.loadCourseData(); this.aiResponses = this.loadAIResponses(); this.quizBank = this.loadQuizBank(); } init() { this.updateUserInterface(); this.setupEventListeners(); this.loadRecentActivity(); } loadUserData() { // In production, this would come from your backend const savedData = localStorage.getItem('userData'); if (savedData) { return JSON.parse(savedData); } return { name: 'Sarah Johnson', program: 'Healthcare Aide (HCA)', currentModule: 3, overallProgress: 30, moduleProgress: 67, completedModules: [1, 2], certificates: ['Module 1', 'Module 2'], totalStudyTime: '45 hours' }; } loadCourseData() { return { 1: { title: 'Foundations of Healthcare Aide Practice', description: 'Ethics, professionalism, roles, communication, and the healthcare system in Canada.', lessons: [ { id: 1, title: 'Introduction to Healthcare', type: 'video', duration: '15 min', completed: true }, { id: 2, title: 'Professional Ethics', type: 'reading', duration: '20 min', completed: true }, { id: 3, title: 'Communication Skills', type: 'interactive', duration: '25 min', completed: true }, { id: 4, title: 'Healthcare Team Roles', type: 'video', duration: '18 min', completed: true } ], quiz: { id: 1, title: 'Module 1 Assessment', questions: 15, completed: true, score: 89 } }, 2: { title: 'Human Body Basics', description: 'Anatomy, physiology, common illnesses, and the aging process.', lessons: [ { id: 5, title: 'Basic Anatomy Overview', type: 'video', duration: '22 min', completed: true }, { id: 6, title: 'Body Systems', type: 'interactive', duration: '30 min', completed: true }, { id: 7, title: 'Common Health Conditions', type: 'reading', duration: '25 min', completed: true }, { id: 8, title: 'Aging Process', type: 'video', duration: '20 min', completed: true } ], quiz: { id: 2, title: 'Module 2 Assessment', questions: 20, completed: true, score: 94 } }, 3: { title: 'Infection Prevention & Control', description: 'Hand hygiene, PPE, isolation precautions, and preventing healthcare-associated infections.', lessons: [ { id: 9, title: 'Hand Hygiene Fundamentals', type: 'video', duration: '18 min', completed: true }, { id: 10, title: 'Personal Protective Equipment', type: 'interactive', duration: '25 min', completed: true }, { id: 11, title: 'Isolation Precautions', type: 'reading', duration: '20 min', completed: false }, { id: 12, title: 'Cleaning & Disinfection', type: 'video', duration: '22 min', completed: false } ], quiz: { id: 3, title: 'Module 3 Assessment', questions: 18, completed: false, score: null } } }; } loadAIResponses() { return { 'hand hygiene': 'Proper hand hygiene involves washing hands with soap and water for at least 20 seconds, or using alcohol-based hand sanitizer with at least 60% alcohol. Key moments: before patient contact, after patient contact, after contact with patient surroundings, before aseptic tasks, and after body fluid exposure.', 'ppe': 'Personal Protective Equipment (PPE) includes gloves, gowns, masks, and eye protection. Always don the PPE in the correct order: hand hygiene → gown → mask → eye protection → gloves. Remove in reverse order and perform hand hygiene after removal.', 'patient transfer': 'Safe patient transfer requires proper body mechanics: keep your back straight, bend at knees, get close to the patient, use your leg muscles, and always communicate with the patient throughout the transfer. Use transfer aids when available.', 'default': 'I understand you\'re studying healthcare aide concepts. Could you be more specific about what you\'d like to learn? I can help with topics like infection control, patient care, communication, safety procedures, and more.' }; } loadQuizBank() { return [ { id: 1, question: "How long should you wash your hands with soap and water?", options: ["10 seconds", "15 seconds", "20 seconds", "30 seconds"], correct: 2, explanation: "Hands should be washed for at least 20 seconds to effectively remove germs and bacteria." }, { id: 2, question: "What is the correct order for donning PPE?", options: ["Gloves, gown, mask, eye protection", "Gown, mask, eye protection, gloves", "Mask, gown, gloves, eye protection", "Eye protection, mask, gown, gloves"], correct: 1, explanation: "The correct order is: hand hygiene → gown → mask → eye protection → gloves." }, { id: 3, question: "Which precaution prevents the spread of infections transmitted by large droplets?", options: ["Contact precautions", "Droplet precautions", "Airborne precautions", "Standard precautions"], correct: 1, explanation: "Droplet precautions prevent transmission of infections spread by large respiratory droplets." } ]; } updateUserInterface() { // Update user name and current program const nameElement = document.getElementById('student-name'); const programElement = document.getElementById('current-program'); if (nameElement) nameElement.textContent = this.currentUser.name; if (programElement) programElement.textContent = this.currentUser.program; // Update progress indicators this.updateProgressBars(); } updateProgressBars() { const progressBar = document.getElementById('progress-bar'); const progressPercentage = document.getElementById('progress-percentage'); const currentModuleSpan = document.getElementById('current-module'); const moduleProgress = document.getElementById('module-progress'); if (progressBar) progressBar.style.width = `${this.currentUser.overallProgress}%`; if (progressPercentage) progressPercentage.textContent = this.currentUser.overallProgress; if (currentModuleSpan) currentModuleSpan.textContent = this.currentUser.currentModule; if (moduleProgress) moduleProgress.textContent = this.currentUser.moduleProgress; } setupEventListeners() { // AI Tutor enter key const aiInput = document.getElementById('ai-question'); if (aiInput) { aiInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') { this.askAITutor(); } }); } } loadRecentActivity() { const activities = [ { type: 'quiz', title: 'Completed Quiz: PPE Procedures', detail: 'Score: 92% • 2 hours ago', icon: 'fa-check', color: 'green' }, { type: 'video', title: 'Watched: Hand Hygiene Best Practices', detail: '15 min video • Yesterday', icon: 'fa-video', color: 'blue' }, { type: 'ai', title: 'AI Tutor Session', detail: 'Asked about isolation procedures • 2 days ago', icon: 'fa-brain', color: 'purple' } ]; // Activities are already in HTML, but this could be dynamic } } // Module and Learning Functions function continueModule() { const moduleNumber = 3; // Current module openModule(moduleNumber); } function openModule(moduleNumber) { const modal = document.getElementById('learning-modal'); const title = document.getElementById('modal-title'); const content = document.getElementById('modal-content'); const lms = window.lmsInstance; const moduleData = lms.courseData[moduleNumber]; if (!moduleData) { alert('Module content not available yet. Coming soon!'); return; } title.textContent = `Module ${moduleNumber}: ${moduleData.title}`; content.innerHTML = `
${moduleData.description}
Learn the correct sequence for putting on and removing PPE.
This lesson will be available in the full version of the platform.
Your Score: ${percentage}%
You got ${score} out of ${state.questions.length} questions correct.
${percentage >= 80 ? 'Excellent work! You\'ve mastered this material.
Good effort! Review the material and try again to improve your score.