1325 lines
25 KiB
JavaScript
1325 lines
25 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Courses = db.courses;
|
|
|
|
const Lessons = db.lessons;
|
|
|
|
const Enrollments = db.enrollments;
|
|
|
|
const ProgressEntries = db.progress_entries;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const CoursesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Foundations of Data Science",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "An introductory course covering data analysis, statistics, and practical workflows.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"level": "advanced",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 0.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_published": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-02-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-04-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Advanced Machine Learning",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "In-depth topics on model architectures, optimization, and deployment.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"level": "intermediate",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 249.99,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_published": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-03-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-06-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Cloud Fundamentals",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Core concepts and hands-on labs for cloud infrastructure and services.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"level": "advanced",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 99.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_published": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-04-10T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-06-10T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const LessonsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Introduction to Data and Tools",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Overview of datasets, tools, and reproducible analysis workflows.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_minutes": 30,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"order": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"video_url": "https://videos.example.com/lessons/1.mp4",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "archived",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Exploratory Data Analysis",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Techniques for summarizing and visualizing datasets to discover patterns.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_minutes": 45,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"order": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"video_url": "https://videos.example.com/lessons/2.mp4",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "draft",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Neural Network Architectures",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Key architectures and tradeoffs for deep learning models.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_minutes": 60,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"order": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"video_url": "https://videos.example.com/lessons/3.mp4",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "draft",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const EnrollmentsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"enrollment_code": "ENR-0001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"enrolled_on": new Date('2026-01-12T10:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 25.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "completed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"grade": 0.0,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"enrollment_code": "ENR-0002",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"enrolled_on": new Date('2026-01-13T09:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 60.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"grade": 0.0,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"enrollment_code": "ENR-0003",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"enrolled_on": new Date('2026-01-14T16:45:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 0.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"grade": 0.0,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ProgressEntriesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_on": new Date('2026-01-20T13:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"score": 85.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Completed initial exercises and quiz",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_on": new Date('2026-01-21T10:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"score": 78.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Reviewed dataset examples",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_on": new Date('2026-01-25T15:45:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"score": 88.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Submitted EDA assignment",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateLessonWithCourse() {
|
|
|
|
const relatedCourse0 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Lesson0 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Lesson0?.setCourse)
|
|
{
|
|
await
|
|
Lesson0.
|
|
setCourse(relatedCourse0);
|
|
}
|
|
|
|
const relatedCourse1 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Lesson1 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Lesson1?.setCourse)
|
|
{
|
|
await
|
|
Lesson1.
|
|
setCourse(relatedCourse1);
|
|
}
|
|
|
|
const relatedCourse2 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Lesson2 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Lesson2?.setCourse)
|
|
{
|
|
await
|
|
Lesson2.
|
|
setCourse(relatedCourse2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateEnrollmentWithUser() {
|
|
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Enrollment0 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Enrollment0?.setUser)
|
|
{
|
|
await
|
|
Enrollment0.
|
|
setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Enrollment1 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Enrollment1?.setUser)
|
|
{
|
|
await
|
|
Enrollment1.
|
|
setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Enrollment2 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Enrollment2?.setUser)
|
|
{
|
|
await
|
|
Enrollment2.
|
|
setUser(relatedUser2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateProgressEntryWithEnrollment() {
|
|
|
|
const relatedEnrollment0 = await Enrollments.findOne({
|
|
offset: Math.floor(Math.random() * (await Enrollments.count())),
|
|
});
|
|
const ProgressEntry0 = await ProgressEntries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (ProgressEntry0?.setEnrollment)
|
|
{
|
|
await
|
|
ProgressEntry0.
|
|
setEnrollment(relatedEnrollment0);
|
|
}
|
|
|
|
const relatedEnrollment1 = await Enrollments.findOne({
|
|
offset: Math.floor(Math.random() * (await Enrollments.count())),
|
|
});
|
|
const ProgressEntry1 = await ProgressEntries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (ProgressEntry1?.setEnrollment)
|
|
{
|
|
await
|
|
ProgressEntry1.
|
|
setEnrollment(relatedEnrollment1);
|
|
}
|
|
|
|
const relatedEnrollment2 = await Enrollments.findOne({
|
|
offset: Math.floor(Math.random() * (await Enrollments.count())),
|
|
});
|
|
const ProgressEntry2 = await ProgressEntries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (ProgressEntry2?.setEnrollment)
|
|
{
|
|
await
|
|
ProgressEntry2.
|
|
setEnrollment(relatedEnrollment2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateProgressEntryWithLesson() {
|
|
|
|
const relatedLesson0 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const ProgressEntry0 = await ProgressEntries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (ProgressEntry0?.setLesson)
|
|
{
|
|
await
|
|
ProgressEntry0.
|
|
setLesson(relatedLesson0);
|
|
}
|
|
|
|
const relatedLesson1 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const ProgressEntry1 = await ProgressEntries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (ProgressEntry1?.setLesson)
|
|
{
|
|
await
|
|
ProgressEntry1.
|
|
setLesson(relatedLesson1);
|
|
}
|
|
|
|
const relatedLesson2 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const ProgressEntry2 = await ProgressEntries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (ProgressEntry2?.setLesson)
|
|
{
|
|
await
|
|
ProgressEntry2.
|
|
setLesson(relatedLesson2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Courses.bulkCreate(CoursesData);
|
|
|
|
|
|
|
|
|
|
await Lessons.bulkCreate(LessonsData);
|
|
|
|
|
|
|
|
|
|
await Enrollments.bulkCreate(EnrollmentsData);
|
|
|
|
|
|
|
|
|
|
await ProgressEntries.bulkCreate(ProgressEntriesData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateCoursWithInstructor(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateLessonWithCourse(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateEnrollmentWithUser(),
|
|
|
|
|
|
|
|
|
|
await associateEnrollmentWithCourse(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateProgressEntryWithEnrollment(),
|
|
|
|
|
|
|
|
|
|
await associateProgressEntryWithLesson(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('courses', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('lessons', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('enrollments', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('progress_entries', null, {});
|
|
|
|
|
|
},
|
|
}; |