diff --git a/db/migrations/007_create_modules_table.sql b/db/migrations/007_create_modules_table.sql new file mode 100644 index 0000000..a029b57 --- /dev/null +++ b/db/migrations/007_create_modules_table.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS modules ( + id INT AUTO_INCREMENT PRIMARY KEY, + skill_id INT NOT NULL, + title VARCHAR(255) NOT NULL, + `order` INT NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (skill_id) REFERENCES skills(id) ON DELETE CASCADE +); \ No newline at end of file diff --git a/db/migrations/008_create_lessons_table.sql b/db/migrations/008_create_lessons_table.sql new file mode 100644 index 0000000..a4226cb --- /dev/null +++ b/db/migrations/008_create_lessons_table.sql @@ -0,0 +1,10 @@ +CREATE TABLE IF NOT EXISTS lessons ( + id INT AUTO_INCREMENT PRIMARY KEY, + module_id INT NOT NULL, + title VARCHAR(255) NOT NULL, + content TEXT, + `order` INT NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (module_id) REFERENCES modules(id) ON DELETE CASCADE +); \ No newline at end of file diff --git a/db/migrations/009_insert_sample_modules.sql b/db/migrations/009_insert_sample_modules.sql new file mode 100644 index 0000000..e7270bd --- /dev/null +++ b/db/migrations/009_insert_sample_modules.sql @@ -0,0 +1,3 @@ +INSERT INTO modules (skill_id, title, `order`) VALUES +(1, 'Module 1: Getting Started', 1), +(1, 'Module 2: Core Concepts', 2); \ No newline at end of file diff --git a/db/migrations/010_insert_sample_lessons.sql b/db/migrations/010_insert_sample_lessons.sql new file mode 100644 index 0000000..146f6e0 --- /dev/null +++ b/db/migrations/010_insert_sample_lessons.sql @@ -0,0 +1,5 @@ +INSERT INTO lessons (module_id, title, content, `order`) VALUES +(1, 'Lesson 1.1: Introduction to the topic', 'This is the content for the introductory lesson.', 1), +(1, 'Lesson 1.2: Setting up your environment', 'Here is how you set up your environment to get started.', 2), +(2, 'Lesson 2.1: Understanding the fundamentals', 'This lesson covers the fundamental principles.', 1), +(2, 'Lesson 2.2: Advanced techniques', 'This lesson delves into more advanced techniques.', 2); \ No newline at end of file diff --git a/learn.php b/learn.php index b8f10cb..8e109e2 100644 --- a/learn.php +++ b/learn.php @@ -15,11 +15,16 @@ $stmt->execute([$skill_id]); $skill = $stmt->fetch(PDO::FETCH_ASSOC); if (!$skill) { - // or redirect to dashboard with an error die('Skill not found!'); } -// Basic page layout +// Fetch modules and lessons +$modules_stmt = $db->prepare("SELECT * FROM modules WHERE skill_id = ? ORDER BY `order` ASC"); +$modules_stmt->execute([$skill_id]); +$modules = $modules_stmt->fetchAll(PDO::FETCH_ASSOC); + +$lessons_stmt = $db->prepare("SELECT * FROM lessons WHERE module_id = ? ORDER BY `order` ASC"); + ?> @@ -37,10 +42,46 @@ if (!$skill) {
(Content for this course will be added soon.)
+(Content for this course will be added soon.)
+ + +No lessons in this module yet.
+ +