New Features: - Comprehensive course content management system - Multi-type content support (Documents, Images, Videos, Articles, Quizzes, Certificates) - File upload system with 100MB limit and type validation - Quiz system with multiple question types - Complete enrollment and subscriber management - Status tracking (pending, active, completed, cancelled) - Payment management (pending, paid, failed, refunded) - Progress tracking (0-100%) with automatic updates - Course capacity limits and validation - Certificate issuance tracking - Enrollment analytics and statistics Technical Improvements: - Enhanced file upload system with type validation - New database models: CourseContent, QuizQuestion - Comprehensive API endpoints for content and enrollment management - Role-based access control for all new features - Enhanced error handling and validation - File management with automatic cleanup This version provides a complete foundation for creating rich educational content and managing student enrollments.
110 lines
No EOL
2 KiB
JavaScript
110 lines
No EOL
2 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
const { sequelize } = require('../config/database');
|
|
|
|
const CourseContent = sequelize.define('CourseContent', {
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true
|
|
},
|
|
courseId: {
|
|
type: DataTypes.UUID,
|
|
allowNull: false
|
|
},
|
|
title: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
validate: {
|
|
notEmpty: true,
|
|
len: [1, 200]
|
|
}
|
|
},
|
|
description: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true
|
|
},
|
|
type: {
|
|
type: DataTypes.ENUM('document', 'image', 'video', 'article', 'quiz', 'certificate'),
|
|
allowNull: false
|
|
},
|
|
content: {
|
|
type: DataTypes.JSONB,
|
|
allowNull: true,
|
|
defaultValue: {}
|
|
},
|
|
fileUrl: {
|
|
type: DataTypes.STRING,
|
|
allowNull: true
|
|
},
|
|
fileSize: {
|
|
type: DataTypes.INTEGER, // in bytes
|
|
allowNull: true
|
|
},
|
|
fileType: {
|
|
type: DataTypes.STRING,
|
|
allowNull: true
|
|
},
|
|
duration: {
|
|
type: DataTypes.INTEGER, // in seconds, for videos
|
|
allowNull: true
|
|
},
|
|
order: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
defaultValue: 0
|
|
},
|
|
isPublished: {
|
|
type: DataTypes.BOOLEAN,
|
|
defaultValue: true
|
|
},
|
|
isRequired: {
|
|
type: DataTypes.BOOLEAN,
|
|
defaultValue: true
|
|
},
|
|
points: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: true,
|
|
defaultValue: 0
|
|
},
|
|
// For quizzes
|
|
quizData: {
|
|
type: DataTypes.JSONB,
|
|
allowNull: true,
|
|
defaultValue: {}
|
|
},
|
|
// For articles
|
|
articleContent: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true
|
|
},
|
|
// For certificates
|
|
certificateTemplate: {
|
|
type: DataTypes.JSONB,
|
|
allowNull: true,
|
|
defaultValue: {}
|
|
},
|
|
// Metadata
|
|
metadata: {
|
|
type: DataTypes.JSONB,
|
|
allowNull: true,
|
|
defaultValue: {}
|
|
}
|
|
}, {
|
|
tableName: 'course_contents',
|
|
indexes: [
|
|
{
|
|
fields: ['courseId']
|
|
},
|
|
{
|
|
fields: ['type']
|
|
},
|
|
{
|
|
fields: ['isPublished']
|
|
},
|
|
{
|
|
fields: ['order']
|
|
}
|
|
]
|
|
});
|
|
|
|
module.exports = CourseContent;
|