1.9
This commit is contained in:
parent
e6ade2ba41
commit
a60b54ddf4
@ -27,11 +27,15 @@ foreach ($all_skills as $skill) {
|
|||||||
$skills_by_category[$skill['category']][] = $skill;
|
$skills_by_category[$skill['category']][] = $skill;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hardcoded enrolled skills for now
|
// Fetch enrolled skills for the current user
|
||||||
$enrolled_skills = [
|
$stmt = db()->prepare("
|
||||||
['title' => 'Introduction to Python', 'progress' => 60, 'thumbnail' => 'assets/images/python.png'],
|
SELECT s.id, s.title, s.category, s.thumbnail, e.progress
|
||||||
['title' => 'Web Development Basics', 'progress' => 25, 'thumbnail' => 'assets/images/webdev.png'],
|
FROM enrollments e
|
||||||
];
|
JOIN skills s ON e.skill_id = s.id
|
||||||
|
WHERE e.user_id = ?
|
||||||
|
");
|
||||||
|
$stmt->execute([$userId]);
|
||||||
|
$enrolled_skills = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@ -97,7 +101,14 @@ $enrolled_skills = [
|
|||||||
<h2 class="h4">My Enrolled Skills</h2>
|
<h2 class="h4">My Enrolled Skills</h2>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<?php if (empty($enrolled_skills)): ?>
|
<?php if (empty($enrolled_skills)): ?>
|
||||||
<p>You are not enrolled in any skills yet. Explore the skills below to get started!</p>
|
<div class="col">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body text-center">
|
||||||
|
<p class="card-text">You haven’t enrolled in any skills yet. Explore new skills to start learning!</p>
|
||||||
|
<a href="#skill-explorer" class="btn btn-primary">Explore Skills</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php foreach ($enrolled_skills as $skill): ?>
|
<?php foreach ($enrolled_skills as $skill): ?>
|
||||||
<div class="col-md-6 col-lg-4 mb-3">
|
<div class="col-md-6 col-lg-4 mb-3">
|
||||||
@ -105,10 +116,11 @@ $enrolled_skills = [
|
|||||||
<img src="<?php echo htmlspecialchars($skill['thumbnail']); ?>" class="card-img-top" alt="<?php echo htmlspecialchars($skill['title']); ?>">
|
<img src="<?php echo htmlspecialchars($skill['thumbnail']); ?>" class="card-img-top" alt="<?php echo htmlspecialchars($skill['title']); ?>">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title"><?php echo htmlspecialchars($skill['title']); ?></h5>
|
<h5 class="card-title"><?php echo htmlspecialchars($skill['title']); ?></h5>
|
||||||
<div class="progress">
|
<p class="card-text text-muted"><?php echo htmlspecialchars($skill['category']); ?></p>
|
||||||
|
<div class="progress mb-2">
|
||||||
<div class="progress-bar" role="progressbar" style="width: <?php echo $skill['progress']; ?>%;" aria-valuenow="<?php echo $skill['progress']; ?>" aria-valuemin="0" aria-valuemax="100"><?php echo $skill['progress']; ?>%</div>
|
<div class="progress-bar" role="progressbar" style="width: <?php echo $skill['progress']; ?>%;" aria-valuenow="<?php echo $skill['progress']; ?>" aria-valuemin="0" aria-valuemax="100"><?php echo $skill['progress']; ?>%</div>
|
||||||
</div>
|
</div>
|
||||||
<a href="#" class="btn btn-primary mt-3">Continue</a>
|
<a href="learn.php?skill_id=<?php echo $skill['id']; ?>" class="btn btn-primary mt-3">Continue Learning</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
16
db/migrations/006_rename_user_skills_to_enrollments.sql
Normal file
16
db/migrations/006_rename_user_skills_to_enrollments.sql
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
-- This migration cleans up previous attempts and creates the enrollments table correctly.
|
||||||
|
DROP TABLE IF EXISTS `user_skills`;
|
||||||
|
DROP TABLE IF EXISTS `enrollments`;
|
||||||
|
|
||||||
|
CREATE TABLE `enrollments` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`user_id` int(11) unsigned NOT NULL,
|
||||||
|
`skill_id` int(11) NOT NULL,
|
||||||
|
`progress` int(11) NOT NULL DEFAULT 0,
|
||||||
|
`date_enrolled` DATETIME NOT NULL DEFAULT current_timestamp(),
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `user_id` (`user_id`),
|
||||||
|
KEY `skill_id` (`skill_id`),
|
||||||
|
CONSTRAINT `enrollments_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
|
||||||
|
CONSTRAINT `enrollments_ibfk_2` FOREIGN KEY (`skill_id`) REFERENCES `skills` (`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
46
learn.php
Normal file
46
learn.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
header('Location: login.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
require_once 'db/config.php';
|
||||||
|
$db = db();
|
||||||
|
|
||||||
|
$skill_id = $_GET['skill_id'] ?? 0;
|
||||||
|
|
||||||
|
// Fetch skill details
|
||||||
|
$stmt = $db->prepare("SELECT * FROM skills WHERE id = ?");
|
||||||
|
$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
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Learning: <?php echo htmlspecialchars($skill['title']); ?></title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container mt-5">
|
||||||
|
<a href="dashboard.php" class="btn btn-secondary mb-4">Back to Dashboard</a>
|
||||||
|
<h1><?php echo htmlspecialchars($skill['title']); ?></h1>
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user