3306 lines
64 KiB
JavaScript
3306 lines
64 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Courses = db.courses;
|
|
|
|
const Lessons = db.lessons;
|
|
|
|
const Quizzes = db.quizzes;
|
|
|
|
const QuizQuestions = db.quiz_questions;
|
|
|
|
const Enrollments = db.enrollments;
|
|
|
|
const Progress = db.progress;
|
|
|
|
const Media = db.media;
|
|
|
|
const Payments = db.payments;
|
|
|
|
const Certificates = db.certificates;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const CoursesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Full-Stack Web Development",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Comprehensive course covering frontend and backend web development.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"summary": "Build modern web apps using React and Node.js.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 199.99,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_datetime": new Date('2026-03-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_datetime": new Date('2026-06-01T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "design",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Data Science Fundamentals",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Introduction to data analysis, statistics, and machine learning basics.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"summary": "Learn data cleaning, visualization, and basic models.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 149.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_datetime": new Date('2026-02-15T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_datetime": new Date('2026-05-15T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "business",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "UX Design Essentials",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Practical UX design techniques for product teams.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"summary": "Understand user research, prototyping, and testing.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 129.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_datetime": new Date('2026-04-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_datetime": new Date('2026-07-01T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "programming",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Marketing Analytics",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Learn how to measure and optimize marketing performance.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"summary": "Use analytics to improve campaign ROI.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 99.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_datetime": new Date('2026-05-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_datetime": new Date('2026-08-01T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "design",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const LessonsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Introduction to HTML and CSS",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Basics of HTML structure, semantic tags and responsive CSS.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"video_url": "https://youtu.be/example1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_minutes": 45,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"order": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "published",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "JavaScript Essentials",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Core JavaScript concepts including DOM and events.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"video_url": "https://vimeo.com/example2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_minutes": 60,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"order": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "published",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Building a REST API with Node.js",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Create endpoints, handle requests, and connect to PostgreSQL.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"video_url": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_minutes": 80,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"order": 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "archived",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Data Cleaning with Python",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Techniques for preparing datasets for analysis.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"video_url": "https://youtu.be/example4",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_minutes": 50,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"order": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "published",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const QuizzesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "HTML & CSS Quiz",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Assess basic HTML and CSS knowledge.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"passing_score": 70,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"time_limit_minutes": 20,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"randomize_questions": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "JavaScript Fundamentals Quiz",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Test core JavaScript skills.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"passing_score": 75,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"time_limit_minutes": 25,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"randomize_questions": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Node API Quiz",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "API design and server-side fundamentals.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"passing_score": 70,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"time_limit_minutes": 30,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"randomize_questions": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Data Cleaning Quiz",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Questions about handling messy datasets.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"passing_score": 65,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"time_limit_minutes": 20,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"randomize_questions": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const QuizQuestionsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"question_text": "Which tag is used for the largest heading in HTML?",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"question_type": "true_false",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"choices": "h1;h2;h3;header",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"correct_answer": "h1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"question_text": "True or False: flexbox works well for two-dimensional layouts.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"question_type": "true_false",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"choices": "true;false",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"correct_answer": "false",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"question_text": "Name the HTTP method typically used to update a resource.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"question_type": "short_answer",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"choices": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"correct_answer": "PUT",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"question_text": "What Python library is commonly used for data frames?",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"question_type": "multiple_choice",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"choices": "numpy;pandas;matplotlib;scipy",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"correct_answer": "pandas",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const EnrollmentsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"enrolled_at": new Date('2026-01-05T10:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 12.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price_paid": 199.99,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"note": "Enrolled with early-bird discount.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"enrolled_at": new Date('2026-02-20T14:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "cancelled",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 40.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price_paid": 149.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"note": "Referral from company program.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"enrolled_at": new Date('2026-01-12T09:15:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 100.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price_paid": 59.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"note": "Completed with certificate issued.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"enrolled_at": new Date('2026-02-18T11:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "completed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 5.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price_paid": 0.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"note": "Enrolled as part of scholarship.",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ProgressData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 100.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_viewed_at": new Date('2026-01-10T16:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"summary": "Completed introductory lesson and exercises.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 30.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_viewed_at": new Date('2026-01-12T12:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"summary": "Working through JavaScript challenges.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 50.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_viewed_at": new Date('2026-02-25T10:20:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"summary": "Data cleaning exercises in progress.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 100.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_viewed_at": new Date('2026-03-20T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"summary": "Finished conversational practice modules.",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const MediaData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Course Intro Video",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"media_type": "image",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"externally_hosted": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"external_url": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Dataset CSV",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"media_type": "document",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"externally_hosted": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"external_url": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Lecture Slides",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"media_type": "image",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"externally_hosted": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"external_url": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "UI Mockups",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"media_type": "video",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"externally_hosted": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"external_url": "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const PaymentsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 199.99,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "USD",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "pending",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"paid_at": new Date('2026-01-05T10:05:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider": "other",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_id": "txn_20260105_001",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 149.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "USD",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "succeeded",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"paid_at": new Date('2026-02-20T14:35:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider": "paypal",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_id": "txn_20260220_002",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 59.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "USD",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "failed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"paid_at": new Date('2026-01-12T09:20:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider": "stripe",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_id": "txn_20260112_003",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"amount": 0.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "USD",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "succeeded",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"paid_at": new Date('2026-02-18T11:05:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"provider": "other",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_id": "txn_20260218_004",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const CertificatesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"issued_at": new Date('2026-03-21T10:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"serial_number": "CERT-2026-0001",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"issued_at": new Date('2026-06-02T12:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"serial_number": "CERT-2026-0002",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"issued_at": new Date('2026-05-16T09:15:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"serial_number": "CERT-2026-0003",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"issued_at": new Date('2026-05-16T09:20:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"serial_number": "CERT-2026-0004",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateCoursWithInstructor() {
|
|
|
|
const relatedInstructor0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Cours0 = await Courses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Cours0?.setInstructor)
|
|
{
|
|
await
|
|
Cours0.
|
|
setInstructor(relatedInstructor0);
|
|
}
|
|
|
|
const relatedInstructor1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Cours1 = await Courses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Cours1?.setInstructor)
|
|
{
|
|
await
|
|
Cours1.
|
|
setInstructor(relatedInstructor1);
|
|
}
|
|
|
|
const relatedInstructor2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Cours2 = await Courses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Cours2?.setInstructor)
|
|
{
|
|
await
|
|
Cours2.
|
|
setInstructor(relatedInstructor2);
|
|
}
|
|
|
|
const relatedInstructor3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Cours3 = await Courses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Cours3?.setInstructor)
|
|
{
|
|
await
|
|
Cours3.
|
|
setInstructor(relatedInstructor3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateQuizzeWithLesson() {
|
|
|
|
const relatedLesson0 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Quizze0 = await Quizzes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Quizze0?.setLesson)
|
|
{
|
|
await
|
|
Quizze0.
|
|
setLesson(relatedLesson0);
|
|
}
|
|
|
|
const relatedLesson1 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Quizze1 = await Quizzes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Quizze1?.setLesson)
|
|
{
|
|
await
|
|
Quizze1.
|
|
setLesson(relatedLesson1);
|
|
}
|
|
|
|
const relatedLesson2 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Quizze2 = await Quizzes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Quizze2?.setLesson)
|
|
{
|
|
await
|
|
Quizze2.
|
|
setLesson(relatedLesson2);
|
|
}
|
|
|
|
const relatedLesson3 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Quizze3 = await Quizzes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Quizze3?.setLesson)
|
|
{
|
|
await
|
|
Quizze3.
|
|
setLesson(relatedLesson3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateQuizQuestionWithQuiz() {
|
|
|
|
const relatedQuiz0 = await Quizzes.findOne({
|
|
offset: Math.floor(Math.random() * (await Quizzes.count())),
|
|
});
|
|
const QuizQuestion0 = await QuizQuestions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (QuizQuestion0?.setQuiz)
|
|
{
|
|
await
|
|
QuizQuestion0.
|
|
setQuiz(relatedQuiz0);
|
|
}
|
|
|
|
const relatedQuiz1 = await Quizzes.findOne({
|
|
offset: Math.floor(Math.random() * (await Quizzes.count())),
|
|
});
|
|
const QuizQuestion1 = await QuizQuestions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (QuizQuestion1?.setQuiz)
|
|
{
|
|
await
|
|
QuizQuestion1.
|
|
setQuiz(relatedQuiz1);
|
|
}
|
|
|
|
const relatedQuiz2 = await Quizzes.findOne({
|
|
offset: Math.floor(Math.random() * (await Quizzes.count())),
|
|
});
|
|
const QuizQuestion2 = await QuizQuestions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (QuizQuestion2?.setQuiz)
|
|
{
|
|
await
|
|
QuizQuestion2.
|
|
setQuiz(relatedQuiz2);
|
|
}
|
|
|
|
const relatedQuiz3 = await Quizzes.findOne({
|
|
offset: Math.floor(Math.random() * (await Quizzes.count())),
|
|
});
|
|
const QuizQuestion3 = await QuizQuestions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (QuizQuestion3?.setQuiz)
|
|
{
|
|
await
|
|
QuizQuestion3.
|
|
setQuiz(relatedQuiz3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateEnrollmentWithStudent() {
|
|
|
|
const relatedStudent0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Enrollment0 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Enrollment0?.setStudent)
|
|
{
|
|
await
|
|
Enrollment0.
|
|
setStudent(relatedStudent0);
|
|
}
|
|
|
|
const relatedStudent1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Enrollment1 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Enrollment1?.setStudent)
|
|
{
|
|
await
|
|
Enrollment1.
|
|
setStudent(relatedStudent1);
|
|
}
|
|
|
|
const relatedStudent2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Enrollment2 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Enrollment2?.setStudent)
|
|
{
|
|
await
|
|
Enrollment2.
|
|
setStudent(relatedStudent2);
|
|
}
|
|
|
|
const relatedStudent3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Enrollment3 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Enrollment3?.setStudent)
|
|
{
|
|
await
|
|
Enrollment3.
|
|
setStudent(relatedStudent3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateEnrollmentWithCourse() {
|
|
|
|
const relatedCourse0 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Enrollment0 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Enrollment0?.setCourse)
|
|
{
|
|
await
|
|
Enrollment0.
|
|
setCourse(relatedCourse0);
|
|
}
|
|
|
|
const relatedCourse1 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Enrollment1 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Enrollment1?.setCourse)
|
|
{
|
|
await
|
|
Enrollment1.
|
|
setCourse(relatedCourse1);
|
|
}
|
|
|
|
const relatedCourse2 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Enrollment2 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Enrollment2?.setCourse)
|
|
{
|
|
await
|
|
Enrollment2.
|
|
setCourse(relatedCourse2);
|
|
}
|
|
|
|
const relatedCourse3 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Enrollment3 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Enrollment3?.setCourse)
|
|
{
|
|
await
|
|
Enrollment3.
|
|
setCourse(relatedCourse3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateProgresWithStudent() {
|
|
|
|
const relatedStudent0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Progres0 = await Progress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Progres0?.setStudent)
|
|
{
|
|
await
|
|
Progres0.
|
|
setStudent(relatedStudent0);
|
|
}
|
|
|
|
const relatedStudent1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Progres1 = await Progress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Progres1?.setStudent)
|
|
{
|
|
await
|
|
Progres1.
|
|
setStudent(relatedStudent1);
|
|
}
|
|
|
|
const relatedStudent2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Progres2 = await Progress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Progres2?.setStudent)
|
|
{
|
|
await
|
|
Progres2.
|
|
setStudent(relatedStudent2);
|
|
}
|
|
|
|
const relatedStudent3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Progres3 = await Progress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Progres3?.setStudent)
|
|
{
|
|
await
|
|
Progres3.
|
|
setStudent(relatedStudent3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateProgresWithCourse() {
|
|
|
|
const relatedCourse0 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Progres0 = await Progress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Progres0?.setCourse)
|
|
{
|
|
await
|
|
Progres0.
|
|
setCourse(relatedCourse0);
|
|
}
|
|
|
|
const relatedCourse1 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Progres1 = await Progress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Progres1?.setCourse)
|
|
{
|
|
await
|
|
Progres1.
|
|
setCourse(relatedCourse1);
|
|
}
|
|
|
|
const relatedCourse2 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Progres2 = await Progress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Progres2?.setCourse)
|
|
{
|
|
await
|
|
Progres2.
|
|
setCourse(relatedCourse2);
|
|
}
|
|
|
|
const relatedCourse3 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Progres3 = await Progress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Progres3?.setCourse)
|
|
{
|
|
await
|
|
Progres3.
|
|
setCourse(relatedCourse3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateProgresWithLesson() {
|
|
|
|
const relatedLesson0 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Progres0 = await Progress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Progres0?.setLesson)
|
|
{
|
|
await
|
|
Progres0.
|
|
setLesson(relatedLesson0);
|
|
}
|
|
|
|
const relatedLesson1 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Progres1 = await Progress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Progres1?.setLesson)
|
|
{
|
|
await
|
|
Progres1.
|
|
setLesson(relatedLesson1);
|
|
}
|
|
|
|
const relatedLesson2 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Progres2 = await Progress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Progres2?.setLesson)
|
|
{
|
|
await
|
|
Progres2.
|
|
setLesson(relatedLesson2);
|
|
}
|
|
|
|
const relatedLesson3 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Progres3 = await Progress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Progres3?.setLesson)
|
|
{
|
|
await
|
|
Progres3.
|
|
setLesson(relatedLesson3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateMediaWithUploaded_by() {
|
|
|
|
const relatedUploaded_by0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Media0 = await Media.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Media0?.setUploaded_by)
|
|
{
|
|
await
|
|
Media0.
|
|
setUploaded_by(relatedUploaded_by0);
|
|
}
|
|
|
|
const relatedUploaded_by1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Media1 = await Media.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Media1?.setUploaded_by)
|
|
{
|
|
await
|
|
Media1.
|
|
setUploaded_by(relatedUploaded_by1);
|
|
}
|
|
|
|
const relatedUploaded_by2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Media2 = await Media.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Media2?.setUploaded_by)
|
|
{
|
|
await
|
|
Media2.
|
|
setUploaded_by(relatedUploaded_by2);
|
|
}
|
|
|
|
const relatedUploaded_by3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Media3 = await Media.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Media3?.setUploaded_by)
|
|
{
|
|
await
|
|
Media3.
|
|
setUploaded_by(relatedUploaded_by3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associatePaymentWithStudent() {
|
|
|
|
const relatedStudent0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Payment0 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Payment0?.setStudent)
|
|
{
|
|
await
|
|
Payment0.
|
|
setStudent(relatedStudent0);
|
|
}
|
|
|
|
const relatedStudent1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Payment1 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Payment1?.setStudent)
|
|
{
|
|
await
|
|
Payment1.
|
|
setStudent(relatedStudent1);
|
|
}
|
|
|
|
const relatedStudent2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Payment2 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Payment2?.setStudent)
|
|
{
|
|
await
|
|
Payment2.
|
|
setStudent(relatedStudent2);
|
|
}
|
|
|
|
const relatedStudent3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Payment3 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Payment3?.setStudent)
|
|
{
|
|
await
|
|
Payment3.
|
|
setStudent(relatedStudent3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associatePaymentWithCourse() {
|
|
|
|
const relatedCourse0 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Payment0 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Payment0?.setCourse)
|
|
{
|
|
await
|
|
Payment0.
|
|
setCourse(relatedCourse0);
|
|
}
|
|
|
|
const relatedCourse1 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Payment1 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Payment1?.setCourse)
|
|
{
|
|
await
|
|
Payment1.
|
|
setCourse(relatedCourse1);
|
|
}
|
|
|
|
const relatedCourse2 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Payment2 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Payment2?.setCourse)
|
|
{
|
|
await
|
|
Payment2.
|
|
setCourse(relatedCourse2);
|
|
}
|
|
|
|
const relatedCourse3 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Payment3 = await Payments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Payment3?.setCourse)
|
|
{
|
|
await
|
|
Payment3.
|
|
setCourse(relatedCourse3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateCertificateWithStudent() {
|
|
|
|
const relatedStudent0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Certificate0 = await Certificates.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Certificate0?.setStudent)
|
|
{
|
|
await
|
|
Certificate0.
|
|
setStudent(relatedStudent0);
|
|
}
|
|
|
|
const relatedStudent1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Certificate1 = await Certificates.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Certificate1?.setStudent)
|
|
{
|
|
await
|
|
Certificate1.
|
|
setStudent(relatedStudent1);
|
|
}
|
|
|
|
const relatedStudent2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Certificate2 = await Certificates.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Certificate2?.setStudent)
|
|
{
|
|
await
|
|
Certificate2.
|
|
setStudent(relatedStudent2);
|
|
}
|
|
|
|
const relatedStudent3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Certificate3 = await Certificates.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Certificate3?.setStudent)
|
|
{
|
|
await
|
|
Certificate3.
|
|
setStudent(relatedStudent3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateCertificateWithCourse() {
|
|
|
|
const relatedCourse0 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Certificate0 = await Certificates.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Certificate0?.setCourse)
|
|
{
|
|
await
|
|
Certificate0.
|
|
setCourse(relatedCourse0);
|
|
}
|
|
|
|
const relatedCourse1 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Certificate1 = await Certificates.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Certificate1?.setCourse)
|
|
{
|
|
await
|
|
Certificate1.
|
|
setCourse(relatedCourse1);
|
|
}
|
|
|
|
const relatedCourse2 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Certificate2 = await Certificates.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Certificate2?.setCourse)
|
|
{
|
|
await
|
|
Certificate2.
|
|
setCourse(relatedCourse2);
|
|
}
|
|
|
|
const relatedCourse3 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Certificate3 = await Certificates.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Certificate3?.setCourse)
|
|
{
|
|
await
|
|
Certificate3.
|
|
setCourse(relatedCourse3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Courses.bulkCreate(CoursesData);
|
|
|
|
|
|
|
|
|
|
await Lessons.bulkCreate(LessonsData);
|
|
|
|
|
|
|
|
|
|
await Quizzes.bulkCreate(QuizzesData);
|
|
|
|
|
|
|
|
|
|
await QuizQuestions.bulkCreate(QuizQuestionsData);
|
|
|
|
|
|
|
|
|
|
await Enrollments.bulkCreate(EnrollmentsData);
|
|
|
|
|
|
|
|
|
|
await Progress.bulkCreate(ProgressData);
|
|
|
|
|
|
|
|
|
|
await Media.bulkCreate(MediaData);
|
|
|
|
|
|
|
|
|
|
await Payments.bulkCreate(PaymentsData);
|
|
|
|
|
|
|
|
|
|
await Certificates.bulkCreate(CertificatesData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateCoursWithInstructor(),
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateQuizzeWithLesson(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateQuizQuestionWithQuiz(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateEnrollmentWithStudent(),
|
|
|
|
|
|
|
|
|
|
await associateEnrollmentWithCourse(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateProgresWithStudent(),
|
|
|
|
|
|
|
|
|
|
await associateProgresWithCourse(),
|
|
|
|
|
|
|
|
|
|
await associateProgresWithLesson(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateMediaWithUploaded_by(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associatePaymentWithStudent(),
|
|
|
|
|
|
|
|
|
|
await associatePaymentWithCourse(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateCertificateWithStudent(),
|
|
|
|
|
|
|
|
|
|
await associateCertificateWithCourse(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('courses', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('lessons', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('quizzes', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('quiz_questions', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('enrollments', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('progress', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('media', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('payments', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('certificates', null, {});
|
|
|
|
|
|
},
|
|
}; |