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.

116 lines • 3.82 kB
export class SettingsService { constructor() { this.listeners = new Set(); this.settings = this.loadSettings(); } static getInstance() { if (!SettingsService.instance) { SettingsService.instance = new SettingsService(); } return SettingsService.instance; } getDefaultSettings() { return { ui: { hideDisabledNavButtons: false, hideAllNavButtons: false, autoAdvanceQuestions: false, clickToAdvance: false, showContinueButton: true, announceSelections: true, selectionFeedbackDuration: 1000, showQuestionNumbers: true, enableAnimations: true, defaultViewMode: 'list', sidebarExpanded: true, theme: 'auto', accessibilityMode: false, clickToSelectCards: true, quizMode: 'cards', }, quiz: { showHints: false, confirmBeforeSubmit: true, highlightAnsweredQuestions: true, useTimer: false, timerDuration: 900, maxAttempts: 3, showImmediateFeedback: true, showExplanationsAfterAnswer: true, enableCoachingMode: true, coachingIntensity: 'basic', instantSubmission: false, instantFeedbackDelay: 1500, allowAnswerChange: true, showInstantExplanation: true, autoAdvanceEnabled: false, autoAdvanceDelay: 3000, smartSubmitLogic: true, partialSubmissionEnabled: false, autoAdvanceMode: 'enhanced', }, }; } getSettings() { return { ...this.settings }; } updateSettings(updates) { this.settings = { ...this.settings, ...updates }; this.saveSettings(); this.notifyListeners(); } updateUISettings(uiSettings) { this.settings.ui = { ...this.settings.ui, ...uiSettings }; this.saveSettings(); this.notifyListeners(); } updateQuizSettings(quizSettings) { this.settings.quiz = { ...this.settings.quiz, ...quizSettings }; this.saveSettings(); this.notifyListeners(); } resetToDefaults() { this.settings = this.getDefaultSettings(); this.saveSettings(); this.notifyListeners(); } subscribe(callback) { this.listeners.add(callback); return () => this.listeners.delete(callback); } loadSettings() { try { const stored = localStorage.getItem(SettingsService.STORAGE_KEY); if (stored) { const parsed = JSON.parse(stored); return { ...this.getDefaultSettings(), ...parsed }; } } catch (error) { console.warn('Failed to load settings:', error); } return this.getDefaultSettings(); } saveSettings() { try { localStorage.setItem(SettingsService.STORAGE_KEY, JSON.stringify(this.settings)); } catch (error) { console.error('Failed to save settings:', error); } } notifyListeners() { this.listeners.forEach(callback => { try { callback(this.settings); } catch (error) { console.error('Error in settings listener:', error); } }); } } SettingsService.STORAGE_KEY = 'quiz-app-settings'; const settingsService = new SettingsService(); export default settingsService; //# sourceMappingURL=SettingsService.js.map