feat: mock exercise template api (#613)
* feat: move mock exercise template to api * feat: add template migration file * chore: - remove exercise templates form api - rework api to pull exercise templates from db - add exercise template seed to seed file - declutter seed file * chore: - refactor template fetch to be dependent on the selected tag - add tag to schema, remote db and template's seed file - clear remote db's template table and replace data and their respective tags * chore: add number of questions and center loading screen on the frontend * chore: pr fixes * chore: type fixes * chore: - move seed functionality to /seed folder - add typing for individual seed functions - pr fixes * chore: pr fixes v2 * update output css * refactor: update seeding script and schema definitions - Renamed `seedTypes` to `seedQuestionTypes` for clarity in the seeding process. - Enhanced the seeding script to include a command-line interface for better usability, allowing specific seed functions to be executed based on flags. - Removed redundant unique constraints in the schema definitions for `courseNewsfeedComment` and `exerciseTemplate` to streamline database structure. * feat: add email verification error handling page and update session management - Introduced a new page for handling email verification errors, providing user-friendly messages based on error types. - Updated session management logic to improve handling of public routes and session states. - Enhanced security policies in the Svelte configuration to include additional sources for styles and scripts. - Removed the old email verification error page to streamline the codebase. * move the exercise template to cloudflare cdn --------- Co-authored-by: Rotimi Best <best@classroomio.com>
This commit is contained in:
co-authored by
Rotimi Best
parent
ac3f35a97f
commit
50d6ee3111
@@ -0,0 +1,98 @@
|
||||
import { db, lesson } from '@db/drizzle';
|
||||
|
||||
interface LessonTemplate {
|
||||
mvcCourseId: string;
|
||||
reactCourseId: string;
|
||||
pandasCourseId: string;
|
||||
adminUserId: string;
|
||||
}
|
||||
|
||||
export async function seedLessons({ mvcCourseId, adminUserId, reactCourseId, pandasCourseId }: LessonTemplate) {
|
||||
const existingLessons = await db.select().from(lesson);
|
||||
const existingLessonIds = existingLessons.map((l) => l.id);
|
||||
|
||||
const lessonsToInsert = [
|
||||
// MVC Course lessons
|
||||
{
|
||||
id: '5c75f4f1-c222-44a9-a8c6-81773ea33872',
|
||||
courseId: mvcCourseId,
|
||||
title: 'Lesson 1: Introduction to MVC Architecture',
|
||||
teacherId: adminUserId,
|
||||
videos: [{ link: 'https://youtu.be/pXLWqkA87e4?si=rUHaBMnuFgAMjm2T', type: 'youtube', metadata: {} }],
|
||||
isUnlocked: false
|
||||
},
|
||||
{
|
||||
id: 'a99e65b7-1394-4751-ad8d-a5fb670ccb9e',
|
||||
courseId: mvcCourseId,
|
||||
title: 'Anatomy of MVC Components',
|
||||
teacherId: adminUserId,
|
||||
videos: [{ link: 'https://youtu.be/4Qfk8MhtZJU?si=VZ7cF-pjvm_RmFMp', type: 'youtube', metadata: {} }],
|
||||
isUnlocked: false
|
||||
},
|
||||
{
|
||||
id: '266b3daa-1eb2-401e-9510-1819952b44b7',
|
||||
courseId: mvcCourseId,
|
||||
title: 'Building Your First MVC Application',
|
||||
teacherId: adminUserId,
|
||||
videos: [{ link: 'https://www.youtube.com/watch?v=EMwu8F0dCXE', type: 'youtube', metadata: {} }],
|
||||
isUnlocked: false
|
||||
},
|
||||
// React Course lessons
|
||||
{
|
||||
id: '6f2d8142-0903-425c-8534-f5105b624752',
|
||||
courseId: reactCourseId,
|
||||
title: 'Introduction to React: Understanding the Basics',
|
||||
teacherId: adminUserId,
|
||||
videos: [{ link: 'https://www.youtube.com/watch?v=H-PkPKF2Tfk', type: 'youtube', metadata: {} }],
|
||||
isUnlocked: false
|
||||
},
|
||||
{
|
||||
id: '0a39ab2f-9451-4a90-902c-3030bf965637',
|
||||
courseId: reactCourseId,
|
||||
title: 'Components and Props: Building Reusable UI Elements',
|
||||
teacherId: adminUserId,
|
||||
videos: [{ link: 'https://www.youtube.com/watch?v=H-PkPKF2Tfk', type: 'youtube', metadata: {} }],
|
||||
isUnlocked: false
|
||||
},
|
||||
{
|
||||
id: '80b79665-733b-41bf-9853-34fd8ab50496',
|
||||
courseId: reactCourseId,
|
||||
title: 'State and Lifecycle: Managing Data in React Applications',
|
||||
teacherId: adminUserId,
|
||||
videos: [{ link: 'https://www.youtube.com/watch?v=DveeFlWzWzc', type: 'youtube', metadata: {} }],
|
||||
isUnlocked: false
|
||||
},
|
||||
// Pandas Course lessons
|
||||
{
|
||||
id: '5e5c8221-4c11-4c40-8664-11743bb79579',
|
||||
courseId: pandasCourseId,
|
||||
title: 'Python Essentials: An Introduction to Data Science',
|
||||
teacherId: adminUserId,
|
||||
videos: [{ link: 'https://www.youtube.com/watch?v=T5pRlIbr6gg&vl=en', type: 'youtube', metadata: {} }],
|
||||
isUnlocked: true
|
||||
},
|
||||
{
|
||||
id: '829da386-8ccd-4c81-b2fb-b9891102c83c',
|
||||
courseId: pandasCourseId,
|
||||
title: 'Delving into Data Analysis with Pandas',
|
||||
teacherId: adminUserId,
|
||||
videos: [{ link: 'https://www.youtube.com/watch?v=T5pRlIbr6gg&vl=en', type: 'youtube', metadata: {} }],
|
||||
isUnlocked: true
|
||||
},
|
||||
{
|
||||
id: '05f03084-3ff1-49e3-aa2a-7a13840cc4b1',
|
||||
courseId: pandasCourseId,
|
||||
title: 'Data Cleaning and Preprocessing Techniques',
|
||||
teacherId: adminUserId,
|
||||
videos: [{ link: 'https://www.youtube.com/watch?v=LI7s_lyooO8', type: 'youtube', metadata: {} }],
|
||||
isUnlocked: true
|
||||
}
|
||||
].filter((l) => !existingLessonIds.includes(l.id));
|
||||
|
||||
if (lessonsToInsert.length > 0) {
|
||||
await db.insert(lesson).values(lessonsToInsert);
|
||||
console.log(` ✓ Inserted ${lessonsToInsert.length} lesson(s)`);
|
||||
} else {
|
||||
console.log(' ✓ Lessons already exist, skipping');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user