Skip to content

Commit 5e72d85

Browse files
committed
fix: map masjid id to name for lms modules in jamaah dashboard view
1 parent a1246d0 commit 5e72d85

3 files changed

Lines changed: 35 additions & 3 deletions

File tree

app-core/app/Controllers/Lms.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,27 @@ class Lms extends BaseController
77
public function index()
88
{
99
$moduleModel = new \App\Models\LmsModuleModel();
10+
$masjidModel = new \App\Models\MasjidModel();
1011

12+
$modules = $moduleModel->where('status', 'published')->orderBy('created_at', 'DESC')->findAll();
13+
14+
$masjids = $masjidModel->findAll();
15+
$masjidMap = [];
16+
foreach ($masjids as $m) {
17+
$masjidMap[$m['id']] = $m['name'];
18+
}
19+
20+
foreach ($modules as &$mod) {
21+
if (is_numeric($mod['lembaga_pemateri']) && isset($masjidMap[$mod['lembaga_pemateri']])) {
22+
$mod['lembaga_nama'] = $masjidMap[$mod['lembaga_pemateri']];
23+
} else {
24+
$mod['lembaga_nama'] = $mod['lembaga_pemateri'];
25+
}
26+
}
27+
1128
$data = [
1229
'title' => 'E-Learning (LMS) - Masj.id',
13-
'modules' => $moduleModel->where('status', 'published')->orderBy('created_at', 'DESC')->findAll(),
30+
'modules' => $modules,
1431
];
1532

1633
return view('dashboard/lms/index', $data);
@@ -27,6 +44,14 @@ public function module($slug)
2744
$module = $moduleModel->where('slug', $slug)->first();
2845
if (!$module) return redirect()->to('dashboard/lms')->with('error', 'Modul tidak ditemukan.');
2946

47+
$masjidModel = new \App\Models\MasjidModel();
48+
if (is_numeric($module['lembaga_pemateri'])) {
49+
$masjid = $masjidModel->find($module['lembaga_pemateri']);
50+
$module['lembaga_nama'] = $masjid ? $masjid['name'] : $module['lembaga_pemateri'];
51+
} else {
52+
$module['lembaga_nama'] = $module['lembaga_pemateri'];
53+
}
54+
3055
$materials = $materialModel->where('module_id', $module['id'])->orderBy('order_number', 'ASC')->findAll();
3156

3257
// Calculate progress
@@ -67,6 +92,13 @@ public function material($id)
6792

6893
$module = $moduleModel->find($material['module_id']);
6994

95+
$masjidModel = new \App\Models\MasjidModel();
96+
if (is_numeric($module['lembaga_pemateri'])) {
97+
$masjid = $masjidModel->find($module['lembaga_pemateri']);
98+
$module['lembaga_nama'] = $masjid ? $masjid['name'] : $module['lembaga_pemateri'];
99+
} else {
100+
$module['lembaga_nama'] = $module['lembaga_pemateri'];
101+
}
70102
// Check if completed
71103
$isCompleted = $progressModel->where(['user_id' => $userId, 'material_id' => $id])->first() ? true : false;
72104

app-core/app/Views/dashboard/lms/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<?php if (!empty($m['lembaga_pemateri'])): ?>
2929
<div class="text-[10px] font-bold text-primary uppercase mb-2 flex items-center gap-1">
3030
<span class="material-symbols-outlined text-[12px]">verified</span>
31-
Oleh: <?= esc($m['lembaga_pemateri']) ?>
31+
Oleh: <?= esc($m['lembaga_nama']) ?>
3232
</div>
3333
<?php endif; ?>
3434
<h3 class="font-bold text-lg text-slate-800 dark:text-white group-hover:text-primary transition-colors line-clamp-2"><?= esc($m['title']) ?></h3>

app-core/app/Views/dashboard/lms/module.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<?php if (!empty($module['lembaga_pemateri'])): ?>
1919
<div class="text-[10px] font-bold text-primary uppercase mb-2 flex items-center gap-1">
2020
<span class="material-symbols-outlined text-[12px]">verified</span>
21-
Oleh: <?= esc($module['lembaga_pemateri']) ?>
21+
Oleh: <?= esc($module['lembaga_nama']) ?>
2222
</div>
2323
<?php endif; ?>
2424
<h2 class="text-xl font-bold text-slate-800 dark:text-white mb-2"><?= esc($module['title']) ?></h2>

0 commit comments

Comments
 (0)