🔐 Authentication Required

You need to be logged in to access your personal kete.

Sign In Create Account

← Back to Te Kete Ako

function showAuthRequired() { document.getElementById('auth-required-message').style.display = 'block'; document.getElementById('kete-content').style.display = 'none'; } function showKeteContent() { document.getElementById('auth-required-message').style.display = 'none'; document.getElementById('kete-content').style.display = 'block'; } async function loadSavedResources() { const loadingElement = document.getElementById('kete-loading'); const emptyElement = document.getElementById('kete-empty'); const gridElement = document.getElementById('saved-resources-grid'); try { loadingElement.style.display = 'block'; emptyElement.style.display = 'none'; gridElement.style.display = 'none'; // Wait a moment for bookmarks system to be ready setTimeout(() => { if (window.simpleBookmarks) { const bookmarks = window.simpleBookmarks.getBookmarks(); const stats = window.simpleBookmarks.getBookmarkStats(); // Update statistics document.getElementById('total-resources').textContent = stats.total; document.getElementById('handouts-count').textContent = (stats.byType.resource || []).filter(b => b.url.includes('handouts')).length; document.getElementById('lessons-count').textContent = (stats.byType.resource || []).filter(b => b.url.includes('lessons')).length; document.getElementById('games-count').textContent = (stats.byType.resource || []).filter(b => b.url.includes('games')).length; loadingElement.style.display = 'none'; if (bookmarks.length === 0) { emptyElement.style.display = 'block'; } else { renderBookmarkedResources(bookmarks); gridElement.style.display = 'grid'; } } else { // Fallback if bookmarks system not ready loadingElement.style.display = 'none'; emptyElement.style.display = 'block'; document.getElementById('total-resources').textContent = '0'; document.getElementById('handouts-count').textContent = '0'; document.getElementById('lessons-count').textContent = '0'; document.getElementById('games-count').textContent = '0'; } }, 500); } catch (error) { console.error('Error loading saved resources:', error); loadingElement.innerHTML = `

❌ Error loading your saved resources. Please try refreshing the page.

`; } } function renderBookmarkedResources(bookmarks) { const gridElement = document.getElementById('saved-resources-grid'); gridElement.innerHTML = ''; bookmarks.forEach(bookmark => { const card = createBookmarkCard(bookmark); gridElement.appendChild(card); }); } function createBookmarkCard(bookmark) { const card = document.createElement('div'); card.className = 'resource-card'; card.style.cssText = ` background: white; border: 1px solid #e1e5e9; border-radius: 12px; padding: 1.5rem; box-shadow: 0 2px 4px rgba(0,0,0,0.1); transition: transform 0.2s ease, box-shadow 0.2s ease; `; // Determine icon based on URL let icon = '📄'; if (bookmark.url.includes('games')) icon = '🎮'; else if (bookmark.url.includes('lessons')) icon = '📖'; else if (bookmark.url.includes('activities')) icon = '⚡'; else if (bookmark.url.includes('handouts')) icon = '📄'; else if (bookmark.url.includes('unit-plans')) icon = '📚'; const savedDate = new Date(bookmark.savedAt).toLocaleDateString('en-NZ', { year: 'numeric', month: 'short', day: 'numeric' }); card.innerHTML = `

${icon} ${bookmark.title}

${bookmark.description ? `

${bookmark.description}

` : ''}
View Resource Saved ${savedDate}
`; // Add remove functionality const removeBtn = card.querySelector('.remove-bookmark-btn'); removeBtn.addEventListener('click', () => { if (confirm(`Remove "${bookmark.title}" from your kete?`)) { window.simpleBookmarks.removeBookmark(bookmark.url); loadSavedResources(); // Refresh the display } }); // Add hover effect card.addEventListener('mouseenter', () => { card.style.transform = 'translateY(-2px)'; card.style.boxShadow = '0 4px 12px rgba(0,0,0,0.15)'; }); card.addEventListener('mouseleave', () => { card.style.transform = 'translateY(0)'; card.style.boxShadow = '0 2px 4px rgba(0,0,0,0.1)'; }); return card; } // NEW: Load progress data and agentic features async function loadProgressData() { try { // Initialize progress tracker if (window.TeKeteProgressTracker) { await window.TeKeteProgressTracker.initialize(); // Load progress summary const summary = window.TeKeteProgressTracker.getProgressSummary(); // Show progress dashboard if user has progress if (summary.total_resources > 0) { document.getElementById('progress-dashboard').style.display = 'block'; updateProgressDashboard(summary); } // Load AI recommendations await loadAIRecommendations(); // Load achievements loadAchievements(summary); } } catch (error) { console.error('Error loading progress data:', error); } } function updateProgressDashboard(summary) { document.getElementById('progress-total').textContent = summary.total_resources; document.getElementById('progress-completed').textContent = summary.completed_resources; document.getElementById('progress-average').textContent = Math.round(summary.average_progress) + '%'; // Calculate achievement count let achievements = 0; if (summary.completed_resources > 0) achievements++; if (summary.completed_resources >= 5) achievements++; if (summary.completed_resources >= 10) achievements++; if (summary.average_progress >= 50) achievements++; document.getElementById('achievement-count').textContent = achievements; // Show recent activities const recentActivities = document.getElementById('recent-activities'); if (summary.recent_activity && summary.recent_activity.length > 0) { recentActivities.innerHTML = summary.recent_activity.map(activity => `
${activity.resource_title}
${activity.progress_percentage}% ${activity.completed ? '' : ''}
`).join(''); } else { recentActivities.innerHTML = '

No recent activity

'; } } async function loadAIRecommendations() { try { // Get personalized recommendations based on user progress const recommendations = await generatePersonalizedRecommendations(); if (recommendations && recommendations.length > 0) { document.getElementById('ai-recommendations').style.display = 'block'; const container = document.getElementById('recommendations-container'); container.innerHTML = recommendations.map(rec => `

${rec.title}

${rec.description}

Explore Resource →
`).join(''); } } catch (error) { console.error('Error loading AI recommendations:', error); } } async function generatePersonalizedRecommendations() { // Generate intelligent recommendations based on user progress and preferences const fallbackRecommendations = [ { title: "🌿 Te Ao Māori Values in Teaching", description: "Deepen your understanding of incorporating Māori perspectives into your classroom practice.", url: "/app/handouts.html" }, { title: "🎮 Interactive Learning Games", description: "Engage students with educational games that make learning fun and memorable.", url: "/app/games.html" }, { title: "📖 Complete Unit Plans", description: "Ready-to-use comprehensive unit plans aligned with NZ Curriculum objectives.", url: "/app/unit-plans.html" } ]; // In future, this would call GraphRAG for personalized recommendations // For now, return contextual recommendations return fallbackRecommendations; } function loadAchievements(summary) { const achievements = []; // Define achievements based on progress if (summary.completed_resources >= 1) { achievements.push({ title: "First Steps", description: "Completed your first learning activity", icon: "🎯", earned: true }); } if (summary.completed_resources >= 5) { achievements.push({ title: "Learning Momentum", description: "Completed 5 learning activities", icon: "🚀", earned: true }); } if (summary.completed_resources >= 10) { achievements.push({ title: "Dedicated Learner", description: "Completed 10 learning activities", icon: "🏆", earned: true }); } if (summary.average_progress >= 75) { achievements.push({ title: "Excellence Pursuer", description: "Maintained high completion rates", icon: "⭐", earned: true }); } // Show achievements if any exist if (achievements.length > 0) { document.getElementById('achievements-section').style.display = 'block'; const container = document.getElementById('achievements-container'); container.innerHTML = achievements.map(achievement => `
${achievement.icon} ${achievement.title}
`).join(''); } } // Listen for auth state changes document.addEventListener('authStateChanged', (event) => { if (!event.detail.isLoggedIn) { // Show login prompt instead of forcing redirect showLoginPrompt(); } else if (event.detail.isLoggedIn && !currentUser) { // User just signed in, reload the page window.location.reload(); } }); // Show login prompt without forcing navigation function showLoginPrompt() { const loginSection = document.querySelector('.login-section'); const keteSection = document.querySelector('.kete-section'); if (loginSection && keteSection) { loginSection.style.display = 'block'; keteSection.style.display = 'none'; } // Update page title to indicate login needed document.title = 'My Kete - Please Sign In | Te Kete Ako'; }