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.
151 lines (150 loc) • 4.73 kB
JavaScript
;
/**
* @fileoverview Dashboard ViewModels - MVVM Pattern
* @version 1.0.0
* @since 2025-08-04
* @module DashboardViewModels
* @description Type-safe view models for dashboard components
* @contributors Claude Code Agent
* @requirements REQ-UI-001 (MVVM Pattern)
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.DashboardViewModelFactory = void 0;
/**
* View Model Factory
*/
class DashboardViewModelFactory {
/**
* Create dashboard home view model
*/
static createDashboardViewModel(user) {
return {
title: 'Dashboard',
user,
stats: {
quizCount: 0,
completedQuizzes: 0,
totalPoints: 0,
},
recentActivity: [
{
id: '1',
type: 'quiz_created',
description: 'Welcome to Quiz Dashboard!',
timestamp: 'Just now',
icon: '🎉',
},
{
id: '2',
type: 'quiz_created',
description: 'Start by creating your first quiz',
timestamp: 'Just now',
icon: '📝',
},
],
quickActions: [
{
id: 'create-quiz',
title: 'Create New Quiz',
description: 'Get Started',
icon: '📝',
action: '/quiz/create',
buttonText: 'Create Quiz →',
},
{
id: 'view-quizzes',
title: 'My Quizzes',
description: '0',
icon: '📋',
action: '/dashboard/quizzes',
buttonText: 'View all →',
},
{
id: 'profile',
title: 'Profile',
description: user.username,
icon: '👤',
action: '/dashboard/profile',
buttonText: 'Manage →',
},
],
};
}
/**
* Create profile view model
*/
static createProfileViewModel(user) {
var _a;
return {
title: 'Profile',
user,
profile: {
username: user.username,
email: user.email || 'Not provided',
firstName: user.firstName || 'Not provided',
lastName: user.lastName || 'Not provided',
role: ((_a = user.roles) === null || _a === void 0 ? void 0 : _a[0]) || 'user',
memberSince: user.createdAt ? new Date(user.createdAt).toLocaleDateString() : 'Unknown',
permissions: user.permissions || [],
},
};
}
/**
* Create quizzes view model
*/
static createQuizzesViewModel(user) {
return {
title: 'My Quizzes',
user,
quizzes: [], // Would be populated from quiz service
pagination: {
currentPage: 1,
totalPages: 1,
totalItems: 0,
},
filters: {
status: 'all',
sortBy: 'created',
sortOrder: 'desc',
},
};
}
/**
* Create analytics view model
*/
static createAnalyticsViewModel(user) {
return {
title: 'Analytics',
user,
metrics: {
totalViews: 0,
averageScore: 0,
completionRate: 0,
topPerformingQuiz: 'No quizzes yet',
},
charts: {
scoreDistribution: {
labels: ['0-20', '21-40', '41-60', '61-80', '81-100'],
datasets: [
{
label: 'Score Distribution',
data: [0, 0, 0, 0, 0],
backgroundColor: '#3B82F6',
},
],
},
dailyActivity: {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
datasets: [
{
label: 'Daily Activity',
data: [0, 0, 0, 0, 0, 0, 0],
borderColor: '#10B981',
},
],
},
},
};
}
}
exports.DashboardViewModelFactory = DashboardViewModelFactory;