2.1
This commit is contained in:
parent
db1d5e038b
commit
e40e03403c
9
db/migrations/007_create_modules_table.sql
Normal file
9
db/migrations/007_create_modules_table.sql
Normal file
@ -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
|
||||
);
|
||||
10
db/migrations/008_create_lessons_table.sql
Normal file
10
db/migrations/008_create_lessons_table.sql
Normal file
@ -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
|
||||
);
|
||||
3
db/migrations/009_insert_sample_modules.sql
Normal file
3
db/migrations/009_insert_sample_modules.sql
Normal file
@ -0,0 +1,3 @@
|
||||
INSERT INTO modules (skill_id, title, `order`) VALUES
|
||||
(1, 'Module 1: Getting Started', 1),
|
||||
(1, 'Module 2: Core Concepts', 2);
|
||||
5
db/migrations/010_insert_sample_lessons.sql
Normal file
5
db/migrations/010_insert_sample_lessons.sql
Normal file
@ -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);
|
||||
49
learn.php
49
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");
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@ -37,10 +42,46 @@ if (!$skill) {
|
||||
<p class="text-muted"><?php echo htmlspecialchars($skill['category']); ?></p>
|
||||
<hr>
|
||||
<p><?php echo nl2br(htmlspecialchars($skill['description'])); ?></p>
|
||||
|
||||
<div class="mt-4">
|
||||
<h3>Course Content</h3>
|
||||
<p><em>(Content for this course will be added soon.)</em></p>
|
||||
<div class="accordion" id="modulesAccordion">
|
||||
<?php if (empty($modules)): ?>
|
||||
<p><em>(Content for this course will be added soon.)</em></p>
|
||||
<?php else: ?>
|
||||
<?php foreach ($modules as $module): ?>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="heading<?php echo $module['id']; ?>">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse<?php echo $module['id']; ?>" aria-expanded="false" aria-controls="collapse<?php echo $module['id']; ?>">
|
||||
<?php echo htmlspecialchars($module['title']); ?>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="collapse<?php echo $module['id']; ?>" class="accordion-collapse collapse" aria-labelledby="heading<?php echo $module['id']; ?>" data-bs-parent="#modulesAccordion">
|
||||
<div class="accordion-body">
|
||||
<?php
|
||||
$lessons_stmt->execute([$module['id']]);
|
||||
$lessons = $lessons_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
?>
|
||||
<?php if (empty($lessons)): ?>
|
||||
<p>No lessons in this module yet.</p>
|
||||
<?php else: ?>
|
||||
<ul class="list-group">
|
||||
<?php foreach ($lessons as $lesson): ?>
|
||||
<li class="list-group-item">
|
||||
<h5><?php echo htmlspecialchars($lesson['title']); ?></h5>
|
||||
<p><?php echo nl2br(htmlspecialchars($lesson['content'])); ?></p>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user