UNPKG

mcp-quiz-server

Version:

🧠 AI-Powered Quiz Management via Model Context Protocol (MCP) - Create, manage, and take quizzes directly from VS Code, Claude, and other AI agents.

88 lines • 3.01 kB
export class DOMUtils { static escapeHtml(text) { const div = document.createElement('div'); div.textContent = text; return div.innerHTML; } static createElement(tag, options = {}) { const element = document.createElement(tag); if (options.className) element.className = options.className; if (options.id) element.id = options.id; if (options.innerHTML) element.innerHTML = options.innerHTML; if (options.textContent) element.textContent = options.textContent; if (options.attributes) { Object.entries(options.attributes).forEach(([key, value]) => { element.setAttribute(key, value); }); } if (options.dataset) { Object.entries(options.dataset).forEach(([key, value]) => { element.dataset[key] = value; }); } return element; } static showToast(message, type = 'info') { const colors = { success: 'bg-green-500', error: 'bg-red-500', info: 'bg-blue-500', }; const toast = this.createElement('div', { className: `fixed top-4 right-4 ${colors[type]} text-white px-4 py-2 rounded-lg shadow-lg z-50 transition-all duration-300`, textContent: message, }); document.body.appendChild(toast); setTimeout(() => toast.classList.add('translate-x-0'), 10); setTimeout(() => { toast.classList.add('translate-x-full', 'opacity-0'); setTimeout(() => toast.remove(), 300); }, 3000); } } export class QuizUtils { static getGrade(percentage) { if (percentage >= 90) return { text: 'Excellent!', color: 'green', icon: 'trophy' }; if (percentage >= 80) return { text: 'Great Job!', color: 'blue', icon: 'thumbs-up' }; if (percentage >= 70) return { text: 'Good Work!', color: 'yellow', icon: 'star' }; if (percentage >= 60) return { text: 'Keep Trying!', color: 'orange', icon: 'target' }; return { text: 'Study More!', color: 'red', icon: 'book-open' }; } static calculateEstimatedTime(questionCount) { return Math.ceil(questionCount * 1.5); } } export class EventEmitter { constructor() { this.events = new Map(); } on(event, callback) { if (!this.events.has(event)) { this.events.set(event, new Set()); } this.events.get(event).add(callback); return () => { this.events.get(event)?.delete(callback); }; } emit(event, data) { this.events.get(event)?.forEach(callback => callback(data)); } off(event, callback) { if (callback) { this.events.get(event)?.delete(callback); } else { this.events.delete(event); } } } //# sourceMappingURL=index.js.map