HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ubuntu-8gb-hel1-1 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64
User: www-data (33)
PHP: 8.1.32
Disabled: NONE
Upload Files
File: /var/www/html/obaasimaghana/app/views/courses/show.php
<?php
$title = $course['title'];
ob_start();
?>

<div class="bg-gray-50 min-h-screen">
    <!-- Course Header -->
    <div class="bg-gradient-to-r from-purple-900 to-indigo-900 text-white py-12">
        <div class="container mx-auto px-4">
            <div class="flex flex-wrap md:flex-nowrap gap-8">
            <!-- Course Info -->
                <div class="w-full md:w-9/12">
                    <nav class="text-sm mb-6">
                    <ol class="list-none p-0 inline-flex">
                        <li class="flex items-center">
                                <a href="<?php echo APP_URL; ?>/courses" class="text-purple-200 hover:text-white transition-colors">Courses</a>
                            <svg class="w-3 h-3 mx-3" fill="currentColor" viewBox="0 0 320 512">
                                <path d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"/>
                            </svg>
                        </li>
                            <li class="text-purple-200"><?php echo htmlspecialchars($course['category'] ?? 'General'); ?></li>
                    </ol>
                </nav>
                
                    <h1 class="text-3xl font-bold mb-4 leading-tight"><?php echo htmlspecialchars($course['title']); ?></h1>
                    <p class="text-lg mb-8 text-purple-100"><?php echo htmlspecialchars($course['description']); ?></p>
                
                <div class="flex flex-wrap items-center gap-6 text-sm">
                        <div class="flex items-center bg-white/10 px-4 py-2 rounded-full">
                        <div class="flex mr-2">
                            <?php for($i = 1; $i <= 5; $i++): ?>
                                    <svg class="w-4 h-4 <?php echo $i <= $data['rating']['average_rating'] ? 'text-yellow-400' : 'text-gray-400'; ?>" fill="currentColor" viewBox="0 0 20 20">
                                    <path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/>
                                </svg>
                            <?php endfor; ?>
                            </div>
                            <span class="text-yellow-400 font-medium"><?php echo number_format($data['rating']['average_rating'], 1); ?></span>
                            <span class="text-purple-200 ml-1">(<?php echo $data['rating']['total_reviews']; ?> ratings)</span>
                        </div>
                        <div class="flex items-center bg-white/10 px-4 py-2 rounded-full">
                            <i class="fas fa-users mr-2"></i>
                            <span><?php echo $course['enrolled_count']; ?> students</span>
                    </div>
                        <div class="flex items-center bg-white/10 px-4 py-2 rounded-full">
                        <i class="fas fa-user-circle fa-2x text-gray-400 mr-2"></i>
                            <span>Tutor: <a href="#" class="text-purple-300 hover:text-white transition-colors"><?php echo htmlspecialchars($course['trainer_name']); ?></a></span>
                        </div>
                </div>
            </div>
            
            <!-- Course Preview/Actions -->
                <div class="w-full md:w-4/12 md:absolute md:right-3">
                    <div class="bg-white rounded-xl shadow-xl overflow-hidden sticky top-4">
                        <div class="relative group">
                        <img src="<?php echo !empty($course['thumbnail']) ? APP_URL . '/uploads/thumbnails/' . $course['thumbnail'] : APP_URL . '/assets/images/course-default.jpg'; ?>" 
                             alt="<?php echo htmlspecialchars($course['title']); ?>"
                             class="w-full aspect-video object-cover">
                            <div class="absolute inset-0 bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center">
                                <button class="transform scale-0 group-hover:scale-100 transition-transform">
                            <svg class="w-20 h-20 text-white" fill="currentColor" viewBox="0 0 20 20">
                                <path d="M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z"/>
                            </svg>
                        </button>
                            </div>
                    </div>
                    
                    <div class="p-6">
                        <?php if (isLoggedIn()): ?>
                            <?php if ($isEnrolled): ?>
                                <?php if ($enrollmentStatus === 'active'): ?>
                                    <div class="space-y-4">
                                            <a href="<?php echo APP_URL; ?>/courses/learn/<?php echo $course['id']; ?>" 
                                               class="block w-full py-3 px-4 text-center bg-purple-600 text-white rounded-lg hover:bg-purple-700 transition-colors font-medium">
                                            Continue Learning
                                        </a>
                                            <div class="bg-gray-50 rounded-lg p-4">
                                                <div class="flex justify-between text-sm mb-2">
                                                <span class="text-gray-600">Your Progress</span>
                                                    <div class="flex items-center space-x-4">
                                                        <div class="flex items-center bg-gray-100 rounded-full px-3 py-1">
                                                            <div class="w-24 h-2 bg-gray-200 rounded-full mr-2">
                                                                <div class="h-full bg-emerald-500 rounded-full transition-all duration-300" 
                                                                     style="width: <?php echo isset($courseProgress) ? $courseProgress : 0; ?>%">
                                                                </div>
                                                            </div>
                                                            <span class="text-xs font-medium text-gray-600">
                                                                <?php echo isset($courseProgress) ? $courseProgress : 0; ?>% complete
                                                            </span>
                                                        </div>
                                                    </div>
                                            </div>
                                        </div>
                                    </div>
                                <?php elseif ($enrollmentStatus === 'completed'): ?>
                                        <div class="bg-green-50 text-green-800 p-4 rounded-lg text-center mb-4">
                                            <svg class="w-8 h-8 mx-auto mb-2 text-green-500" fill="currentColor" viewBox="0 0 20 20">
                                            <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
                                        </svg>
                                            <p class="font-medium">Course Completed</p>
                                            <p class="text-sm mt-1">Congratulations on completing this course!</p>
                                            <div class="text-center my-6">
                                                <a href="<?php echo APP_URL; ?>/courses/certificate/<?php echo $course['id']; ?>" target="_blank"
                                                   class="inline-block px-6 py-2 bg-emerald-600 text-white rounded-lg hover:bg-emerald-700 transition-colors font-medium">
                                                    View Certificate
                                                </a>
                                            </div>
                                        </div>
                                    <?php endif; ?>
                                <?php else: ?>
                                    <?php if ($_SESSION['user_id'] == $course['trainer_id']): ?>
                                        <div class="bg-blue-50 text-blue-800 p-6 rounded-lg text-center">
                                            <i class="fas fa-chalkboard-teacher text-3xl mb-3 text-blue-500"></i>
                                            <p class="font-medium text-lg mb-2">You are the trainer of this course</p>
                                            <p class="text-sm mb-4">You can manage course content and view student progress from your dashboard.</p>
                                            <a href="<?php echo APP_URL; ?>/dashboard" 
                                               class="inline-block px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors">
                                                Go to Dashboard
                                            </a>
                                    </div>
                                    <?php else: ?>
                                        <a href="<?php echo APP_URL; ?>/courses/enroll/<?php echo $course['id']; ?>" 
                                           class="block w-full py-3 px-4 text-center bg-purple-600 text-white rounded-lg hover:bg-purple-700 transition-colors font-medium">
                                            Enroll Now
                                        </a>
                                    <?php endif; ?>
                                <?php endif; ?>
                            <?php else: ?>
                                <a href="<?php echo SITE_URL; ?>/auth/login" 
                                   class="block w-full py-3 px-4 text-center bg-purple-600 text-white rounded-lg hover:bg-purple-700 transition-colors font-medium">
                                    Login to Enroll
                            </a>
                        <?php endif; ?>
                        
                        <div class="mt-6 space-y-4">
                                <div class="flex items-center p-3 bg-gray-50 rounded-lg">
                                    <svg class="w-5 h-5 text-purple-600 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
                                </svg>
                                    <span class="text-gray-700">
                                    <?php echo count($materials); ?> lectures • 
                                    <?php echo isset($course['duration']) ? $course['duration'] : 'Self-paced'; ?>
                                </span>
                            </div>
                                <div class="flex items-center p-3 bg-gray-50 rounded-lg">
                                    <svg class="w-5 h-5 text-purple-600 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 21v-4m0 0V5a2 2 0 012-2h6.5l1 1H21l-3 6 3 6h-8.5l-1-1H5a2 2 0 00-2 2zm9-13.5V9"/>
                                </svg>
                                    <span class="text-gray-700"><?php echo ucfirst($course['level'] ?? 'All Levels'); ?></span>
                            </div>
                                <div class="flex items-center p-3 bg-gray-50 rounded-lg">
                                    <svg class="w-5 h-5 text-purple-600 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5h12M9 3v2m1.048 9.5A18.022 18.022 0 016.412 9m6.088 9h7M11 21l5-10 5 10M12.751 5C11.783 10.77 8.07 15.61 3 18.129"/>
                                </svg>
                                    <span class="text-gray-700"><?php echo ucfirst($course['language'] ?? 'English'); ?></span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="container mx-auto px-4 py-8">
        <div class="flex flex-wrap md:flex-nowrap gap-6">
            <!-- Main Content -->
            <div class="w-full md:w-7/12">
                <!-- What you'll learn -->
                <div class="bg-white rounded-xl shadow-sm p-6 mb-6">
                    <h2 class="text-base font-semibold mb-4 text-gray-900">What you'll learn</h2>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                        <?php if (!empty($course['objectives'])): ?>
                            <?php foreach ($course['objectives'] as $objective): ?>
                                <div class="flex items-start">
                                    <svg class="w-4 h-4 text-purple-600 mr-2 flex-shrink-0 mt-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
                                    </svg>
                                    <span class="text-xs text-gray-700"><?php echo htmlspecialchars($objective); ?></span>
                                </div>
                            <?php endforeach; ?>
                        <?php else: ?>
                            <p class="text-xs text-gray-500">No learning objectives specified.</p>
                        <?php endif; ?>
                    </div>
                </div>

                <!-- Prerequisites -->
                <div class="bg-white rounded-xl shadow-sm p-6 mb-6">
                    <h2 class="text-base font-semibold mb-4 text-gray-900">Prerequisites</h2>
                    <?php if (!empty($course['prerequisites'])): ?>
                        <ul class="space-y-3">
                            <?php foreach ($course['prerequisites'] as $prerequisite): ?>
                                <li class="flex items-start">
                                    <svg class="w-4 h-4 text-purple-600 mr-2 flex-shrink-0 mt-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
                                    </svg>
                                    <span class="text-xs text-gray-700"><?php echo htmlspecialchars($prerequisite); ?></span>
                                </li>
                            <?php endforeach; ?>
                        </ul>
                    <?php else: ?>
                        <p class="text-xs text-gray-500">No prerequisites specified for this course.</p>
                    <?php endif; ?>
                </div>

                <!-- Course Content -->
                <div id="course-content" class="bg-white rounded-xl shadow-sm p-8 mb-8">
                    <div class="flex items-center justify-between mb-6">
                        <h2 class="text-lg font-bold text-gray-900">Course Content</h2>
                        <?php if (isLoggedIn() && isset($_SESSION['user_id']) && $_SESSION['user_id'] == $course['trainer_id']): ?>
                            <a href="<?php echo APP_URL; ?>/courses/add-material/<?php echo $course['id']; ?>" 
                               class="inline-flex items-center px-4 py-2 bg-purple-600 text-white rounded-lg hover:bg-purple-700 transition-colors">
                                <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"/>
                                </svg>
                                Add Material
                            </a>
                        <?php endif; ?>
                    </div>

                    <?php if (empty($materials)): ?>
                        <p class="text-gray-500">No materials available yet.</p>
                    <?php else: ?>
                        <?php if (!isLoggedIn()): ?>
                            <div class="text-center py-12">
                                <svg class="w-16 h-16 mx-auto text-gray-400 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"/>
                                </svg>
                                <h3 class="text-base font-semibold mb-2">Login Required</h3>
                                <p class="text-gray-600 mb-4">Please log in to view the course content</p>
                                <a href="<?php echo SITE_URL; ?>/auth/login" 
                                   class="inline-block px-6 py-3 bg-purple-600 text-white rounded-lg hover:bg-purple-700 transition-colors">
                                    Login to Continue
                                </a>
                            </div>
                        <?php elseif (!$isEnrolled && $_SESSION['user_id'] != $course['trainer_id']): ?>
                            <div class="text-center py-12">
                                <svg class="w-16 h-16 mx-auto text-gray-400 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
                                </svg>
                                <h3 class="text-base font-semibold mb-2">Enrollment Required</h3>
                                <p class="text-gray-600 mb-4">You need to be enrolled in this course to access its content</p>
                                <a href="<?php echo APP_URL; ?>/courses/enroll/<?php echo $course['id']; ?>" 
                                   class="inline-block px-6 py-3 bg-purple-600 text-white rounded-lg hover:bg-purple-700 transition-colors">
                                    Enroll Now
                                </a>
                            </div>
                        <?php else: ?>
                            <div class="space-y-4">
                                <?php foreach ($materials as $index => $material): ?>
                                    <div class="border rounded-lg hover:border-purple-500 transition-colors">
                                        <div class="p-4 hover:bg-gray-50 cursor-pointer">
                                            <div class="flex items-center justify-between">
                                                <div class="flex items-center space-x-3">
                                                    <?php if ($material['type'] === 'video'): ?>
                                                        <svg class="w-5 h-5 text-purple-600" fill="currentColor" viewBox="0 0 20 20">
                                                            <path d="M2 6a2 2 0 012-2h6a2 2 0 012 2v8a2 2 0 01-2 2H4a2 2 0 01-2-2V6zM14.553 7.106A1 1 0 0014 8v4a1 1 0 00.553.894l2 1A1 1 0 0018 13V7a1 1 0 00-1.447-.894l-2 1z"/>
                                                        </svg>
                                                    <?php elseif ($material['type'] === 'pdf'): ?>
                                                        <svg class="w-5 h-5 text-purple-600" fill="currentColor" viewBox="0 0 20 20">
                                                            <path fill-rule="evenodd" d="M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z" clip-rule="evenodd"/>
                                                        </svg>
                                                    <?php else: ?>
                                                        <svg class="w-5 h-5 text-purple-600" fill="currentColor" viewBox="0 0 20 20">
                                                            <path fill-rule="evenodd" d="M4 4a2 2 0 012-2h8a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 3a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7zm0 3a1 1 0 100 2h6a1 1 0 100-2H7z" clip-rule="evenodd"/>
                                                        </svg>
                                                    <?php endif; ?>
                                                    <span class="font-medium text-gray-900"><?php echo htmlspecialchars($material['title']); ?></span>
                                                </div>
                                                
                                                <div class="flex items-center space-x-4">
                                                    <?php if (isset($material['status'])): ?>
                                                        <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium <?php echo $material['status'] === 'completed' ? 'bg-green-100 text-green-800' : 'bg-yellow-100 text-yellow-800'; ?>">
                                                            <?php echo ucfirst($material['status']); ?>
                                                        </span>
                                                    <?php endif; ?>
                                                    
                                                    <?php if (($material['type'] === 'video' || $material['type'] === 'pdf') && isset($_SESSION['user_role']) && $_SESSION['user_role'] === 'learner'): ?>
                                                        <a href="<?php echo APP_URL; ?>/courses/learn/<?php echo $course['id']; ?>/material/<?php echo $material['id']; ?>" 
                                                           class="text-xs text-purple-600 hover:text-purple-700">
                                                            Start Learning
                                                        </a>
                                                    <?php endif; ?>
                                                    
                                                    <?php if (isset($_SESSION['user_role']) && $_SESSION['user_role'] === 'trainer' && $course['trainer_id'] == $_SESSION['user_id']): ?>
                                                        <a href="<?php echo APP_URL; ?>/courses/learn/<?php echo $course['id']; ?>/material/<?php echo $material['id']; ?>" 
                                                           class="text-xs text-blue-600 hover:text-blue-700">
                                                            View Material
                                                        </a>
                                                    <?php endif; ?>
                                                    
                                                 <!--   <form action="<?php echo APP_URL; ?>/courses/updateMaterialProgress" method="POST" class="inline">
                                                        <input type="hidden" name="material_id" value="<?php echo $material['id']; ?>">
                                                        <input type="hidden" name="course_id" value="<?php echo $course['id']; ?>">
                                                        <input type="hidden" name="status" value="<?php echo $material['status'] === 'completed' ? 'not_started' : 'completed'; ?>">
                                                        <button type="submit" class="text-sm text-purple-600 hover:text-purple-700">
                                                            <?php echo $material['status'] === 'completed' ? 'Mark Incomplete' : 'Mark Complete'; ?>
                                                        </button>
                                                    </form> -->
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                <?php endforeach; ?>
                            </div>
                        <?php endif; ?>
                    <?php endif; ?>
                </div>

                <!-- Reviews -->
                <div class="bg-white rounded-xl shadow-sm p-6">
                    <div class="flex items-center justify-between mb-4">
                        <h2 class="text-base font-semibold text-gray-900">Student Feedback</h2>
                        <?php if(isLoggedIn() && !$data['has_reviewed'] && $data['enrollmentStatus'] === 'completed' && isset($_SESSION['user_role']) && $_SESSION['user_role'] === 'learner'): ?>
                            <div class="flex gap-2">
                                <button onclick="document.getElementById('reviewModal').classList.remove('hidden')"
                                        class="text-xs text-purple-600 hover:text-purple-700 font-medium">
                                    Write a Review
                                </button>
                                <a href="<?php echo APP_URL; ?>/courses/certificate/<?php echo $course['id']; ?>" target="_blank"
                                   class="text-xs text-emerald-600 hover:text-emerald-700 font-medium">
                                    View Certificate
                                </a>
                            </div>
                        <?php endif; ?>
                    </div>

                    <?php if(empty($data['reviews'])): ?>
                        <div class="text-center py-8">
                            <svg class="w-12 h-12 mx-auto text-gray-400 mb-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"/>
                            </svg>
                            <h3 class="text-sm font-medium mb-2">No Reviews Yet</h3>
                            <p class="text-xs text-gray-600 mb-3">Be the first to review this course!</p>
                            <?php if(isLoggedIn() && $data['enrollmentStatus'] === 'completed' && isset($_SESSION['user_role']) && $_SESSION['user_role'] === 'learner'): ?>
                                <button onclick="document.getElementById('reviewModal').classList.remove('hidden')" 
                                        class="inline-block px-4 py-2 text-xs bg-purple-600 text-white rounded-lg hover:bg-purple-700 transition-colors">
                                    Write a Review
                                </button>
                            <?php endif; ?>
                        </div>
                    <?php else: ?>
                        <div class="space-y-6">
                            <?php foreach($data['reviews'] as $review): ?>
                                <div class="border-b border-gray-100 pb-6 last:border-b-0 last:pb-0">
                                    <div class="flex items-center mb-3">
                                        <div class="w-8 h-8 rounded-full bg-gray-100 flex items-center justify-center mr-3">
                                            <?php if(!empty($review['profile_picture'])): ?>
                                                <img src="<?php echo APP_URL; ?>/uploads/profile/<?php echo $review['profile_picture']; ?>" 
                                                     alt="<?php echo htmlspecialchars($review['full_name']); ?>" 
                                                     class="w-full h-full rounded-full object-cover">
                                            <?php else: ?>
                                                <span class="text-gray-600 font-medium text-xs"><?php echo substr($review['full_name'], 0, 1); ?></span>
                                            <?php endif; ?>
                                        </div>
                                        <div>
                                            <h4 class="text-xs font-medium text-gray-900"><?php echo htmlspecialchars($review['full_name']); ?></h4>
                                            <div class="flex items-center text-xs text-gray-500">
                                                <div class="flex mr-2">
                                                    <?php for($i = 1; $i <= 5; $i++): ?>
                                                        <svg class="w-3 h-3 <?php echo $i <= $review['rating'] ? 'text-yellow-400' : 'text-gray-300'; ?>" fill="currentColor" viewBox="0 0 20 20">
                                                            <path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/>
                                                        </svg>
                                                    <?php endfor; ?>
                                                </div>
                                                <span><?php echo date('M j, Y', strtotime($review['created_at'])); ?></span>
                                            </div>
                                        </div>
                                    </div>
                                    <?php if(!empty($review['review'])): ?>
                                        <p class="text-xs text-gray-700 leading-relaxed"><?php echo nl2br(htmlspecialchars($review['review'])); ?></p>
                                    <?php endif; ?>
                                </div>
                            <?php endforeach; ?>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Review Modal -->
<?php require APP_PATH . '/views/courses/_review_modal.php'; ?>

<script>
document.addEventListener('DOMContentLoaded', function() {
    // Star rating functionality
    const ratingInputs = document.querySelectorAll('input[name="rating"]');
    const ratingLabels = document.querySelectorAll('label[for^="rating"]');
    
    ratingInputs.forEach(input => {
        input.addEventListener('change', function() {
            const selectedRating = this.value;
            ratingLabels.forEach((label, index) => {
                const svg = label.querySelector('svg');
                if (5 - index <= selectedRating) {
                    svg.classList.remove('text-gray-300');
                    svg.classList.add('text-yellow-400');
                } else {
                    svg.classList.remove('text-yellow-400');
                    svg.classList.add('text-gray-300');
                }
            });
        });
    });

    // Show review modal if there are flash messages
    if (document.querySelector('.alert.alert-danger')) {
        const reviewModal = document.getElementById('reviewModal');
        if (reviewModal) {
            reviewModal.classList.remove('hidden');
        }
    }
});
</script>

<?php
$content = ob_get_clean();
require APP_PATH . '/views/layouts/dashboard.php';
?>