prepare( "SELECT t.id, t.title, t.description, t.due_date, ta.status, ta.id as assignment_id FROM tasks t JOIN task_assignments ta ON t.id = ta.task_id WHERE ta.assigned_to_user_id = ? ORDER BY t.due_date ASC" ); $stmt->execute([$user_id]); $tasks = $stmt->fetchAll(); $dashboard_content = '

Daftar Tugas Anda

'; if (empty($tasks)) { $dashboard_content .= '

Belum ada tugas untuk Anda. Selamat beristirahat!

'; } else { $dashboard_content .= '
'; foreach ($tasks as $task) { $status_class = 'status-' . str_replace('_', '-', $task['status']); $due_date = $task['due_date'] ? date('d M Y', strtotime($task['due_date'])) : 'Tidak ada tenggat'; $is_done = $task['status'] === 'done'; $dashboard_content .= '

' . htmlspecialchars($task['title']) . '

' . htmlspecialchars($task['description']) . '

Tenggat: ' . $due_date . '
' . ucfirst(str_replace('_', ' ', $task['status'])) . '
'; } $dashboard_content .= '
'; } break; case 'guru': // Fetch tasks created by this teacher $stmt_tasks = $pdo->prepare("SELECT * FROM tasks WHERE created_by_user_id = ? ORDER BY created_at DESC"); $stmt_tasks->execute([$user_id]); $created_tasks = $stmt_tasks->fetchAll(); // Fetch all students for the assignment form $stmt_students = $pdo->prepare("SELECT id, username FROM users WHERE role = 'siswa' ORDER BY username ASC"); $stmt_students->execute(); $students = $stmt_students->fetchAll(); $dashboard_content = '

Manajemen Tugas

Daftar Tugas yang Dibuat

'; if (empty($created_tasks)) { $dashboard_content .= ''; } else { foreach ($created_tasks as $task) { $dashboard_content .= ' '; } } $dashboard_content .= '
Judul Tenggat Waktu Dibuat pada Aksi
Anda belum membuat tugas apapun.
' . htmlspecialchars($task['title']) . ' ' . ($task['due_date'] ? date('d M Y', strtotime($task['due_date'])) : '-') . ' ' . date('d M Y', strtotime($task['created_at'])) . '
'; break; case 'admin': // Fetch all users for the admin view $stmt = $pdo->prepare("SELECT id, username, role, created_at FROM users ORDER BY created_at DESC"); $stmt->execute(); $users = $stmt->fetchAll(); $dashboard_content = '

Manajemen Pengguna

'; if (empty($users)) { $dashboard_content .= ''; } else { foreach ($users as $user) { $dashboard_content .= ' '; } } $dashboard_content .= '
ID Username Peran Bergabung pada Aksi
Tidak ada pengguna yang ditemukan.
' . htmlspecialchars($user['id']) . ' ' . htmlspecialchars($user['username']) . ' ' . htmlspecialchars($user['role']) . ' ' . date('d M Y', strtotime($user['created_at'])) . '
'; break; default: $dashboard_content = '

Selamat Datang!

Dashboard Anda sudah siap.

'; break; } } catch (PDOException $e) { $dashboard_content = '

Gagal memuat data. Silakan coba lagi nanti.

'; } ?> <?php echo htmlspecialchars($page_title); ?> - EduTask
EduTask
Halo, ! ()
Logout

Buat Tugas Baru

Tidak ada siswa yang ditemukan.

Buat Pengguna Baru

Kosongkan jika tidak ingin mengubah password.

© EduTask. Hak cipta dilindungi.