2265 lines
45 KiB
JavaScript
2265 lines
45 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Courses = db.courses;
|
|
|
|
const Units = db.units;
|
|
|
|
const Lessons = db.lessons;
|
|
|
|
const Resources = db.resources;
|
|
|
|
const StudentProgress = db.student_progress;
|
|
|
|
const Chats = db.chats;
|
|
|
|
const AiQueries = db.ai_queries;
|
|
|
|
const Analytics = db.analytics;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const CoursesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Introduction to Web Design",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"slug": "intro-web-design",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Foundations of responsive and accessible web design.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-01-10T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-03-10T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "HTML and CSS Essentials",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"slug": "html-css-essentials",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Practical course covering HTML structure and CSS styling.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-02-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-04-01T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "JavaScript for Web Designers",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"slug": "js-for-designers",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Introductory JavaScript concepts tailored for designers.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-03-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-05-01T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const UnitsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Basics and Layouts",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"order": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"overview": "Core layout techniques and the box model.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Typography and Color",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"order": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"overview": "Working with fonts, readability, and color systems.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Responsive Techniques",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"order": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"overview": "Media queries and flexible grids for multiple devices.",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const LessonsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Understanding the Box Model",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Explain margin padding border and content roles in layouts.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"video_url": "https://videos.example.com/box-model.mp4",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"has_activity": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"show_search_box": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Building a Responsive Header",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Create a top navbar that adapts to screen sizes.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"video_url": "https://videos.example.com/responsive-header.mp4",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"has_activity": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"show_search_box": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Choosing Fonts for Readability",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Techniques for selecting and pairing web fonts.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"video_url": "https://videos.example.com/fonts.mp4",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"has_activity": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"show_search_box": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ResourcesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "MDN Web Docs - Box Model",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"resource_type": "website",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"link": "https://developer.mozilla.org/en-US/docs/Web/CSS/box_model",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Responsive Header Example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"resource_type": "video",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"link": "https://codepen.io/responsive-header-example",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Font Pairing Guide",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"resource_type": "website",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"link": "https://fonts.example.com/pairing-guide",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const StudentProgressData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "in_progress",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"time_spent_seconds": 1500,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_at": new Date('2026-01-15T12:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status_text": "Completed lesson 1",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "in_progress",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"time_spent_seconds": 600,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_at": new Date('2020-01-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status_text": "Working on lesson 2",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "completed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"time_spent_seconds": 900,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_at": new Date('2026-01-14T16:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status_text": "Completed lesson 1",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ChatsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"message": "How do margins differ from padding in responsive layouts?",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_bot": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-01-15T12:05:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"message": "Use margin to separate elements and padding to create inner space.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_bot": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-01-15T12:07:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"message": "Try the header activity and share your result for feedback.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_bot": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-01-20T09:15:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const AiQueriesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"query": "Generate HTML for a responsive navbar",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"response": "Provided a simple responsive navbar example with CSS and HTML.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created": new Date('2026-01-20T09:16:30Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tool_used": "analysis",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"query": "Explain difference between padding and margin",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"response": "Padding is inner space; margin is outer space between elements.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created": new Date('2026-01-15T12:06:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tool_used": "search",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"query": "List common media query breakpoints",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"response": "Suggested mobile tablet and desktop breakpoints with examples.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created": new Date('2026-01-25T10:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"tool_used": "analysis",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const AnalyticsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"page": "lesson_1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"visits": 4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"time_spent_minutes": 25.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lessons_completed": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_visit": new Date('2026-01-15T12:10:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"page": "course_intro",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"visits": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"time_spent_minutes": 10.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lessons_completed": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_visit": new Date('2026-01-14T11:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"page": "lesson_1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"visits": 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"time_spent_minutes": 15.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lessons_completed": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_visit": new Date('2026-01-14T16:35:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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 associateUnitWithCourse() {
|
|
|
|
const relatedCourse0 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Unit0 = await Units.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Unit0?.setCourse)
|
|
{
|
|
await
|
|
Unit0.
|
|
setCourse(relatedCourse0);
|
|
}
|
|
|
|
const relatedCourse1 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Unit1 = await Units.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Unit1?.setCourse)
|
|
{
|
|
await
|
|
Unit1.
|
|
setCourse(relatedCourse1);
|
|
}
|
|
|
|
const relatedCourse2 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Unit2 = await Units.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Unit2?.setCourse)
|
|
{
|
|
await
|
|
Unit2.
|
|
setCourse(relatedCourse2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateLessonWithUnit() {
|
|
|
|
const relatedUnit0 = await Units.findOne({
|
|
offset: Math.floor(Math.random() * (await Units.count())),
|
|
});
|
|
const Lesson0 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Lesson0?.setUnit)
|
|
{
|
|
await
|
|
Lesson0.
|
|
setUnit(relatedUnit0);
|
|
}
|
|
|
|
const relatedUnit1 = await Units.findOne({
|
|
offset: Math.floor(Math.random() * (await Units.count())),
|
|
});
|
|
const Lesson1 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Lesson1?.setUnit)
|
|
{
|
|
await
|
|
Lesson1.
|
|
setUnit(relatedUnit1);
|
|
}
|
|
|
|
const relatedUnit2 = await Units.findOne({
|
|
offset: Math.floor(Math.random() * (await Units.count())),
|
|
});
|
|
const Lesson2 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Lesson2?.setUnit)
|
|
{
|
|
await
|
|
Lesson2.
|
|
setUnit(relatedUnit2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateLessonWithPrevious_lesson() {
|
|
|
|
const relatedPrevious_lesson0 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Lesson0 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Lesson0?.setPrevious_lesson)
|
|
{
|
|
await
|
|
Lesson0.
|
|
setPrevious_lesson(relatedPrevious_lesson0);
|
|
}
|
|
|
|
const relatedPrevious_lesson1 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Lesson1 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Lesson1?.setPrevious_lesson)
|
|
{
|
|
await
|
|
Lesson1.
|
|
setPrevious_lesson(relatedPrevious_lesson1);
|
|
}
|
|
|
|
const relatedPrevious_lesson2 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Lesson2 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Lesson2?.setPrevious_lesson)
|
|
{
|
|
await
|
|
Lesson2.
|
|
setPrevious_lesson(relatedPrevious_lesson2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateLessonWithNext_lesson() {
|
|
|
|
const relatedNext_lesson0 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Lesson0 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Lesson0?.setNext_lesson)
|
|
{
|
|
await
|
|
Lesson0.
|
|
setNext_lesson(relatedNext_lesson0);
|
|
}
|
|
|
|
const relatedNext_lesson1 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Lesson1 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Lesson1?.setNext_lesson)
|
|
{
|
|
await
|
|
Lesson1.
|
|
setNext_lesson(relatedNext_lesson1);
|
|
}
|
|
|
|
const relatedNext_lesson2 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Lesson2 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Lesson2?.setNext_lesson)
|
|
{
|
|
await
|
|
Lesson2.
|
|
setNext_lesson(relatedNext_lesson2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateResourceWithLesson() {
|
|
|
|
const relatedLesson0 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Resource0 = await Resources.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Resource0?.setLesson)
|
|
{
|
|
await
|
|
Resource0.
|
|
setLesson(relatedLesson0);
|
|
}
|
|
|
|
const relatedLesson1 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Resource1 = await Resources.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Resource1?.setLesson)
|
|
{
|
|
await
|
|
Resource1.
|
|
setLesson(relatedLesson1);
|
|
}
|
|
|
|
const relatedLesson2 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Resource2 = await Resources.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Resource2?.setLesson)
|
|
{
|
|
await
|
|
Resource2.
|
|
setLesson(relatedLesson2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateStudentProgresWithUser() {
|
|
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const StudentProgres0 = await StudentProgress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (StudentProgres0?.setUser)
|
|
{
|
|
await
|
|
StudentProgres0.
|
|
setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const StudentProgres1 = await StudentProgress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (StudentProgres1?.setUser)
|
|
{
|
|
await
|
|
StudentProgres1.
|
|
setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const StudentProgres2 = await StudentProgress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (StudentProgres2?.setUser)
|
|
{
|
|
await
|
|
StudentProgres2.
|
|
setUser(relatedUser2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateStudentProgresWithLesson() {
|
|
|
|
const relatedLesson0 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const StudentProgres0 = await StudentProgress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (StudentProgres0?.setLesson)
|
|
{
|
|
await
|
|
StudentProgres0.
|
|
setLesson(relatedLesson0);
|
|
}
|
|
|
|
const relatedLesson1 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const StudentProgres1 = await StudentProgress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (StudentProgres1?.setLesson)
|
|
{
|
|
await
|
|
StudentProgres1.
|
|
setLesson(relatedLesson1);
|
|
}
|
|
|
|
const relatedLesson2 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const StudentProgres2 = await StudentProgress.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (StudentProgres2?.setLesson)
|
|
{
|
|
await
|
|
StudentProgres2.
|
|
setLesson(relatedLesson2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateChatWithUser() {
|
|
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Chat0 = await Chats.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Chat0?.setUser)
|
|
{
|
|
await
|
|
Chat0.
|
|
setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Chat1 = await Chats.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Chat1?.setUser)
|
|
{
|
|
await
|
|
Chat1.
|
|
setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Chat2 = await Chats.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Chat2?.setUser)
|
|
{
|
|
await
|
|
Chat2.
|
|
setUser(relatedUser2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateChatWithLesson() {
|
|
|
|
const relatedLesson0 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Chat0 = await Chats.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Chat0?.setLesson)
|
|
{
|
|
await
|
|
Chat0.
|
|
setLesson(relatedLesson0);
|
|
}
|
|
|
|
const relatedLesson1 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Chat1 = await Chats.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Chat1?.setLesson)
|
|
{
|
|
await
|
|
Chat1.
|
|
setLesson(relatedLesson1);
|
|
}
|
|
|
|
const relatedLesson2 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const Chat2 = await Chats.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Chat2?.setLesson)
|
|
{
|
|
await
|
|
Chat2.
|
|
setLesson(relatedLesson2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateAiQueryWithUser() {
|
|
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AiQuery0 = await AiQueries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (AiQuery0?.setUser)
|
|
{
|
|
await
|
|
AiQuery0.
|
|
setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AiQuery1 = await AiQueries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (AiQuery1?.setUser)
|
|
{
|
|
await
|
|
AiQuery1.
|
|
setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AiQuery2 = await AiQueries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (AiQuery2?.setUser)
|
|
{
|
|
await
|
|
AiQuery2.
|
|
setUser(relatedUser2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateAiQueryWithLesson() {
|
|
|
|
const relatedLesson0 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const AiQuery0 = await AiQueries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (AiQuery0?.setLesson)
|
|
{
|
|
await
|
|
AiQuery0.
|
|
setLesson(relatedLesson0);
|
|
}
|
|
|
|
const relatedLesson1 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const AiQuery1 = await AiQueries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (AiQuery1?.setLesson)
|
|
{
|
|
await
|
|
AiQuery1.
|
|
setLesson(relatedLesson1);
|
|
}
|
|
|
|
const relatedLesson2 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const AiQuery2 = await AiQueries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (AiQuery2?.setLesson)
|
|
{
|
|
await
|
|
AiQuery2.
|
|
setLesson(relatedLesson2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateAnalyticWithUser() {
|
|
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Analytic0 = await Analytics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Analytic0?.setUser)
|
|
{
|
|
await
|
|
Analytic0.
|
|
setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Analytic1 = await Analytics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Analytic1?.setUser)
|
|
{
|
|
await
|
|
Analytic1.
|
|
setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Analytic2 = await Analytics.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Analytic2?.setUser)
|
|
{
|
|
await
|
|
Analytic2.
|
|
setUser(relatedUser2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Courses.bulkCreate(CoursesData);
|
|
|
|
|
|
|
|
|
|
await Units.bulkCreate(UnitsData);
|
|
|
|
|
|
|
|
|
|
await Lessons.bulkCreate(LessonsData);
|
|
|
|
|
|
|
|
|
|
await Resources.bulkCreate(ResourcesData);
|
|
|
|
|
|
|
|
|
|
await StudentProgress.bulkCreate(StudentProgressData);
|
|
|
|
|
|
|
|
|
|
await Chats.bulkCreate(ChatsData);
|
|
|
|
|
|
|
|
|
|
await AiQueries.bulkCreate(AiQueriesData);
|
|
|
|
|
|
|
|
|
|
await Analytics.bulkCreate(AnalyticsData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateCoursWithInstructor(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateUnitWithCourse(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateLessonWithUnit(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateLessonWithPrevious_lesson(),
|
|
|
|
|
|
|
|
|
|
await associateLessonWithNext_lesson(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateResourceWithLesson(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateStudentProgresWithUser(),
|
|
|
|
|
|
|
|
|
|
await associateStudentProgresWithLesson(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateChatWithUser(),
|
|
|
|
|
|
|
|
|
|
await associateChatWithLesson(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateAiQueryWithUser(),
|
|
|
|
|
|
|
|
|
|
await associateAiQueryWithLesson(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateAnalyticWithUser(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('courses', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('units', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('lessons', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('resources', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('student_progress', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('chats', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('ai_queries', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('analytics', null, {});
|
|
|
|
|
|
},
|
|
}; |